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

Commit 513be145 authored by Amith Yamasani's avatar Amith Yamasani Committed by Android Git Automerger
Browse files

am 7dd4831f: am b0975540: Merge "Avoid deadlock between mUsers and cacheLock" into klp-dev

* commit '7dd4831f':
  Avoid deadlock between mUsers and cacheLock
parents 467b30bb 7dd4831f
Loading
Loading
Loading
Loading
+20 −22
Original line number Diff line number Diff line
@@ -293,8 +293,8 @@ public class AccountManagerService
        return mUserManager;
    }

    private UserAccounts initUser(int userId) {
        synchronized (mUsers) {
    /* Caller should lock mUsers */
    private UserAccounts initUserLocked(int userId) {
        UserAccounts accounts = mUsers.get(userId);
        if (accounts == null) {
            accounts = new UserAccounts(mContext, userId);
@@ -304,7 +304,6 @@ public class AccountManagerService
        }
        return accounts;
    }
    }

    private void purgeOldGrantsAll() {
        synchronized (mUsers) {
@@ -427,7 +426,7 @@ public class AccountManagerService
        synchronized (mUsers) {
            UserAccounts accounts = mUsers.get(userId);
            if (accounts == null) {
                accounts = initUser(userId);
                accounts = initUserLocked(userId);
                mUsers.append(userId, accounts);
            }
            return accounts;
@@ -1798,7 +1797,6 @@ public class AccountManagerService

    private AccountAndUser[] getAccounts(int[] userIds) {
        final ArrayList<AccountAndUser> runningAccounts = Lists.newArrayList();
        synchronized (mUsers) {
        for (int userId : userIds) {
            UserAccounts userAccounts = getUserAccounts(userId);
            if (userAccounts == null) continue;
@@ -1810,7 +1808,6 @@ public class AccountManagerService
                }
            }
        }
        }

        AccountAndUser[] accountsArray = new AccountAndUser[runningAccounts.size()];
        return runningAccounts.toArray(accountsArray);
@@ -2858,7 +2855,8 @@ public class AccountManagerService
                || callingUid == Process.myUid()) {
            return unfiltered;
        }
        if (mUserManager.getUserInfo(userAccounts.userId).isRestricted()) {
        UserInfo user = mUserManager.getUserInfo(userAccounts.userId);
        if (user != null && user.isRestricted()) {
            String[] packages = mPackageManager.getPackagesForUid(callingUid);
            // If any of the packages is a white listed package, return the full set,
            // otherwise return non-shared accounts only.