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
diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java
index ee2f374..e614d72 100644
--- a/services/core/java/com/android/server/pm/ShortcutService.java
+++ b/services/core/java/com/android/server/pm/ShortcutService.java
@@ -330,7 +330,10 @@
| 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 @@
if (DEBUG) {
Slog.d(TAG, "handleUnlockUser: user=" + userId);
}
- synchronized (mLock) {
+ synchronized (mUnlockedUsers) {
mUnlockedUsers.put(userId, true);
}
@@ -628,7 +631,9 @@
synchronized (mLock) {
unloadUserLocked(userId);
- mUnlockedUsers.put(userId, false);
+ synchronized (mUnlockedUsers) {
+ mUnlockedUsers.put(userId, false);
+ }
}
}
@@ -1149,9 +1154,12 @@
// 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.
- if (mUnlockedUsers.get(userId)) {
- return true;
+ 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