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

Commit 1e185e94 authored by Pierre Barbier de Reuille's avatar Pierre Barbier de Reuille
Browse files

Force enter desktop mode on secondary display

From go/desktop-first-eng, this should always be the case.

Fix: 403506870
Test: atest DesktopTasksControllerTest
Flag: com.android.window.flags.enter_desktop_by_default_on_freeform_displays
Change-Id: Id56444e3358dcb3670adfa5b751e1aeebd6e2d0c
parent c2a8374d
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -449,6 +449,11 @@ class DesktopTasksController(
            return false
            return false
        }
        }


        // Secondary displays are always desktop-first
        if (displayId != DEFAULT_DISPLAY) {
            return true
        }

        val tdaInfo = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(displayId)
        val tdaInfo = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(displayId)
        // A non-organized display (e.g., non-trusted virtual displays used in CTS) doesn't have
        // A non-organized display (e.g., non-trusted virtual displays used in CTS) doesn't have
        // TDA.
        // TDA.
@@ -1116,6 +1121,7 @@ class DesktopTasksController(
        }
        }
        val t =
        val t =
            if (remoteTransition == null) {
            if (remoteTransition == null) {
                logV("startLaunchTransition -- no remoteTransition -- wct = $launchTransaction")
                desktopMixedTransitionHandler.startLaunchTransition(
                desktopMixedTransitionHandler.startLaunchTransition(
                    transitionType = transitionType,
                    transitionType = transitionType,
                    wct = launchTransaction,
                    wct = launchTransaction,
+19 −0
Original line number Original line Diff line number Diff line
@@ -4282,6 +4282,25 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        verify(desksOrganizer).moveTaskToDesk(wct, deskId, fullscreenTask)
        verify(desksOrganizer).moveTaskToDesk(wct, deskId, fullscreenTask)
    }
    }


    @Test
    @EnableFlags(
        Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY,
        Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND,
    )
    fun handleRequest_fullscreenTask_noInDesk_enforceDesktop_secondaryDisplay_movesToDesk() {
        val deskId = 5
        taskRepository.addDesk(displayId = SECONDARY_DISPLAY_ID, deskId = deskId)
        taskRepository.setDeskInactive(deskId)
        whenever(desktopWallpaperActivityTokenProvider.getToken()).thenReturn(null)
        whenever(DesktopModeStatus.enterDesktopByDefaultOnFreeformDisplay(context)).thenReturn(true)

        val fullscreenTask = createFullscreenTask(displayId = SECONDARY_DISPLAY_ID)
        val wct = controller.handleRequest(Binder(), createTransition(fullscreenTask))

        assertNotNull(wct, "should handle request")
        verify(desksOrganizer).moveTaskToDesk(wct, deskId, fullscreenTask)
    }

    @Test
    @Test
    fun handleRequest_fullscreenTask_notInDesk_enforceDesktop_fullscreenDisplay_returnNull() {
    fun handleRequest_fullscreenTask_notInDesk_enforceDesktop_fullscreenDisplay_returnNull() {
        taskRepository.setDeskInactive(deskId = 0)
        taskRepository.setDeskInactive(deskId = 0)