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

Commit 3a6dcfef authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Do not move desktop task to the next display" into main

parents 057622e5 00095bb1
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -1903,7 +1903,22 @@ class DesktopTasksController(
    /** Move task to the next display which can host desktop tasks. */
    fun moveToNextDesktopDisplay(taskId: Int) =
        moveToNextDisplay(taskId) { displayId ->
            desktopState.isDesktopModeSupportedOnDisplay(displayId)
            if (!desktopState.isDesktopModeSupportedOnDisplay(displayId)) {
                logD(
                    "moveToNextDesktopDisplay: Skip displayId=$displayId as desktop mode " +
                        "is not supported."
                )
                return@moveToNextDisplay false
            }
            if (!getFocusedNonDesktopTasks(displayId).isEmpty()) {
                logD(
                    "moveToNextDesktopDisplay: Skip displayId=$displayId as the focused " +
                        "task is not desktop task focused non desktop tasks."
                )
                return@moveToNextDisplay false
            }
            logD("moveToNextDesktopDisplay: Choose displayId=$displayId for the next display.")
            return@moveToNextDisplay true
        }

    /**
+25 −0
Original line number Diff line number Diff line
@@ -4112,6 +4112,31 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        moveToNextDesktopDisplay_moveIifDesktopModeSupportedOnDestination(false)
    }

    @Test
    fun moveToNextDesktopDisplay_dontMoveIfDestinationFocusesFullscreenTask() {
        // Set up displays
        whenever(rootTaskDisplayAreaOrganizer.displayIds)
            .thenReturn(intArrayOf(DEFAULT_DISPLAY, SECOND_DISPLAY))
        taskRepository.addDesk(displayId = SECOND_DISPLAY, deskId = 2)
        desktopState.overrideDesktopModeSupportPerDisplay[SECOND_DISPLAY] = true

        // Set up a focused fullscreen task on the secondary display
        val fullscreenTask = setUpFullscreenTask(displayId = SECOND_DISPLAY)
        fullscreenTask.isFocused = true

        // Set up a task on the default display
        val task = setUpFreeformTask(displayId = DEFAULT_DISPLAY)

        controller.moveToNextDesktopDisplay(task.taskId)

        verify(transitions, never())
            .startTransition(
                eq(TRANSIT_CHANGE),
                any<WindowContainerTransaction>(),
                isA(DesktopModeMoveToDisplayTransitionHandler::class.java),
            )
    }

    @Test
    fun getTaskWindowingMode() {
        val fullscreenTask = setUpFullscreenTask()