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

Commit 51d58e85 authored by Steven Ng's avatar Steven Ng Committed by Automerger Merge Worker
Browse files

Merge "Fix the user ID check in note controller for updating note taking...

Merge "Fix the user ID check in note controller for updating note taking shortcuts" into udc-qpr-dev am: 8228c296

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24267803



Change-Id: If4e0e1e4475f7d70c8f525533643033b1a31a236
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents f6d2c1d7 8228c296
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -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
+3 −2
Original line number Diff line number Diff line
@@ -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)