diff options
author | Christopher Tate <ctate@google.com> | 2013-09-03 16:57:34 -0700 |
---|---|---|
committer | Christopher Tate <ctate@google.com> | 2013-09-03 16:57:34 -0700 |
commit | 38e7a60fd7fecdf1c6593724111a92147b4c50ff (patch) | |
tree | ba3b03b7383f16172996f18e413194c3567b1e9f /packages/SettingsProvider/src/com/android/providers/settings | |
parent | bfa29c7181d4b811cb39dbd013c45ff653d8a5f4 (diff) | |
download | frameworks_base-38e7a60fd7fecdf1c6593724111a92147b4c50ff.zip frameworks_base-38e7a60fd7fecdf1c6593724111a92147b4c50ff.tar.gz frameworks_base-38e7a60fd7fecdf1c6593724111a92147b4c50ff.tar.bz2 |
Sanity check users before committing new Android ID
In creation/deletion cycling we can wind up racing and attempting
to establish the Android ID on first access *after* the user has
already been deleted. Cope gracefully with this outcome.
Bug 10608503
Change-Id: I169d5052e5a2e354ce0e1f61258e45e31f5ba171
Diffstat (limited to 'packages/SettingsProvider/src/com/android/providers/settings')
-rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java index 6753922..a5dab33 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java @@ -33,6 +33,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; +import android.content.pm.UserInfo; import android.content.res.AssetFileDescriptor; import android.database.AbstractCursor; import android.database.Cursor; @@ -477,6 +478,13 @@ public class SettingsProvider extends ContentProvider { try { final String value = c.moveToNext() ? c.getString(0) : null; if (value == null) { + // sanity-check the user before touching the db + final UserInfo user = mUserManager.getUserInfo(userHandle); + if (user == null) { + // can happen due to races when deleting users; treat as benign + return false; + } + final SecureRandom random = new SecureRandom(); final String newAndroidIdValue = Long.toHexString(random.nextLong()); final ContentValues values = new ContentValues(); @@ -490,7 +498,7 @@ public class SettingsProvider extends ContentProvider { Slog.d(TAG, "Generated and saved new ANDROID_ID [" + newAndroidIdValue + "] for user " + userHandle); // Write a dropbox entry if it's a restricted profile - if (mUserManager.getUserInfo(userHandle).isRestricted()) { + if (user.isRestricted()) { DropBoxManager dbm = (DropBoxManager) getContext().getSystemService(Context.DROPBOX_SERVICE); if (dbm != null && dbm.isTagEnabled(DROPBOX_TAG_USERLOG)) { |