From efd9a5ba01be857e837e01fc9a5df24ada19a17b Mon Sep 17 00:00:00 2001 From: Chong Zhang Date: Tue, 26 Apr 2016 16:21:07 -0700 Subject: [PATCH] Finish immediately if the resumed activity is already visible When in FINISH_AFTER_VISIBLE mode, we need to check visibility of both the current activity, and the activity to be resumed. If the resumed activity is already visible, we should finish immediately. We can't put it into stopping state and wait because there won't be a window visible callback from the next activity. bug: 28378359 Change-Id: Ib1fb44acfec33616da76f48102cc00b453e41914 --- services/core/java/com/android/server/am/ActivityStack.java | 3 ++- 1 file changed, 2 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 a7c994b3c8074..37bd401eca57d 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -3457,7 +3457,8 @@ 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. - if (mode == FINISH_AFTER_VISIBLE && (r.visible || r.nowVisible)) { + if (mode == FINISH_AFTER_VISIBLE && (r.visible || r.nowVisible) + && !mStackSupervisor.allResumedActivitiesVisible()) { if (!mStackSupervisor.mStoppingActivities.contains(r)) { addToStopping(r, false /* immediate */); }