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

Commit 642ead3a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move adjacent tasks forward together to ensure occluding state" into sc-v2-dev

parents 7cbd05ad 99702662
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3289,7 +3289,7 @@ package android.window {
    method @NonNull public android.window.WindowContainerTransaction reparentTasks(@Nullable android.window.WindowContainerToken, @Nullable android.window.WindowContainerToken, @Nullable int[], @Nullable int[], boolean);
    method @NonNull public android.window.WindowContainerTransaction scheduleFinishEnterPip(@NonNull android.window.WindowContainerToken, @NonNull android.graphics.Rect);
    method @NonNull public android.window.WindowContainerTransaction setActivityWindowingMode(@NonNull android.window.WindowContainerToken, int);
    method @NonNull public android.window.WindowContainerTransaction setAdjacentRoots(@NonNull android.window.WindowContainerToken, @NonNull android.window.WindowContainerToken);
    method @NonNull public android.window.WindowContainerTransaction setAdjacentRoots(@NonNull android.window.WindowContainerToken, @NonNull android.window.WindowContainerToken, boolean);
    method @NonNull public android.window.WindowContainerTransaction setAdjacentTaskFragments(@NonNull android.os.IBinder, @Nullable android.os.IBinder, @Nullable android.window.WindowContainerTransaction.TaskFragmentAdjacentParams);
    method @NonNull public android.window.WindowContainerTransaction setAppBounds(@NonNull android.window.WindowContainerToken, @NonNull android.graphics.Rect);
    method @NonNull public android.window.WindowContainerTransaction setBounds(@NonNull android.window.WindowContainerToken, @NonNull android.graphics.Rect);
+28 −4
Original line number Diff line number Diff line
@@ -368,10 +368,12 @@ public final class WindowContainerTransaction implements Parcelable {
     */
    @NonNull
    public WindowContainerTransaction setAdjacentRoots(
            @NonNull WindowContainerToken root1, @NonNull WindowContainerToken root2) {
            @NonNull WindowContainerToken root1, @NonNull WindowContainerToken root2,
            boolean moveTogether) {
        mHierarchyOps.add(HierarchyOp.createForAdjacentRoots(
                root1.asBinder(),
                root2.asBinder()));
                root2.asBinder(),
                moveTogether));
        return this;
    }

