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

Commit ef4af100 authored by Matt Sziklay's avatar Matt Sziklay Committed by Android (Google) Code Review
Browse files

Merge "Allow freeform openInstance to handle non-freeform running tasks." into main

parents 11c1114d 01ca704c
Loading
Loading
Loading
Loading
+12 −17
Original line number Diff line number Diff line
@@ -467,10 +467,7 @@ class DesktopTasksController(
        }
        // TODO(342378842): Instead of using default display, support multiple displays
        val displayId = runningTask?.displayId ?: DEFAULT_DISPLAY
        val deskId =
            checkNotNull(taskRepository.getDefaultDeskId(displayId)) {
                "Expected a default desk to exist"
            }
        val deskId = getDefaultDeskId(displayId)
        return moveTaskToDesk(
            taskId = taskId,
            deskId = deskId,
@@ -715,10 +712,7 @@ class DesktopTasksController(
     * [startDragToDesktop].
     */
    private fun finalizeDragToDesktop(taskInfo: RunningTaskInfo) {
        val deskId =
            checkNotNull(taskRepository.getDefaultDeskId(taskInfo.displayId)) {
                "Expected a default desk to exist"
            }
        val deskId = getDefaultDeskId(taskInfo.displayId)
        ProtoLog.v(
            WM_SHELL_DESKTOP_MODE,
            "DesktopTasksController: finalizeDragToDesktop taskId=%d deskId=%d",
@@ -2050,8 +2044,10 @@ class DesktopTasksController(
                    unminimizeReason = UnminimizeReason.APP_HANDLE_MENU_BUTTON,
                )
            } else {
                moveBackgroundTaskToDesktop(
                val deskId = getDefaultDeskId(callingTask.displayId)
                moveTaskToDesk(
                    requestedTaskId,
                    deskId,
                    WindowContainerTransaction(),
                    DesktopModeTransitionSource.APP_HANDLE_MENU_BUTTON,
                )
@@ -2661,10 +2657,7 @@ class DesktopTasksController(
        displayId: Int,
        remoteTransition: RemoteTransition? = null,
    ) {
        val deskId =
            checkNotNull(taskRepository.getDefaultDeskId(displayId)) {
                "Expected a default desk to exist"
            }
        val deskId = getDefaultDeskId(displayId)
        activateDesk(deskId, remoteTransition)
    }

@@ -2728,13 +2721,15 @@ class DesktopTasksController(
    /** Removes the default desk in the given display. */
    @Deprecated("Deprecated with multi-desks.", ReplaceWith("removeDesk()"))
    fun removeDefaultDeskInDisplay(displayId: Int) {
        val deskId =
            checkNotNull(taskRepository.getDefaultDeskId(displayId)) {
                "Expected a default desk to exist"
            }
        val deskId = getDefaultDeskId(displayId)
        removeDesk(displayId = displayId, deskId = deskId)
    }

    private fun getDefaultDeskId(displayId: Int) =
        checkNotNull(taskRepository.getDefaultDeskId(displayId)) {
            "Expected a default desk to exist in display: $displayId"
        }

    /** Removes the given desk. */
    fun removeDesk(deskId: Int) {
        val displayId = taskRepository.getDisplayForDesk(deskId)