summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/current.txt1
-rw-r--r--core/java/android/os/Build.java7
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java35
-rw-r--r--services/java/com/android/server/am/ActivityStack.java7
-rw-r--r--services/java/com/android/server/am/ProcessList.java12
5 files changed, 55 insertions, 7 deletions
diff --git a/api/current.txt b/api/current.txt
index 9d38566..b180f7d 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -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 {
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 17a882d..7d03494 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -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". */
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index f8a7d6a..310ace0 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -408,6 +408,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++;
}
}
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 28c3bae..a47502e 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -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
diff --git a/services/java/com/android/server/am/ProcessList.java b/services/java/com/android/server/am/ProcessList.java
index f368a70..af7b314 100644
--- a/services/java/com/android/server/am/ProcessList.java
+++ b/services/java/com/android/server/am/ProcessList.java
@@ -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,