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

Commit fd128546 authored by Jeremy Sim's avatar Jeremy Sim
Browse files

Flexible split: mBounds1 and mBounds2

Refactors SplitLayout so that it no longer relies on discrete variables mBounds1 and mBounds2, but an array of bounds. In this CL, the array is hard-coded to contain 2 Rects so that it is exactly backward compatible. Later, we will need to figure out when and where to add and remove bounds to accomodate 3 apps.

Also adds more documentation clarifying what is what in SplitLayout.

Bug: 349828130
Flag: com.android.wm.shell.enable_flexible_split
Test: Unchanged behavior, passes manual smoke test
Change-Id: Idf6212ed3af4bf8fdb122b8d94c2e9baa0b32a0f
parent 744c95c7
Loading
Loading
Loading
Loading
+96 −71
Original line number Original line Diff line number Diff line
@@ -88,6 +88,7 @@ import com.android.wm.shell.shared.split.SplitScreenConstants.SplitPosition;
import com.android.wm.shell.splitscreen.StageTaskListener;
import com.android.wm.shell.splitscreen.StageTaskListener;


import java.io.PrintWriter;
import java.io.PrintWriter;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Consumer;


/**
/**
@@ -139,15 +140,21 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
    private final Rect mTempRect = new Rect();
    private final Rect mTempRect = new Rect();
    private final Rect mRootBounds = new Rect();
    private final Rect mRootBounds = new Rect();
    private final Rect mDividerBounds = new Rect();
    private final Rect mDividerBounds = new Rect();
    // Bounds1 final position should be always at top or left
    /**
    private final Rect mBounds1 = new Rect();
     * A list of stage bounds, kept in order from top/left to bottom/right. These are the sizes of
    // Bounds2 final position should be always at bottom or right
     * the app surfaces, not necessarily the same as the size of the rendered content.
    private final Rect mBounds2 = new Rect();
     * See {@link #mContentBounds}.
     */
    private final List<Rect> mStageBounds = List.of(new Rect(), new Rect());
    /**
     * A list of app content bounds, kept in order from top/left to bottom/right. These are the
     * sizes of the rendered app contents, not necessarily the same as the size of the drawn app
     * surfaces. See {@link #mStageBounds}.
     */
    private final List<Rect> mContentBounds = List.of(new Rect(), new Rect());
    // The temp bounds outside of display bounds for side stage when split screen inactive to avoid
    // The temp bounds outside of display bounds for side stage when split screen inactive to avoid
    // flicker next time active split screen.
    // flicker next time active split screen.
    private final Rect mInvisibleBounds = new Rect();
    private final Rect mInvisibleBounds = new Rect();
    private final Rect mWinBounds1 = new Rect();
    private final Rect mWinBounds2 = new Rect();
    private final SplitLayoutHandler mSplitLayoutHandler;
    private final SplitLayoutHandler mSplitLayoutHandler;
    private final SplitWindowManager mSplitWindowManager;
    private final SplitWindowManager mSplitWindowManager;
    private final DisplayController mDisplayController;
    private final DisplayController mDisplayController;
