Loading core/java/android/app/ActivityManager.java +8 −0 Original line number Diff line number Diff line Loading @@ -1254,6 +1254,12 @@ public class ActivityManager { */ public ComponentName importanceReasonComponent; /** * When {@link importanceReasonPid} is non-0, this is the importance * of the other pid. @hide */ public int importanceReasonImportance; public RunningAppProcessInfo() { importance = IMPORTANCE_FOREGROUND; importanceReasonCode = REASON_UNKNOWN; Loading @@ -1280,6 +1286,7 @@ public class ActivityManager { dest.writeInt(importanceReasonCode); dest.writeInt(importanceReasonPid); ComponentName.writeToParcel(importanceReasonComponent, dest); dest.writeInt(importanceReasonImportance); } public void readFromParcel(Parcel source) { Loading @@ -1293,6 +1300,7 @@ public class ActivityManager { importanceReasonCode = source.readInt(); importanceReasonPid = source.readInt(); importanceReasonComponent = ComponentName.readFromParcel(source); importanceReasonImportance = source.readInt(); } public static final Creator<RunningAppProcessInfo> CREATOR = Loading core/java/android/content/Context.java +3 −0 Original line number Diff line number Diff line Loading @@ -239,6 +239,9 @@ public abstract class Context { * methods of activities and other components are called. Note that you * <em>must</em> be sure to use {@link #unregisterComponentCallbacks} when * appropriate in the future; this will not be removed for you. * * @param callback The interface to call. This can be either a * {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface. */ public void registerComponentCallbacks(ComponentCallbacks callback) { getApplicationContext().registerComponentCallbacks(callback); Loading core/java/com/android/internal/app/ResolverActivity.java +12 −1 Original line number Diff line number Diff line Loading @@ -58,9 +58,20 @@ public class ResolverActivity extends AlertActivity implements private TextView mClearDefaultHint; private PackageManager mPm; private Intent makeMyIntent() { Intent intent = new Intent(getIntent()); // The resolver activity is set to be hidden from recent tasks. // we don't want this attribute to be propagated to the next activity // being launched. Note that if the original Intent also had this // flag set, we are now losing it. That should be a very rare case // and we can live with this. intent.setFlags(intent.getFlags()&~Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); return intent; } @Override protected void onCreate(Bundle savedInstanceState) { onCreate(savedInstanceState, new Intent(getIntent()), onCreate(savedInstanceState, makeMyIntent(), getResources().getText(com.android.internal.R.string.whichApplication), null, null, true); } Loading core/res/AndroidManifest.xml +16 −8 Original line number Diff line number Diff line Loading @@ -1499,19 +1499,23 @@ android:theme="@style/Theme.Holo.Dialog" android:label="@string/heavy_weight_switcher_title" android:finishOnCloseSystemDialogs="true" android:excludeFromRecents="true"> android:excludeFromRecents="true" android:process=":ui"> </activity> <activity android:name="com.android.internal.app.PlatLogoActivity" android:theme="@style/Theme.Wallpaper.NoTitleBar.Fullscreen"> android:theme="@style/Theme.Wallpaper.NoTitleBar.Fullscreen" android:process=":ui"> </activity> <activity android:name="com.android.internal.app.DisableCarModeActivity" android:theme="@style/Theme.NoDisplay" android:excludeFromRecents="true"> android:excludeFromRecents="true" android:process=":ui"> </activity> <activity android:name="com.android.internal.app.RingtonePickerActivity" android:theme="@style/Theme.Holo.Dialog.Alert" android:excludeFromRecents="true" android:multiprocess="true"> android:multiprocess="true" android:process=":ui"> <intent-filter> <action android:name="android.intent.action.RINGTONE_PICKER" /> <category android:name="android.intent.category.DEFAULT" /> Loading @@ -1522,18 +1526,21 @@ android:excludeFromRecents="true" android:exported="true" android:theme="@android:style/Theme.Holo.Dialog" android:label="@string/choose_account_label"> android:label="@string/choose_account_label" android:process=":ui"> </activity> <activity android:name="android.accounts.GrantCredentialsPermissionActivity" android:excludeFromRecents="true" android:exported="true" android:theme="@android:style/Theme.Holo.DialogWhenLarge"> android:theme="@android:style/Theme.Holo.DialogWhenLarge" android:process=":ui"> </activity> <activity android:name="android.content.SyncActivityTooManyDeletes" android:theme="@android:style/Theme.Holo.Dialog" android:label="@string/sync_too_many_deletes"> android:label="@string/sync_too_many_deletes" android:process=":ui"> </activity> <activity android:name="com.android.server.ShutdownActivity" Loading @@ -1551,7 +1558,8 @@ <activity android:name="com.android.internal.app.NetInitiatedActivity" android:theme="@style/Theme.Holo.Dialog.Alert" android:excludeFromRecents="true"> android:excludeFromRecents="true" android:process=":ui"> </activity> <receiver android:name="com.android.server.BootReceiver" > Loading services/java/com/android/server/am/ActivityManagerService.java +84 −59 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ import android.os.SystemClock; import android.os.SystemProperties; import android.provider.Settings; import android.util.EventLog; import android.util.Pair; import android.util.Slog; import android.util.Log; import android.util.PrintWriterPrinter; Loading Loading @@ -5004,7 +5005,13 @@ public final class ActivityManagerService extends ActivityManagerNative maxNum < N ? maxNum : N); for (int i=0; i<N && maxNum > 0; i++) { TaskRecord tr = mRecentTasks.get(i); if (((flags&ActivityManager.RECENT_WITH_EXCLUDED) != 0) // Return the entry if desired by the caller. We always return // the first entry, because callers always expect this to be the // forground app. We may filter others if the caller has // not supplied RECENT_WITH_EXCLUDED and there is some reason // we should exclude the entry. if (i == 0 || ((flags&ActivityManager.RECENT_WITH_EXCLUDED) != 0) || (tr.intent == null) || ((tr.intent.getFlags() &Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0)) { Loading Loading @@ -7547,6 +7554,32 @@ public final class ActivityManagerService extends ActivityManagerNative return errList; } static int oomAdjToImportance(int adj, ActivityManager.RunningAppProcessInfo currApp) { if (adj >= ProcessList.EMPTY_APP_ADJ) { return ActivityManager.RunningAppProcessInfo.IMPORTANCE_EMPTY; } else if (adj >= ProcessList.HIDDEN_APP_MIN_ADJ) { if (currApp != null) { currApp.lru = adj - ProcessList.HIDDEN_APP_MIN_ADJ + 1; } return ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND; } else if (adj >= ProcessList.HOME_APP_ADJ) { if (currApp != null) { currApp.lru = 0; } return ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND; } else if (adj >= ProcessList.SECONDARY_SERVER_ADJ) { return ActivityManager.RunningAppProcessInfo.IMPORTANCE_SERVICE; } else if (adj >= ProcessList.HEAVY_WEIGHT_APP_ADJ) { return ActivityManager.RunningAppProcessInfo.IMPORTANCE_CANT_SAVE_STATE; } else if (adj >= ProcessList.PERCEPTIBLE_APP_ADJ) { return ActivityManager.RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE; } else if (adj >= ProcessList.VISIBLE_APP_ADJ) { return ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE; } else { return ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND; } } public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses() { // Lazy instantiation of list List<ActivityManager.RunningAppProcessInfo> runList = null; Loading @@ -7567,28 +7600,12 @@ public final class ActivityManagerService extends ActivityManagerNative currApp.flags |= ActivityManager.RunningAppProcessInfo.FLAG_PERSISTENT; } int adj = app.curAdj; if (adj >= ProcessList.EMPTY_APP_ADJ) { currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_EMPTY; } else if (adj >= ProcessList.HIDDEN_APP_MIN_ADJ) { currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND; currApp.lru = adj - ProcessList.HIDDEN_APP_MIN_ADJ + 1; } else if (adj >= ProcessList.HOME_APP_ADJ) { currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND; currApp.lru = 0; } else if (adj >= ProcessList.SECONDARY_SERVER_ADJ) { currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_SERVICE; } else if (adj >= ProcessList.HEAVY_WEIGHT_APP_ADJ) { currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_CANT_SAVE_STATE; } else if (adj >= ProcessList.PERCEPTIBLE_APP_ADJ) { currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE; } else if (adj >= ProcessList.VISIBLE_APP_ADJ) { currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE; } else { currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND; } currApp.importance = oomAdjToImportance(adj, currApp); currApp.importanceReasonCode = app.adjTypeCode; if (app.adjSource instanceof ProcessRecord) { currApp.importanceReasonPid = ((ProcessRecord)app.adjSource).pid; currApp.importanceReasonImportance = oomAdjToImportance( app.adjSourceOom, null); } else if (app.adjSource instanceof ActivityRecord) { ActivityRecord r = (ActivityRecord)app.adjSource; if (r.app != null) currApp.importanceReasonPid = r.app.pid; Loading Loading @@ -7891,7 +7908,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (mLruProcesses.size() > 0) { if (needSep) pw.println(" "); needSep = true; pw.println(" Process LRU list (most recent first):"); pw.println(" Process LRU list (sorted by oom_adj):"); dumpProcessOomList(pw, this, mLruProcesses, " ", "Proc", "PERS", false); needSep = true; Loading Loading @@ -8069,29 +8086,6 @@ public final class ActivityManagerService extends ActivityManagerNative boolean needSep = false; if (mLruProcesses.size() > 0) { ArrayList<ProcessRecord> procs = new ArrayList<ProcessRecord>(mLruProcesses); Comparator<ProcessRecord> comparator = new Comparator<ProcessRecord>() { @Override public int compare(ProcessRecord object1, ProcessRecord object2) { if (object1.setAdj != object2.setAdj) { return object1.setAdj > object2.setAdj ? -1 : 1; } if (object1.setSchedGroup != object2.setSchedGroup) { return object1.setSchedGroup > object2.setSchedGroup ? -1 : 1; } if (object1.keeping != object2.keeping) { return object1.keeping ? -1 : 1; } if (object1.pid != object2.pid) { return object1.pid > object2.pid ? -1 : 1; } return 0; } }; Collections.sort(procs, comparator); if (needSep) pw.println(" "); needSep = true; pw.println(" OOM levels:"); Loading @@ -8110,7 +8104,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (needSep) pw.println(" "); needSep = true; pw.println(" Process OOM control:"); dumpProcessOomList(pw, this, procs, " ", dumpProcessOomList(pw, this, mLruProcesses, " ", "Proc", "PERS", true); needSep = true; } Loading Loading @@ -8859,10 +8853,33 @@ public final class ActivityManagerService extends ActivityManagerNative } private static final void dumpProcessOomList(PrintWriter pw, ActivityManagerService service, List<ProcessRecord> list, ActivityManagerService service, List<ProcessRecord> origList, String prefix, String normalLabel, String persistentLabel, boolean inclDetails) { ArrayList<Pair<ProcessRecord, Integer>> list = new ArrayList<Pair<ProcessRecord, Integer>>(origList.size()); for (int i=0; i<origList.size(); i++) { list.add(new Pair<ProcessRecord, Integer>(origList.get(i), i)); } Comparator<Pair<ProcessRecord, Integer>> comparator = new Comparator<Pair<ProcessRecord, Integer>>() { @Override public int compare(Pair<ProcessRecord, Integer> object1, Pair<ProcessRecord, Integer> object2) { if (object1.first.setAdj != object2.first.setAdj) { return object1.first.setAdj > object2.first.setAdj ? -1 : 1; } if (object1.second.intValue() != object2.second.intValue()) { return object1.second.intValue() > object2.second.intValue() ? -1 : 1; } return 0; } }; Collections.sort(list, comparator); final long curRealtime = SystemClock.elapsedRealtime(); final long realtimeSince = curRealtime - service.mLastPowerCheckRealtime; final long curUptime = SystemClock.uptimeMillis(); Loading @@ -8870,7 +8887,7 @@ public final class ActivityManagerService extends ActivityManagerNative final int N = list.size()-1; for (int i=N; i>=0; i--) { ProcessRecord r = list.get(i); ProcessRecord r = list.get(i).first; String oomAdj; if (r.setAdj >= ProcessList.EMPTY_APP_ADJ) { oomAdj = buildOomTag("empty", null, r.setAdj, ProcessList.EMPTY_APP_ADJ); Loading Loading @@ -8919,7 +8936,7 @@ public final class ActivityManagerService extends ActivityManagerNative } pw.println(String.format("%s%s #%2d: adj=%s/%s%s trm=%2d %s (%s)", prefix, (r.persistent ? persistentLabel : normalLabel), N-i, oomAdj, schedGroup, foreground, r.trimMemoryLevel, N-list.get(i).second, oomAdj, schedGroup, foreground, r.trimMemoryLevel, r.toShortString(), r.adjType)); if (r.adjSource != null || r.adjTarget != null) { pw.print(prefix); Loading Loading @@ -13118,6 +13135,7 @@ public final class ActivityManagerService extends ActivityManagerNative app.adjTypeCode = ActivityManager.RunningAppProcessInfo .REASON_SERVICE_IN_USE; app.adjSource = cr.binding.client; app.adjSourceOom = clientAdj; app.adjTarget = s.name; } if ((cr.flags&Context.BIND_NOT_FOREGROUND) == 0) { Loading @@ -13140,6 +13158,7 @@ public final class ActivityManagerService extends ActivityManagerNative app.adjTypeCode = ActivityManager.RunningAppProcessInfo .REASON_SERVICE_IN_USE; app.adjSource = a; app.adjSourceOom = adj; app.adjTarget = s.name; } } Loading Loading @@ -13201,6 +13220,7 @@ public final class ActivityManagerService extends ActivityManagerNative app.adjTypeCode = ActivityManager.RunningAppProcessInfo .REASON_PROVIDER_IN_USE; app.adjSource = client; app.adjSourceOom = clientAdj; app.adjTarget = cpr.name; } if (client.curSchedGroup == Process.THREAD_GROUP_DEFAULT) { Loading Loading @@ -13511,6 +13531,10 @@ public final class ActivityManagerService extends ActivityManagerNative computeOomAdjLocked(app, hiddenAdj, TOP_APP, false); if (app.curRawAdj != app.setRawAdj) { if (false) { // Removing for now. Forcing GCs is not so useful anymore // with Dalvik, and the new memory level hint facility is // better for what we need to do these days. if (app.curRawAdj > ProcessList.FOREGROUND_APP_ADJ && app.setRawAdj <= ProcessList.FOREGROUND_APP_ADJ) { // If this app is transitioning from foreground to Loading @@ -13522,6 +13546,7 @@ public final class ActivityManagerService extends ActivityManagerNative // background (such as a service stopping). scheduleAppGcLocked(app); } } if (wasKeeping && !app.keeping) { // This app is no longer something we want to keep. Note Loading
core/java/android/app/ActivityManager.java +8 −0 Original line number Diff line number Diff line Loading @@ -1254,6 +1254,12 @@ public class ActivityManager { */ public ComponentName importanceReasonComponent; /** * When {@link importanceReasonPid} is non-0, this is the importance * of the other pid. @hide */ public int importanceReasonImportance; public RunningAppProcessInfo() { importance = IMPORTANCE_FOREGROUND; importanceReasonCode = REASON_UNKNOWN; Loading @@ -1280,6 +1286,7 @@ public class ActivityManager { dest.writeInt(importanceReasonCode); dest.writeInt(importanceReasonPid); ComponentName.writeToParcel(importanceReasonComponent, dest); dest.writeInt(importanceReasonImportance); } public void readFromParcel(Parcel source) { Loading @@ -1293,6 +1300,7 @@ public class ActivityManager { importanceReasonCode = source.readInt(); importanceReasonPid = source.readInt(); importanceReasonComponent = ComponentName.readFromParcel(source); importanceReasonImportance = source.readInt(); } public static final Creator<RunningAppProcessInfo> CREATOR = Loading
core/java/android/content/Context.java +3 −0 Original line number Diff line number Diff line Loading @@ -239,6 +239,9 @@ public abstract class Context { * methods of activities and other components are called. Note that you * <em>must</em> be sure to use {@link #unregisterComponentCallbacks} when * appropriate in the future; this will not be removed for you. * * @param callback The interface to call. This can be either a * {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface. */ public void registerComponentCallbacks(ComponentCallbacks callback) { getApplicationContext().registerComponentCallbacks(callback); Loading
core/java/com/android/internal/app/ResolverActivity.java +12 −1 Original line number Diff line number Diff line Loading @@ -58,9 +58,20 @@ public class ResolverActivity extends AlertActivity implements private TextView mClearDefaultHint; private PackageManager mPm; private Intent makeMyIntent() { Intent intent = new Intent(getIntent()); // The resolver activity is set to be hidden from recent tasks. // we don't want this attribute to be propagated to the next activity // being launched. Note that if the original Intent also had this // flag set, we are now losing it. That should be a very rare case // and we can live with this. intent.setFlags(intent.getFlags()&~Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); return intent; } @Override protected void onCreate(Bundle savedInstanceState) { onCreate(savedInstanceState, new Intent(getIntent()), onCreate(savedInstanceState, makeMyIntent(), getResources().getText(com.android.internal.R.string.whichApplication), null, null, true); } Loading
core/res/AndroidManifest.xml +16 −8 Original line number Diff line number Diff line Loading @@ -1499,19 +1499,23 @@ android:theme="@style/Theme.Holo.Dialog" android:label="@string/heavy_weight_switcher_title" android:finishOnCloseSystemDialogs="true" android:excludeFromRecents="true"> android:excludeFromRecents="true" android:process=":ui"> </activity> <activity android:name="com.android.internal.app.PlatLogoActivity" android:theme="@style/Theme.Wallpaper.NoTitleBar.Fullscreen"> android:theme="@style/Theme.Wallpaper.NoTitleBar.Fullscreen" android:process=":ui"> </activity> <activity android:name="com.android.internal.app.DisableCarModeActivity" android:theme="@style/Theme.NoDisplay" android:excludeFromRecents="true"> android:excludeFromRecents="true" android:process=":ui"> </activity> <activity android:name="com.android.internal.app.RingtonePickerActivity" android:theme="@style/Theme.Holo.Dialog.Alert" android:excludeFromRecents="true" android:multiprocess="true"> android:multiprocess="true" android:process=":ui"> <intent-filter> <action android:name="android.intent.action.RINGTONE_PICKER" /> <category android:name="android.intent.category.DEFAULT" /> Loading @@ -1522,18 +1526,21 @@ android:excludeFromRecents="true" android:exported="true" android:theme="@android:style/Theme.Holo.Dialog" android:label="@string/choose_account_label"> android:label="@string/choose_account_label" android:process=":ui"> </activity> <activity android:name="android.accounts.GrantCredentialsPermissionActivity" android:excludeFromRecents="true" android:exported="true" android:theme="@android:style/Theme.Holo.DialogWhenLarge"> android:theme="@android:style/Theme.Holo.DialogWhenLarge" android:process=":ui"> </activity> <activity android:name="android.content.SyncActivityTooManyDeletes" android:theme="@android:style/Theme.Holo.Dialog" android:label="@string/sync_too_many_deletes"> android:label="@string/sync_too_many_deletes" android:process=":ui"> </activity> <activity android:name="com.android.server.ShutdownActivity" Loading @@ -1551,7 +1558,8 @@ <activity android:name="com.android.internal.app.NetInitiatedActivity" android:theme="@style/Theme.Holo.Dialog.Alert" android:excludeFromRecents="true"> android:excludeFromRecents="true" android:process=":ui"> </activity> <receiver android:name="com.android.server.BootReceiver" > Loading
services/java/com/android/server/am/ActivityManagerService.java +84 −59 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ import android.os.SystemClock; import android.os.SystemProperties; import android.provider.Settings; import android.util.EventLog; import android.util.Pair; import android.util.Slog; import android.util.Log; import android.util.PrintWriterPrinter; Loading Loading @@ -5004,7 +5005,13 @@ public final class ActivityManagerService extends ActivityManagerNative maxNum < N ? maxNum : N); for (int i=0; i<N && maxNum > 0; i++) { TaskRecord tr = mRecentTasks.get(i); if (((flags&ActivityManager.RECENT_WITH_EXCLUDED) != 0) // Return the entry if desired by the caller. We always return // the first entry, because callers always expect this to be the // forground app. We may filter others if the caller has // not supplied RECENT_WITH_EXCLUDED and there is some reason // we should exclude the entry. if (i == 0 || ((flags&ActivityManager.RECENT_WITH_EXCLUDED) != 0) || (tr.intent == null) || ((tr.intent.getFlags() &Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0)) { Loading Loading @@ -7547,6 +7554,32 @@ public final class ActivityManagerService extends ActivityManagerNative return errList; } static int oomAdjToImportance(int adj, ActivityManager.RunningAppProcessInfo currApp) { if (adj >= ProcessList.EMPTY_APP_ADJ) { return ActivityManager.RunningAppProcessInfo.IMPORTANCE_EMPTY; } else if (adj >= ProcessList.HIDDEN_APP_MIN_ADJ) { if (currApp != null) { currApp.lru = adj - ProcessList.HIDDEN_APP_MIN_ADJ + 1; } return ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND; } else if (adj >= ProcessList.HOME_APP_ADJ) { if (currApp != null) { currApp.lru = 0; } return ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND; } else if (adj >= ProcessList.SECONDARY_SERVER_ADJ) { return ActivityManager.RunningAppProcessInfo.IMPORTANCE_SERVICE; } else if (adj >= ProcessList.HEAVY_WEIGHT_APP_ADJ) { return ActivityManager.RunningAppProcessInfo.IMPORTANCE_CANT_SAVE_STATE; } else if (adj >= ProcessList.PERCEPTIBLE_APP_ADJ) { return ActivityManager.RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE; } else if (adj >= ProcessList.VISIBLE_APP_ADJ) { return ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE; } else { return ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND; } } public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses() { // Lazy instantiation of list List<ActivityManager.RunningAppProcessInfo> runList = null; Loading @@ -7567,28 +7600,12 @@ public final class ActivityManagerService extends ActivityManagerNative currApp.flags |= ActivityManager.RunningAppProcessInfo.FLAG_PERSISTENT; } int adj = app.curAdj; if (adj >= ProcessList.EMPTY_APP_ADJ) { currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_EMPTY; } else if (adj >= ProcessList.HIDDEN_APP_MIN_ADJ) { currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND; currApp.lru = adj - ProcessList.HIDDEN_APP_MIN_ADJ + 1; } else if (adj >= ProcessList.HOME_APP_ADJ) { currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND; currApp.lru = 0; } else if (adj >= ProcessList.SECONDARY_SERVER_ADJ) { currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_SERVICE; } else if (adj >= ProcessList.HEAVY_WEIGHT_APP_ADJ) { currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_CANT_SAVE_STATE; } else if (adj >= ProcessList.PERCEPTIBLE_APP_ADJ) { currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE; } else if (adj >= ProcessList.VISIBLE_APP_ADJ) { currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE; } else { currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND; } currApp.importance = oomAdjToImportance(adj, currApp); currApp.importanceReasonCode = app.adjTypeCode; if (app.adjSource instanceof ProcessRecord) { currApp.importanceReasonPid = ((ProcessRecord)app.adjSource).pid; currApp.importanceReasonImportance = oomAdjToImportance( app.adjSourceOom, null); } else if (app.adjSource instanceof ActivityRecord) { ActivityRecord r = (ActivityRecord)app.adjSource; if (r.app != null) currApp.importanceReasonPid = r.app.pid; Loading Loading @@ -7891,7 +7908,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (mLruProcesses.size() > 0) { if (needSep) pw.println(" "); needSep = true; pw.println(" Process LRU list (most recent first):"); pw.println(" Process LRU list (sorted by oom_adj):"); dumpProcessOomList(pw, this, mLruProcesses, " ", "Proc", "PERS", false); needSep = true; Loading Loading @@ -8069,29 +8086,6 @@ public final class ActivityManagerService extends ActivityManagerNative boolean needSep = false; if (mLruProcesses.size() > 0) { ArrayList<ProcessRecord> procs = new ArrayList<ProcessRecord>(mLruProcesses); Comparator<ProcessRecord> comparator = new Comparator<ProcessRecord>() { @Override public int compare(ProcessRecord object1, ProcessRecord object2) { if (object1.setAdj != object2.setAdj) { return object1.setAdj > object2.setAdj ? -1 : 1; } if (object1.setSchedGroup != object2.setSchedGroup) { return object1.setSchedGroup > object2.setSchedGroup ? -1 : 1; } if (object1.keeping != object2.keeping) { return object1.keeping ? -1 : 1; } if (object1.pid != object2.pid) { return object1.pid > object2.pid ? -1 : 1; } return 0; } }; Collections.sort(procs, comparator); if (needSep) pw.println(" "); needSep = true; pw.println(" OOM levels:"); Loading @@ -8110,7 +8104,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (needSep) pw.println(" "); needSep = true; pw.println(" Process OOM control:"); dumpProcessOomList(pw, this, procs, " ", dumpProcessOomList(pw, this, mLruProcesses, " ", "Proc", "PERS", true); needSep = true; } Loading Loading @@ -8859,10 +8853,33 @@ public final class ActivityManagerService extends ActivityManagerNative } private static final void dumpProcessOomList(PrintWriter pw, ActivityManagerService service, List<ProcessRecord> list, ActivityManagerService service, List<ProcessRecord> origList, String prefix, String normalLabel, String persistentLabel, boolean inclDetails) { ArrayList<Pair<ProcessRecord, Integer>> list = new ArrayList<Pair<ProcessRecord, Integer>>(origList.size()); for (int i=0; i<origList.size(); i++) { list.add(new Pair<ProcessRecord, Integer>(origList.get(i), i)); } Comparator<Pair<ProcessRecord, Integer>> comparator = new Comparator<Pair<ProcessRecord, Integer>>() { @Override public int compare(Pair<ProcessRecord, Integer> object1, Pair<ProcessRecord, Integer> object2) { if (object1.first.setAdj != object2.first.setAdj) { return object1.first.setAdj > object2.first.setAdj ? -1 : 1; } if (object1.second.intValue() != object2.second.intValue()) { return object1.second.intValue() > object2.second.intValue() ? -1 : 1; } return 0; } }; Collections.sort(list, comparator); final long curRealtime = SystemClock.elapsedRealtime(); final long realtimeSince = curRealtime - service.mLastPowerCheckRealtime; final long curUptime = SystemClock.uptimeMillis(); Loading @@ -8870,7 +8887,7 @@ public final class ActivityManagerService extends ActivityManagerNative final int N = list.size()-1; for (int i=N; i>=0; i--) { ProcessRecord r = list.get(i); ProcessRecord r = list.get(i).first; String oomAdj; if (r.setAdj >= ProcessList.EMPTY_APP_ADJ) { oomAdj = buildOomTag("empty", null, r.setAdj, ProcessList.EMPTY_APP_ADJ); Loading Loading @@ -8919,7 +8936,7 @@ public final class ActivityManagerService extends ActivityManagerNative } pw.println(String.format("%s%s #%2d: adj=%s/%s%s trm=%2d %s (%s)", prefix, (r.persistent ? persistentLabel : normalLabel), N-i, oomAdj, schedGroup, foreground, r.trimMemoryLevel, N-list.get(i).second, oomAdj, schedGroup, foreground, r.trimMemoryLevel, r.toShortString(), r.adjType)); if (r.adjSource != null || r.adjTarget != null) { pw.print(prefix); Loading Loading @@ -13118,6 +13135,7 @@ public final class ActivityManagerService extends ActivityManagerNative app.adjTypeCode = ActivityManager.RunningAppProcessInfo .REASON_SERVICE_IN_USE; app.adjSource = cr.binding.client; app.adjSourceOom = clientAdj; app.adjTarget = s.name; } if ((cr.flags&Context.BIND_NOT_FOREGROUND) == 0) { Loading @@ -13140,6 +13158,7 @@ public final class ActivityManagerService extends ActivityManagerNative app.adjTypeCode = ActivityManager.RunningAppProcessInfo .REASON_SERVICE_IN_USE; app.adjSource = a; app.adjSourceOom = adj; app.adjTarget = s.name; } } Loading Loading @@ -13201,6 +13220,7 @@ public final class ActivityManagerService extends ActivityManagerNative app.adjTypeCode = ActivityManager.RunningAppProcessInfo .REASON_PROVIDER_IN_USE; app.adjSource = client; app.adjSourceOom = clientAdj; app.adjTarget = cpr.name; } if (client.curSchedGroup == Process.THREAD_GROUP_DEFAULT) { Loading Loading @@ -13511,6 +13531,10 @@ public final class ActivityManagerService extends ActivityManagerNative computeOomAdjLocked(app, hiddenAdj, TOP_APP, false); if (app.curRawAdj != app.setRawAdj) { if (false) { // Removing for now. Forcing GCs is not so useful anymore // with Dalvik, and the new memory level hint facility is // better for what we need to do these days. if (app.curRawAdj > ProcessList.FOREGROUND_APP_ADJ && app.setRawAdj <= ProcessList.FOREGROUND_APP_ADJ) { // If this app is transitioning from foreground to Loading @@ -13522,6 +13546,7 @@ public final class ActivityManagerService extends ActivityManagerNative // background (such as a service stopping). scheduleAppGcLocked(app); } } if (wasKeeping && !app.keeping) { // This app is no longer something we want to keep. Note