@@ -975,6 +977,9 @@ public final class WindowContainerTransaction implements Parcelable {

        private boolean mReparentTopOnly;

        // TODO(b/207185041): Remove this once having a single-top root for split screen.
        private boolean mMoveAdjacentTogether;

        @Nullable
        private int[]  mWindowingModes;

@@ -1033,10 +1038,13 @@ public final class WindowContainerTransaction implements Parcelable {
                    .build();
        }

        public static HierarchyOp createForAdjacentRoots(IBinder root1, IBinder root2) {
        /** Create a hierarchy op for setting adjacent root tasks. */
        public static HierarchyOp createForAdjacentRoots(IBinder root1, IBinder root2,
                boolean moveTogether) {
            return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS)
                    .setContainer(root1)
                    .setReparentContainer(root2)
                    .setMoveAdjacentTogether(moveTogether)
                    .build();
        }

@@ -1070,6 +1078,7 @@ public final class WindowContainerTransaction implements Parcelable {
            mReparent = copy.mReparent;
            mToTop = copy.mToTop;
            mReparentTopOnly = copy.mReparentTopOnly;
            mMoveAdjacentTogether = copy.mMoveAdjacentTogether;
            mWindowingModes = copy.mWindowingModes;
            mActivityTypes = copy.mActivityTypes;
            mLaunchOptions = copy.mLaunchOptions;
@@ -1084,6 +1093,7 @@ public final class WindowContainerTransaction implements Parcelable {
            mReparent = in.readStrongBinder();
            mToTop = in.readBoolean();
            mReparentTopOnly = in.readBoolean();
            mMoveAdjacentTogether = in.readBoolean();
            mWindowingModes = in.createIntArray();
            mActivityTypes = in.createIntArray();
            mLaunchOptions = in.readBundle();
@@ -1128,6 +1138,10 @@ public final class WindowContainerTransaction implements Parcelable {
            return mReparentTopOnly;
        }

        public boolean getMoveAdjacentTogether() {
            return mMoveAdjacentTogether;
        }

        public int[] getWindowingModes() {
            return mWindowingModes;
        }
@@ -1175,7 +1189,8 @@ public final class WindowContainerTransaction implements Parcelable {
                    return "{reorder: " + mContainer + " to " + (mToTop ? "top" : "bottom") + "}";
                case HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS:
                    return "{SetAdjacentRoot: container=" + mContainer
                            + " adjacentRoot=" + mReparent + "}";
                            + " adjacentRoot=" + mReparent + " mMoveAdjacentTogether="
                            + mMoveAdjacentTogether + "}";
                case HIERARCHY_OP_TYPE_LAUNCH_TASK:
                    return "{LaunchTask: " + mLaunchOptions + "}";
                case HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT:
@@ -1212,6 +1227,7 @@ public final class WindowContainerTransaction implements Parcelable {
            dest.writeStrongBinder(mReparent);
            dest.writeBoolean(mToTop);
            dest.writeBoolean(mReparentTopOnly);
            dest.writeBoolean(mMoveAdjacentTogether);
            dest.writeIntArray(mWindowingModes);
            dest.writeIntArray(mActivityTypes);
            dest.writeBundle(mLaunchOptions);
@@ -1251,6 +1267,8 @@ public final class WindowContainerTransaction implements Parcelable {

            private boolean mReparentTopOnly;

            private boolean mMoveAdjacentTogether;

            @Nullable
            private int[]  mWindowingModes;

@@ -1293,6 +1311,11 @@ public final class WindowContainerTransaction implements Parcelable {
                return this;
            }

            Builder setMoveAdjacentTogether(boolean moveAdjacentTogether) {
                mMoveAdjacentTogether = moveAdjacentTogether;
                return this;
            }

            Builder setWindowingModes(@Nullable int[] windowingModes) {
                mWindowingModes = windowingModes;
                return this;
@@ -1336,6 +1359,7 @@ public final class WindowContainerTransaction implements Parcelable {
                        : null;
                hierarchyOp.mToTop = mToTop;
                hierarchyOp.mReparentTopOnly = mReparentTopOnly;
                hierarchyOp.mMoveAdjacentTogether = mMoveAdjacentTogether;
                hierarchyOp.mLaunchOptions = mLaunchOptions;
                hierarchyOp.mActivityIntent = mActivityIntent;
                hierarchyOp.mPendingIntent = mPendingIntent;
+2 −1
Original line number Diff line number Diff line
@@ -793,7 +793,8 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        if (mMainStageListener.mHasRootTask && mSideStageListener.mHasRootTask) {
            final WindowContainerTransaction wct = new WindowContainerTransaction();
            // Make the stages adjacent to each other so they occlude what's behind them.
            wct.setAdjacentRoots(mMainStage.mRootTaskInfo.token, mSideStage.mRootTaskInfo.token);
            wct.setAdjacentRoots(mMainStage.mRootTaskInfo.token, mSideStage.mRootTaskInfo.token,
                    true /* moveTogether */);
            wct.setLaunchAdjacentFlagRoot(mSideStage.mRootTaskInfo.token);
            mTaskOrganizer.applyTransaction(wct);
        }
+2 −1
Original line number Diff line number Diff line
@@ -634,7 +634,8 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            mUseLegacySplit = mContext.getResources().getBoolean(R.bool.config_useLegacySplit);
            final WindowContainerTransaction wct = new WindowContainerTransaction();
            // Make the stages adjacent to each other so they occlude what's behind them.
            wct.setAdjacentRoots(mMainStage.mRootTaskInfo.token, mSideStage.mRootTaskInfo.token);
            wct.setAdjacentRoots(mMainStage.mRootTaskInfo.token, mSideStage.mRootTaskInfo.token,
                    true /* moveTogether */);

            // Only sets side stage as launch-adjacent-flag-root when the device is not using legacy
            // split to prevent new split behavior confusing users.
+22 −11
Original line number Diff line number Diff line
@@ -4647,23 +4647,14 @@ class Task extends TaskFragment {
        moveToFront(reason, null);
    }

    /**
     * @param reason The reason for moving the root task to the front.
     * @param task If non-null, the task will be moved to the top of the root task.
     */
    void moveToFront(String reason, Task task) {
        if (!isAttached()) {
            return;
        }

        final TaskDisplayArea taskDisplayArea = getDisplayArea();

        if (inSplitScreenSecondaryWindowingMode()) {
            // If the root task is in split-screen secondary mode, we need to make sure we move the
            // primary split-screen root task forward in the case it is currently behind a
            // fullscreen root task so both halves of the split-screen appear on-top and the
            // fullscreen root task isn't cutting between them.
            // TODO(b/70677280): This is a workaround until we can fix as part of b/70677280.
            final TaskDisplayArea taskDisplayArea = getDisplayArea();
            final Task topFullScreenRootTask =
                    taskDisplayArea.getTopRootTaskInWindowingMode(WINDOWING_MODE_FULLSCREEN);
            if (topFullScreenRootTask != null) {
@@ -4671,10 +4662,30 @@ class Task extends TaskFragment {
                        taskDisplayArea.getRootSplitScreenPrimaryTask();
                if (primarySplitScreenRootTask != null
                        && topFullScreenRootTask.compareTo(primarySplitScreenRootTask) > 0) {
                    primarySplitScreenRootTask.moveToFront(reason + " splitScreenToTop");
                    primarySplitScreenRootTask.moveToFrontInner(reason + " splitScreenToTop",
                            null /* task */);
                }
            }
        } else if (mMoveAdjacentTogether && getAdjacentTaskFragment() != null) {
            final Task adjacentTask = getAdjacentTaskFragment().asTask();
            if (adjacentTask != null) {
                adjacentTask.moveToFrontInner(reason + " adjacentTaskToTop", null /* task */);
            }
        }
        moveToFrontInner(reason, task);
    }

    /**
     * @param reason The reason for moving the root task to the front.
     * @param task If non-null, the task will be moved to the top of the root task.
     */
    @VisibleForTesting
    void moveToFrontInner(String reason, Task task) {
        if (!isAttached()) {
            return;
        }

        final TaskDisplayArea taskDisplayArea = getDisplayArea();

        if (!isActivityTypeHome() && returnsToHomeRootTask()) {
            // Make sure the root home task is behind this root task since that is where we
Loading