@@ -233,26 +240,26 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
        mDividerWindowWidth = mDividerSize + 2 * mDividerInsets;
        mDividerWindowWidth = mDividerSize + 2 * mDividerInsets;
    }
    }


    /** Gets bounds of the primary split with screen based coordinate. */
    /** Gets the bounds of the top/left app in screen-based coordinates. */
    public Rect getBounds1() {
    public Rect getTopLeftBounds() {
        return new Rect(mBounds1);
        return mStageBounds.getFirst();
    }
    }


    /** Gets bounds of the primary split with parent based coordinate. */
    /** Gets the bounds of the bottom/right app in screen-based coordinates. */
    public Rect getRefBounds1() {
    public Rect getBottomRightBounds() {
        Rect outBounds = getBounds1();
        return mStageBounds.getLast();
        outBounds.offset(-mRootBounds.left, -mRootBounds.top);
        return outBounds;
    }
    }


    /** Gets bounds of the secondary split with screen based coordinate. */
    /** Gets the bounds of the top/left app in parent-based coordinates. */
    public Rect getBounds2() {
    public Rect getTopLeftRefBounds() {
        return new Rect(mBounds2);
        Rect outBounds = getTopLeftBounds();
        outBounds.offset(-mRootBounds.left, -mRootBounds.top);
        return outBounds;
    }
    }


    /** Gets bounds of the secondary split with parent based coordinate. */
    /** Gets the bounds of the bottom/right app in parent-based coordinates. */
    public Rect getRefBounds2() {
    public Rect getBottomRightRefBounds() {
        final Rect outBounds = getBounds2();
        Rect outBounds = getBottomRightBounds();
        outBounds.offset(-mRootBounds.left, -mRootBounds.top);
        outBounds.offset(-mRootBounds.left, -mRootBounds.top);
        return outBounds;
        return outBounds;
    }
    }
@@ -274,31 +281,42 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
        return outBounds;
        return outBounds;
    }
    }


    /** Gets bounds of the primary split with screen based coordinate on the param Rect. */
    /** Copies the top/left bounds to the provided Rect (screen-based coordinates). */
    public void getBounds1(Rect rect) {
    public void copyTopLeftBounds(Rect rect) {
        rect.set(mBounds1);
        rect.set(getTopLeftBounds());
    }
    }


    /** Gets bounds of the primary split with parent based coordinate on the param Rect. */
    /** Copies the top/left bounds to the provided Rect (parent-based coordinates). */
    public void getRefBounds1(Rect rect) {
    public void copyTopLeftRefBounds(Rect rect) {
        getBounds1(rect);
        copyTopLeftBounds(rect);
        rect.offset(-mRootBounds.left, -mRootBounds.top);
        rect.offset(-mRootBounds.left, -mRootBounds.top);
    }
    }


    /** Gets bounds of the secondary split with screen based coordinate on the param Rect. */
    /** Copies the bottom/right bounds to the provided Rect (screen-based coordinates). */
    public void getBounds2(Rect rect) {
    public void copyBottomRightBounds(Rect rect) {
        rect.set(mBounds2);
        rect.set(getBottomRightBounds());
    }
    }


    /** Gets bounds of the secondary split with parent based coordinate on the param Rect. */
    /** Copies the bottom/right bounds to the provided Rect (parent-based coordinates). */
    public void getRefBounds2(Rect rect) {
    public void copyBottomRightRefBounds(Rect rect) {
        getBounds2(rect);
        copyBottomRightBounds(rect);
        rect.offset(-mRootBounds.left, -mRootBounds.top);
        rect.offset(-mRootBounds.left, -mRootBounds.top);
    }
    }


    /** Gets root bounds of the whole split layout on the param Rect. */
    /**
    public void getRootBounds(Rect rect) {
     * Gets the content bounds of the top/left app (the bounds of where the app contents would be
        rect.set(mRootBounds);
     * drawn). Might be larger than the available surface space.
     */
    public Rect getTopLeftContentBounds() {
        return mContentBounds.getFirst();
    }

    /**
     * Gets the content bounds of the bottom/right app (the bounds of where the app contents would
     * be drawn). Might be larger than the available surface space.
     */
    public Rect getBottomRightContentBounds() {
        return mContentBounds.getLast();
    }
    }


    /** Gets bounds of divider window with screen based coordinate on the param Rect. */
    /** Gets bounds of divider window with screen based coordinate on the param Rect. */
