* commit '7dd4831fd6f8966c6fd765279303b636314b7754': Avoid deadlock between mUsers and cacheLock
This commit is contained in:
@ -293,17 +293,16 @@ public class AccountManagerService
|
|||||||
return mUserManager;
|
return mUserManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserAccounts initUser(int userId) {
|
/* Caller should lock mUsers */
|
||||||
synchronized (mUsers) {
|
private UserAccounts initUserLocked(int userId) {
|
||||||
UserAccounts accounts = mUsers.get(userId);
|
UserAccounts accounts = mUsers.get(userId);
|
||||||
if (accounts == null) {
|
if (accounts == null) {
|
||||||
accounts = new UserAccounts(mContext, userId);
|
accounts = new UserAccounts(mContext, userId);
|
||||||
mUsers.append(userId, accounts);
|
mUsers.append(userId, accounts);
|
||||||
purgeOldGrants(accounts);
|
purgeOldGrants(accounts);
|
||||||
validateAccountsInternal(accounts, true /* invalidateAuthenticatorCache */);
|
validateAccountsInternal(accounts, true /* invalidateAuthenticatorCache */);
|
||||||
}
|
|
||||||
return accounts;
|
|
||||||
}
|
}
|
||||||
|
return accounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void purgeOldGrantsAll() {
|
private void purgeOldGrantsAll() {
|
||||||
@ -427,7 +426,7 @@ public class AccountManagerService
|
|||||||
synchronized (mUsers) {
|
synchronized (mUsers) {
|
||||||
UserAccounts accounts = mUsers.get(userId);
|
UserAccounts accounts = mUsers.get(userId);
|
||||||
if (accounts == null) {
|
if (accounts == null) {
|
||||||
accounts = initUser(userId);
|
accounts = initUserLocked(userId);
|
||||||
mUsers.append(userId, accounts);
|
mUsers.append(userId, accounts);
|
||||||
}
|
}
|
||||||
return accounts;
|
return accounts;
|
||||||
@ -1798,16 +1797,14 @@ public class AccountManagerService
|
|||||||
|
|
||||||
private AccountAndUser[] getAccounts(int[] userIds) {
|
private AccountAndUser[] getAccounts(int[] userIds) {
|
||||||
final ArrayList<AccountAndUser> runningAccounts = Lists.newArrayList();
|
final ArrayList<AccountAndUser> runningAccounts = Lists.newArrayList();
|
||||||
synchronized (mUsers) {
|
for (int userId : userIds) {
|
||||||
for (int userId : userIds) {
|
UserAccounts userAccounts = getUserAccounts(userId);
|
||||||
UserAccounts userAccounts = getUserAccounts(userId);
|
if (userAccounts == null) continue;
|
||||||
if (userAccounts == null) continue;
|
synchronized (userAccounts.cacheLock) {
|
||||||
synchronized (userAccounts.cacheLock) {
|
Account[] accounts = getAccountsFromCacheLocked(userAccounts, null,
|
||||||
Account[] accounts = getAccountsFromCacheLocked(userAccounts, null,
|
Binder.getCallingUid(), null);
|
||||||
Binder.getCallingUid(), null);
|
for (int a = 0; a < accounts.length; a++) {
|
||||||
for (int a = 0; a < accounts.length; a++) {
|
runningAccounts.add(new AccountAndUser(accounts[a], userId));
|
||||||
runningAccounts.add(new AccountAndUser(accounts[a], userId));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2858,7 +2855,8 @@ public class AccountManagerService
|
|||||||
|| callingUid == Process.myUid()) {
|
|| callingUid == Process.myUid()) {
|
||||||
return unfiltered;
|
return unfiltered;
|
||||||
}
|
}
|
||||||
if (mUserManager.getUserInfo(userAccounts.userId).isRestricted()) {
|
UserInfo user = mUserManager.getUserInfo(userAccounts.userId);
|
||||||
|
if (user != null && user.isRestricted()) {
|
||||||
String[] packages = mPackageManager.getPackagesForUid(callingUid);
|
String[] packages = mPackageManager.getPackagesForUid(callingUid);
|
||||||
// If any of the packages is a white listed package, return the full set,
|
// If any of the packages is a white listed package, return the full set,
|
||||||
// otherwise return non-shared accounts only.
|
// otherwise return non-shared accounts only.
|
||||||
|
Reference in New Issue
Block a user