Loading core/java/android/app/ActivityThread.java +3 −1 Original line number Diff line number Diff line Loading @@ -955,7 +955,7 @@ public final class ActivityThread { } public void scheduleTrimMemory(int level) { queueOrSendMessage(H.TRIM_MEMORY, level); queueOrSendMessage(H.TRIM_MEMORY, null, level); } } Loading Loading @@ -1185,8 +1185,10 @@ public final class ActivityThread { break; case UPDATE_PACKAGE_COMPATIBILITY_INFO: handleUpdatePackageCompatibilityInfo((UpdateCompatibilityData)msg.obj); break; case TRIM_MEMORY: handleTrimMemory(msg.arg1); break; } if (DEBUG_MESSAGES) Slog.v(TAG, "<<< done: " + msg.what); } Loading core/java/android/content/ComponentCallbacks.java +2 −5 Original line number Diff line number Diff line Loading @@ -56,11 +56,8 @@ public interface ComponentCallbacks { static final int TRIM_MEMORY_COMPLETE = 80; /** @hide */ static final int TRIM_MEMORY_MODERATE = 60; static final int TRIM_MEMORY_MODERATE = 50; /** @hide */ static final int TRIM_MEMORY_BACKGROUND = 40; /** @hide */ static final int TRIM_MEMORY_INVISIBLE = 20; static final int TRIM_MEMORY_BACKGROUND = 20; } services/java/com/android/server/am/ActivityManagerService.java +29 −19 Original line number Diff line number Diff line Loading @@ -3628,6 +3628,7 @@ public final class ActivityManagerService extends ActivityManagerNative app.setSchedGroup = Process.THREAD_GROUP_BG_NONINTERACTIVE; app.forcingToForeground = null; app.foregroundServices = false; app.hasShownUi = false; app.debugging = false; mHandler.removeMessages(PROC_START_TIMEOUT_MSG, app); Loading Loading @@ -9218,6 +9219,7 @@ public final class ActivityManagerService extends ActivityManagerNative app.forcingToForeground = null; app.foregroundServices = false; app.foregroundActivities = false; app.hasShownUi = false; killServicesLocked(app, true); Loading Loading @@ -9331,8 +9333,6 @@ public final class ActivityManagerService extends ActivityManagerNative // This app is persistent, so we need to keep its record around. // If it is not already on the pending app list, add it there // and start a new process for it. app.forcingToForeground = null; app.foregroundServices = false; if (mPersistentStartingProcesses.indexOf(app) < 0) { mPersistentStartingProcesses.add(app); restart = true; Loading Loading @@ -12728,6 +12728,15 @@ public final class ActivityManagerService extends ActivityManagerNative while (jt.hasNext() && adj > FOREGROUND_APP_ADJ) { ServiceRecord s = jt.next(); if (s.startRequested) { if (app.hasShownUi) { // If this process has shown some UI, let it immediately // go to the LRU list because it may be pretty heavy with // UI stuff. We'll tag it with a label just to help // debug and understand what is going on. if (adj > SECONDARY_SERVER_ADJ) { app.adjType = "started-bg-ui-services"; } } else { if (now < (s.lastActivity+MAX_SERVICE_INACTIVITY)) { // This service has seen some activity within // recent memory, so we will keep its process ahead Loading @@ -12744,6 +12753,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (adj > SECONDARY_SERVER_ADJ) { app.adjType = "started-bg-services"; } } // Don't kill this process because it is doing work; it // has said it is doing work. app.keeping = true; Loading Loading @@ -13351,15 +13361,15 @@ public final class ActivityManagerService extends ActivityManagerNative break; } } } else if (app.curAdj >= PERCEPTIBLE_APP_ADJ) { if (app.trimMemoryLevel < ComponentCallbacks.TRIM_MEMORY_INVISIBLE } else if (app.curAdj == HEAVY_WEIGHT_APP_ADJ) { if (app.trimMemoryLevel < ComponentCallbacks.TRIM_MEMORY_BACKGROUND && app.thread != null) { try { app.thread.scheduleTrimMemory(ComponentCallbacks.TRIM_MEMORY_INVISIBLE); app.thread.scheduleTrimMemory(ComponentCallbacks.TRIM_MEMORY_BACKGROUND); } catch (RemoteException e) { } } app.trimMemoryLevel = ComponentCallbacks.TRIM_MEMORY_INVISIBLE; app.trimMemoryLevel = ComponentCallbacks.TRIM_MEMORY_BACKGROUND; } else { app.trimMemoryLevel = 0; } services/java/com/android/server/am/ActivityStack.java +1 −0 Original line number Diff line number Diff line Loading @@ -559,6 +559,7 @@ final class ActivityStack { r.forceNewConfig = false; showAskCompatModeDialogLocked(r); r.compat = mService.compatibilityInfoForPackageLocked(r.info.applicationInfo); app.hasShownUi = true; app.thread.scheduleLaunchActivity(new Intent(r.intent), r, System.identityHashCode(r), r.info, r.compat, r.icicle, results, newIntents, !andResume, Loading services/java/com/android/server/am/ProcessRecord.java +2 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ class ProcessRecord { boolean setIsForeground; // Running foreground UI when last set? boolean foregroundServices; // Running any services that are foreground? boolean foregroundActivities; // Running any activities that are foreground? boolean hasShownUi; // Has UI been shown in this process since it was started? boolean bad; // True if disabled in the bad process list boolean killedBackground; // True when proc has been killed due to too many bg String waitingToKill; // Process is waiting to be killed when in the bg; reason Loading Loading @@ -185,6 +186,7 @@ class ProcessRecord { pw.print(prefix); pw.print("curSchedGroup="); pw.print(curSchedGroup); pw.print(" setSchedGroup="); pw.print(setSchedGroup); pw.print(" trimMemoryLevel="); pw.println(trimMemoryLevel); pw.print(" hasShownUi="); pw.println(hasShownUi); pw.print(prefix); pw.print("setIsForeground="); pw.print(setIsForeground); pw.print(" foregroundServices="); pw.print(foregroundServices); pw.print(" forcingToForeground="); pw.println(forcingToForeground); Loading Loading
core/java/android/app/ActivityThread.java +3 −1 Original line number Diff line number Diff line Loading @@ -955,7 +955,7 @@ public final class ActivityThread { } public void scheduleTrimMemory(int level) { queueOrSendMessage(H.TRIM_MEMORY, level); queueOrSendMessage(H.TRIM_MEMORY, null, level); } } Loading Loading @@ -1185,8 +1185,10 @@ public final class ActivityThread { break; case UPDATE_PACKAGE_COMPATIBILITY_INFO: handleUpdatePackageCompatibilityInfo((UpdateCompatibilityData)msg.obj); break; case TRIM_MEMORY: handleTrimMemory(msg.arg1); break; } if (DEBUG_MESSAGES) Slog.v(TAG, "<<< done: " + msg.what); } Loading
core/java/android/content/ComponentCallbacks.java +2 −5 Original line number Diff line number Diff line Loading @@ -56,11 +56,8 @@ public interface ComponentCallbacks { static final int TRIM_MEMORY_COMPLETE = 80; /** @hide */ static final int TRIM_MEMORY_MODERATE = 60; static final int TRIM_MEMORY_MODERATE = 50; /** @hide */ static final int TRIM_MEMORY_BACKGROUND = 40; /** @hide */ static final int TRIM_MEMORY_INVISIBLE = 20; static final int TRIM_MEMORY_BACKGROUND = 20; }
services/java/com/android/server/am/ActivityManagerService.java +29 −19 Original line number Diff line number Diff line Loading @@ -3628,6 +3628,7 @@ public final class ActivityManagerService extends ActivityManagerNative app.setSchedGroup = Process.THREAD_GROUP_BG_NONINTERACTIVE; app.forcingToForeground = null; app.foregroundServices = false; app.hasShownUi = false; app.debugging = false; mHandler.removeMessages(PROC_START_TIMEOUT_MSG, app); Loading Loading @@ -9218,6 +9219,7 @@ public final class ActivityManagerService extends ActivityManagerNative app.forcingToForeground = null; app.foregroundServices = false; app.foregroundActivities = false; app.hasShownUi = false; killServicesLocked(app, true); Loading Loading @@ -9331,8 +9333,6 @@ public final class ActivityManagerService extends ActivityManagerNative // This app is persistent, so we need to keep its record around. // If it is not already on the pending app list, add it there // and start a new process for it. app.forcingToForeground = null; app.foregroundServices = false; if (mPersistentStartingProcesses.indexOf(app) < 0) { mPersistentStartingProcesses.add(app); restart = true; Loading Loading @@ -12728,6 +12728,15 @@ public final class ActivityManagerService extends ActivityManagerNative while (jt.hasNext() && adj > FOREGROUND_APP_ADJ) { ServiceRecord s = jt.next(); if (s.startRequested) { if (app.hasShownUi) { // If this process has shown some UI, let it immediately // go to the LRU list because it may be pretty heavy with // UI stuff. We'll tag it with a label just to help // debug and understand what is going on. if (adj > SECONDARY_SERVER_ADJ) { app.adjType = "started-bg-ui-services"; } } else { if (now < (s.lastActivity+MAX_SERVICE_INACTIVITY)) { // This service has seen some activity within // recent memory, so we will keep its process ahead Loading @@ -12744,6 +12753,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (adj > SECONDARY_SERVER_ADJ) { app.adjType = "started-bg-services"; } } // Don't kill this process because it is doing work; it // has said it is doing work. app.keeping = true; Loading Loading @@ -13351,15 +13361,15 @@ public final class ActivityManagerService extends ActivityManagerNative break; } } } else if (app.curAdj >= PERCEPTIBLE_APP_ADJ) { if (app.trimMemoryLevel < ComponentCallbacks.TRIM_MEMORY_INVISIBLE } else if (app.curAdj == HEAVY_WEIGHT_APP_ADJ) { if (app.trimMemoryLevel < ComponentCallbacks.TRIM_MEMORY_BACKGROUND && app.thread != null) { try { app.thread.scheduleTrimMemory(ComponentCallbacks.TRIM_MEMORY_INVISIBLE); app.thread.scheduleTrimMemory(ComponentCallbacks.TRIM_MEMORY_BACKGROUND); } catch (RemoteException e) { } } app.trimMemoryLevel = ComponentCallbacks.TRIM_MEMORY_INVISIBLE; app.trimMemoryLevel = ComponentCallbacks.TRIM_MEMORY_BACKGROUND; } else { app.trimMemoryLevel = 0; }
services/java/com/android/server/am/ActivityStack.java +1 −0 Original line number Diff line number Diff line Loading @@ -559,6 +559,7 @@ final class ActivityStack { r.forceNewConfig = false; showAskCompatModeDialogLocked(r); r.compat = mService.compatibilityInfoForPackageLocked(r.info.applicationInfo); app.hasShownUi = true; app.thread.scheduleLaunchActivity(new Intent(r.intent), r, System.identityHashCode(r), r.info, r.compat, r.icicle, results, newIntents, !andResume, Loading
services/java/com/android/server/am/ProcessRecord.java +2 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ class ProcessRecord { boolean setIsForeground; // Running foreground UI when last set? boolean foregroundServices; // Running any services that are foreground? boolean foregroundActivities; // Running any activities that are foreground? boolean hasShownUi; // Has UI been shown in this process since it was started? boolean bad; // True if disabled in the bad process list boolean killedBackground; // True when proc has been killed due to too many bg String waitingToKill; // Process is waiting to be killed when in the bg; reason Loading Loading @@ -185,6 +186,7 @@ class ProcessRecord { pw.print(prefix); pw.print("curSchedGroup="); pw.print(curSchedGroup); pw.print(" setSchedGroup="); pw.print(setSchedGroup); pw.print(" trimMemoryLevel="); pw.println(trimMemoryLevel); pw.print(" hasShownUi="); pw.println(hasShownUi); pw.print(prefix); pw.print("setIsForeground="); pw.print(setIsForeground); pw.print(" foregroundServices="); pw.print(foregroundServices); pw.print(" forcingToForeground="); pw.println(forcingToForeground); Loading