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

Commit 30a16a11 authored by Shuming Hao's avatar Shuming Hao
Browse files

Reset side stage position after child task vanishes

This CL resets side stage position in split screen when all stages has no child tasks. This ensures the new split screen can be opened from the default position.

Bug: 333270112
Test: open links from Gmail
Flag: EXEMPT bugfix
Change-Id: I9c512f7dcf822b05fee0df1a06a3f3dd17ff3d24
parent e6a2f840
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ import static com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_MAIN;
import static com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_SIDE;
import static com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_UNDEFINED;
import static com.android.wm.shell.splitscreen.SplitScreenController.ENTER_REASON_LAUNCHER;
import static com.android.wm.shell.splitscreen.SplitScreenController.ENTER_REASON_MULTI_INSTANCE;
import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON_APP_DOES_NOT_SUPPORT_MULTIWINDOW;
import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON_APP_FINISHED;
import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON_CHILD_TASK_ENTER_PIP;
@@ -1099,16 +1098,11 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,

    void setSideStagePosition(@SplitPosition int sideStagePosition,
            @Nullable WindowContainerTransaction wct) {
        setSideStagePosition(sideStagePosition, true /* updateBounds */, wct);
    }

    private void setSideStagePosition(@SplitPosition int sideStagePosition, boolean updateBounds,
            @Nullable WindowContainerTransaction wct) {
        if (mSideStagePosition == sideStagePosition) return;
        mSideStagePosition = sideStagePosition;
        sendOnStagePositionChanged();

        if (mSideStage.mVisible && updateBounds) {
        if (mSideStage.mVisible) {
            if (wct == null) {
                // onLayoutChanged builds/applies a wct with the contents of updateWindowBounds.
                onLayoutSizeChanged(mSplitLayout);
@@ -1275,6 +1269,8 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        final WindowContainerTransaction wct = new WindowContainerTransaction();
        prepareExitSplitScreen(stage, wct);
        mSplitTransitions.startDismissTransition(wct, this, stage, exitReason);
        // reset stages to their default sides.
        setSideStagePosition(SPLIT_POSITION_BOTTOM_OR_RIGHT, null);
        logExit(exitReason);
    }

@@ -1598,6 +1594,13 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        }
        if (present) {
            updateRecentTasksSplitPair();
        } else if (mMainStage.getChildCount() == 0 && mSideStage.getChildCount() == 0) {
            mRecentTasks.ifPresent(recentTasks -> {
                // remove the split pair mapping from recentTasks, and disable further updates
                // to splits in the recents until we enter split again.
                recentTasks.removeSplitPair(taskId);
            });
            dismissSplitScreen(-1, EXIT_REASON_ROOT_TASK_VANISHED);
        }

        for (int i = mListeners.size() - 1; i >= 0; --i) {