Restore separate challenge state on error
Otherwise if something goes wrong when tying the profile to the primary user, challenge will remain in inconsistent state and the user won't be able to unlock the profile. Bug: 110262879 Test: manual, unified both compliant and uncompliant challenge. Change-Id: I2bea3867541f43cbabd5cabbe8a0f61acc2602ca
This commit is contained in:
@@ -955,12 +955,18 @@ public class LockSettingsService extends ILockSettings.Stub {
|
||||
@GuardedBy("mSeparateChallengeLock")
|
||||
private void setSeparateProfileChallengeEnabledLocked(@UserIdInt int userId, boolean enabled,
|
||||
String managedUserPassword) {
|
||||
final boolean old = getBoolean(SEPARATE_PROFILE_CHALLENGE_KEY, false, userId);
|
||||
setBoolean(SEPARATE_PROFILE_CHALLENGE_KEY, enabled, userId);
|
||||
if (enabled) {
|
||||
mStorage.removeChildProfileLock(userId);
|
||||
removeKeystoreProfileKey(userId);
|
||||
} else {
|
||||
tieManagedProfileLockIfNecessary(userId, managedUserPassword);
|
||||
try {
|
||||
if (enabled) {
|
||||
mStorage.removeChildProfileLock(userId);
|
||||
removeKeystoreProfileKey(userId);
|
||||
} else {
|
||||
tieManagedProfileLockIfNecessary(userId, managedUserPassword);
|
||||
}
|
||||
} catch (IllegalStateException e) {
|
||||
setBoolean(SEPARATE_PROFILE_CHALLENGE_KEY, old, userId);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user