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

Commit 374f09eb authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Gerrit Code Review
Browse files

Merge "[Bugfix] avoid deadlock caused by AppBatteryTracker.dump" into main

parents 88184c47 072bc7d6
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -749,12 +749,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
@@ -19604,33 +19606,36 @@ 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) {
            synchronized (mCompanionAppUidsMap) {
                final Set<Integer> allUids = mCompanionAppUidsMap.get(userId);
                if (allUids == null) {
                    return false;
                }
                return allUids.contains(uid);
            }
        }
        @Override
        public void addPendingTopUid(int uid, int pid, @Nullable IApplicationThread thread) {