From c01428ffb1c314fc40549d0fc45cee2c2ca747f2 Mon Sep 17 00:00:00 2001 From: Louis Chang Date: Fri, 16 Dec 2022 08:30:06 +0000 Subject: [PATCH] Ensure the above-top finishing activity is invisible The finishing activity was the top-most activity in the Task. The activity was not updated to invisible because it was above the top running activity. Bug: 259566326 Test: Starts a fullscreen activity in a new Task on top that resulted in two activities below (in ActivityEmbedding) to pause while the pausing activity is also finishing Change-Id: I446cadf84afd4cad54f357fe9fec5ec6e8ac47b8 --- .../wm/EnsureActivitiesVisibleHelper.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/services/core/java/com/android/server/wm/EnsureActivitiesVisibleHelper.java b/services/core/java/com/android/server/wm/EnsureActivitiesVisibleHelper.java index bd837940dfb27..dde89e9bca2e3 100644 --- a/services/core/java/com/android/server/wm/EnsureActivitiesVisibleHelper.java +++ b/services/core/java/com/android/server/wm/EnsureActivitiesVisibleHelper.java @@ -28,7 +28,7 @@ import java.util.ArrayList; /** Helper class to ensure activities are in the right visible state for a container. */ class EnsureActivitiesVisibleHelper { private final TaskFragment mTaskFragment; - private ActivityRecord mTop; + private ActivityRecord mTopRunningActivity; private ActivityRecord mStarting; private boolean mAboveTop; private boolean mContainerShouldBeVisible; @@ -54,10 +54,10 @@ class EnsureActivitiesVisibleHelper { void reset(ActivityRecord starting, int configChanges, boolean preserveWindows, boolean notifyClients) { mStarting = starting; - mTop = mTaskFragment.topRunningActivity(); + mTopRunningActivity = mTaskFragment.topRunningActivity(); // If the top activity is not fullscreen, then we need to make sure any activities under it // are now visible. - mAboveTop = mTop != null; + mAboveTop = mTopRunningActivity != null; mContainerShouldBeVisible = mTaskFragment.shouldBeVisible(mStarting); mBehindFullyOccludedContainer = !mContainerShouldBeVisible; mConfigChanges = configChanges; @@ -85,18 +85,19 @@ class EnsureActivitiesVisibleHelper { reset(starting, configChanges, preserveWindows, notifyClients); if (DEBUG_VISIBILITY) { - Slog.v(TAG_VISIBILITY, "ensureActivitiesVisible behind " + mTop + Slog.v(TAG_VISIBILITY, "ensureActivitiesVisible behind " + mTopRunningActivity + " configChanges=0x" + Integer.toHexString(configChanges)); } - if (mTop != null && mTaskFragment.asTask() != null) { + if (mTopRunningActivity != null && mTaskFragment.asTask() != null) { // TODO(14709632): Check if this needed to be implemented in TaskFragment. - mTaskFragment.asTask().checkTranslucentActivityWaiting(mTop); + mTaskFragment.asTask().checkTranslucentActivityWaiting(mTopRunningActivity); } // We should not resume activities that being launched behind because these // activities are actually behind other fullscreen activities, but still required // to be visible (such as performing Recents animation). - final boolean resumeTopActivity = mTop != null && !mTop.mLaunchTaskBehind + final boolean resumeTopActivity = mTopRunningActivity != null + && !mTopRunningActivity.mLaunchTaskBehind && mTaskFragment.canBeResumed(starting) && (starting == null || !starting.isDescendantOf(mTaskFragment)); @@ -113,7 +114,7 @@ class EnsureActivitiesVisibleHelper { mBehindFullyOccludedContainer |= (childTaskFragment.getBounds().equals(mTaskFragment.getBounds()) && !childTaskFragment.isTranslucent(starting)); - if (mAboveTop && mTop.getTaskFragment() == childTaskFragment) { + if (mAboveTop && mTopRunningActivity.getTaskFragment() == childTaskFragment) { mAboveTop = false; } @@ -147,8 +148,11 @@ class EnsureActivitiesVisibleHelper { private void setActivityVisibilityState(ActivityRecord r, ActivityRecord starting, final boolean resumeTopActivity) { - final boolean isTop = r == mTop; + final boolean isTop = r == mTopRunningActivity; if (mAboveTop && !isTop) { + // Ensure activities above the top-running activity to be invisible because the + // activity should be finishing or cannot show to current user. + r.makeInvisible(); return; } mAboveTop = false;