Merge "ChooseLockPassword: convert to use PasswordMetrics#validateCredential()" into main am: 00f5d9e7a6 am: 335752ed98

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/2776714

Change-Id: I7aa857ea6fd3bb5f36e8d6fda1fa27ce6df27f2e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Eric Biggers
2023-10-09 21:47:02 +00:00
committed by Automerger Merge Worker
2 changed files with 33 additions and 16 deletions

View File

@@ -705,18 +705,17 @@ public class ChooseLockPassword extends SettingsActivity {
/**
* Validates PIN/Password and returns the validation result and updates mValidationErrors
* and mPasswordReused to reflect validation results.
* to reflect validation results.
*
* @param credential credential the user typed in.
* @return whether password satisfies all the requirements.
*/
@VisibleForTesting
boolean validatePassword(LockscreenCredential credential) {
final byte[] password = credential.getCredential();
mValidationErrors = PasswordMetrics.validatePassword(
mMinMetrics, mMinComplexity, !mIsAlphaMode, password);
if (mValidationErrors.isEmpty() && mLockPatternUtils.checkPasswordHistory(
password, getPasswordHistoryHashFactor(), mUserId)) {
mValidationErrors = PasswordMetrics.validateCredential(mMinMetrics, mMinComplexity,
credential);
if (mValidationErrors.isEmpty() && mLockPatternUtils.checkPasswordHistory(
credential.getCredential(), getPasswordHistoryHashFactor(), mUserId)) {
mValidationErrors =
Collections.singletonList(new PasswordValidationError(RECENTLY_USED));
}
@@ -893,8 +892,8 @@ public class ChooseLockPassword extends SettingsActivity {
final boolean canInput = mSaveAndFinishWorker == null;
LockscreenCredential password = mIsAlphaMode
? LockscreenCredential.createPasswordOrNone(mPasswordEntry.getText())
: LockscreenCredential.createPinOrNone(mPasswordEntry.getText());
? LockscreenCredential.createPassword(mPasswordEntry.getText())
: LockscreenCredential.createPin(mPasswordEntry.getText());
final int length = password.size();
if (mUiStage == Stage.Introduction) {
mPasswordRestrictionView.setVisibility(View.VISIBLE);