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

Commit 20629dbe authored by Shuming Hao's avatar Shuming Hao
Browse files

Move app pair back when it's clicked on default display

Bug fix for non default display CUJ where app pair is clicked on default
display when it's launched on external display. The app pair should be
moved back to default display on the click.

Bug: 399674814
Test: manual
Flag: com.android.window.flags.enable_non_default_display_split
Change-Id: I8f665ed36ba67f0c46464f4c96e7f0490ea2819b
parent 10555fef
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -847,6 +847,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;