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

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

Merge "Skip move-to-desktop for tasks with disabled entry points" into main

parents d394b20e 40260c4f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2435,6 +2435,13 @@ class DesktopTasksController(
            snapEventHandler.removeTaskIfTiled(task.displayId, task.taskId)
            // TODO: b/393977830 and b/397437641 - do not assume that freeform==desktop.
            if (!task.isFreeform) {
                if (desktopModeCompatPolicy.shouldDisableDesktopEntryPoints(task)) {
                    logW(
                        "moveToDisplay: do nothing because the desktop entry points should be " +
                            "disabled for the focused task"
                    )
                    return
                }
                addMoveToDeskTaskChanges(wct = wct, task = task, deskId = destinationDeskId)
            } else {
                if (DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue) {
+52 −0
Original line number Diff line number Diff line
@@ -4412,6 +4412,58 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        wct.assertPendingIntentActivityOptionsLaunchDisplayId(SECOND_DISPLAY)
    }
    @Test
    @EnableFlags(
        FLAG_ENABLE_MOVE_TO_NEXT_DISPLAY_SHORTCUT,
        FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND,
        FLAG_MOVE_TO_NEXT_DISPLAY_SHORTCUT_WITH_PROJECTED_MODE,
    )
    fun moveToNextDesktopDisplay_projectedMode_movesToDesktopOnConnectedDisplay() {
        // Setup state where a desktop task is running on a secondary display while the device is in
        // projected mode
        desktopState.isProjected = true
        whenever(rootTaskDisplayAreaOrganizer.displayIds)
            .thenReturn(intArrayOf(DEFAULT_DISPLAY, SECOND_DISPLAY))
        taskRepository.addDesk(displayId = SECOND_DISPLAY, deskId = SECOND_DISPLAY)
        val task = setUpFullscreenTask(displayId = DEFAULT_DISPLAY)
        doReturn(false).whenever(desktopModeCompatPolicy).shouldDisableDesktopEntryPoints(task)
        controller.moveToNextDesktopDisplay(
            taskId = task.taskId,
            userId = taskRepository.userId,
            enterReason = EnterReason.UNKNOWN_ENTER,
        )
        verify(desksOrganizer).moveTaskToDesk(any(), eq(SECOND_DISPLAY), eq(task), eq(false))
    }
    @Test
    @EnableFlags(
        FLAG_ENABLE_MOVE_TO_NEXT_DISPLAY_SHORTCUT,
        FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND,
        FLAG_MOVE_TO_NEXT_DISPLAY_SHORTCUT_WITH_PROJECTED_MODE,
    )
    fun moveToNextDesktopDisplay_projectedMode_movesToDesktopOnConnectedDisplay_skipTasksWithDisabledEntryPoints() {
        // Setup state where a desktop task is running on a secondary display while the device is in
        // projected mode
        desktopState.isProjected = true
        whenever(rootTaskDisplayAreaOrganizer.displayIds)
            .thenReturn(intArrayOf(DEFAULT_DISPLAY, SECOND_DISPLAY))
        taskRepository.addDesk(displayId = SECOND_DISPLAY, deskId = SECOND_DISPLAY)
        val task = setUpFullscreenTask(displayId = DEFAULT_DISPLAY)
        // The task should not have desktop entry points
        doReturn(true).whenever(desktopModeCompatPolicy).shouldDisableDesktopEntryPoints(task)
        controller.moveToNextDesktopDisplay(
            taskId = task.taskId,
            userId = taskRepository.userId,
            enterReason = EnterReason.UNKNOWN_ENTER,
        )
        verify(desksOrganizer, never()).moveTaskToDesk(any(), any(), eq(task), any())
    }
    private fun moveToNextDesktopDisplay_moveIifDesktopModeSupportedOnDestination(
        isDesktopModeSupportedOnDestination: Boolean
    ) {