From 1df4d9f8c772bb77a13205b81091771ea8ba4fbc Mon Sep 17 00:00:00 2001 From: riddle_hsu Date: Thu, 31 Jul 2014 00:26:51 +0800 Subject: [PATCH] [ActivityManager] Avoid mistaking visibility by finishing task. Sympton: Next activity only adds to history but does not launch/resume then results ANR. Root Cause: In a rare timing, some windows are switched at the same time, it will cause some finishing records on the top temporarily, then set startIt to false that skip to resume the real top activty. Solution: If all activities in a task are finishing, do not use it to check. The behavior/checking is the same concept as in JellyBean: // If starting in an existing task, find where that is... boolean startIt = true; for (int i = NH-1; i >= 0; i--) { ActivityRecord p = mHistory.get(i); if (p.finishing) { // <-- continue; } Change-Id: I9d81a7b5182400c52e173da23eee61c74692beee --- services/java/com/android/server/am/ActivityStack.java | 4 ++++ 1 file changed, 4 insertions(+) mode change 100755 => 100644 services/java/com/android/server/am/ActivityStack.java diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java old mode 100755 new mode 100644 index 75d32e3b74bb3..c151cc8a9ee22 --- a/services/java/com/android/server/am/ActivityStack.java +++ b/services/java/com/android/server/am/ActivityStack.java @@ -1705,6 +1705,10 @@ final class ActivityStack { boolean startIt = true; for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) { task = mTaskHistory.get(taskNdx); + if (task.getTopActivity() == null) { + // All activities in task are finishing. + continue; + } if (task == r.task) { // Here it is! Now, if this is not yet visible to the // user, then just add it without starting; it will