Merge "Don't save the password metrics to disk."
This commit is contained in:
@@ -2304,7 +2304,7 @@ public class DevicePolicyManager {
|
||||
* Determine whether the current password the user has set is sufficient to meet the policy
|
||||
* requirements (e.g. quality, minimum length) that have been requested by the admins of this
|
||||
* user and its participating profiles. Restrictions on profiles that have a separate challenge
|
||||
* are not taken into account.
|
||||
* are not taken into account. The user must be unlocked in order to perform the check.
|
||||
* <p>
|
||||
* The calling device admin must have requested
|
||||
* {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has
|
||||
@@ -2317,6 +2317,7 @@ public class DevicePolicyManager {
|
||||
* @return Returns true if the password meets the current requirements, else false.
|
||||
* @throws SecurityException if the calling application does not own an active administrator
|
||||
* that uses {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD}
|
||||
* @throws InvalidStateException if the user is not unlocked.
|
||||
*/
|
||||
public boolean isActivePasswordSufficient() {
|
||||
if (mService != null) {
|
||||
@@ -3824,6 +3825,19 @@ public class DevicePolicyManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public void reportPasswordChanged(@UserIdInt int userId) {
|
||||
if (mService != null) {
|
||||
try {
|
||||
mService.reportPasswordChanged(userId);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
|
||||
@@ -123,6 +123,7 @@ interface IDevicePolicyManager {
|
||||
boolean hasGrantedPolicy(in ComponentName policyReceiver, int usesPolicy, int userHandle);
|
||||
|
||||
void setActivePasswordState(in PasswordMetrics metrics, int userHandle);
|
||||
void reportPasswordChanged(int userId);
|
||||
void reportFailedPasswordAttempt(int userHandle);
|
||||
void reportSuccessfulPasswordAttempt(int userHandle);
|
||||
void reportFailedFingerprintAttempt(int userHandle);
|
||||
|
||||
@@ -590,8 +590,6 @@ public class LockPatternUtils {
|
||||
setCredentialRequiredToDecrypt(false);
|
||||
}
|
||||
|
||||
getDevicePolicyManager().setActivePasswordState(new PasswordMetrics(), userHandle);
|
||||
|
||||
onAfterChangingPassword(userHandle);
|
||||
}
|
||||
|
||||
@@ -644,6 +642,7 @@ public class LockPatternUtils {
|
||||
+ MIN_LOCK_PATTERN_SIZE + " dots long.");
|
||||
}
|
||||
|
||||
setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, userId);
|
||||
getLockSettings().setLockPattern(patternToString(pattern), savedPattern, userId);
|
||||
DevicePolicyManager dpm = getDevicePolicyManager();
|
||||
|
||||
@@ -659,10 +658,6 @@ public class LockPatternUtils {
|
||||
}
|
||||
|
||||
setBoolean(PATTERN_EVER_CHOSEN_KEY, true, userId);
|
||||
|
||||
setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, userId);
|
||||
dpm.setActivePasswordState(new PasswordMetrics(
|
||||
DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, pattern.size()), userId);
|
||||
onAfterChangingPassword(userId);
|
||||
} catch (RemoteException re) {
|
||||
Log.e(TAG, "Couldn't save lock pattern " + re);
|
||||
@@ -775,10 +770,9 @@ public class LockPatternUtils {
|
||||
+ "of length " + MIN_LOCK_PASSWORD_SIZE);
|
||||
}
|
||||
|
||||
final int computedQuality = PasswordMetrics.computeForPassword(password).quality;
|
||||
setLong(PASSWORD_TYPE_KEY, Math.max(quality, computedQuality), userHandle);
|
||||
getLockSettings().setLockPassword(password, savedPassword, userHandle);
|
||||
getLockSettings().setSeparateProfileChallengeEnabled(userHandle, true, null);
|
||||
final PasswordMetrics metrics = PasswordMetrics.computeForPassword(password);
|
||||
final int computedQuality = metrics.quality;
|
||||
|
||||
// Update the device encryption password.
|
||||
if (userHandle == UserHandle.USER_SYSTEM
|
||||
@@ -796,15 +790,6 @@ public class LockPatternUtils {
|
||||
}
|
||||
}
|
||||
|
||||
setLong(PASSWORD_TYPE_KEY, Math.max(quality, computedQuality), userHandle);
|
||||
if (computedQuality != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
|
||||
metrics.quality = Math.max(quality, metrics.quality);
|
||||
dpm.setActivePasswordState(metrics, userHandle);
|
||||
} else {
|
||||
// The password is not anything.
|
||||
dpm.setActivePasswordState(new PasswordMetrics(), userHandle);
|
||||
}
|
||||
|
||||
// Add the password to the password history. We assume all
|
||||
// password hashes have the same length for simplicity of implementation.
|
||||
String passwordHistory = getString(PASSWORD_HISTORY_KEY, userHandle);
|
||||
|
||||
Reference in New Issue
Block a user