uifw/AknGlobalUI/AknCapServer/src/AknEikSgcs.cpp
branchRCL_3
changeset 9 aabf2c525e0f
parent 0 2f259fa3e83a
child 15 08e69e956a8c
equal deleted inserted replaced
4:8ca85d2f0db7 9:aabf2c525e0f
    48 #endif
    48 #endif
    49 
    49 
    50 #include <LayoutPack.cdl.h>
    50 #include <LayoutPack.cdl.h>
    51 #include <CdlRefs.h>
    51 #include <CdlRefs.h>
    52 const TInt KCdlEComInterfaceId = 0x101f8243;
    52 const TInt KCdlEComInterfaceId = 0x101f8243;
       
    53 const TInt KMatrixMenuAppId = 0x101F4CD2;
    53 
    54 
    54 const TInt KLayoutChangeTimeout = 2000000; // 2s
    55 const TInt KLayoutChangeTimeout = 2000000; // 2s
    55 const TInt KWgStatesGranularity = 4;
    56 const TInt KWgStatesGranularity = 4;
    56 const TInt KRelinquishedThreadListGranularity = 4;
    57 const TInt KRelinquishedThreadListGranularity = 4;
    57 const TInt KRemoveBlankDelay = 200000; // 0.2s
    58 const TInt KRemoveBlankDelay = 200000; // 0.2s
       
    59 const TInt KChangeIdleStateDelay = 200000; // 0.2s
    58 // Drawing is slower when transparency is enabled. The time needs to be
    60 // Drawing is slower when transparency is enabled. The time needs to be
    59 // big enough to account for slowest drawing application.
    61 // big enough to account for slowest drawing application.
    60 const TInt KRemoveBlankDelayTransparency = 1500000; // 1.5s
    62 const TInt KRemoveBlankDelayTransparency = 1500000; // 1.5s
    61 
    63 
    62 // 4s should be enough for foreground app's operations to complete.
    64 // 4s should be enough for foreground app's operations to complete.
   410     // ECom notifier for ILD installations
   412     // ECom notifier for ILD installations
   411 	TCallBack callback(CEikSgcServer::LayoutInstallationCallBack, this);
   413 	TCallBack callback(CEikSgcServer::LayoutInstallationCallBack, this);
   412 	iLayoutNotifier = CEComPluginNotifier::NewL(KNullUid, callback);
   414 	iLayoutNotifier = CEComPluginNotifier::NewL(KNullUid, callback);
   413 	iLayoutNotifier->Start();
   415 	iLayoutNotifier->Start();
   414 	EComPluginUtils::GetInfoArrayL(TUid::Uid(KCdlEComInterfaceId), iPrevPluginInfo);
   416 	EComPluginUtils::GetInfoArrayL(TUid::Uid(KCdlEComInterfaceId), iPrevPluginInfo);
       
   417 	
       
   418 	iChangeIdleState = CPeriodic::NewL(CActive::EPriorityStandard);  
   415     }
   419     }
   416 
   420 
   417 TInt CEikSgcServer::LayoutInstallationCallBack(TAny* aPtr)
   421 TInt CEikSgcServer::LayoutInstallationCallBack(TAny* aPtr)
   418 	{
   422 	{
   419 	return ((CEikSgcServer*)aPtr)->RefreshLayoutIfRequiredL();
   423 	return ((CEikSgcServer*)aPtr)->RefreshLayoutIfRequiredL();
   511     delete iWinChange;
   515     delete iWinChange;
   512     delete iLayoutChangeCallBack;
   516     delete iLayoutChangeCallBack;
   513     delete iWgStates;
   517     delete iWgStates;
   514     delete iRemoveBlankCallBack;
   518     delete iRemoveBlankCallBack;
   515     delete iLayoutNotifier;
   519     delete iLayoutNotifier;
       
   520     delete iChangeIdleState;
   516     }
   521     }
   517 
   522 
   518 void CEikSgcServer::HandleWindowGroupListChangeL()
   523 void CEikSgcServer::HandleWindowGroupListChangeL()
   519     {
   524     {
   520     CWgIds* wgIds = CreateWgIdListLC();
   525     CWgIds* wgIds = CreateWgIdListLC();
   521     if (!TestWgListOrderOk(wgIds))
   526     if (!TestWgListOrderOk(wgIds))
   522         {
   527         {
   523         ReOrderWgStatesL(wgIds);
   528         ReOrderWgStatesL(wgIds);
   524         PostChangeRecalcL();
   529         PostChangeRecalcL();
   525         UpdateNotificationsInIdleAllowedKey();
   530         UpdateIdleState();
   526         }
   531         }
   527     CleanupStack::PopAndDestroy( wgIds );
   532     CleanupStack::PopAndDestroy( wgIds );
   528     }
   533     }
   529 
   534 
   530 void CEikSgcServer::HandleWindowGroupParamChangeL(TInt aWgId, TBitFlags aAppFlags, TInt aSpLayout, 
   535 void CEikSgcServer::HandleWindowGroupParamChangeL(TInt aWgId, TBitFlags aAppFlags, TInt aSpLayout, 
   563     if (understandsPartialForegroundChanged || fullScreenChanged)
   568     if (understandsPartialForegroundChanged || fullScreenChanged)
   564         {
   569         {
   565         LOGTEXT1("  understandsPartialForegroundChanged: %d", understandsPartialForegroundChanged);
   570         LOGTEXT1("  understandsPartialForegroundChanged: %d", understandsPartialForegroundChanged);
   566         LOGTEXT1("  fullScreenChanged: %d",                   fullScreenChanged);        
   571         LOGTEXT1("  fullScreenChanged: %d",                   fullScreenChanged);        
   567         
   572         
   568         UpdateNotificationsInIdleAllowedKey();
   573         UpdateIdleState();
   569         }
   574         }
   570     
   575     
   571     LOGTEXT0("CEikSgcServer::HandleWindowGroupParamChangeL - EXIT");
   576     LOGTEXT0("CEikSgcServer::HandleWindowGroupParamChangeL - EXIT");
   572     }
   577     }
   573 
   578 
  1306         event.SetHandle(0);
  1311         event.SetHandle(0);
  1307         eikEnv->WsSession().SendEventToAllWindowGroups( 0, event );
  1312         eikEnv->WsSession().SendEventToAllWindowGroups( 0, event );
  1308         }
  1313         }
  1309     }
  1314     }
  1310 
  1315 
  1311 void CEikSgcServer::UpdateNotificationsInIdleAllowedKey()
  1316 TInt  CEikSgcServer::ForegroundWgId()
  1312     {
  1317     {
  1313     // First, get screensaver window group identifier.
  1318     // First, get screensaver window group identifier.
  1314     TApaTaskList taskList(CEikonEnv::Static()->WsSession());
  1319     TApaTaskList taskList(CEikonEnv::Static()->WsSession());
  1315     const TApaTask screensaverTask = taskList.FindApp(KScreensaverAppUid);
  1320     const TApaTask screensaverTask = taskList.FindApp(KScreensaverAppUid);
  1316     const TInt screensaverWgId = screensaverTask.WgId();
  1321     const TInt screensaverWgId = screensaverTask.WgId();
  1317     
  1322 
       
  1323     const TInt wgCount = iWgStates->Count();
       
  1324     TInt ii = FocusWgIndex();
       
  1325 
       
  1326     LOGTEXT0("======================================");LOGTEXT1("Window groups: %d", wgCount);LOGTEXT1("Idle wg id: %d", idleWgId);LOGTEXT1("Screensaver wg id: %d", screensaverWgId);LOGTEXT1("Focus window group: %d", ii);LOGTEXT0("======================================");
       
  1327 
       
  1328     // Loops window groups from top to bottom, starting from focus window group.
       
  1329     // (Index 0 contains the foreground window group.)
       
  1330     while (ii < wgCount)
       
  1331         {
       
  1332         const TWgState& state = iWgStates->At(ii);
       
  1333         const TInt currentWgId = state.WgId();
       
  1334 
       
  1335         LOGTEXT0("\n");LOGTEXT1("  Window group id: %d", currentWgId);LOGTEXT1("  UnderstandsPartialForeground: %d", state.UnderstandsPartialForeground());LOGTEXT1("  IsFullScreen: %d", state.IsFullScreen());
       
  1336 
       
  1337         // Ignores non-application window groups (e.g. incall bubble), partial screen
       
  1338         // applications and screensaver. 
       
  1339         if (state.UnderstandsPartialForeground() && state.IsFullScreen()
       
  1340                 && currentWgId != screensaverWgId)
       
  1341             {
       
  1342             return currentWgId;
       
  1343             }
       
  1344         ++ii;
       
  1345         }
       
  1346     return KErrNotFound;
       
  1347     }
       
  1348 
       
  1349 TBool CEikSgcServer::IsIdleForeground()
       
  1350     {
       
  1351     TApaTaskList taskList(CEikonEnv::Static()->WsSession());
  1318     // Get also idle window group identifier.
  1352     // Get also idle window group identifier.
  1319     TVwsViewId idleView;
  1353     TVwsViewId idleView;
  1320     if (AknDef::GetPhoneIdleViewId(idleView) != KErrNone)
  1354     if (AknDef::GetPhoneIdleViewId(idleView) != KErrNone)
  1321         {
  1355         {
  1322         return;
  1356         return EFalse;
  1323         }
  1357         }
  1324         
       
  1325     const TApaTask idleTask = taskList.FindApp(idleView.iAppUid);
  1358     const TApaTask idleTask = taskList.FindApp(idleView.iAppUid);
  1326     const TInt idleWgId = idleTask.WgId();
  1359     return (idleTask.WgId() == ForegroundWgId());
  1327     
  1360     }
  1328     // Then go through window groups skipping partial apps and screensaver - 
  1361 
  1329     // check if idleWgId follows.
  1362 void CEikSgcServer::SetIdleState(TBool aFlag)
  1330     TBool result = EFalse;
  1363     {
  1331     TBool found = EFalse;
       
  1332     const TInt wgCount = iWgStates->Count();
       
  1333     TInt ii = FocusWgIndex();
       
  1334         
       
  1335     LOGTEXT0("======================================");
       
  1336     LOGTEXT1("Window groups: %d",      wgCount);
       
  1337     LOGTEXT1("Idle wg id: %d",         idleWgId);
       
  1338     LOGTEXT1("Screensaver wg id: %d",  screensaverWgId);
       
  1339     LOGTEXT1("Focus window group: %d", ii);
       
  1340     LOGTEXT0("======================================");
       
  1341                 
       
  1342     // Loops window groups from top to bottom, starting from focus window group.
       
  1343     // (Index 0 contains the foreground window group.)
       
  1344     while (ii < wgCount && !found)
       
  1345         {
       
  1346         const TWgState& state = iWgStates->At(ii);
       
  1347         const TInt currentWgId = state.WgId();
       
  1348         
       
  1349         LOGTEXT0("\n");
       
  1350         LOGTEXT1("  Window group id: %d",              currentWgId);
       
  1351         LOGTEXT1("  UnderstandsPartialForeground: %d", state.UnderstandsPartialForeground());
       
  1352         LOGTEXT1("  IsFullScreen: %d",                 state.IsFullScreen());
       
  1353         
       
  1354         // Ignores non-application window groups (e.g. incall bubble), partial screen
       
  1355         // applications and screensaver. 
       
  1356         if (state.UnderstandsPartialForeground() &&
       
  1357             state.IsFullScreen()                 && 
       
  1358             currentWgId != screensaverWgId)        
       
  1359             {
       
  1360             // Check if current app is idle.
       
  1361             result = (idleWgId == currentWgId);
       
  1362             found = ETrue;
       
  1363             
       
  1364             LOGTEXT0("\n");
       
  1365             LOGTEXT1("Window group found. Result: %d", result);
       
  1366             }
       
  1367             
       
  1368         ii++;
       
  1369         }
       
  1370         
       
  1371     // Update the P&S key only if the value has been changed.
  1364     // Update the P&S key only if the value has been changed.
  1372     if ((iNotificationsInIdleAllowed && !result) || (!iNotificationsInIdleAllowed && result))
  1365     if ((iNotificationsInIdleAllowed && !aFlag)
  1373         {
  1366             || (!iNotificationsInIdleAllowed && aFlag))
  1374         iNotificationsInIdleAllowed = result;
  1367         {
  1375         RProperty::Set(KPSUidAvkonDomain, KAknNotificationsInIdleAllowed, result);
  1368         iNotificationsInIdleAllowed = aFlag;
  1376         }
  1369         RProperty::Set(KPSUidAvkonDomain, KAknNotificationsInIdleAllowed,aFlag);
  1377     } 
  1370         }
  1378     
  1371     }
       
  1372 
       
  1373 void CEikSgcServer::UpdateNotificationsInIdleAllowedKey()
       
  1374     {
       
  1375     SetIdleState(IsIdleForeground());
       
  1376     }     
  1379 
  1377 
  1380 TInt CEikSgcServer::RemoveBlankCallBack( TAny* aThis )
  1378 TInt CEikSgcServer::RemoveBlankCallBack( TAny* aThis )
  1381     {
  1379     {
  1382     static_cast<CEikSgcServer*>( aThis )->DoRemoveBlank();
  1380     static_cast<CEikSgcServer*>( aThis )->DoRemoveBlank();
  1383     return EFalse;
  1381     return EFalse;
  1491 			task.SendToBackground();	
  1489 			task.SendToBackground();	
  1492 		iMoveAppWdId = 0;
  1490 		iMoveAppWdId = 0;
  1493     	}
  1491     	}
  1494 	}
  1492 	}
  1495 
  1493 
       
  1494 void CEikSgcServer::UpdateIdleState()
       
  1495     {
       
  1496     if (ForegroundWgId() == KMatrixMenuAppId)
       
  1497         {
       
  1498         UpdateNotificationsInIdleAllowedKey();
       
  1499         return;
       
  1500         }
       
  1501 
       
  1502     if (iChangeIdleState && iChangeIdleState->IsActive())
       
  1503         {
       
  1504         iChangeIdleState->Cancel();
       
  1505         }
       
  1506 
       
  1507     iChangeIdleState->Start(KChangeIdleStateDelay, KChangeIdleStateDelay, TCallBack(ChangeIdleStateCallBack, this));
       
  1508     }
       
  1509 
       
  1510 void CEikSgcServer::DoChangeIdleState()
       
  1511     {
       
  1512     if(iChangeIdleState)
       
  1513         {
       
  1514         iChangeIdleState->Cancel();
       
  1515         }
       
  1516 
       
  1517     UpdateNotificationsInIdleAllowedKey();
       
  1518     }
       
  1519 TInt CEikSgcServer::ChangeIdleStateCallBack(TAny* aThis)
       
  1520     {
       
  1521     static_cast<CEikSgcServer*>(aThis)->DoChangeIdleState();
       
  1522     return EFalse;
       
  1523     }
  1496 
  1524 
  1497 //
  1525 //
  1498 // CAknSgcServerImpl
  1526 // CAknSgcServerImpl
  1499 //
  1527 //
  1500 CAknSgcServerImpl::CAknSgcServerImpl(CEikSgcServer* aServer)
  1528 CAknSgcServerImpl::CAknSgcServerImpl(CEikSgcServer* aServer)