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

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

Merge "Default-to-desktop based on the state of desktop first" into main

parents 08d2f088 05c1f555
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -251,6 +251,9 @@ public class DesktopModeStatus {
     * of the display's root [TaskDisplayArea] is set to WINDOWING_MODE_FREEFORM.
     */
    public static boolean enterDesktopByDefaultOnFreeformDisplay(@NonNull Context context) {
        if (DesktopExperienceFlags.ENABLE_DESKTOP_FIRST_BASED_DEFAULT_TO_DESKTOP_BUGFIX.isTrue()) {
            return true;
        }
        if (!DesktopExperienceFlags.ENTER_DESKTOP_BY_DEFAULT_ON_FREEFORM_DISPLAYS.isTrue()) {
            return false;
        }
+1 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ interface DesktopState {
     * Whether a display should enter desktop mode by default when the windowing mode of the
     * display's root [TaskDisplayArea] is set to `WINDOWING_MODE_FREEFORM`.
     */
    @Deprecated("Use isDisplayDesktopFirst() instead.", ReplaceWith("isDisplayDesktopFirst()"))
    @get:JvmName("enterDesktopByDefaultOnFreeformDisplay")
    val enterDesktopByDefaultOnFreeformDisplay: Boolean

+1 −0
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ class DesktopStateImpl(context: Context) : DesktopState {
        Flags.showDesktopExperienceDevOption() && isDeviceEligibleForDesktopMode

    override val enterDesktopByDefaultOnFreeformDisplay: Boolean =
        DesktopExperienceFlags.ENABLE_DESKTOP_FIRST_BASED_DEFAULT_TO_DESKTOP_BUGFIX.isTrue ||
        DesktopExperienceFlags.ENTER_DESKTOP_BY_DEFAULT_ON_FREEFORM_DISPLAYS.isTrue &&
            SystemProperties.getBoolean(
                ENTER_DESKTOP_BY_DEFAULT_ON_FREEFORM_DISPLAY_SYS_PROP,
+5 −0
Original line number Diff line number Diff line
@@ -458,7 +458,12 @@ class DesktopTasksController(
    private fun getSplitFocusedTask(task1: RunningTaskInfo, task2: RunningTaskInfo) =
        if (task1.taskId == task2.parentTaskId) task2 else task1

    @Deprecated("Use isDisplayDesktopFirst() instead.", ReplaceWith("isDisplayDesktopFirst()"))
    private fun forceEnterDesktop(displayId: Int): Boolean {
        if (DesktopExperienceFlags.ENABLE_DESKTOP_FIRST_BASED_DEFAULT_TO_DESKTOP_BUGFIX.isTrue) {
            return rootTaskDisplayAreaOrganizer.isDisplayDesktopFirst(displayId)
        }

        if (!desktopState.enterDesktopByDefaultOnFreeformDisplay) {
            return false
        }
+33 −1
Original line number Diff line number Diff line
@@ -2623,6 +2623,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
    @DisableFlags(
        Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND,
        com.android.launcher3.Flags.FLAG_ENABLE_ALT_TAB_KQS_FLATENNING,
        Flags.FLAG_ENABLE_DESKTOP_FIRST_BASED_DEFAULT_TO_DESKTOP_BUGFIX,
    )
    fun moveToFullscreen_tdaFreeform_windowingModeFullscreen_removesWallpaperActivity() {
        desktopState.enterDesktopByDefaultOnFreeformDisplay = false
@@ -2684,6 +2685,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_FOR_SYSTEM_USER,
        Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND,
    )
    @DisableFlags(Flags.FLAG_ENABLE_DESKTOP_FIRST_BASED_DEFAULT_TO_DESKTOP_BUGFIX)
    fun moveToFullscreen_tdaFreeform_windowingModeFullscreen_homeBehindFullscreen_multiDesksEnabled() {
        desktopState.enterDesktopByDefaultOnFreeformDisplay = false
        val homeTask = setUpHomeTask()
@@ -4892,6 +4894,29 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        verify(desksOrganizer).moveTaskToDesk(wct, deskId, fullscreenTask)
    }

    @Test
    @EnableFlags(
        Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY,
        Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND,
        Flags.FLAG_ENABLE_DESKTOP_FIRST_BASED_DEFAULT_TO_DESKTOP_BUGFIX,
    )
    fun handleRequest_fullscreenTask_noInDesk_enforceDesktop_freeformDisplay_movesToDesk_desktopFirst() {
        // Ensure the force enter desktop works when the deprecated flag is off.
        desktopState.enterDesktopByDefaultOnFreeformDisplay = false
        val deskId = 0
        taskRepository.setDeskInactive(deskId)
        whenever(desktopWallpaperActivityTokenProvider.getToken()).thenReturn(null)
        desktopState.enterDesktopByDefaultOnFreeformDisplay = true
        val tda = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY)!!
        tda.configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FREEFORM

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

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

    @Test
    @EnableFlags(
        Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY,
@@ -4903,6 +4928,10 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        taskRepository.setDeskInactive(deskId)
        whenever(desktopWallpaperActivityTokenProvider.getToken()).thenReturn(null)
        desktopState.enterDesktopByDefaultOnFreeformDisplay = true
        assertNotNull(rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY))
            .configuration
            .windowConfiguration
            .windowingMode = WINDOWING_MODE_FREEFORM

        val fullscreenTask = createFullscreenTask(displayId = SECONDARY_DISPLAY_ID)
        val wct = controller.handleRequest(Binder(), createTransition(fullscreenTask))
@@ -10016,7 +10045,10 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        @JvmStatic
        @Parameters(name = "{0}")
        fun getParams(): List<FlagsParameterization> =
            FlagsParameterization.allCombinationsOf(Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND)
            FlagsParameterization.allCombinationsOf(
                Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND,
                Flags.FLAG_ENABLE_DESKTOP_FIRST_BASED_DEFAULT_TO_DESKTOP_BUGFIX,
            )
    }
}