From 3145b2490214a8feaff83950d6b903b2180aa869 Mon Sep 17 00:00:00 2001 From: riddle_hsu Date: Fri, 4 Jul 2014 17:01:56 +0800 Subject: [PATCH] [ActivityManager] Avoid keeping restarting home when only home activity exists. Root Cause: When there is only home activity existed, updating home apk will call forceStopPackageLocked to finish the activity. Then activity history becomes empty, then home will be launched, but its package is still target to close that results a loop. Solution: If home activity has been force-stopped, do not stop the same home activity again. Change-Id: Icff12028d407873c2e6f50a06bcad231b908ccbd --- services/java/com/android/server/am/ActivityStack.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java index 4d6727c84f5cf..8f777f9cbfad2 100755 --- a/services/java/com/android/server/am/ActivityStack.java +++ b/services/java/com/android/server/am/ActivityStack.java @@ -3370,6 +3370,7 @@ final class ActivityStack { 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 activities = mTaskHistory.get(taskNdx).mActivities; int numActivities = activities.size(); @@ -3388,6 +3389,14 @@ final class ActivityStack { } 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) {