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

Commit e0c5e575 authored by Ats Jenk's avatar Ats Jenk
Browse files

Add a desktop mode API to hide stashed apps

Allows launcher to cancel selecting desktop app to be launched and hide
the stashed apps.

Bug: 261234402
Test: atest DesktopTasksControllerTest
Change-Id: I2708267011aca5b1c933dbf0172547ba1936c2ab
parent 7713260e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -514,6 +514,11 @@ public class DesktopModeController implements RemoteCallable<DesktopModeControll
            // Stashing of desktop apps not needed. Apps always launch on desktop
        }

        @Override
        public void hideStashedDesktopApps(int displayId) throws RemoteException {
            // Stashing of desktop apps not needed. Apps always launch on desktop
        }

        @Override
        public void setTaskListener(IDesktopTaskListener listener) throws RemoteException {
            // TODO(b/261234402): move visibility from sysui state to listener
+19 −0
Original line number Diff line number Diff line
@@ -131,6 +131,18 @@ class DesktopTasksController(
        desktopModeTaskRepository.setStashed(displayId, true)
    }

    /**
     * Clear the stashed state for the given display
     */
    fun hideStashedDesktopApps(displayId: Int) {
        KtProtoLog.v(
                WM_SHELL_DESKTOP_MODE,
                "DesktopTasksController: hideStashedApps displayId=%d",
                displayId
        )
        desktopModeTaskRepository.setStashed(displayId, false)
    }

    /** Get number of tasks that are marked as visible */
    fun getVisibleTaskCount(displayId: Int): Int {
        return desktopModeTaskRepository.getVisibleTaskCount(displayId)
@@ -753,6 +765,13 @@ class DesktopTasksController(
            ) { c -> c.stashDesktopApps(displayId) }
        }

        override fun hideStashedDesktopApps(displayId: Int) {
            ExecutorUtils.executeRemoteCallWithTaskPermission(
                    controller,
                    "hideStashedDesktopApps"
            ) { c -> c.hideStashedDesktopApps(displayId) }
        }

        override fun getVisibleTaskCount(displayId: Int): Int {
            val result = IntArray(1)
            ExecutorUtils.executeRemoteCallWithTaskPermission(
+3 −0
Original line number Diff line number Diff line
@@ -29,6 +29,9 @@ interface IDesktopMode {
    /** Stash apps on the desktop to allow launching another app from home screen */
    void stashDesktopApps(int displayId);

    /** Hide apps that may be stashed */
    void hideStashedDesktopApps(int displayId);

    /** Get count of visible desktop tasks on the given display */
    int getVisibleTaskCount(int displayId);

+11 −0
Original line number Diff line number Diff line
@@ -587,6 +587,17 @@ class DesktopTasksControllerTest : ShellTestCase() {
        assertThat(desktopModeTaskRepository.isStashed(SECOND_DISPLAY)).isFalse()
    }

    @Test
    fun hideStashedDesktopApps_stateUpdates() {
        desktopModeTaskRepository.setStashed(DEFAULT_DISPLAY, true)
        desktopModeTaskRepository.setStashed(SECOND_DISPLAY, true)
        controller.hideStashedDesktopApps(DEFAULT_DISPLAY)

        assertThat(desktopModeTaskRepository.isStashed(DEFAULT_DISPLAY)).isFalse()
        // Check that second display is not affected
        assertThat(desktopModeTaskRepository.isStashed(SECOND_DISPLAY)).isTrue()
    }

    private fun setUpFreeformTask(displayId: Int = DEFAULT_DISPLAY): RunningTaskInfo {
        val task = createFreeformTask(displayId)
        whenever(shellTaskOrganizer.getRunningTaskInfo(task.taskId)).thenReturn(task)