From 824b6dcb55f6bc436d5aa8f461d5b269a4f5180b Mon Sep 17 00:00:00 2001 From: Chong Zhang Date: Wed, 27 Apr 2016 14:11:12 -0700 Subject: [PATCH] Don't wait for visible if there is no running activity left. We could run into this situation on some devices (eg. clockworks), the next activity doesn't get launched until we destroy this one. allResumedActivitiesVisible() will return false if there is no other activity running at all. Check top running activity and it's visibility instead. bug: 28400334 Change-Id: Ib8957e499580a10206fdd4e27da19fbc2bdb5843 --- services/core/java/com/android/server/am/ActivityStack.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index 37bd401eca57..7beb4f512b43 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -3457,8 +3457,11 @@ final class ActivityStack { // First things first: if this activity is currently visible, // and the resumed activity is not yet visible, then hold off on // finishing until the resumed one becomes visible. + + final ActivityRecord next = mStackSupervisor.topRunningActivityLocked(); + if (mode == FINISH_AFTER_VISIBLE && (r.visible || r.nowVisible) - && !mStackSupervisor.allResumedActivitiesVisible()) { + && next != null && !next.nowVisible) { if (!mStackSupervisor.mStoppingActivities.contains(r)) { addToStopping(r, false /* immediate */); } -- 2.11.0