@@ -340,8 +358,10 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
     */
     */
    public float getDividerPositionAsFraction() {
    public float getDividerPositionAsFraction() {
        return Math.min(1f, Math.max(0f, mIsLeftRightSplit
        return Math.min(1f, Math.max(0f, mIsLeftRightSplit
                ? (float) ((mBounds1.right + mBounds2.left) / 2f) / mBounds2.right
                ? (float) ((getTopLeftBounds().right + getBottomRightBounds().left) / 2f)
                : (float) ((mBounds1.bottom + mBounds2.top) / 2f) / mBounds2.bottom));
                        / getBottomRightBounds().right
                : (float) ((getTopLeftBounds().bottom + getBottomRightBounds().top) / 2f)
                        / getBottomRightBounds().bottom));
    }
    }


    private void updateInvisibleRect() {
    private void updateInvisibleRect() {
@@ -435,7 +455,8 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
    }
    }


    private void updateBounds(int position) {
    private void updateBounds(int position) {
        updateBounds(position, mBounds1, mBounds2, mDividerBounds, true /* setEffectBounds */);
        updateBounds(position, getTopLeftBounds(), getBottomRightBounds(), mDividerBounds,
                true /* setEffectBounds */);
    }
    }


    /** Updates recording bounds of divider window and both of the splits. */
    /** Updates recording bounds of divider window and both of the splits. */
@@ -638,8 +659,8 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
        updateBounds(mDividerPosition);
        updateBounds(mDividerPosition);
        mWinToken1 = null;
        mWinToken1 = null;
        mWinToken2 = null;
        mWinToken2 = null;
        mWinBounds1.setEmpty();
        getTopLeftContentBounds().setEmpty();
        mWinBounds2.setEmpty();
        getBottomRightContentBounds().setEmpty();
    }
    }


    /**
    /**
@@ -835,7 +856,8 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
                insets.left != 0 || insets.top != 0 || insets.right != 0 || insets.bottom != 0;
                insets.left != 0 || insets.top != 0 || insets.right != 0 || insets.bottom != 0;


        final int dividerPos = mDividerSnapAlgorithm.calculateNonDismissingSnapTarget(
        final int dividerPos = mDividerSnapAlgorithm.calculateNonDismissingSnapTarget(
                mIsLeftRightSplit ? mBounds2.width() : mBounds2.height()).position;
                mIsLeftRightSplit ? getBottomRightBounds().width() : getBottomRightBounds().height()
        ).position;
        final Rect endBounds1 = new Rect();
        final Rect endBounds1 = new Rect();
        final Rect endBounds2 = new Rect();
        final Rect endBounds2 = new Rect();
        final Rect endDividerBounds = new Rect();
        final Rect endDividerBounds = new Rect();
@@ -847,12 +869,12 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
        endBounds2.offset(-mRootBounds.left, -mRootBounds.top);
        endBounds2.offset(-mRootBounds.left, -mRootBounds.top);
        endDividerBounds.offset(-mRootBounds.left, -mRootBounds.top);
        endDividerBounds.offset(-mRootBounds.left, -mRootBounds.top);


        ValueAnimator animator1 = moveSurface(t, topLeftStage, getRefBounds1(), endBounds1,
        ValueAnimator animator1 = moveSurface(t, topLeftStage, getTopLeftRefBounds(), endBounds1,
                -insets.left, -insets.top, true /* roundCorners */, true /* isGoingBehind */,
                -insets.left, -insets.top, true /* roundCorners */, true /* isGoingBehind */,
                shouldVeil);
                shouldVeil);
        ValueAnimator animator2 = moveSurface(t, bottomRightStage, getRefBounds2(), endBounds2,
        ValueAnimator animator2 = moveSurface(t, bottomRightStage, getBottomRightRefBounds(),
                insets.left, insets.top, true /* roundCorners */, false /* isGoingBehind */,
                endBounds2, insets.left, insets.top, true /* roundCorners */,
                shouldVeil);
                false /* isGoingBehind */, shouldVeil);
        ValueAnimator animator3 = moveSurface(t, null /* stage */, getRefDividerBounds(),
        ValueAnimator animator3 = moveSurface(t, null /* stage */, getRefDividerBounds(),
                endDividerBounds, 0 /* offsetX */, 0 /* offsetY */, false /* roundCorners */,
                endDividerBounds, 0 /* offsetX */, 0 /* offsetY */, false /* roundCorners */,
                false /* isGoingBehind */, false /* addVeil */);
                false /* isGoingBehind */, false /* addVeil */);
