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

Commit 676aaab6 authored by Ats Jenk's avatar Ats Jenk
Browse files

Update listeners of stashed state after add

When a VisibleTasksListener is added to DesktopModeTaskRepository, send
an update with the current stashed value.
This is in addition to the update on visibility.

Launcher will start using the visibility listener for updating its
state. Remove the TODO for it.

Test: atest DesktopModeTaskRepositoryTest
Bug: 280490493
Change-Id: I9d6638a73283f5121599384b80ea84f671bb884b
parent 5c8ee219
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -86,8 +86,10 @@ class DesktopModeTaskRepository {
        visibleTasksListeners[visibleTasksListener] = executor
        visibleTasksListeners[visibleTasksListener] = executor
        displayData.keyIterator().forEach { displayId ->
        displayData.keyIterator().forEach { displayId ->
            val visibleTasks = getVisibleTaskCount(displayId)
            val visibleTasks = getVisibleTaskCount(displayId)
            val stashed = isStashed(displayId)
            executor.execute {
            executor.execute {
                visibleTasksListener.onVisibilityChanged(displayId, visibleTasks > 0)
                visibleTasksListener.onVisibilityChanged(displayId, visibleTasks > 0)
                visibleTasksListener.onStashedChanged(displayId, stashed)
            }
            }
        }
        }
    }
    }
+9 −4
Original line number Original line Diff line number Diff line
@@ -742,16 +742,21 @@ class DesktopTasksController(


        private val listener: VisibleTasksListener = object : VisibleTasksListener {
        private val listener: VisibleTasksListener = object : VisibleTasksListener {
            override fun onVisibilityChanged(displayId: Int, visible: Boolean) {
            override fun onVisibilityChanged(displayId: Int, visible: Boolean) {
                // TODO(b/261234402): move visibility from sysui state to listener
                KtProtoLog.v(
                        WM_SHELL_DESKTOP_MODE,
                        "IDesktopModeImpl: onVisibilityChanged display=%d visible=%b",
                        displayId,
                        visible
                )
                remoteListener.call { l -> l.onVisibilityChanged(displayId, visible) }
                remoteListener.call { l -> l.onVisibilityChanged(displayId, visible) }
            }
            }


            override fun onStashedChanged(displayId: Int, stashed: Boolean) {
            override fun onStashedChanged(displayId: Int, stashed: Boolean) {
                KtProtoLog.v(
                KtProtoLog.v(
                        WM_SHELL_DESKTOP_MODE,
                        WM_SHELL_DESKTOP_MODE,
                        "IDesktopModeImpl: onStashedChanged stashed=%b display=%d",
                        "IDesktopModeImpl: onStashedChanged display=%d stashed=%b",
                        stashed,
                        displayId,
                        displayId
                        stashed
                )
                )
                remoteListener.call { l -> l.onStashedChanged(displayId, stashed) }
                remoteListener.call { l -> l.onStashedChanged(displayId, stashed) }
            }
            }
+12 −0
Original line number Original line Diff line number Diff line
@@ -128,6 +128,18 @@ class DesktopModeTaskRepositoryTest : ShellTestCase() {
        assertThat(listener.visibleChangesOnDefaultDisplay).isEqualTo(1)
        assertThat(listener.visibleChangesOnDefaultDisplay).isEqualTo(1)
    }
    }


    @Test
    fun addListener_notifiesStashed() {
        repo.setStashed(DEFAULT_DISPLAY, true)
        val listener = TestVisibilityListener()
        val executor = TestShellExecutor()
        repo.addVisibleTasksListener(listener, executor)
        executor.flushAll()

        assertThat(listener.stashedOnDefaultDisplay).isTrue()
        assertThat(listener.stashedChangesOnDefaultDisplay).isEqualTo(1)
    }

    @Test
    @Test
    fun addListener_tasksOnDifferentDisplay_doesNotNotify() {
    fun addListener_tasksOnDifferentDisplay_doesNotNotify() {
        repo.updateVisibleFreeformTasks(SECOND_DISPLAY, taskId = 1, visible = true)
        repo.updateVisibleFreeformTasks(SECOND_DISPLAY, taskId = 1, visible = true)