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

Commit 78fab995 authored by Orhan Uysal's avatar Orhan Uysal
Browse files

Let SplitScreenController handle the split tasks.

On split to desktop transition, we remove the leftover split screen
task. This shouldn't be done for 2 reasons:

1) StageCoordinater already reparents the task on exit, so we shouldn't
   need to close it.
2) removeTask() removes the task from recents as well. Expected behaviour is that the leftover split task is moved to recents.

Test: Move from split to desktop using the handle/menu/keyboard
shortcut. Leftover split app is still in recents.
Bug: 326043729

Change-Id: Ie0414f7672f244260c975120ce27f473d0676527
parent 467325a9
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ import com.android.wm.shell.common.SyncTransactionQueue
import com.android.wm.shell.common.annotations.ExternalThread
import com.android.wm.shell.common.annotations.ShellMainThread
import com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT
import com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT
import com.android.wm.shell.desktopmode.DesktopModeTaskRepository.VisibleTasksListener
import com.android.wm.shell.desktopmode.DragToDesktopTransitionHandler.DragToDesktopStateListener
import com.android.wm.shell.draganddrop.DragAndDropController
@@ -405,22 +404,8 @@ class DesktopTasksController(
                    splitScreenController.getStageOfTask(taskInfo.taskId),
                    EXIT_REASON_DESKTOP_MODE
            )
            getOtherSplitTask(taskInfo.taskId)?.let { otherTaskInfo ->
                wct.removeTask(otherTaskInfo.token)
        }
    }
    }

    private fun getOtherSplitTask(taskId: Int): RunningTaskInfo? {
        val remainingTaskPosition: Int =
                if (splitScreenController.getSplitPosition(taskId)
                        == SPLIT_POSITION_BOTTOM_OR_RIGHT) {
                    SPLIT_POSITION_TOP_OR_LEFT
                } else {
                    SPLIT_POSITION_BOTTOM_OR_RIGHT
                }
        return splitScreenController.getTaskInfo(remainingTaskPosition)
    }

    /**
     * The second part of the animated drag to desktop transition, called after
+3 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import static com.android.wm.shell.splitscreen.SplitScreenController.ENTER_REASO
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;
import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON_DESKTOP_MODE;
import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON_DEVICE_FOLDED;
import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON_DRAG_DIVIDER;
import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON_FULLSCREEN_SHORTCUT;
@@ -1572,6 +1573,8 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
                // The device is folded
            case EXIT_REASON_FULLSCREEN_SHORTCUT:
                // User has used a keyboard shortcut to go back to fullscreen from split
            case EXIT_REASON_DESKTOP_MODE:
                // One of the children enters desktop mode
                return true;
            default:
                return false;
+0 −7
Original line number Diff line number Diff line
@@ -368,7 +368,6 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
                    // been added, so they must be added here
                    mWindowDecorByTaskId.get(mTaskId).addCaptionInset(wct);
                    mDesktopTasksController.get().moveToDesktop(mTaskId, wct);
                    closeOtherSplitTask(mTaskId);
                }
                decoration.closeHandleMenu();
            } else if (id == R.id.fullscreen_button) {
@@ -1041,12 +1040,6 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
        return mSplitScreenController.getTaskInfo(remainingTaskPosition);
    }

    private void closeOtherSplitTask(int taskId) {
        if (isTaskInSplitScreen(taskId)) {
            mTaskOperations.closeTask(getOtherSplitTask(taskId).token);
        }
    }

    private boolean isTaskInSplitScreen(int taskId) {
        return mSplitScreenController != null
                && mSplitScreenController.isTaskInSplitScreen(taskId);