am a7f02a5c: am ef2e7667: Merge "[ActivityManager] Avoid keeping restarting home when only home activity exists."
* commit 'a7f02a5cda27147fe7076805187fb6fbc60fdcfb':
[ActivityManager] Avoid keeping restarting home when only home activity exists.
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 59e0d16..995f992 100755
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -3432,6 +3432,7 @@
boolean forceStopPackageLocked(String name, boolean doit, boolean evenPersistent, int userId) {
boolean didSomething = false;
TaskRecord lastTask = null;
+ ComponentName homeActivity = null;
for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
final ArrayList<ActivityRecord> activities = mTaskHistory.get(taskNdx).mActivities;
int numActivities = activities.size();
@@ -3450,6 +3451,14 @@
}
return true;
}
+ if (r.isHomeActivity()) {
+ if (homeActivity != null && homeActivity.equals(r.realActivity)) {
+ Slog.i(TAG, "Skip force-stop again " + r);
+ continue;
+ } else {
+ homeActivity = r.realActivity;
+ }
+ }
didSomething = true;
Slog.i(TAG, " Force finishing activity " + r);
if (samePackage) {