@@ -1059,10 +1081,10 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
            // Resets layer of divider bar to make sure it is always on top.
            // Resets layer of divider bar to make sure it is always on top.
            t.setLayer(dividerLeash, Integer.MAX_VALUE);
            t.setLayer(dividerLeash, Integer.MAX_VALUE);
        }
        }
        getRefBounds1(mTempRect);
        copyTopLeftRefBounds(mTempRect);
        t.setPosition(leash1, mTempRect.left, mTempRect.top)
        t.setPosition(leash1, mTempRect.left, mTempRect.top)
                .setWindowCrop(leash1, mTempRect.width(), mTempRect.height());
                .setWindowCrop(leash1, mTempRect.width(), mTempRect.height());
        getRefBounds2(mTempRect);
        copyBottomRightRefBounds(mTempRect);
        t.setPosition(leash2, mTempRect.left, mTempRect.top)
        t.setPosition(leash2, mTempRect.left, mTempRect.top)
                .setWindowCrop(leash2, mTempRect.width(), mTempRect.height());
                .setWindowCrop(leash2, mTempRect.width(), mTempRect.height());


@@ -1084,15 +1106,17 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
    public boolean applyTaskChanges(WindowContainerTransaction wct,
    public boolean applyTaskChanges(WindowContainerTransaction wct,
            ActivityManager.RunningTaskInfo task1, ActivityManager.RunningTaskInfo task2) {
            ActivityManager.RunningTaskInfo task1, ActivityManager.RunningTaskInfo task2) {
        boolean boundsChanged = false;
        boolean boundsChanged = false;
        if (!mBounds1.equals(mWinBounds1) || !task1.token.equals(mWinToken1)) {
        if (!getTopLeftBounds().equals(getTopLeftContentBounds())
            setTaskBounds(wct, task1, mBounds1);
                || !task1.token.equals(mWinToken1)) {
            mWinBounds1.set(mBounds1);
            setTaskBounds(wct, task1, getTopLeftBounds());
            getTopLeftContentBounds().set(getTopLeftBounds());
            mWinToken1 = task1.token;
            mWinToken1 = task1.token;
            boundsChanged = true;
            boundsChanged = true;
        }
        }
        if (!mBounds2.equals(mWinBounds2) || !task2.token.equals(mWinToken2)) {
        if (!getBottomRightBounds().equals(getBottomRightContentBounds())
            setTaskBounds(wct, task2, mBounds2);
                || !task2.token.equals(mWinToken2)) {
            mWinBounds2.set(mBounds2);
            setTaskBounds(wct, task2, getBottomRightBounds());
            getBottomRightContentBounds().set(getBottomRightBounds());
            mWinToken2 = task2.token;
            mWinToken2 = task2.token;
            boundsChanged = true;
            boundsChanged = true;
        }
        }
@@ -1129,22 +1153,22 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
    public void applyLayoutOffsetTarget(WindowContainerTransaction wct, int offsetX, int offsetY,
    public void applyLayoutOffsetTarget(WindowContainerTransaction wct, int offsetX, int offsetY,
            ActivityManager.RunningTaskInfo taskInfo1, ActivityManager.RunningTaskInfo taskInfo2) {
            ActivityManager.RunningTaskInfo taskInfo1, ActivityManager.RunningTaskInfo taskInfo2) {
        if (offsetX == 0 && offsetY == 0) {
        if (offsetX == 0 && offsetY == 0) {
            wct.setBounds(taskInfo1.token, mBounds1);
            wct.setBounds(taskInfo1.token, getTopLeftBounds());
            wct.setScreenSizeDp(taskInfo1.token,
            wct.setScreenSizeDp(taskInfo1.token,
                    SCREEN_WIDTH_DP_UNDEFINED, SCREEN_HEIGHT_DP_UNDEFINED);
                    SCREEN_WIDTH_DP_UNDEFINED, SCREEN_HEIGHT_DP_UNDEFINED);


            wct.setBounds(taskInfo2.token, mBounds2);
            wct.setBounds(taskInfo2.token, getBottomRightBounds());
            wct.setScreenSizeDp(taskInfo2.token,
            wct.setScreenSizeDp(taskInfo2.token,
                    SCREEN_WIDTH_DP_UNDEFINED, SCREEN_HEIGHT_DP_UNDEFINED);
                    SCREEN_WIDTH_DP_UNDEFINED, SCREEN_HEIGHT_DP_UNDEFINED);
        } else {
        } else {
            getBounds1(mTempRect);
            copyTopLeftBounds(mTempRect);
            mTempRect.offset(offsetX, offsetY);
            mTempRect.offset(offsetX, offsetY);
            wct.setBounds(taskInfo1.token, mTempRect);
            wct.setBounds(taskInfo1.token, mTempRect);
            wct.setScreenSizeDp(taskInfo1.token,
            wct.setScreenSizeDp(taskInfo1.token,
                    taskInfo1.configuration.screenWidthDp,
                    taskInfo1.configuration.screenWidthDp,
                    taskInfo1.configuration.screenHeightDp);
                    taskInfo1.configuration.screenHeightDp);


            getBounds2(mTempRect);
            copyBottomRightBounds(mTempRect);
            mTempRect.offset(offsetX, offsetY);
            mTempRect.offset(offsetX, offsetY);
            wct.setBounds(taskInfo2.token, mTempRect);
            wct.setBounds(taskInfo2.token, mTempRect);
            wct.setScreenSizeDp(taskInfo2.token,
            wct.setScreenSizeDp(taskInfo2.token,
@@ -1162,9 +1186,9 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
        pw.println(innerPrefix + "mFreezeDividerWindow=" + mFreezeDividerWindow);
        pw.println(innerPrefix + "mFreezeDividerWindow=" + mFreezeDividerWindow);
        pw.println(innerPrefix + "mDimNonImeSide=" + mDimNonImeSide);
        pw.println(innerPrefix + "mDimNonImeSide=" + mDimNonImeSide);
        pw.println(innerPrefix + "mDividerPosition=" + mDividerPosition);
        pw.println(innerPrefix + "mDividerPosition=" + mDividerPosition);
        pw.println(innerPrefix + "bounds1=" + mBounds1.toShortString());
        pw.println(innerPrefix + "bounds1=" + getTopLeftBounds().toShortString());
        pw.println(innerPrefix + "dividerBounds=" + mDividerBounds.toShortString());
        pw.println(innerPrefix + "dividerBounds=" + mDividerBounds.toShortString());
        pw.println(innerPrefix + "bounds2=" + mBounds2.toShortString());
        pw.println(innerPrefix + "bounds2=" + getBottomRightBounds().toShortString());
    }
    }


    /** Handles layout change event. */
    /** Handles layout change event. */
@@ -1274,15 +1298,16 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
            }
            }


            final boolean topLeftShrink = isLeftRightSplit
            final boolean topLeftShrink = isLeftRightSplit
                    ? position < mWinBounds1.right : position < mWinBounds1.bottom;
                    ? position < getTopLeftContentBounds().right
                    : position < getTopLeftContentBounds().bottom;
            if (topLeftShrink) {
            if (topLeftShrink) {
                mShrinkSide = isLeftRightSplit ? DOCKED_LEFT : DOCKED_TOP;
                mShrinkSide = isLeftRightSplit ? DOCKED_LEFT : DOCKED_TOP;
                mContentBounds.set(mWinBounds1);
                mContentBounds.set(getTopLeftContentBounds());
                mSurfaceBounds.set(mBounds1);
                mSurfaceBounds.set(getTopLeftBounds());
            } else {
            } else {
                mShrinkSide = isLeftRightSplit ? DOCKED_RIGHT : DOCKED_BOTTOM;
                mShrinkSide = isLeftRightSplit ? DOCKED_RIGHT : DOCKED_BOTTOM;
                mContentBounds.set(mWinBounds2);
                mContentBounds.set(getBottomRightContentBounds());
                mSurfaceBounds.set(mBounds2);
                mSurfaceBounds.set(getBottomRightBounds());
            }
            }


            if (mDismissingSide != DOCKED_INVALID) {
            if (mDismissingSide != DOCKED_INVALID) {
@@ -1334,12 +1359,12 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
                    case DOCKED_TOP:
                    case DOCKED_TOP:
                    case DOCKED_LEFT:
                    case DOCKED_LEFT:
                        targetLeash = leash1;
                        targetLeash = leash1;
                        mTempRect.set(mBounds1);
                        mTempRect.set(getTopLeftBounds());
                        break;
                        break;
                    case DOCKED_BOTTOM:
                    case DOCKED_BOTTOM:
                    case DOCKED_RIGHT:
                    case DOCKED_RIGHT:
                        targetLeash = leash2;
                        targetLeash = leash2;
                        mTempRect.set(mBounds2);
                        mTempRect.set(getBottomRightBounds());
                        break;
                        break;
                }
                }
            } else if (mParallaxType == PARALLAX_ALIGN_CENTER) {
            } else if (mParallaxType == PARALLAX_ALIGN_CENTER) {
@@ -1347,12 +1372,12 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
                    case DOCKED_TOP:
                    case DOCKED_TOP:
                    case DOCKED_LEFT:
                    case DOCKED_LEFT:
                        targetLeash = leash1;
                        targetLeash = leash1;
                        mTempRect.set(mBounds1);
                        mTempRect.set(getTopLeftBounds());
                        break;
                        break;
                    case DOCKED_BOTTOM:
                    case DOCKED_BOTTOM:
                    case DOCKED_RIGHT:
                    case DOCKED_RIGHT:
                        targetLeash = leash2;
                        targetLeash = leash2;
                        mTempRect.set(mBounds2);
                        mTempRect.set(getBottomRightBounds());
                        break;
                        break;
                }
                }
            }
            }
