Add new OOM adjustment for the "previous" process.
This is the process that you had previously been interacting with in the UI before the current one. Treating it specially should allow us to improve the scenario of switching back and forth between two apps. Also add API constent for ICS MR1. Change-Id: Ib3fe4df36b270be11dfd6b7e8d107c9994058a4d
This commit is contained in:
@ -14399,6 +14399,7 @@ package android.os {
|
||||
field public static final int HONEYCOMB_MR1 = 12; // 0xc
|
||||
field public static final int HONEYCOMB_MR2 = 13; // 0xd
|
||||
field public static final int ICE_CREAM_SANDWICH = 14; // 0xe
|
||||
field public static final int ICE_CREAM_SANDWICH_MR1 = 15; // 0xf
|
||||
}
|
||||
|
||||
public final class Bundle implements java.lang.Cloneable android.os.Parcelable {
|
||||
|
@ -277,7 +277,7 @@ public class Build {
|
||||
public static final int HONEYCOMB_MR2 = 13;
|
||||
|
||||
/**
|
||||
* Android 4.0.
|
||||
* October 2011: Android 4.0.
|
||||
*
|
||||
* <p>Applications targeting this or a later release will get these
|
||||
* new changes in behavior:</p>
|
||||
@ -309,6 +309,11 @@ public class Build {
|
||||
* </ul>
|
||||
*/
|
||||
public static final int ICE_CREAM_SANDWICH = 14;
|
||||
|
||||
/**
|
||||
* Android 4.1.
|
||||
*/
|
||||
public static final int ICE_CREAM_SANDWICH_MR1 = 15;
|
||||
}
|
||||
|
||||
/** The type of build, like "user" or "eng". */
|
||||
|
@ -407,6 +407,12 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
*/
|
||||
ProcessRecord mHomeProcess;
|
||||
|
||||
/**
|
||||
* This is the process holding the activity the user last visited that
|
||||
* is in a different process from the one they are currently in.
|
||||
*/
|
||||
ProcessRecord mPreviousProcess;
|
||||
|
||||
/**
|
||||
* Packages that the user has asked to have run in screen size
|
||||
* compatibility mode instead of filling the screen.
|
||||
@ -8114,6 +8120,7 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
|
||||
pw.println();
|
||||
pw.println(" mHomeProcess: " + mHomeProcess);
|
||||
pw.println(" mPreviousProcess: " + mPreviousProcess);
|
||||
if (mHeavyWeightProcess != null) {
|
||||
pw.println(" mHeavyWeightProcess: " + mHeavyWeightProcess);
|
||||
}
|
||||
@ -8212,6 +8219,7 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
pw.print(" BACKUP_APP_ADJ: "); pw.println(ProcessList.BACKUP_APP_ADJ);
|
||||
pw.print(" SERVICE_ADJ: "); pw.println(ProcessList.SERVICE_ADJ);
|
||||
pw.print(" HOME_APP_ADJ: "); pw.println(ProcessList.HOME_APP_ADJ);
|
||||
pw.print(" PREVIOUS_APP_ADJ: "); pw.println(ProcessList.PREVIOUS_APP_ADJ);
|
||||
pw.print(" SERVICE_B_ADJ: "); pw.println(ProcessList.SERVICE_B_ADJ);
|
||||
pw.print(" HIDDEN_APP_MIN_ADJ: "); pw.println(ProcessList.HIDDEN_APP_MIN_ADJ);
|
||||
pw.print(" HIDDEN_APP_MAX_ADJ: "); pw.println(ProcessList.HIDDEN_APP_MAX_ADJ);
|
||||
@ -8228,6 +8236,7 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
|
||||
pw.println();
|
||||
pw.println(" mHomeProcess: " + mHomeProcess);
|
||||
pw.println(" mPreviousProcess: " + mPreviousProcess);
|
||||
if (mHeavyWeightProcess != null) {
|
||||
pw.println(" mHeavyWeightProcess: " + mHeavyWeightProcess);
|
||||
}
|
||||
@ -9009,6 +9018,8 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
oomAdj = buildOomTag("bak", " ", r.setAdj, ProcessList.HIDDEN_APP_MIN_ADJ);
|
||||
} else if (r.setAdj >= ProcessList.SERVICE_B_ADJ) {
|
||||
oomAdj = buildOomTag("svcb ", null, r.setAdj, ProcessList.SERVICE_B_ADJ);
|
||||
} else if (r.setAdj >= ProcessList.PREVIOUS_APP_ADJ) {
|
||||
oomAdj = buildOomTag("prev ", null, r.setAdj, ProcessList.PREVIOUS_APP_ADJ);
|
||||
} else if (r.setAdj >= ProcessList.HOME_APP_ADJ) {
|
||||
oomAdj = buildOomTag("home ", null, r.setAdj, ProcessList.HOME_APP_ADJ);
|
||||
} else if (r.setAdj >= ProcessList.SERVICE_ADJ) {
|
||||
@ -9287,12 +9298,13 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
ProcessList.SYSTEM_ADJ, ProcessList.PERSISTENT_PROC_ADJ, ProcessList.FOREGROUND_APP_ADJ,
|
||||
ProcessList.VISIBLE_APP_ADJ, ProcessList.PERCEPTIBLE_APP_ADJ, ProcessList.HEAVY_WEIGHT_APP_ADJ,
|
||||
ProcessList.BACKUP_APP_ADJ, ProcessList.SERVICE_ADJ, ProcessList.HOME_APP_ADJ,
|
||||
ProcessList.SERVICE_B_ADJ, ProcessList.HIDDEN_APP_MAX_ADJ
|
||||
ProcessList.PREVIOUS_APP_ADJ, ProcessList.SERVICE_B_ADJ, ProcessList.HIDDEN_APP_MAX_ADJ
|
||||
};
|
||||
final String[] oomLabel = new String[] {
|
||||
"System", "Persistent", "Foreground",
|
||||
"Visible", "Perceptible", "Heavy Weight",
|
||||
"Backup", "A Services", "Home", "B Services", "Background"
|
||||
"Backup", "A Services", "Home", "Previous",
|
||||
"B Services", "Background"
|
||||
};
|
||||
long oomPss[] = new long[oomLabel.length];
|
||||
ArrayList<MemItem>[] oomProcs = (ArrayList<MemItem>[])new ArrayList[oomLabel.length];
|
||||
@ -9714,7 +9726,10 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
if (app == mHomeProcess) {
|
||||
mHomeProcess = null;
|
||||
}
|
||||
|
||||
if (app == mPreviousProcess) {
|
||||
mPreviousProcess = null;
|
||||
}
|
||||
|
||||
if (restart) {
|
||||
// We have components that still need to be running in the
|
||||
// process, so re-launch it.
|
||||
@ -13112,6 +13127,17 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
app.adjType = "home";
|
||||
}
|
||||
|
||||
if (adj > ProcessList.PREVIOUS_APP_ADJ && app == mPreviousProcess
|
||||
&& app.activities.size() > 0) {
|
||||
// This was the previous process that showed UI to the user.
|
||||
// We want to try to keep it around more aggressively, to give
|
||||
// a good experience around switching between two apps.
|
||||
adj = ProcessList.PREVIOUS_APP_ADJ;
|
||||
schedGroup = Process.THREAD_GROUP_BG_NONINTERACTIVE;
|
||||
app.hidden = false;
|
||||
app.adjType = "previous";
|
||||
}
|
||||
|
||||
if (false) Slog.i(TAG, "OOM " + app + ": initial adj=" + adj
|
||||
+ " reason=" + app.adjType);
|
||||
|
||||
@ -13841,7 +13867,8 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
} else {
|
||||
numBg++;
|
||||
}
|
||||
} else if (app.curAdj >= ProcessList.HOME_APP_ADJ) {
|
||||
} else if (app.curAdj >= ProcessList.HOME_APP_ADJ
|
||||
&& app.curAdj != ProcessList.SERVICE_B_ADJ) {
|
||||
numBg++;
|
||||
}
|
||||
}
|
||||
|
@ -1363,6 +1363,13 @@ final class ActivityStack {
|
||||
+ ", nowVisible=" + next.nowVisible);
|
||||
}
|
||||
}
|
||||
|
||||
if (!prev.finishing && prev.app != null && prev.app != next.app) {
|
||||
// We are switching to a new activity that is in a different
|
||||
// process than the previous one. Note the previous process,
|
||||
// so we can try to keep it around.
|
||||
mService.mPreviousProcess = prev.app;
|
||||
}
|
||||
}
|
||||
|
||||
// Launching this app's activity, make sure the app is no longer
|
||||
|
@ -38,11 +38,19 @@ class ProcessList {
|
||||
// This is a process only hosting activities that are not visible,
|
||||
// so it can be killed without any disruption.
|
||||
static final int HIDDEN_APP_MAX_ADJ = 15;
|
||||
static int HIDDEN_APP_MIN_ADJ = 8;
|
||||
static int HIDDEN_APP_MIN_ADJ = 9;
|
||||
|
||||
// The B list of SERVICE_ADJ -- these are the old and decrepit
|
||||
// services that aren't as shiny and interesting as the ones in the A list.
|
||||
static final int SERVICE_B_ADJ = 7;
|
||||
static final int SERVICE_B_ADJ = 8;
|
||||
|
||||
// This is the process of the previous application that the user was in.
|
||||
// This process is kept above other things, because it is very common to
|
||||
// switch back to the previous app. This is important both for recent
|
||||
// task switch (toggling between the two top recent apps) as well as normal
|
||||
// UI flow such as clicking on a URI in the e-mail app to view in the browser,
|
||||
// and then pressing back to return to e-mail.
|
||||
static final int PREVIOUS_APP_ADJ = 7;
|
||||
|
||||
// This is a process holding the home application -- we want to try
|
||||
// avoiding killing it, even if it would normally be in the background,
|
||||
|
Reference in New Issue
Block a user