From f87b21953947f2fda8ac960c458dc7395ef90bbb Mon Sep 17 00:00:00 2001 From: louis_chang Date: Wed, 16 Jul 2014 18:15:35 +0800 Subject: [ActivityManager] Do not finish root activity when reset task Symptom: The root activity not always located at index 0 of the task. For example, the index 1 activity will become the new root when the original root activity (at index 0) finished. The new root activity might be finished unexpectedly before the original root activity actually destroyed. Solution: Check frontOfTask to avoid finishing the root activity unexpectedly Change-Id: I623ab97e9c95c83b3cfe7c9dfc151a291a391ea4 --- services/java/com/android/server/am/ActivityStack.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java index 8f777f9cbfad..3d66d8458b85 100755 --- a/services/java/com/android/server/am/ActivityStack.java +++ b/services/java/com/android/server/am/ActivityStack.java @@ -1873,6 +1873,8 @@ final class ActivityStack { final int numActivities = activities.size(); for (int i = numActivities - 1; i > 0; --i ) { ActivityRecord target = activities.get(i); + if (target.frontOfTask) + break; final int flags = target.info.flags; final boolean finishOnTaskLaunch = @@ -2040,6 +2042,8 @@ final class ActivityStack { // Do not operate on the root Activity. for (int i = numActivities - 1; i > 0; --i) { ActivityRecord target = activities.get(i); + if (target.frontOfTask) + break; final int flags = target.info.flags; boolean finishOnTaskLaunch = (flags & ActivityInfo.FLAG_FINISH_ON_TASK_LAUNCH) != 0; -- cgit v1.2.3-59-g8ed1b