Loading packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt +17 −15 Original line number Diff line number Diff line Loading @@ -321,7 +321,7 @@ constructor( // When switched to a secondary user, the sysUI is still running in the main user, we will // need to update the shortcut in the secondary user. if (user == getCurrentRunningUser()) { updateNoteTaskAsUserInternal(user) launchUpdateNoteTaskAsUser(user) } else { // TODO(b/278729185): Replace fire and forget service with a bounded service. val intent = NoteTaskControllerUpdateService.createIntent(context) Loading @@ -330,10 +330,11 @@ constructor( } @InternalNoteTaskApi fun updateNoteTaskAsUserInternal(user: UserHandle) { fun launchUpdateNoteTaskAsUser(user: UserHandle) { applicationScope.launch { if (!userManager.isUserUnlocked(user)) { debugLog { "updateNoteTaskAsUserInternal call but user locked: user=$user" } return return@launch } val packageName = roleManager.getDefaultRoleHolderAsUser(ROLE_NOTES, user) Loading @@ -349,6 +350,7 @@ constructor( shortcutManager.disableShortcuts(listOf(SHORTCUT_ID)) } } } /** @see OnRoleHoldersChangedListener */ fun onRoleHoldersChanged(roleName: String, user: UserHandle) { Loading packages/SystemUI/src/com/android/systemui/notetask/NoteTaskControllerUpdateService.kt +1 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ constructor( override fun onCreate() { super.onCreate() // TODO(b/278729185): Replace fire and forget service with a bounded service. controller.updateNoteTaskAsUserInternal(user) controller.launchUpdateNoteTaskAsUser(user) stopSelf() } Loading packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskControllerTest.kt +11 −7 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ import kotlin.test.assertNotNull import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.runCurrent import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading Loading @@ -705,12 +706,12 @@ internal class NoteTaskControllerTest : SysuiTestCase() { fun updateNoteTaskAsUser_sameUser_shouldUpdateShortcuts() { val user = UserHandle.CURRENT val controller = spy(createNoteTaskController()) doNothing().whenever(controller).updateNoteTaskAsUserInternal(any()) doNothing().whenever(controller).launchUpdateNoteTaskAsUser(any()) whenever(controller.getCurrentRunningUser()).thenReturn(user) controller.updateNoteTaskAsUser(user) verify(controller).updateNoteTaskAsUserInternal(user) verify(controller).launchUpdateNoteTaskAsUser(user) verify(context, never()).startServiceAsUser(any(), any()) } Loading @@ -718,12 +719,12 @@ internal class NoteTaskControllerTest : SysuiTestCase() { fun updateNoteTaskAsUser_differentUser_shouldUpdateShortcutsInUserProcess() { val user = UserHandle.CURRENT val controller = spy(createNoteTaskController(isEnabled = true)) doNothing().whenever(controller).updateNoteTaskAsUserInternal(any()) doNothing().whenever(controller).launchUpdateNoteTaskAsUser(any()) whenever(controller.getCurrentRunningUser()).thenReturn(UserHandle.SYSTEM) controller.updateNoteTaskAsUser(user) verify(controller, never()).updateNoteTaskAsUserInternal(any()) verify(controller, never()).launchUpdateNoteTaskAsUser(any()) val intent = withArgCaptor { verify(context).startServiceAsUser(capture(), eq(user)) } assertThat(intent).hasComponentClass(NoteTaskControllerUpdateService::class.java) } Loading @@ -733,7 +734,8 @@ internal class NoteTaskControllerTest : SysuiTestCase() { @Test fun updateNoteTaskAsUserInternal_withNotesRole_withShortcuts_shouldUpdateShortcuts() { createNoteTaskController(isEnabled = true) .updateNoteTaskAsUserInternal(userTracker.userHandle) .launchUpdateNoteTaskAsUser(userTracker.userHandle) testScope.runCurrent() val actualComponent = argumentCaptor<ComponentName>() verify(context.packageManager) Loading Loading @@ -768,7 +770,8 @@ internal class NoteTaskControllerTest : SysuiTestCase() { .thenReturn(emptyList()) createNoteTaskController(isEnabled = true) .updateNoteTaskAsUserInternal(userTracker.userHandle) .launchUpdateNoteTaskAsUser(userTracker.userHandle) testScope.runCurrent() val argument = argumentCaptor<ComponentName>() verify(context.packageManager) Loading @@ -787,7 +790,8 @@ internal class NoteTaskControllerTest : SysuiTestCase() { @Test fun updateNoteTaskAsUserInternal_flagDisabled_shouldDisableShortcuts() { createNoteTaskController(isEnabled = false) .updateNoteTaskAsUserInternal(userTracker.userHandle) .launchUpdateNoteTaskAsUser(userTracker.userHandle) testScope.runCurrent() val argument = argumentCaptor<ComponentName>() verify(context.packageManager) Loading Loading
packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt +17 −15 Original line number Diff line number Diff line Loading @@ -321,7 +321,7 @@ constructor( // When switched to a secondary user, the sysUI is still running in the main user, we will // need to update the shortcut in the secondary user. if (user == getCurrentRunningUser()) { updateNoteTaskAsUserInternal(user) launchUpdateNoteTaskAsUser(user) } else { // TODO(b/278729185): Replace fire and forget service with a bounded service. val intent = NoteTaskControllerUpdateService.createIntent(context) Loading @@ -330,10 +330,11 @@ constructor( } @InternalNoteTaskApi fun updateNoteTaskAsUserInternal(user: UserHandle) { fun launchUpdateNoteTaskAsUser(user: UserHandle) { applicationScope.launch { if (!userManager.isUserUnlocked(user)) { debugLog { "updateNoteTaskAsUserInternal call but user locked: user=$user" } return return@launch } val packageName = roleManager.getDefaultRoleHolderAsUser(ROLE_NOTES, user) Loading @@ -349,6 +350,7 @@ constructor( shortcutManager.disableShortcuts(listOf(SHORTCUT_ID)) } } } /** @see OnRoleHoldersChangedListener */ fun onRoleHoldersChanged(roleName: String, user: UserHandle) { Loading
packages/SystemUI/src/com/android/systemui/notetask/NoteTaskControllerUpdateService.kt +1 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ constructor( override fun onCreate() { super.onCreate() // TODO(b/278729185): Replace fire and forget service with a bounded service. controller.updateNoteTaskAsUserInternal(user) controller.launchUpdateNoteTaskAsUser(user) stopSelf() } Loading
packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskControllerTest.kt +11 −7 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ import kotlin.test.assertNotNull import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.runCurrent import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading Loading @@ -705,12 +706,12 @@ internal class NoteTaskControllerTest : SysuiTestCase() { fun updateNoteTaskAsUser_sameUser_shouldUpdateShortcuts() { val user = UserHandle.CURRENT val controller = spy(createNoteTaskController()) doNothing().whenever(controller).updateNoteTaskAsUserInternal(any()) doNothing().whenever(controller).launchUpdateNoteTaskAsUser(any()) whenever(controller.getCurrentRunningUser()).thenReturn(user) controller.updateNoteTaskAsUser(user) verify(controller).updateNoteTaskAsUserInternal(user) verify(controller).launchUpdateNoteTaskAsUser(user) verify(context, never()).startServiceAsUser(any(), any()) } Loading @@ -718,12 +719,12 @@ internal class NoteTaskControllerTest : SysuiTestCase() { fun updateNoteTaskAsUser_differentUser_shouldUpdateShortcutsInUserProcess() { val user = UserHandle.CURRENT val controller = spy(createNoteTaskController(isEnabled = true)) doNothing().whenever(controller).updateNoteTaskAsUserInternal(any()) doNothing().whenever(controller).launchUpdateNoteTaskAsUser(any()) whenever(controller.getCurrentRunningUser()).thenReturn(UserHandle.SYSTEM) controller.updateNoteTaskAsUser(user) verify(controller, never()).updateNoteTaskAsUserInternal(any()) verify(controller, never()).launchUpdateNoteTaskAsUser(any()) val intent = withArgCaptor { verify(context).startServiceAsUser(capture(), eq(user)) } assertThat(intent).hasComponentClass(NoteTaskControllerUpdateService::class.java) } Loading @@ -733,7 +734,8 @@ internal class NoteTaskControllerTest : SysuiTestCase() { @Test fun updateNoteTaskAsUserInternal_withNotesRole_withShortcuts_shouldUpdateShortcuts() { createNoteTaskController(isEnabled = true) .updateNoteTaskAsUserInternal(userTracker.userHandle) .launchUpdateNoteTaskAsUser(userTracker.userHandle) testScope.runCurrent() val actualComponent = argumentCaptor<ComponentName>() verify(context.packageManager) Loading Loading @@ -768,7 +770,8 @@ internal class NoteTaskControllerTest : SysuiTestCase() { .thenReturn(emptyList()) createNoteTaskController(isEnabled = true) .updateNoteTaskAsUserInternal(userTracker.userHandle) .launchUpdateNoteTaskAsUser(userTracker.userHandle) testScope.runCurrent() val argument = argumentCaptor<ComponentName>() verify(context.packageManager) Loading @@ -787,7 +790,8 @@ internal class NoteTaskControllerTest : SysuiTestCase() { @Test fun updateNoteTaskAsUserInternal_flagDisabled_shouldDisableShortcuts() { createNoteTaskController(isEnabled = false) .updateNoteTaskAsUserInternal(userTracker.userHandle) .launchUpdateNoteTaskAsUser(userTracker.userHandle) testScope.runCurrent() val argument = argumentCaptor<ComponentName>() verify(context.packageManager) Loading