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

Commit 6dea99f8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Don't take mLock in handleUnlockUser()."

parents 4c2009c2 e63b04ad
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