Merge "Fix issue #17811029: Settings provider race when removing users" into lmp-dev

This commit is contained in:
Dianne Hackborn
2014-10-03 20:15:11 +00:00
committed by Android (Google) Code Review

View File

@@ -506,7 +506,14 @@ public class SettingsProvider extends ContentProvider {
} }
private void fullyPopulateCaches(final int userHandle) { private void fullyPopulateCaches(final int userHandle) {
DatabaseHelper dbHelper = mOpenHelpers.get(userHandle); DatabaseHelper dbHelper;
synchronized (this) {
dbHelper = mOpenHelpers.get(userHandle);
}
if (dbHelper == null) {
// User is gone.
return;
}
// Only populate the globals cache once, for the owning user // Only populate the globals cache once, for the owning user
if (userHandle == UserHandle.USER_OWNER) { if (userHandle == UserHandle.USER_OWNER) {
fullyPopulateCache(dbHelper, TABLE_GLOBAL, sGlobalCache); fullyPopulateCache(dbHelper, TABLE_GLOBAL, sGlobalCache);
@@ -611,11 +618,16 @@ public class SettingsProvider extends ContentProvider {
long oldId = Binder.clearCallingIdentity(); long oldId = Binder.clearCallingIdentity();
try { try {
DatabaseHelper dbHelper = mOpenHelpers.get(callingUser); DatabaseHelper dbHelper;
synchronized (this) {
dbHelper = mOpenHelpers.get(callingUser);
}
if (null == dbHelper) { if (null == dbHelper) {
establishDbTracking(callingUser); establishDbTracking(callingUser);
synchronized (this) {
dbHelper = mOpenHelpers.get(callingUser); dbHelper = mOpenHelpers.get(callingUser);
} }
}
return dbHelper; return dbHelper;
} finally { } finally {
Binder.restoreCallingIdentity(oldId); Binder.restoreCallingIdentity(oldId);