diff options
author | 2024-09-19 02:37:12 +0000 | |
---|---|---|
committer | 2024-09-19 02:37:12 +0000 | |
commit | cc8e8c9ac6ced3fbcaad933c7116c91dd47b896c (patch) | |
tree | 6844732e3d6536c3cefb22683588b9ca02ee60a6 | |
parent | b1075ab0569e2e0ca19e377dbad88dc1024a33b6 (diff) | |
parent | d128efafec0c1a1d4cf7d2e1ba2d0a4ee5dafc78 (diff) |
Merge "[Bugfix] avoid deadlock caused by AppBatteryTracker.dump" into main am: 374f09ebb7 am: d128efafec
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/3263912
Change-Id: Idd4e123d10a01826feb8e1d293a30c4957f7ae2a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 54a741060bbe..871c32086a7f 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -714,12 +714,14 @@ public class ActivityManagerService extends IActivityManager.Stub /** * Map userId to its companion app uids. */ + @GuardedBy("mCompanionAppUidsMap") private final Map<Integer, Set<Integer>> mCompanionAppUidsMap = new ArrayMap<>(); /** * The profile owner UIDs. */ - private ArraySet<Integer> mProfileOwnerUids = null; + @GuardedBy("mProfileOwnerUids") + private final ArraySet<Integer> mProfileOwnerUids = new ArraySet<>(); final UserController mUserController; @VisibleForTesting @@ -17535,32 +17537,35 @@ public class ActivityManagerService extends IActivityManager.Stub @Override public void setProfileOwnerUid(ArraySet<Integer> profileOwnerUids) { - synchronized (ActivityManagerService.this) { - mProfileOwnerUids = profileOwnerUids; + synchronized (mProfileOwnerUids) { + mProfileOwnerUids.clear(); + mProfileOwnerUids.addAll(profileOwnerUids); } } @Override public boolean isProfileOwner(int uid) { - synchronized (ActivityManagerService.this) { - return mProfileOwnerUids != null && mProfileOwnerUids.indexOf(uid) >= 0; + synchronized (mProfileOwnerUids) { + return mProfileOwnerUids.indexOf(uid) >= 0; } } @Override public void setCompanionAppUids(int userId, Set<Integer> companionAppUids) { - synchronized (ActivityManagerService.this) { + synchronized (mCompanionAppUidsMap) { mCompanionAppUidsMap.put(userId, companionAppUids); } } @Override public boolean isAssociatedCompanionApp(int userId, int uid) { - final Set<Integer> allUids = mCompanionAppUidsMap.get(userId); - if (allUids == null) { - return false; + synchronized (mCompanionAppUidsMap) { + final Set<Integer> allUids = mCompanionAppUidsMap.get(userId); + if (allUids == null) { + return false; + } + return allUids.contains(uid); } - return allUids.contains(uid); } @Override |