@@ -1530,7 +1555,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
        private int getTargetYOffset() {
        private int getTargetYOffset() {
            final int desireOffset = Math.abs(mEndImeTop - mStartImeTop);
            final int desireOffset = Math.abs(mEndImeTop - mStartImeTop);
            // Make sure to keep at least 30% visible for the top split.
            // Make sure to keep at least 30% visible for the top split.
            final int maxOffset = (int) (mBounds1.height() * ADJUSTED_SPLIT_FRACTION_MAX);
            final int maxOffset = (int) (getTopLeftBounds().height() * ADJUSTED_SPLIT_FRACTION_MAX);
            return -Math.min(desireOffset, maxOffset);
            return -Math.min(desireOffset, maxOffset);
        }
        }


@@ -1580,11 +1605,11 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
                    t.setPosition(dividerLeash, mTempRect.left, mTempRect.top);
                    t.setPosition(dividerLeash, mTempRect.left, mTempRect.top);
                }
                }


                getRefBounds1(mTempRect);
                copyTopLeftRefBounds(mTempRect);
                mTempRect.offset(0, mYOffsetForIme);
                mTempRect.offset(0, mYOffsetForIme);
                t.setPosition(leash1, mTempRect.left, mTempRect.top);
                t.setPosition(leash1, mTempRect.left, mTempRect.top);


                getRefBounds2(mTempRect);
                copyBottomRightRefBounds(mTempRect);
                mTempRect.offset(0, mYOffsetForIme);
                mTempRect.offset(0, mYOffsetForIme);
                t.setPosition(leash2, mTempRect.left, mTempRect.top);
                t.setPosition(leash2, mTempRect.left, mTempRect.top);
                adjusted = true;
                adjusted = true;
