uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp
branchRCL_3
changeset 19 e5af45d51884
parent 18 1801340c26a2
child 20 31fccae4f8a7
equal deleted inserted replaced
18:1801340c26a2 19:e5af45d51884
   161     TInt pluginIndex = iPluginList->Count();
   161     TInt pluginIndex = iPluginList->Count();
   162     while (pluginIndex--)
   162     while (pluginIndex--)
   163         {
   163         {
   164         // Get the config for this plugin
   164         // Get the config for this plugin
   165         CGOomRunPluginConfig& pluginConfig = aConfig.GetPluginConfig(iPluginList->Uid(pluginIndex));
   165         CGOomRunPluginConfig& pluginConfig = aConfig.GetPluginConfig(iPluginList->Uid(pluginIndex));
   166         TInt priority = pluginConfig.CalculatePluginPriority(aWindowGroupList);
       
   167 
       
   168         TGOomSyncMode syncMode = pluginConfig.iSyncMode;
       
   169         TInt ramEstimate = pluginConfig.iRamEstimate;
       
   170 
       
   171         TActionRef::TActionType actionType;
       
   172 
       
   173         if (pluginConfig.PluginType() == EGOomAppPlugin)
       
   174             {
       
   175             actionType = TActionRef::EAppPlugin;
       
   176             }
       
   177         else
       
   178             actionType = TActionRef::ESystemPlugin;
       
   179 
       
   180 
   166 
   181         //get skip plugin config for foreground app
   167         //get skip plugin config for foreground app
   182         TUint foregroundUid = iMonitor.ForegroundAppUid();
   168         TUint foregroundUid = iMonitor.ForegroundAppUid();
   183         if(aConfig.GetApplicationConfig(foregroundUid).iSkipPluginId == iPluginList->Uid(pluginIndex))
   169         if(aConfig.GetApplicationConfig(foregroundUid).iSkipPluginId == iPluginList->Uid(pluginIndex))
   184             {
   170             {
   195                         TRACES2("Skiping plugin %x, configured for app %x", iPluginList->Uid(pluginIndex), foregroundUid);
   181                         TRACES2("Skiping plugin %x, configured for app %x", iPluginList->Uid(pluginIndex), foregroundUid);
   196                         actionsIndex++;
   182                         actionsIndex++;
   197                         continue ; //skip this and continue with next plugin
   183                         continue ; //skip this and continue with next plugin
   198                         }
   184                         }
   199             }
   185             }
   200         
   186 
   201         TActionRef ref = TActionRef(actionType, priority, syncMode, ramEstimate, *(iRunPluginActions[actionsIndex]), aWindowGroupList.GetIndexFromAppId(pluginConfig.TargetApp()));
   187         actionsIndex--;
   202         iAppsProtectedByPlugins.Append(pluginConfig.TargetApp());
   188         CGOomRunPluginConfig * nextConfigForSamePlugin = &pluginConfig; 
   203         TRACES2("Creating Plugin Action Item %x , TargetAppId %x", iPluginList->Uid(pluginIndex), pluginConfig.TargetApp());
   189         while(nextConfigForSamePlugin)
   204         //It is valid to have plugins with equal priority
   190             {
   205         User::LeaveIfError(iActionRefs.InsertInOrderAllowRepeats(ref, ComparePriorities));
   191             TInt priority = nextConfigForSamePlugin->CalculatePluginPriority(aWindowGroupList);
       
   192             TGOomSyncMode syncMode = nextConfigForSamePlugin->iSyncMode;
       
   193             TInt ramEstimate = nextConfigForSamePlugin->iRamEstimate;
       
   194             TActionRef::TActionType actionType;
       
   195             if (nextConfigForSamePlugin->PluginType() == EGOomAppPlugin)
       
   196                 actionType = TActionRef::EAppPlugin;
       
   197             else
       
   198                 actionType = TActionRef::ESystemPlugin;
       
   199 
       
   200             TActionRef ref = TActionRef(actionType, priority, syncMode, ramEstimate, *(iRunPluginActions[++actionsIndex]), aWindowGroupList.GetIndexFromAppId(nextConfigForSamePlugin->TargetApp()));
       
   201             iAppsProtectedByPlugins.Append(nextConfigForSamePlugin->TargetApp());
       
   202             TRACES2("Creating Plugin Action Item %x , TargetAppId %x", iPluginList->Uid(pluginIndex), nextConfigForSamePlugin->TargetApp());
       
   203             //It is valid to have plugins with equal priority
       
   204             User::LeaveIfError(iActionRefs.InsertInOrderAllowRepeats(ref, ComparePriorities));
       
   205             nextConfigForSamePlugin = nextConfigForSamePlugin->iNextConfig;
       
   206             }
   206 
   207 
   207         actionsIndex++;
   208         actionsIndex++;
   208         }
   209         }
   209     
   210     
   210     TRACES1("BuildActionListL: Action list built with %d Plugin items",iActionRefs.Count());
   211     TRACES1("BuildActionListL: Action list built with %d Plugin items",iActionRefs.Count());
   233     TInt oldcount = iActionRefs.Count();
   234     TInt oldcount = iActionRefs.Count();
   234     
   235     
   235     if (aWindowGroupList.Count())
   236     if (aWindowGroupList.Count())
   236             {
   237             {
   237             // Go through each item in the wglist, create an app close action for this application
   238             // Go through each item in the wglist, create an app close action for this application
   238             TInt wgIndex = 0;
   239             TInt wgIndex = aWindowGroupList.Count() - 1;
   239             
   240             
   240             TRACES1("BuildActionListL: Windowgroup list count %d ",aWindowGroupList.Count());
   241             TRACES1("BuildActionListL: Windowgroup list count %d ",aWindowGroupList.Count());
   241     
   242     
   242             // Fix for when fast swap has focus, or pen input server has put itself into the foreground:
   243             // Fix for when fast swap has focus, or pen input server has put itself into the foreground:
   243             // the wg at index 1 should be considered as the foreground app.
   244             // the wg at index 1 should be considered as the foreground app.
   244             // stopIndex is calculated to take this into account.
   245             // stopIndex is calculated to take this into account.
   245             TUid foregroundUid = TUid::Uid(iMonitor.ForegroundAppUid());
   246             TUid foregroundUid = TUid::Uid(iMonitor.ForegroundAppUid());
   246     
   247     
   247             TRACES1("BuildActionListL: Foreground App %x ", foregroundUid);
   248             TRACES1("BuildActionListL: Foreground App %x ", foregroundUid);
   248             
   249             
   249             while (wgIndex < aWindowGroupList.Count())
   250             while (wgIndex >= 0)
   250                 {
   251                 {
   251                 CGOomCloseAppConfig* appCloseConfig = NULL;
   252                 CGOomCloseAppConfig* appCloseConfig = NULL;
   252     
   253     
   253                 // Get the app ID for the wglist item
   254                 // Get the app ID for the wglist item
   254                 // This sets the window group name
   255                 // This sets the window group name
   255                 TInt32 appId = aWindowGroupList.AppId(wgIndex, ETrue);
   256                 TInt32 appId = aWindowGroupList.AppId(wgIndex, ETrue);
   256                 
   257                 
   257                 if(AppCloseActionAlreadyExists(aWindowGroupList, appId))
   258                 if(AppCloseActionAlreadyExists(aWindowGroupList, appId))
   258                     {
   259                     {
   259                     TRACES2("CGOomActionList::BuildKillAppActionListL - Action item already exists for this app %x wgid %d", appId, aWindowGroupList.WgId(wgIndex).iId)
   260                     wgIndex--;
   260                     wgIndex++;
       
   261                     continue;
   261                     continue;
   262                     }
   262                     }
   263                     
   263                     
   264                 CApaWindowGroupName* wgName = aWindowGroupList.WgName();
   264                 CApaWindowGroupName* wgName = aWindowGroupList.WgName();
   265                 __ASSERT_DEBUG(wgName, GOomMonitorPanic(KInvalidWgName));
   265                 __ASSERT_DEBUG(wgName, GOomMonitorPanic(KInvalidWgName));
   317                         User::Leave(err);
   317                         User::Leave(err);
   318                         }
   318                         }
   319                     TRACES3("BuildActionListL: Adding app to action list, Uid = %x, wgId = %d, wgIndex = %d", appId, wgId, wgIndex);
   319                     TRACES3("BuildActionListL: Adding app to action list, Uid = %x, wgId = %d, wgIndex = %d", appId, wgId, wgIndex);
   320                     }
   320                     }
   321     
   321     
   322                 wgIndex++;
   322                 wgIndex--;
   323                 }
   323                 }
   324             }
   324             }
   325             
   325             
   326         TRACES1("BuildActionListL: Action list built with %d  new items",iActionRefs.Count()- oldcount);
   326         TRACES1("BuildActionListL: Action list built with %d  new items",iActionRefs.Count()- oldcount);
   327     }    
   327     }    
   333         {
   333         {
   334         TActionRef ref = iActionRefs[i];
   334         TActionRef ref = iActionRefs[i];
   335         if(ref.Type() == TActionRef::EAppClose )
   335         if(ref.Type() == TActionRef::EAppClose )
   336             {
   336             {
   337             if(aWindowGroupList.AppIdfromWgId(ref.WgId(), ETrue) == appId)
   337             if(aWindowGroupList.AppIdfromWgId(ref.WgId(), ETrue) == appId)
   338                 {
       
   339                 TRACES2("CGOomActionList::AppCloseActionAlreadyExists AppId %x already added with wgid %d",appId, ref.WgId());
       
   340                 return ETrue;
   338                 return ETrue;
   341                 }
       
   342             }
   339             }
   343         }
   340         }
   344         return EFalse;
   341         return EFalse;
   345     }
   342     }
   346 
   343 
   663 
   660 
   664 void CGOomActionList::AppNotExiting(TInt aWgId)
   661 void CGOomActionList::AppNotExiting(TInt aWgId)
   665     {
   662     {
   666     FUNC_LOG;
   663     FUNC_LOG;
   667 
   664 
   668     TInt index = 0;
   665     TInt index = iCloseAppActions.Count();
   669 
   666     TRACES1("CGOomCloseApp::AppNotExiting: count of actions %d",index);
   670     while (index < iCloseAppActions.Count())
   667 
       
   668     while (index--)
   671         {
   669         {
   672         CGOomCloseApp* action = iCloseAppActions[index];
   670         CGOomCloseApp* action = iCloseAppActions[index];
   673         TRACES3("CGOomCloseApp::AppNotExiting: recvd from %d , checking against %d , isRunning %d", aWgId, action->WgId(), action->IsRunning());
   671         TRACES3("CGOomCloseApp::AppNotExiting: %d %d %d", aWgId, action->WgId(), action->IsRunning());
   674         
   672         
   675         if ( (action->WgId() == aWgId) && (action->IsRunning()) )
   673         if ( (action->WgId() == aWgId) && (action->IsRunning()) )
   676             {
   674             {
   677             TRACES1("CGOomCloseApp::AppNotExiting: App with window group id %d has responded to the close event", aWgId);
   675             TRACES1("CGOomCloseApp::AppNotExiting: App with window group id %d has not responded to the close event", aWgId);
   678             action->CloseAppEvent();
   676             action->CloseAppEvent();
   679             break;
   677             }
   680             }
       
   681         
       
   682         index++;
       
   683         }
   678         }
   684     }
   679     }
   685 
   680 
   686 // From MGOomActionObserver
   681 // From MGOomActionObserver
   687 // An action has changed state (possibly it has completed freeing memory)
   682 // An action has changed state (possibly it has completed freeing memory)
   741                     iMonitor.WaitAndSynchroniseMemoryState();
   736                     iMonitor.WaitAndSynchroniseMemoryState();
   742                     }
   737                     }
   743                 }
   738                 }
   744             else
   739             else
   745                 {
   740                 {
       
   741                 iMonitor.SwitchMemMode(CMemoryMonitor::EGOomLowMemMode);
   746                 TRACES1("CGOomActionList::StateChanged: All current Plugin actions complete, below good threshold, Time to kill bad guys. freeMemory=%d", freeMemory);
   742                 TRACES1("CGOomActionList::StateChanged: All current Plugin actions complete, below good threshold, Time to kill bad guys. freeMemory=%d", freeMemory);
   747                 iRunningKillAppActions = ETrue;
   743                 iRunningKillAppActions = ETrue;
   748                 iMonitor.RunCloseAppActions(iMaxPriority);
   744                 iMonitor.RunCloseAppActions(iMaxPriority);
   749                 }
   745                 }
   750         
   746         
   786 
   782 
   787         // Create an action acording to the config
   783         // Create an action acording to the config
   788         CGOomRunPlugin* action = CGOomRunPlugin::NewL(iPluginList->Uid(pluginIndex), pluginConfig, *this, iPluginList->Implementation(pluginIndex));
   784         CGOomRunPlugin* action = CGOomRunPlugin::NewL(iPluginList->Uid(pluginIndex), pluginConfig, *this, iPluginList->Implementation(pluginIndex));
   789 
   785 
   790         iRunPluginActions.AppendL(action);
   786         iRunPluginActions.AppendL(action);
       
   787         
       
   788         CGOomRunPluginConfig * nextConfigForSamePlugin = pluginConfig.iNextConfig; 
       
   789         while(nextConfigForSamePlugin)
       
   790             {
       
   791             CGOomRunPlugin* action = CGOomRunPlugin::NewL(iPluginList->Uid(pluginIndex), *(nextConfigForSamePlugin), *this, iPluginList->Implementation(pluginIndex));
       
   792             iRunPluginActions.AppendL(action);
       
   793             nextConfigForSamePlugin = nextConfigForSamePlugin->iNextConfig; 
       
   794             }
   791         }
   795         }
   792 
   796 
   793 	//references to v2 plugin types removed as these are not yet used by GOOM
   797 	//references to v2 plugin types removed as these are not yet used by GOOM
   794 	
   798 	
   795     //allocate empty CGOomCloseApp objects
   799     //allocate empty CGOomCloseApp objects