Loading packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingControllerImpl.kt +8 −2 Original line number Diff line number Diff line Loading @@ -106,9 +106,15 @@ class ControlsListingControllerImpl @VisibleForTesting constructor( override fun changeUser(newUser: UserHandle) { backgroundExecutor.execute { callbacks.clear() availableServices = emptyList() serviceListing.setListening(false) // Notify all callbacks in order to clear their existing state prior to attaching // a new listener availableServices = emptyList() callbacks.forEach { it.onServicesUpdated(emptyList()) } currentUserId = newUser.identifier val contextForUser = context.createContextAsUser(newUser, 0) serviceListing = serviceListingBuilder(contextForUser) Loading packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsListingControllerImplTest.kt +28 −1 Original line number Diff line number Diff line Loading @@ -177,4 +177,31 @@ class ControlsListingControllerImplTest : SysuiTestCase() { inOrder.verify(mockSL).setListening(true) inOrder.verify(mockSL).reload() } @Test fun testChangeUserResetsExistingCallbackServices() { val list = listOf(serviceInfo) controller.addCallback(mockCallback) @Suppress("unchecked_cast") val captor: ArgumentCaptor<List<ControlsServiceInfo>> = ArgumentCaptor.forClass(List::class.java) as ArgumentCaptor<List<ControlsServiceInfo>> executor.runAllReady() reset(mockCallback) serviceListingCallbackCaptor.value.onServicesReloaded(list) executor.runAllReady() verify(mockCallback).onServicesUpdated(capture(captor)) assertEquals(1, captor.value.size) reset(mockCallback) controller.changeUser(UserHandle.of(otherUser)) executor.runAllReady() assertEquals(otherUser, controller.currentUserId) verify(mockCallback).onServicesUpdated(capture(captor)) assertEquals(0, captor.value.size) } } Loading
packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingControllerImpl.kt +8 −2 Original line number Diff line number Diff line Loading @@ -106,9 +106,15 @@ class ControlsListingControllerImpl @VisibleForTesting constructor( override fun changeUser(newUser: UserHandle) { backgroundExecutor.execute { callbacks.clear() availableServices = emptyList() serviceListing.setListening(false) // Notify all callbacks in order to clear their existing state prior to attaching // a new listener availableServices = emptyList() callbacks.forEach { it.onServicesUpdated(emptyList()) } currentUserId = newUser.identifier val contextForUser = context.createContextAsUser(newUser, 0) serviceListing = serviceListingBuilder(contextForUser) Loading
packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsListingControllerImplTest.kt +28 −1 Original line number Diff line number Diff line Loading @@ -177,4 +177,31 @@ class ControlsListingControllerImplTest : SysuiTestCase() { inOrder.verify(mockSL).setListening(true) inOrder.verify(mockSL).reload() } @Test fun testChangeUserResetsExistingCallbackServices() { val list = listOf(serviceInfo) controller.addCallback(mockCallback) @Suppress("unchecked_cast") val captor: ArgumentCaptor<List<ControlsServiceInfo>> = ArgumentCaptor.forClass(List::class.java) as ArgumentCaptor<List<ControlsServiceInfo>> executor.runAllReady() reset(mockCallback) serviceListingCallbackCaptor.value.onServicesReloaded(list) executor.runAllReady() verify(mockCallback).onServicesUpdated(capture(captor)) assertEquals(1, captor.value.size) reset(mockCallback) controller.changeUser(UserHandle.of(otherUser)) executor.runAllReady() assertEquals(otherUser, controller.currentUserId) verify(mockCallback).onServicesUpdated(capture(captor)) assertEquals(0, captor.value.size) } }