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

Commit e63b04ad authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Don't take mLock in handleUnlockUser().

Bug: 64303666
Test: adb shell am instrument -w -e class com.android.server.pm.ShortcutManagerTest1 -w com.android.frameworks.servicestests
Test: adb shell am instrument -w -e class com.android.server.pm.ShortcutManagerTest2 -w com.android.frameworks.servicestests
Test: adb shell am instrument -w -e class com.android.server.pm.ShortcutManagerTest3 -w com.android.frameworks.servicestests
Test: adb shell am instrument -w -e class com.android.server.pm.ShortcutManagerTest4 -w com.android.frameworks.servicestests
Test: adb shell am instrument -w -e class com.android.server.pm.ShortcutManagerTest5 -w com.android.frameworks.servicestests
Test: adb shell am instrument -w -e class com.android.server.pm.ShortcutManagerTest6 -w com.android.frameworks.servicestests
Test: adb shell am instrument -w -e class com.android.server.pm.ShortcutManagerTest7 -w com.android.frameworks.servicestests
Test: adb shell am instrument -w -e class com.android.server.pm.ShortcutManagerTest8 -w com.android.frameworks.servicestests
Test: adb shell am instrument -w -e class com.android.server.pm.ShortcutManagerTest9 -w com.android.frameworks.servicestests
Test: adb shell am instrument -w -e class com.android.server.pm.ShortcutManagerTest10 -w com.android.frameworks.servicestests
Change-Id: I3afb814714aae404e4f07d8b179f4598cf507af5
parent 454c831d
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -330,7 +330,10 @@ public class ShortcutService extends IShortcutService.Stub {
                    | PackageManager.MATCH_DIRECT_BOOT_UNAWARE
                    | PackageManager.MATCH_UNINSTALLED_PACKAGES;

    @GuardedBy("mLock")
    /**
     * Note we use a fine-grained lock for {@link #mUnlockedUsers} due to b/64303666.
     */
    @GuardedBy("mUnlockedUsers")
    final SparseBooleanArray mUnlockedUsers = new SparseBooleanArray();

    // Stats
@@ -600,7 +603,7 @@ public class ShortcutService extends IShortcutService.Stub {
        if (DEBUG) {
        Slog.d(TAG, "handleUnlockUser: user=" + userId);
        }
        synchronized (mLock) {
        synchronized (mUnlockedUsers) {
            mUnlockedUsers.put(userId, true);
        }

@@ -628,9 +631,11 @@ public class ShortcutService extends IShortcutService.Stub {
        synchronized (mLock) {
            unloadUserLocked(userId);

            synchronized (mUnlockedUsers) {
                mUnlockedUsers.put(userId, false);
            }
        }
    }

    private void unloadUserLocked(int userId) {
        if (DEBUG) {
@@ -1149,9 +1154,12 @@ public class ShortcutService extends IShortcutService.Stub {
    // Requires mLock held, but "Locked" prefix would look weired so we just say "L".
    protected boolean isUserUnlockedL(@UserIdInt int userId) {
        // First, check the local copy.
        synchronized (mUnlockedUsers) {
            if (mUnlockedUsers.get(userId)) {
                return true;
            }
        }
        
        // If the local copy says the user is locked, check with AM for the actual state, since
        // the user might just have been unlocked.
        // Note we just don't use isUserUnlockingOrUnlocked() here, because it'll return false