47 #include <glxnavigationalstate.h> |
47 #include <glxnavigationalstate.h> |
48 #include <glxnavigationalstatedefs.h> |
48 #include <glxnavigationalstatedefs.h> |
49 #include <glxfullscreenviewplugin.hrh> |
49 #include <glxfullscreenviewplugin.hrh> |
50 #include <glxivwr.rsg> |
50 #include <glxivwr.rsg> |
51 #include <AknGlobalNote.h> |
51 #include <AknGlobalNote.h> |
|
52 #include <hal.h> |
|
53 #include <hal_data.h> |
|
54 #include <oommonitorsession.h> |
52 #include <glxtracer.h> |
55 #include <glxtracer.h> |
53 |
|
54 |
|
55 #include <glxbackservicewrapper.h> |
|
56 |
|
57 #include <glxuistd.h> |
56 #include <glxuistd.h> |
58 #include <apgcli.h> |
57 #include <apgcli.h> |
|
58 |
|
59 //constants |
|
60 const TInt KGlxFullThumbnailCount = 1 ; // 1 visible thumnail |
|
61 #ifdef __MARM |
|
62 const TInt KGlxMaxMegaPixelsSupportedByCamera = 5242880 ; // 5 MB |
|
63 #else |
|
64 const TInt KGlxMaxMegaPixelsSupportedByCamera = 2097152 ; // 2 MB |
|
65 #endif |
|
66 const TInt KGlxMaxMemoryToDecodeCapturedPicture = 2 * KGlxMaxMegaPixelsSupportedByCamera ; |
|
67 const TInt KGlxMemoryForOOMFwk = 1048576 ; // 1 MB |
|
68 const TInt KGlxThumbNailRepresentation = 4; // Thumbnail Representation; Could be 3 also |
59 |
69 |
60 // ----------------------------------------------------------------------------- |
70 // ----------------------------------------------------------------------------- |
61 // Constructor |
71 // Constructor |
62 // ----------------------------------------------------------------------------- |
72 // ----------------------------------------------------------------------------- |
63 // |
73 // |
78 // Create navigational state |
88 // Create navigational state |
79 iNavigationalState = CGlxNavigationalState::InstanceL(); |
89 iNavigationalState = CGlxNavigationalState::InstanceL(); |
80 |
90 |
81 iNavigationalState->AddObserverL( *this ); |
91 iNavigationalState->AddObserverL( *this ); |
82 |
92 |
83 // Create Back Stepping Service wrapper |
|
84 iBSWrapper = CGlxBackServiceWrapper::NewL( TUid::Uid( KGlxGalleryApplicationUid ) ); |
|
85 iNavigationalState->SetBackExitStatus(EFalse); |
93 iNavigationalState->SetBackExitStatus(EFalse); |
86 |
94 |
87 // Get an instance of view utility |
95 // Get an instance of view utility |
88 iViewUtility = MMPXViewUtility::UtilityL(); |
96 iViewUtility = MMPXViewUtility::UtilityL(); |
89 |
97 |
90 iUiUtility = CGlxUiUtility::UtilityL(); |
98 iUiUtility = CGlxUiUtility::UtilityL(); |
91 // Always start in default orientation |
99 // Always start in default orientation |
92 iUiUtility->SetAppOrientationL(EGlxOrientationDefault); |
100 iUiUtility->SetAppOrientationL(EGlxOrientationDefault); |
|
101 ReserveMemoryL(EEntryTypeStartUp); |
93 // publish zoom context, no zoom keys for now |
102 // publish zoom context, no zoom keys for now |
94 NGlxZoomStatePublisher::PublishStateL( EFalse ); |
103 NGlxZoomStatePublisher::PublishStateL( EFalse ); |
95 } |
104 } |
96 |
105 |
97 // ----------------------------------------------------------------------------- |
106 // ----------------------------------------------------------------------------- |
357 iNavigationalState->NavigateToL( *path ); |
361 iNavigationalState->NavigateToL( *path ); |
358 CleanupStack::PopAndDestroy( path ); |
362 CleanupStack::PopAndDestroy( path ); |
359 } |
363 } |
360 |
364 |
361 // --------------------------------------------------------------------------- |
365 // --------------------------------------------------------------------------- |
|
366 // OOMRequestFreeMemoryL |
|
367 // --------------------------------------------------------------------------- |
|
368 // |
|
369 TInt CGlxIVwrAppUi::OOMRequestFreeMemoryL( TInt aBytesRequested) |
|
370 { |
|
371 TRACER("TInt CGlxIVwrAppUi::OOMRequestFreeMemoryL( TInt aBytesRequested)"); |
|
372 GLX_LOG_INFO1("CGlxIVwrAppUi::OOMRequestFreeMemoryL() aBytesRequested=%d", |
|
373 aBytesRequested); |
|
374 |
|
375 ROomMonitorSession oomMonitor; |
|
376 User::LeaveIfError( oomMonitor.Connect() ); |
|
377 // No leaving code after this point, so no need to use cleanup stack |
|
378 // for oomMonitor |
|
379 TInt errorCode = oomMonitor.RequestFreeMemory( aBytesRequested ); |
|
380 GLX_LOG_INFO1("CGlxIVwrAppUi::OOMRequestFreeMemoryL(1) errorCode=%d",errorCode); |
|
381 if ( errorCode != KErrNone ) |
|
382 { |
|
383 // try one more time |
|
384 errorCode = oomMonitor.RequestFreeMemory( aBytesRequested ); |
|
385 GLX_LOG_INFO1("CGlxIVwrAppUi::OOMRequestFreeMemoryL(2) errorCode=%d",errorCode); |
|
386 } |
|
387 oomMonitor.Close(); |
|
388 return errorCode; |
|
389 } |
|
390 |
|
391 // --------------------------------------------------------------------------- |
|
392 // ReserveMemoryL |
|
393 // --------------------------------------------------------------------------- |
|
394 // |
|
395 TInt CGlxIVwrAppUi::ReserveMemoryL(TInt aCriticalMemoryRequired) |
|
396 { |
|
397 TRACER("void CGlxIVwrAppUi::ReserveMemoryL(TInt aCriticalMemoryRequired)"); |
|
398 |
|
399 TInt memoryLeft = 0; |
|
400 TInt error = KErrNone ; |
|
401 HAL::Get( HALData::EMemoryRAMFree, memoryLeft ); |
|
402 GLX_LOG_INFO2("CGlxIVwrAppUi::ReserveMemoryL() - aCriticalMemoryRequired=%d, memoryLeft=%d", |
|
403 aCriticalMemoryRequired, memoryLeft); |
|
404 if ( aCriticalMemoryRequired > memoryLeft ) |
|
405 { |
|
406 // Request for critical memory required |
|
407 error = OOMRequestFreeMemoryL( aCriticalMemoryRequired); |
|
408 GLX_LOG_INFO1("CGlxIVwrAppUi::ReserveMemoryL() - OOMRequestFreeMemoryL() error=%d", error); |
|
409 } |
|
410 return error; |
|
411 } |
|
412 |
|
413 // --------------------------------------------------------------------------- |
|
414 // RamRequiredInBytesL |
|
415 // --------------------------------------------------------------------------- |
|
416 // |
|
417 TInt CGlxIVwrAppUi::RamRequiredInBytesL(TEntryType aType) |
|
418 { |
|
419 TRACER("TInt CGlxIVwrAppUi::RamRequiredInBytesL(TEntryType aType)"); |
|
420 TInt criticalRamMemory = 0 ; |
|
421 TSize displaySize = iUiUtility->DisplaySize(); |
|
422 if(EEntryTypeStartUp == aType) |
|
423 { |
|
424 // This is Bare Minimum Required Memory for Photos to start |
|
425 // For Framework to work and to do the on-the-fly decoding |
|
426 // for the just captured picture = KGlxMemoryForOOMFwk + KGlxMaxMemoryToDecodeCapturedPicture |
|
427 // For FullScreen to Work Number of Thumbnail(s) * Width * Height * Representation |
|
428 criticalRamMemory = KGlxMemoryForOOMFwk + KGlxMaxMemoryToDecodeCapturedPicture + |
|
429 (KGlxFullThumbnailCount * |
|
430 displaySize.iWidth * displaySize.iHeight * |
|
431 KGlxThumbNailRepresentation ); |
|
432 |
|
433 GLX_LOG_INFO1("CGlxIVwrAppUi::RamRequiredInBytesL(EEntryTypeStartUp): criticalRamMemory=%d", |
|
434 criticalRamMemory); |
|
435 } |
|
436 else |
|
437 { |
|
438 GLX_LOG_INFO("CGlxIVwrAppUi::RamRequiredInBytesL(): Photos Already Running"); |
|
439 } |
|
440 |
|
441 return criticalRamMemory; |
|
442 } |
|
443 |
|
444 // --------------------------------------------------------------------------- |
|
445 // ReserveMemoryL |
|
446 // --------------------------------------------------------------------------- |
|
447 // |
|
448 void CGlxIVwrAppUi::ReserveMemoryL(TEntryType aType) |
|
449 { |
|
450 TRACER("TInt CGlxIVwrAppUi::ReserveMemoryL(TEntryType aType)"); |
|
451 |
|
452 TInt error = ReserveMemoryL(RamRequiredInBytesL(aType)); |
|
453 GLX_LOG_INFO1("CGlxIVwrAppUi::ReserveMemoryL() error=%d", error); |
|
454 |
|
455 if (KErrNoMemory == error) |
|
456 { |
|
457 GLX_LOG_INFO("CGlxIVwrAppUi::ReserveMemoryL(): LEAVE with KErrNoMemory "); |
|
458 User::Leave(KErrNoMemory); |
|
459 } |
|
460 } |
|
461 |
|
462 // --------------------------------------------------------------------------- |
362 // HandleApplicationSpecificEventL |
463 // HandleApplicationSpecificEventL |
363 // |
464 // |
364 // --------------------------------------------------------------------------- |
465 // --------------------------------------------------------------------------- |
365 // |
466 // |
366 |
467 |