Merge "Prevent crash in AccountManager after profile removal."
This commit is contained in:
@@ -67,6 +67,7 @@ import android.content.pm.Signature;
|
||||
import android.content.pm.SigningDetails.CertCapabilities;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteCantOpenDatabaseException;
|
||||
import android.database.sqlite.SQLiteFullException;
|
||||
import android.database.sqlite.SQLiteStatement;
|
||||
import android.os.Binder;
|
||||
@@ -1383,7 +1384,13 @@ public class AccountManagerService
|
||||
private void purgeOldGrants(UserAccounts accounts) {
|
||||
synchronized (accounts.dbLock) {
|
||||
synchronized (accounts.cacheLock) {
|
||||
List<Integer> uids = accounts.accountsDb.findAllUidGrants();
|
||||
List<Integer> uids;
|
||||
try {
|
||||
uids = accounts.accountsDb.findAllUidGrants();
|
||||
} catch (SQLiteCantOpenDatabaseException e) {
|
||||
Log.w(TAG, "Could not delete grants for user = " + accounts.userId);
|
||||
return;
|
||||
}
|
||||
for (int uid : uids) {
|
||||
final boolean packageExists = mPackageManager.getPackagesForUid(uid) != null;
|
||||
if (packageExists) {
|
||||
@@ -1409,7 +1416,13 @@ public class AccountManagerService
|
||||
mPackageManager.getPackageUidAsUser(packageName, accounts.userId);
|
||||
} catch (NameNotFoundException e) {
|
||||
// package does not exist - remove visibility values
|
||||
accounts.accountsDb.deleteAccountVisibilityForPackage(packageName);
|
||||
try {
|
||||
accounts.accountsDb.deleteAccountVisibilityForPackage(packageName);
|
||||
} catch (SQLiteCantOpenDatabaseException sqlException) {
|
||||
Log.w(TAG, "Could not delete account visibility for user = "
|
||||
+ accounts.userId, sqlException);
|
||||
continue;
|
||||
}
|
||||
synchronized (accounts.dbLock) {
|
||||
synchronized (accounts.cacheLock) {
|
||||
for (Account account : accounts.visibilityCache.keySet()) {
|
||||
|
||||
Reference in New Issue
Block a user