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

Commit 6a565b14 authored by Ats Jenk's avatar Ats Jenk
Browse files

Flag desktop stashing behavior

Turn off desktop stashing by default. When going home from desktop, user
exits the desktop and subsequent app launches will be to fullscreen.
Keep the stashing behavior behind a flag so that it can be enabled if
desired.

Bug: 292109910
Test: atest DesktopTasksControllerTest
Change-Id: I566c33c4787542da70bcc052d3c3f2788ea90c4b
parent f9b73ffb
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -54,6 +54,15 @@ public class DesktopModeStatus {
    public static final boolean IS_DISPLAY_CHANGE_ENABLED = SystemProperties.getBoolean(
            "persist.wm.debug.desktop_change_display", false);


    /**
     * Flag to indicate that desktop stashing is enabled.
     * When enabled, swiping home from desktop stashes the open apps. Next app that launches,
     * will be added to the desktop.
     */
    private static final boolean IS_STASHING_ENABLED = SystemProperties.getBoolean(
            "persist.wm.debug.desktop_stashing", false);

    /**
     * Return {@code true} if desktop mode support is enabled
     */
@@ -83,6 +92,13 @@ public class DesktopModeStatus {
        return IS_VEILED_RESIZE_ENABLED;
    }

    /**
     * Return {@code true} if desktop task stashing is enabled when going home.
     * Allows users to use home screen to add tasks to desktop.
     */
    public static boolean isStashingEnabled() {
        return IS_STASHING_ENABLED;
    }
    /**
     * Check if desktop mode is active
     *
+12 −8
Original line number Diff line number Diff line
@@ -150,14 +150,17 @@ class DesktopTasksController(
     * back to front during the launch.
     */
    fun stashDesktopApps(displayId: Int) {
        if (DesktopModeStatus.isStashingEnabled()) {
            KtProtoLog.v(WM_SHELL_DESKTOP_MODE, "DesktopTasksController: stashDesktopApps")
            desktopModeTaskRepository.setStashed(displayId, true)
        }
    }

    /**
     * Clear the stashed state for the given display
     */
    fun hideStashedDesktopApps(displayId: Int) {
        if (DesktopModeStatus.isStashingEnabled()) {
            KtProtoLog.v(
                    WM_SHELL_DESKTOP_MODE,
                    "DesktopTasksController: hideStashedApps displayId=%d",
@@ -165,6 +168,7 @@ class DesktopTasksController(
            )
            desktopModeTaskRepository.setStashed(displayId, false)
        }
    }

    /** Get number of tasks that are marked as visible */
    fun getVisibleTaskCount(displayId: Int): Int {
+6 −0
Original line number Diff line number Diff line
@@ -498,6 +498,7 @@ class DesktopTasksControllerTest : ShellTestCase() {
    @Test
    fun handleRequest_fullscreenTask_desktopStashed_returnWCTWithAllAppsBroughtToFront() {
        assumeTrue(ENABLE_SHELL_TRANSITIONS)
        whenever(DesktopModeStatus.isStashingEnabled()).thenReturn(true)

        val stashedFreeformTask = setUpFreeformTask(DEFAULT_DISPLAY)
        markTaskHidden(stashedFreeformTask)
@@ -569,6 +570,7 @@ class DesktopTasksControllerTest : ShellTestCase() {
    @Test
    fun handleRequest_freeformTask_desktopStashed_returnWCTWithAllAppsBroughtToFront() {
        assumeTrue(ENABLE_SHELL_TRANSITIONS)
        whenever(DesktopModeStatus.isStashingEnabled()).thenReturn(true)

        val stashedFreeformTask = setUpFreeformTask(DEFAULT_DISPLAY)
        markTaskHidden(stashedFreeformTask)
@@ -626,6 +628,8 @@ class DesktopTasksControllerTest : ShellTestCase() {

    @Test
    fun stashDesktopApps_stateUpdates() {
        whenever(DesktopModeStatus.isStashingEnabled()).thenReturn(true)

        controller.stashDesktopApps(DEFAULT_DISPLAY)

        assertThat(desktopModeTaskRepository.isStashed(DEFAULT_DISPLAY)).isTrue()
@@ -634,6 +638,8 @@ class DesktopTasksControllerTest : ShellTestCase() {

    @Test
    fun hideStashedDesktopApps_stateUpdates() {
        whenever(DesktopModeStatus.isStashingEnabled()).thenReturn(true)

        desktopModeTaskRepository.setStashed(DEFAULT_DISPLAY, true)
        desktopModeTaskRepository.setStashed(SECOND_DISPLAY, true)
        controller.hideStashedDesktopApps(DEFAULT_DISPLAY)