summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Amith Yamasani <yamasani@google.com> 2016-06-16 08:20:07 -0700
committer Amith Yamasani <yamasani@google.com> 2016-06-16 08:31:56 -0700
commitf11a574027a8dbe18d79ce467984d63d07fea9e1 (patch)
tree6c520cc3f5ad3793d39fe989990d6b46a5df0412
parentd430f1a0be42bbf85fe75578a871d920ff922770 (diff)
Clean up ex-users in lock settings db
Just in case a userid was not properly cleaned when the user was removed, make sure it is cleaned up when a new user takes up the same userid. This prevents inconsistent lockscreen state and avoids a crash in Settings when trying to set a password for the new user. Fixes: 29412112 Change-Id: Ic4f0efbb97786b0290c74325b28c9d74825e9e53
-rw-r--r--services/core/java/com/android/server/LockSettingsService.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/LockSettingsService.java b/services/core/java/com/android/server/LockSettingsService.java
index 1e715f93d041..66e2da0f89c3 100644
--- a/services/core/java/com/android/server/LockSettingsService.java
+++ b/services/core/java/com/android/server/LockSettingsService.java
@@ -423,6 +423,9 @@ public class LockSettingsService extends ILockSettings.Stub {
if (Intent.ACTION_USER_ADDED.equals(intent.getAction())) {
// Notify keystore that a new user was added.
final int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
+ if (userHandle > UserHandle.USER_SYSTEM) {
+ removeUser(userHandle, /* unknownUser= */ true);
+ }
final KeyStore ks = KeyStore.getInstance();
final UserInfo parentInfo = mUserManager.getProfileParent(userHandle);
final int parentHandle = parentInfo != null ? parentInfo.id : -1;
@@ -433,7 +436,7 @@ public class LockSettingsService extends ILockSettings.Stub {
} else if (Intent.ACTION_USER_REMOVED.equals(intent.getAction())) {
final int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
if (userHandle > 0) {
- removeUser(userHandle);
+ removeUser(userHandle, /* unknownUser= */ false);
}
}
}
@@ -1464,7 +1467,7 @@ public class LockSettingsService extends ILockSettings.Stub {
return false;
}
- private void removeUser(int userId) {
+ private void removeUser(int userId, boolean unknownUser) {
mStorage.removeUser(userId);
mStrongAuth.removeUser(userId);
@@ -1479,7 +1482,7 @@ public class LockSettingsService extends ILockSettings.Stub {
} catch (RemoteException ex) {
Slog.w(TAG, "unable to clear GK secure user id");
}
- if (mUserManager.getUserInfo(userId).isManagedProfile()) {
+ if (unknownUser || mUserManager.getUserInfo(userId).isManagedProfile()) {
removeKeystoreProfileKey(userId);
}
}