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

Commit d40ffd2f authored by Shuming Hao's avatar Shuming Hao Committed by Android (Google) Code Review
Browse files

Merge "Move app pair back when it's clicked on default display" into main

parents 49be5c50 20629dbe
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -848,6 +848,27 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
                "startTasks: task1=%d task2=%d position=%d snapPosition=%d",
                taskId1, taskId2, splitPosition, snapPosition);
        final WindowContainerTransaction wct = new WindowContainerTransaction();

        // If the two tasks are already in split screen on external display, only reparent the
        // split root to the default display if the app pair is clicked on default display.
        // TODO(b/393217881): cover more cases and extract this to a new method when split screen
        //  in connected display is fully supported.
        if (enableNonDefaultDisplaySplit()) {
            DisplayAreaInfo displayAreaInfo = mRootTDAOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY);
            ActivityManager.RunningTaskInfo taskInfo1 = mTaskOrganizer.getRunningTaskInfo(taskId1);
            ActivityManager.RunningTaskInfo taskInfo2 = mTaskOrganizer.getRunningTaskInfo(taskId2);

            if (displayAreaInfo != null && taskInfo1 != null && taskInfo2 != null
                    && getStageOfTask(taskId1) != STAGE_TYPE_UNDEFINED
                    && getStageOfTask(taskId2) != STAGE_TYPE_UNDEFINED
                    && taskInfo1.displayId != DEFAULT_DISPLAY
                    && taskInfo1.displayId == taskInfo2.displayId) {
                wct.reparent(mRootTaskInfo.token, displayAreaInfo.token, true);
                mTaskOrganizer.applyTransaction(wct);
                return;
            }
        }

        if (taskId2 == INVALID_TASK_ID) {
            startSingleTask(taskId1, options1, wct, remoteTransition);
            return;