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 |
166 |
180 |
167 //get skip plugin config for foreground app |
181 //get skip plugin config for foreground app |
168 TUint foregroundUid = iMonitor.ForegroundAppUid(); |
182 TUint foregroundUid = iMonitor.ForegroundAppUid(); |
169 if(aConfig.GetApplicationConfig(foregroundUid).iSkipPluginId == iPluginList->Uid(pluginIndex)) |
183 if(aConfig.GetApplicationConfig(foregroundUid).iSkipPluginId == iPluginList->Uid(pluginIndex)) |
170 { |
184 { |
181 TRACES2("Skiping plugin %x, configured for app %x", iPluginList->Uid(pluginIndex), foregroundUid); |
195 TRACES2("Skiping plugin %x, configured for app %x", iPluginList->Uid(pluginIndex), foregroundUid); |
182 actionsIndex++; |
196 actionsIndex++; |
183 continue ; //skip this and continue with next plugin |
197 continue ; //skip this and continue with next plugin |
184 } |
198 } |
185 } |
199 } |
186 |
200 |
187 actionsIndex--; |
201 TActionRef ref = TActionRef(actionType, priority, syncMode, ramEstimate, *(iRunPluginActions[actionsIndex]), aWindowGroupList.GetIndexFromAppId(pluginConfig.TargetApp())); |
188 CGOomRunPluginConfig * nextConfigForSamePlugin = &pluginConfig; |
202 iAppsProtectedByPlugins.Append(pluginConfig.TargetApp()); |
189 while(nextConfigForSamePlugin) |
203 TRACES2("Creating Plugin Action Item %x , TargetAppId %x", iPluginList->Uid(pluginIndex), pluginConfig.TargetApp()); |
190 { |
204 //It is valid to have plugins with equal priority |
191 TInt priority = nextConfigForSamePlugin->CalculatePluginPriority(aWindowGroupList); |
205 User::LeaveIfError(iActionRefs.InsertInOrderAllowRepeats(ref, ComparePriorities)); |
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 } |
|
207 |
206 |
208 actionsIndex++; |
207 actionsIndex++; |
209 } |
208 } |
210 |
209 |
211 TRACES1("BuildActionListL: Action list built with %d Plugin items",iActionRefs.Count()); |
210 TRACES1("BuildActionListL: Action list built with %d Plugin items",iActionRefs.Count()); |
234 TInt oldcount = iActionRefs.Count(); |
233 TInt oldcount = iActionRefs.Count(); |
235 |
234 |
236 if (aWindowGroupList.Count()) |
235 if (aWindowGroupList.Count()) |
237 { |
236 { |
238 // Go through each item in the wglist, create an app close action for this application |
237 // Go through each item in the wglist, create an app close action for this application |
239 TInt wgIndex = aWindowGroupList.Count() - 1; |
238 TInt wgIndex = 0; |
240 |
239 |
241 TRACES1("BuildActionListL: Windowgroup list count %d ",aWindowGroupList.Count()); |
240 TRACES1("BuildActionListL: Windowgroup list count %d ",aWindowGroupList.Count()); |
242 |
241 |
243 // Fix for when fast swap has focus, or pen input server has put itself into the foreground: |
242 // Fix for when fast swap has focus, or pen input server has put itself into the foreground: |
244 // the wg at index 1 should be considered as the foreground app. |
243 // the wg at index 1 should be considered as the foreground app. |
245 // stopIndex is calculated to take this into account. |
244 // stopIndex is calculated to take this into account. |
246 TUid foregroundUid = TUid::Uid(iMonitor.ForegroundAppUid()); |
245 TUid foregroundUid = TUid::Uid(iMonitor.ForegroundAppUid()); |
247 |
246 |
248 TRACES1("BuildActionListL: Foreground App %x ", foregroundUid); |
247 TRACES1("BuildActionListL: Foreground App %x ", foregroundUid); |
249 |
248 |
250 while (wgIndex >= 0) |
249 while (wgIndex < aWindowGroupList.Count()) |
251 { |
250 { |
252 CGOomCloseAppConfig* appCloseConfig = NULL; |
251 CGOomCloseAppConfig* appCloseConfig = NULL; |
253 |
252 |
254 // Get the app ID for the wglist item |
253 // Get the app ID for the wglist item |
255 // This sets the window group name |
254 // This sets the window group name |
256 TInt32 appId = aWindowGroupList.AppId(wgIndex, ETrue); |
255 TInt32 appId = aWindowGroupList.AppId(wgIndex, ETrue); |
257 |
256 |
258 if(AppCloseActionAlreadyExists(aWindowGroupList, appId)) |
257 if(AppCloseActionAlreadyExists(aWindowGroupList, appId)) |
259 { |
258 { |
260 wgIndex--; |
259 TRACES2("CGOomActionList::BuildKillAppActionListL - Action item already exists for this app %x wgid %d", appId, aWindowGroupList.WgId(wgIndex).iId) |
|
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 } |
660 |
663 |
661 void CGOomActionList::AppNotExiting(TInt aWgId) |
664 void CGOomActionList::AppNotExiting(TInt aWgId) |
662 { |
665 { |
663 FUNC_LOG; |
666 FUNC_LOG; |
664 |
667 |
665 TInt index = iCloseAppActions.Count(); |
668 TInt index = 0; |
666 TRACES1("CGOomCloseApp::AppNotExiting: count of actions %d",index); |
669 |
667 |
670 while (index < iCloseAppActions.Count()) |
668 while (index--) |
|
669 { |
671 { |
670 CGOomCloseApp* action = iCloseAppActions[index]; |
672 CGOomCloseApp* action = iCloseAppActions[index]; |
671 TRACES3("CGOomCloseApp::AppNotExiting: %d %d %d", aWgId, action->WgId(), action->IsRunning()); |
673 TRACES3("CGOomCloseApp::AppNotExiting: recvd from %d , checking against %d , isRunning %d", aWgId, action->WgId(), action->IsRunning()); |
672 |
674 |
673 if ( (action->WgId() == aWgId) && (action->IsRunning()) ) |
675 if ( (action->WgId() == aWgId) && (action->IsRunning()) ) |
674 { |
676 { |
675 TRACES1("CGOomCloseApp::AppNotExiting: App with window group id %d has not responded to the close event", aWgId); |
677 TRACES1("CGOomCloseApp::AppNotExiting: App with window group id %d has responded to the close event", aWgId); |
676 action->CloseAppEvent(); |
678 action->CloseAppEvent(); |
677 } |
679 break; |
|
680 } |
|
681 |
|
682 index++; |
678 } |
683 } |
679 } |
684 } |
680 |
685 |
681 // From MGOomActionObserver |
686 // From MGOomActionObserver |
682 // An action has changed state (possibly it has completed freeing memory) |
687 // An action has changed state (possibly it has completed freeing memory) |
736 iMonitor.WaitAndSynchroniseMemoryState(); |
741 iMonitor.WaitAndSynchroniseMemoryState(); |
737 } |
742 } |
738 } |
743 } |
739 else |
744 else |
740 { |
745 { |
741 iMonitor.SwitchMemMode(CMemoryMonitor::EGOomLowMemMode); |
|
742 TRACES1("CGOomActionList::StateChanged: All current Plugin actions complete, below good threshold, Time to kill bad guys. freeMemory=%d", freeMemory); |
746 TRACES1("CGOomActionList::StateChanged: All current Plugin actions complete, below good threshold, Time to kill bad guys. freeMemory=%d", freeMemory); |
743 iRunningKillAppActions = ETrue; |
747 iRunningKillAppActions = ETrue; |
744 iMonitor.RunCloseAppActions(iMaxPriority); |
748 iMonitor.RunCloseAppActions(iMaxPriority); |
745 } |
749 } |
746 |
750 |
782 |
786 |
783 // Create an action acording to the config |
787 // Create an action acording to the config |
784 CGOomRunPlugin* action = CGOomRunPlugin::NewL(iPluginList->Uid(pluginIndex), pluginConfig, *this, iPluginList->Implementation(pluginIndex)); |
788 CGOomRunPlugin* action = CGOomRunPlugin::NewL(iPluginList->Uid(pluginIndex), pluginConfig, *this, iPluginList->Implementation(pluginIndex)); |
785 |
789 |
786 iRunPluginActions.AppendL(action); |
790 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 } |
|
795 } |
791 } |
796 |
792 |
797 //references to v2 plugin types removed as these are not yet used by GOOM |
793 //references to v2 plugin types removed as these are not yet used by GOOM |
798 |
794 |
799 //allocate empty CGOomCloseApp objects |
795 //allocate empty CGOomCloseApp objects |