+17 −14
Original line number Original line Diff line number Diff line
@@ -1709,8 +1709,8 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
    }
    }


    void getStageBounds(Rect outTopOrLeftBounds, Rect outBottomOrRightBounds) {
    void getStageBounds(Rect outTopOrLeftBounds, Rect outBottomOrRightBounds) {
        outTopOrLeftBounds.set(mSplitLayout.getBounds1());
        outTopOrLeftBounds.set(mSplitLayout.getTopLeftBounds());
        outBottomOrRightBounds.set(mSplitLayout.getBounds2());
        outBottomOrRightBounds.set(mSplitLayout.getBottomRightBounds());
    }
    }


    private void runForActiveStages(Consumer<StageTaskListener> consumer) {
    private void runForActiveStages(Consumer<StageTaskListener> consumer) {
@@ -1857,8 +1857,11 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            return;
            return;
        }
        }
        mRecentTasks.ifPresent(recentTasks -> {
        mRecentTasks.ifPresent(recentTasks -> {
            Rect topLeftBounds = mSplitLayout.getBounds1();
            Rect topLeftBounds = new Rect();
            Rect bottomRightBounds = mSplitLayout.getBounds2();
            mSplitLayout.copyTopLeftBounds(topLeftBounds);
            Rect bottomRightBounds = new Rect();
            mSplitLayout.copyBottomRightBounds(bottomRightBounds);

            int sideStageTopTaskId;
            int sideStageTopTaskId;
            int mainStageTopTaskId;
            int mainStageTopTaskId;
            if (enableFlexibleSplit()) {
            if (enableFlexibleSplit()) {
@@ -2392,7 +2395,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        boolean updated = layout.applyTaskChanges(wct, topLeftStage.mRootTaskInfo,
        boolean updated = layout.applyTaskChanges(wct, topLeftStage.mRootTaskInfo,
                bottomRightStage.mRootTaskInfo);
                bottomRightStage.mRootTaskInfo);
        ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "updateWindowBounds: topLeftStage=%s bottomRightStage=%s",
        ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "updateWindowBounds: topLeftStage=%s bottomRightStage=%s",
                layout.getBounds1(), layout.getBounds2());
                layout.getTopLeftBounds(), layout.getBottomRightBounds());
        return updated;
        return updated;
    }
    }


@@ -2420,7 +2423,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
                applyResizingOffset);
                applyResizingOffset);
        ProtoLog.d(WM_SHELL_SPLIT_SCREEN,
        ProtoLog.d(WM_SHELL_SPLIT_SCREEN,
                "updateSurfaceBounds: topLeftStage=%s bottomRightStage=%s",
                "updateSurfaceBounds: topLeftStage=%s bottomRightStage=%s",
                layout.getBounds1(), layout.getBounds2());
                layout.getTopLeftBounds(), layout.getBottomRightBounds());
    }
    }


    @Override
    @Override
