taskswitcher/taskswitcherui/taskswitcherapp/src/tsappui.cpp
branchRCL_3
changeset 28 d721605b30d0
parent 26 1b758917cafc
equal deleted inserted replaced
26:1b758917cafc 28:d721605b30d0
    66 const TUid KTsAppUid = { KTsAppUidValue };
    66 const TUid KTsAppUid = { KTsAppUidValue };
    67 
    67 
    68 const TUid KTsCameraUid = { 0x101F857a };
    68 const TUid KTsCameraUid = { 0x101F857a };
    69 const TUid KTsTelephoneUid = { 0x100058b3 };
    69 const TUid KTsTelephoneUid = { 0x100058b3 };
    70 
    70 
       
    71 const TInt KTsMultimediaAppActivationDelay = 1500000;
       
    72 
    71 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    72 // CTsAppUi::ConstructL()
    74 // CTsAppUi::ConstructL()
    73 // ConstructL is called by the application framework
    75 // ConstructL is called by the application framework
    74 // -----------------------------------------------------------------------------
    76 // -----------------------------------------------------------------------------
    75 //
    77 //
   115         }
   117         }
   116     Cba()->MakeVisible(EFalse);
   118     Cba()->MakeVisible(EFalse);
   117 
   119 
   118     // Create timer
   120     // Create timer
   119     iGoToBackgroundTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   121     iGoToBackgroundTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
   122     iForegroundDelayTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   120 
   123 
   121     // Create commonly used instances (device state only?)
   124     // Create commonly used instances (device state only?)
   122     iDeviceState = CTsDeviceState::NewL();
   125     iDeviceState = CTsDeviceState::NewL();
   123 
   126 
   124     // Create custom window group
   127     // Create custom window group
   167     // Set process priority to high to avoid being
   170     // Set process priority to high to avoid being
   168     // locked by heavy ui apps processing
   171     // locked by heavy ui apps processing
   169     iEikonEnv->WsSession().ComputeMode(RWsSession::EPriorityControlDisabled);
   172     iEikonEnv->WsSession().ComputeMode(RWsSession::EPriorityControlDisabled);
   170     RProcess().SetPriority(EPriorityHigh);
   173     RProcess().SetPriority(EPriorityHigh);
   171     
   174     
       
   175     iForegroundDelayed = EFalse;
       
   176     iDelayedForegroundInProgress = EFalse;
       
   177     
   172     TSLOG_OUT();
   178     TSLOG_OUT();
   173     }
   179     }
   174 
   180 
   175 // -----------------------------------------------------------------------------
   181 // -----------------------------------------------------------------------------
   176 // CTsAppUi::CTsAppUi()
   182 // CTsAppUi::CTsAppUi()
   196         
   202         
   197         }
   203         }
   198     GfxTransEffect::SetTransitionObserver(0);
   204     GfxTransEffect::SetTransitionObserver(0);
   199     
   205     
   200     delete iGoToBackgroundTimer;
   206     delete iGoToBackgroundTimer;
       
   207     delete iForegroundDelayTimer;
   201     delete iPropListener;
   208     delete iPropListener;
   202     delete iLayoutListener;
   209     delete iLayoutListener;
   203 
   210 
   204     // destroy UI first
   211     // destroy UI first
   205     if ( iAppView )
   212     if ( iAppView )
   546 
   553 
   547     return 0;
   554     return 0;
   548     }
   555     }
   549 
   556 
   550 // -----------------------------------------------------------------------------
   557 // -----------------------------------------------------------------------------
       
   558 // CTsAppUi::DelayedForegroundCallback
       
   559 // -----------------------------------------------------------------------------
       
   560 //
       
   561 TInt CTsAppUi::DelayedForegroundCallback( TAny* aParam )
       
   562     {
       
   563     CTsAppUi* self = static_cast<CTsAppUi*>( aParam );
       
   564     self->iDelayedForegroundInProgress = ETrue;
       
   565     
       
   566     if ( self->iForegroundDelayTimer )
       
   567         {
       
   568         self->iForegroundDelayTimer->Cancel();
       
   569         }
       
   570     self->iForegroundDelayed = EFalse;
       
   571     self->HandleSwitchToForegroundEvent();
       
   572     
       
   573     self->iDelayedForegroundInProgress = EFalse;
       
   574     
       
   575     return 0;
       
   576     }
       
   577 
       
   578 // -----------------------------------------------------------------------------
   551 // CTsAppUi::MoveAppToForeground()
   579 // CTsAppUi::MoveAppToForeground()
   552 // -----------------------------------------------------------------------------
   580 // -----------------------------------------------------------------------------
   553 //
   581 //
   554 void CTsAppUi::MoveAppToForeground( TUint  /*aTransitionType*/ )
   582 void CTsAppUi::MoveAppToForeground( TUint  /*aTransitionType*/ )
   555     {
   583     {
   561     // Request window server to bring our application
   589     // Request window server to bring our application
   562     // to foreground
   590     // to foreground
   563     iApplicationTask.BringToForeground();
   591     iApplicationTask.BringToForeground();
   564 
   592 
   565     // Notify
   593     // Notify
   566     HandleSwitchToForegroundEvent();
   594     TBool delayForeground(EFalse);
       
   595     TRAP_IGNORE( delayForeground = IsUnderlyingAppMultimediaL() );
       
   596     if ( delayForeground )
       
   597         {
       
   598         iForegroundDelayed = ETrue;
       
   599         iForegroundDelayTimer->Cancel();
       
   600         iForegroundDelayTimer->Start( 
       
   601                 KTsMultimediaAppActivationDelay, 
       
   602                 0,
       
   603                 TCallBack( DelayedForegroundCallback, this ) );
       
   604         }
       
   605     else
       
   606         {
       
   607         HandleSwitchToForegroundEvent();
       
   608         }
   567 
   609 
   568     TSLOG_OUT();
   610     TSLOG_OUT();
   569     }
   611     }
   570 
   612 
   571 // -----------------------------------------------------------------------------
   613 // -----------------------------------------------------------------------------
   587 
   629 
   588         // notify view
   630         // notify view
   589         iAppView->HandleSwitchToBackgroundEvent();
   631         iAppView->HandleSwitchToBackgroundEvent();
   590         
   632         
   591         iWg.SetOrdinalPosition(-1, ECoeWinPriorityNormal);
   633         iWg.SetOrdinalPosition(-1, ECoeWinPriorityNormal);
       
   634         
       
   635         iForegroundDelayed = EFalse;
   592         }
   636         }
   593 
   637 
   594     TSLOG_OUT();
   638     TSLOG_OUT();
   595     }
   639     }
   596 
   640 
   602     {
   646     {
   603     TSLOG_CONTEXT( HandleSwitchToForegroundEvent, TSLOG_LOCAL );
   647     TSLOG_CONTEXT( HandleSwitchToForegroundEvent, TSLOG_LOCAL );
   604     TSLOG_IN();
   648     TSLOG_IN();
   605 
   649 
   606     // must not do anything if iForeground is already up-to-date
   650     // must not do anything if iForeground is already up-to-date
   607     if ( !iForeground )
   651     if ( !iForeground && !iForegroundDelayed )
   608         {
   652         {
   609         TInt freeRamMemory;
   653         TInt freeRamMemory;
   610         HAL::Get( HALData::EMemoryRAMFree, freeRamMemory );
   654         HAL::Get( HALData::EMemoryRAMFree, freeRamMemory );
   611         if ( freeRamMemory <= KMinMemoryAmountInBytes )
   655         if ( freeRamMemory <= KMinMemoryAmountInBytes )
   612             {
   656             {
   882         wgId = underlyingWg;
   926         wgId = underlyingWg;
   883         }
   927         }
   884     return wgId;
   928     return wgId;
   885     }
   929     }
   886 
   930 
       
   931 // -----------------------------------------------------------------------------
       
   932 // CTsAppUi::IsUnderlyingAppMultimediaL
       
   933 // -----------------------------------------------------------------------------
       
   934 //
       
   935 TBool CTsAppUi::IsUnderlyingAppMultimediaL()
       
   936     {
       
   937     TBool retVal(EFalse);
       
   938     
       
   939     TApaTaskList taskList( iEikonEnv->WsSession() );
       
   940     TInt underlyingWg = taskList.FindByPos(0).WgId();
       
   941     
       
   942     CApaWindowGroupName* windowName =
       
   943         CApaWindowGroupName::NewLC( iEikonEnv->WsSession(), underlyingWg );
       
   944     TUid appUid = windowName->AppUid();
       
   945     CleanupStack::PopAndDestroy( windowName );
       
   946     if ( appUid == KTsCameraUid )
       
   947         {
       
   948         retVal = ETrue;
       
   949         }
       
   950     
       
   951     return retVal;
       
   952     }
       
   953 
       
   954 
       
   955 // -----------------------------------------------------------------------------
       
   956 // CTsAppUi::DelayedForegroundLaunched
       
   957 // -----------------------------------------------------------------------------
       
   958 //
       
   959 TBool CTsAppUi::DelayedForegroundLaunched()
       
   960     {
       
   961     return iDelayedForegroundInProgress;
       
   962     }
       
   963 
   887 // End of file
   964 // End of file