Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 577cf49a authored by Ben Lin's avatar Ben Lin
Browse files

Check visibility when moving task to front.

Currently when we move a task to the front, we try to resume its
top-most activity and pause the back stacks. However, in a multi-resume
world, it's possible that this becomes a resume -> resume operation,
which no-ops and exits early without pausing the back stack. Instead, we
should check visibility before trying to resume the activity, in order
to update any other tasks that are now no longer visible and thus should
be STOPPED or PAUSED.

Bug: 168852384
Test: atest
PinnedStackTests#testAutoEnterPictureInPictureOnUserLeaveHintWhenPipRequestedNotOverridden

Change-Id: I4dfdaab1f2b0c2116121e460cf3e3183107662e2
parent bea090f3
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -2738,7 +2738,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

            if (ensureVisibility) {
                mDisplayContent.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */,
                        false /* preserveWindows */, true /* notifyClients */);
                        false /* preserveWindows */, true /* notifyClients */,
                        mStackSupervisor.mUserLeaving);
            }
        }

@@ -4752,7 +4753,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        handleAlreadyVisible();
    }

    void makeInvisible() {
    void makeInvisible(boolean userLeaving) {
        if (!mVisibleRequested) {
            if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Already invisible: " + this);
            return;
@@ -4793,9 +4794,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                    // If the app is capable of entering PIP, we should try pausing it now
                    // so it can PIP correctly.
                    if (deferHidingClient) {
                        getRootTask().startPausingLocked(
                                mStackSupervisor.mUserLeaving /* userLeaving */,
                                false /* uiSleeping */, null /* resuming */, "makeInvisible");
                        getRootTask().startPausingLocked(userLeaving, false /* uiSleeping */,
                                null /* resuming */, "makeInvisible");
                        break;
                    }
                case INITIALIZING:
+1 −1
Original line number Diff line number Diff line
@@ -2189,7 +2189,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
                        .notifyActivityDismissingDockedStack();
                taskDisplayArea.onSplitScreenModeDismissed(task);
                taskDisplayArea.mDisplayContent.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS,
                        true /* notifyClients */);
                        true /* notifyClients */, mUserLeaving);
            }
            return;
        }
+1 −1
Original line number Diff line number Diff line
@@ -2460,7 +2460,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                } else {
                    stack.setWindowingMode(windowingMode);
                    stack.mDisplayContent.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS,
                            true /* notifyClients */);
                            true /* notifyClients */, mStackSupervisor.mUserLeaving);
                }
                return true;
            } finally {
+2 −2
Original line number Diff line number Diff line
@@ -5308,7 +5308,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp


    void ensureActivitiesVisible(ActivityRecord starting, int configChanges,
            boolean preserveWindows, boolean notifyClients) {
            boolean preserveWindows, boolean notifyClients, boolean userLeaving) {
        if (mInEnsureActivitiesVisible) {
            // Don't do recursive work.
            return;
@@ -5317,7 +5317,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        try {
            forAllTaskDisplayAreas(taskDisplayArea -> {
                taskDisplayArea.ensureActivitiesVisible(starting, configChanges,
                        preserveWindows, notifyClients);
                        preserveWindows, notifyClients, userLeaving);
            });
        } finally {
            mInEnsureActivitiesVisible = false;
+8 −4
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ class EnsureActivitiesVisibleHelper {
    private int mConfigChanges;
    private boolean mPreserveWindows;
    private boolean mNotifyClients;
    private boolean mUserLeaving;

    EnsureActivitiesVisibleHelper(Task container) {
        mTask = container;
@@ -49,7 +50,7 @@ class EnsureActivitiesVisibleHelper {
     *                      be sent to the clients.
     */
    void reset(ActivityRecord starting, int configChanges, boolean preserveWindows,
            boolean notifyClients) {
            boolean notifyClients, boolean userLeaving) {
        mStarting = starting;
        mTop = mTask.topRunningActivity();
        // If the top activity is not fullscreen, then we need to make sure any activities under it
@@ -60,6 +61,7 @@ class EnsureActivitiesVisibleHelper {
        mConfigChanges = configChanges;
        mPreserveWindows = preserveWindows;
        mNotifyClients = notifyClients;
        mUserLeaving = userLeaving;
    }

    /**
@@ -76,10 +78,12 @@ class EnsureActivitiesVisibleHelper {
     * @param preserveWindows Flag indicating whether windows should be preserved when updating.
     * @param notifyClients Flag indicating whether the configuration and visibility changes shoulc
     *                      be sent to the clients.
     * @param userLeaving Flag indicating whether a userLeaving callback should be issued in the
     *                      case the activity is being set to invisible.
     */
    void process(@Nullable ActivityRecord starting, int configChanges, boolean preserveWindows,
            boolean notifyClients) {
        reset(starting, configChanges, preserveWindows, notifyClients);
            boolean notifyClients, boolean userLeaving) {
        reset(starting, configChanges, preserveWindows, notifyClients, userLeaving);

        if (DEBUG_VISIBILITY) {
            Slog.v(TAG_VISIBILITY, "ensureActivitiesVisible behind " + mTop
@@ -173,7 +177,7 @@ class EnsureActivitiesVisibleHelper {
                        + " behindFullscreenActivity=" + mBehindFullscreenActivity
                        + " mLaunchTaskBehind=" + r.mLaunchTaskBehind);
            }
            r.makeInvisible();
            r.makeInvisible(mUserLeaving);
        }

        if (!mBehindFullscreenActivity && mTask.isActivityTypeHome() && r.isRootOfTask()) {
Loading