@@ -2541,12 +2544,12 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,


    private Rect getSideStageBounds() {
    private Rect getSideStageBounds() {
        return mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT
        return mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT
                ? mSplitLayout.getBounds1() : mSplitLayout.getBounds2();
                ? mSplitLayout.getTopLeftBounds() : mSplitLayout.getBottomRightBounds();
    }
    }


    private Rect getMainStageBounds() {
    private Rect getMainStageBounds() {
        return mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT
        return mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT
                ? mSplitLayout.getBounds2() : mSplitLayout.getBounds1();
                ? mSplitLayout.getBottomRightBounds() : mSplitLayout.getTopLeftBounds();
    }
    }


    /**
    /**
@@ -2559,11 +2562,11 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            // Split Layout doesn't actually keep track of the bounds based on the stage,
            // Split Layout doesn't actually keep track of the bounds based on the stage,
            // it only knows that bounds1 is leftTop position and bounds2 is bottomRight position
            // it only knows that bounds1 is leftTop position and bounds2 is bottomRight position
            // We'll then assume this method is to get bounds of bottomRight stage
            // We'll then assume this method is to get bounds of bottomRight stage
            mSplitLayout.getBounds2(rect);
            mSplitLayout.copyBottomRightBounds(rect);
        }  else if (mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT) {
        }  else if (mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT) {
            mSplitLayout.getBounds1(rect);
            mSplitLayout.copyTopLeftBounds(rect);
        } else {
        } else {
            mSplitLayout.getBounds2(rect);
            mSplitLayout.copyBottomRightBounds(rect);
        }
        }
    }
    }


@@ -2577,12 +2580,12 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            // Split Layout doesn't actually keep track of the bounds based on the stage,
            // Split Layout doesn't actually keep track of the bounds based on the stage,
            // it only knows that bounds1 is leftTop position and bounds2 is bottomRight position
            // it only knows that bounds1 is leftTop position and bounds2 is bottomRight position
            // We'll then assume this method is to get bounds of topLeft stage
            // We'll then assume this method is to get bounds of topLeft stage
            mSplitLayout.getBounds1(rect);
            mSplitLayout.copyTopLeftBounds(rect);
        } else {
        } else {
            if (mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT) {
            if (mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT) {
                mSplitLayout.getBounds2(rect);
                mSplitLayout.copyBottomRightBounds(rect);
            } else {
            } else {
                mSplitLayout.getBounds1(rect);
                mSplitLayout.copyTopLeftBounds(rect);
            }
            }
        }
        }
    }
    }
+2 −2
Original line number Original line Diff line number Diff line
@@ -53,8 +53,8 @@ public class SplitTestUtils {
        doReturn(dividerBounds).when(out).getDividerBounds();
        doReturn(dividerBounds).when(out).getDividerBounds();
        doReturn(dividerBounds).when(out).getRefDividerBounds();
        doReturn(dividerBounds).when(out).getRefDividerBounds();
        doReturn(leash).when(out).getDividerLeash();
        doReturn(leash).when(out).getDividerLeash();
        doReturn(bounds1).when(out).getBounds1();
        doReturn(bounds1).when(out).getTopLeftBounds();
        doReturn(bounds2).when(out).getBounds2();
        doReturn(bounds2).when(out).getBottomRightBounds();
        return out;
        return out;
    }
    }


+2 −2
Original line number Original line Diff line number Diff line
@@ -141,8 +141,8 @@ public class StageCoordinatorTests extends ShellTestCase {
                Optional.empty()));
                Optional.empty()));
        mDividerLeash = new SurfaceControl.Builder().setName("fakeDivider").build();
        mDividerLeash = new SurfaceControl.Builder().setName("fakeDivider").build();


        when(mSplitLayout.getBounds1()).thenReturn(mBounds1);
        when(mSplitLayout.getTopLeftBounds()).thenReturn(mBounds1);
        when(mSplitLayout.getBounds2()).thenReturn(mBounds2);
        when(mSplitLayout.getBottomRightBounds()).thenReturn(mBounds2);
        when(mSplitLayout.getRootBounds()).thenReturn(mRootBounds);
        when(mSplitLayout.getRootBounds()).thenReturn(mRootBounds);
        when(mSplitLayout.isLeftRightSplit()).thenReturn(false);
        when(mSplitLayout.isLeftRightSplit()).thenReturn(false);
        when(mSplitLayout.applyTaskChanges(any(), any(), any())).thenReturn(true);
        when(mSplitLayout.applyTaskChanges(any(), any(), any())).thenReturn(true);