Merge "Fix the user ID check in note controller for updating note taking shortcuts" into udc-qpr-dev
This commit is contained in:
@@ -31,6 +31,7 @@ import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.pm.ShortcutManager
|
||||
import android.graphics.drawable.Icon
|
||||
import android.os.Process
|
||||
import android.os.UserHandle
|
||||
import android.os.UserManager
|
||||
import android.provider.Settings
|
||||
@@ -317,7 +318,9 @@ constructor(
|
||||
return
|
||||
}
|
||||
|
||||
if (user == userTracker.userHandle) {
|
||||
// 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)
|
||||
} else {
|
||||
// TODO(b/278729185): Replace fire and forget service with a bounded service.
|
||||
@@ -354,6 +357,9 @@ constructor(
|
||||
updateNoteTaskAsUser(user)
|
||||
}
|
||||
|
||||
// Returns the [UserHandle] that this class is running on.
|
||||
@VisibleForTesting internal fun getCurrentRunningUser(): UserHandle = Process.myUserHandle()
|
||||
|
||||
private val SecureSettings.preferredUser: UserHandle
|
||||
get() {
|
||||
val trackingUserId = userTracker.userHandle.identifier
|
||||
|
||||
@@ -702,9 +702,10 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
|
||||
// region updateNoteTaskAsUser
|
||||
@Test
|
||||
fun updateNoteTaskAsUser_sameUser_shouldUpdateShortcuts() {
|
||||
val user = userTracker.userHandle
|
||||
val user = UserHandle.CURRENT
|
||||
val controller = spy(createNoteTaskController())
|
||||
doNothing().whenever(controller).updateNoteTaskAsUserInternal(any())
|
||||
whenever(controller.getCurrentRunningUser()).thenReturn(user)
|
||||
|
||||
controller.updateNoteTaskAsUser(user)
|
||||
|
||||
@@ -714,10 +715,10 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun updateNoteTaskAsUser_differentUser_shouldUpdateShortcutsInUserProcess() {
|
||||
// FakeUserTracker will default to UserHandle.SYSTEM.
|
||||
val user = UserHandle.CURRENT
|
||||
val controller = spy(createNoteTaskController(isEnabled = true))
|
||||
doNothing().whenever(controller).updateNoteTaskAsUserInternal(any())
|
||||
whenever(controller.getCurrentRunningUser()).thenReturn(UserHandle.SYSTEM)
|
||||
|
||||
controller.updateNoteTaskAsUser(user)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user