Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopRepository.kt +3 −1 Original line number Diff line number Diff line Loading @@ -733,7 +733,8 @@ class DesktopRepository( desktopData.getActiveDesk(displayId)?.topTransparentFullscreenTaskId = null } private fun notifyVisibleTaskListeners(displayId: Int, visibleTasksCount: Int) { @VisibleForTesting public fun notifyVisibleTaskListeners(displayId: Int, visibleTasksCount: Int) { visibleTasksListeners.forEach { (listener, executor) -> executor.execute { listener.onTasksVisibilityChanged(displayId, visibleTasksCount) } } Loading Loading @@ -915,6 +916,7 @@ class DesktopRepository( val wasActive = desktopData.getActiveDesk(desk.displayId)?.deskId == desk.deskId val activeTasks = ArraySet(desk.activeTasks) desktopData.remove(desk.deskId) notifyVisibleTaskListeners(desk.displayId, getVisibleTaskCount(displayId = desk.displayId)) deskChangeListeners.forEach { (listener, executor) -> executor.execute { if (wasActive) { Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopRepositoryTest.kt +7 −1 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() { datastoreScope = CoroutineScope(Dispatchers.Unconfined + SupervisorJob()) shellInit = spy(ShellInit(testExecutor)) repo = DesktopRepository(persistentRepository, datastoreScope, DEFAULT_USER_ID) repo = spy(DesktopRepository(persistentRepository, datastoreScope, DEFAULT_USER_ID)) whenever(runBlocking { persistentRepository.readDesktop(any(), any()) }) .thenReturn(Desktop.getDefaultInstance()) shellInit.init() Loading Loading @@ -1171,6 +1171,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() { val tasksBeforeRemoval = repo.removeDesk(deskId = DEFAULT_DISPLAY) verify(repo, times(1)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0) assertThat(tasksBeforeRemoval).containsExactly(1, 2, 3).inOrder() assertThat(repo.getActiveTasks(displayId = DEFAULT_DISPLAY)).isEmpty() } Loading @@ -1184,6 +1185,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() { repo.removeDesk(deskId = 3) verify(repo, times(1)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0) assertThat(repo.getDeskIds(displayId = DEFAULT_DISPLAY)).doesNotContain(3) } Loading @@ -1196,6 +1198,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() { repo.removeDesk(deskId = 2) verify(repo, times(1)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0) assertThat(repo.getDeskIds(displayId = DEFAULT_DISPLAY)).doesNotContain(2) } Loading Loading @@ -1424,6 +1427,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() { repo.removeDesk(deskId = 1) executor.flushAll() verify(repo, times(1)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0) val lastRemoval = assertNotNull(listener.lastRemoval) assertThat(lastRemoval.displayId).isEqualTo(0) assertThat(lastRemoval.deskId).isEqualTo(1) Loading @@ -1440,6 +1444,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() { repo.removeDesk(deskId = 2) executor.flushAll() verify(repo, times(0)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0) assertThat(listener.lastRemoval).isNull() } Loading @@ -1455,6 +1460,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() { repo.removeDesk(deskId = 1) executor.flushAll() verify(repo, times(1)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0) val lastActivationChange = assertNotNull(listener.lastActivationChange) assertThat(lastActivationChange.displayId).isEqualTo(0) assertThat(lastActivationChange.oldActive).isEqualTo(1) Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopRepository.kt +3 −1 Original line number Diff line number Diff line Loading @@ -733,7 +733,8 @@ class DesktopRepository( desktopData.getActiveDesk(displayId)?.topTransparentFullscreenTaskId = null } private fun notifyVisibleTaskListeners(displayId: Int, visibleTasksCount: Int) { @VisibleForTesting public fun notifyVisibleTaskListeners(displayId: Int, visibleTasksCount: Int) { visibleTasksListeners.forEach { (listener, executor) -> executor.execute { listener.onTasksVisibilityChanged(displayId, visibleTasksCount) } } Loading Loading @@ -915,6 +916,7 @@ class DesktopRepository( val wasActive = desktopData.getActiveDesk(desk.displayId)?.deskId == desk.deskId val activeTasks = ArraySet(desk.activeTasks) desktopData.remove(desk.deskId) notifyVisibleTaskListeners(desk.displayId, getVisibleTaskCount(displayId = desk.displayId)) deskChangeListeners.forEach { (listener, executor) -> executor.execute { if (wasActive) { Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopRepositoryTest.kt +7 −1 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() { datastoreScope = CoroutineScope(Dispatchers.Unconfined + SupervisorJob()) shellInit = spy(ShellInit(testExecutor)) repo = DesktopRepository(persistentRepository, datastoreScope, DEFAULT_USER_ID) repo = spy(DesktopRepository(persistentRepository, datastoreScope, DEFAULT_USER_ID)) whenever(runBlocking { persistentRepository.readDesktop(any(), any()) }) .thenReturn(Desktop.getDefaultInstance()) shellInit.init() Loading Loading @@ -1171,6 +1171,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() { val tasksBeforeRemoval = repo.removeDesk(deskId = DEFAULT_DISPLAY) verify(repo, times(1)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0) assertThat(tasksBeforeRemoval).containsExactly(1, 2, 3).inOrder() assertThat(repo.getActiveTasks(displayId = DEFAULT_DISPLAY)).isEmpty() } Loading @@ -1184,6 +1185,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() { repo.removeDesk(deskId = 3) verify(repo, times(1)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0) assertThat(repo.getDeskIds(displayId = DEFAULT_DISPLAY)).doesNotContain(3) } Loading @@ -1196,6 +1198,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() { repo.removeDesk(deskId = 2) verify(repo, times(1)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0) assertThat(repo.getDeskIds(displayId = DEFAULT_DISPLAY)).doesNotContain(2) } Loading Loading @@ -1424,6 +1427,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() { repo.removeDesk(deskId = 1) executor.flushAll() verify(repo, times(1)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0) val lastRemoval = assertNotNull(listener.lastRemoval) assertThat(lastRemoval.displayId).isEqualTo(0) assertThat(lastRemoval.deskId).isEqualTo(1) Loading @@ -1440,6 +1444,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() { repo.removeDesk(deskId = 2) executor.flushAll() verify(repo, times(0)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0) assertThat(listener.lastRemoval).isNull() } Loading @@ -1455,6 +1460,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() { repo.removeDesk(deskId = 1) executor.flushAll() verify(repo, times(1)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0) val lastActivationChange = assertNotNull(listener.lastActivationChange) assertThat(lastActivationChange.displayId).isEqualTo(0) assertThat(lastActivationChange.oldActive).isEqualTo(1) Loading