Loading core/java/android/app/admin/PasswordMetrics.java +14 −11 Original line number Diff line number Diff line Loading @@ -221,7 +221,10 @@ public class PasswordMetrics implements Parcelable { } }; public static PasswordMetrics computeForPassword(@NonNull String password) { /** * Returns the {@code PasswordMetrics} for a given password */ public static PasswordMetrics computeForPassword(@NonNull byte[] password) { // Analyse the characters used int letters = 0; int upperCase = 0; Loading @@ -229,9 +232,9 @@ public class PasswordMetrics implements Parcelable { int numeric = 0; int symbols = 0; int nonLetter = 0; final int length = password.length(); final int length = password.length; for (int i = 0; i < length; i++) { switch (categoryChar(password.charAt(i))) { switch (categoryChar((char) password[i])) { case CHAR_LOWER_CASE: letters++; lowerCase++; Loading Loading @@ -296,7 +299,7 @@ public class PasswordMetrics implements Parcelable { return false; } /* /** * Returns the maximum length of a sequential characters. A sequence is defined as * monotonically increasing characters with a constant interval or the same character repeated. * Loading @@ -310,19 +313,19 @@ public class PasswordMetrics implements Parcelable { * maxLengthSequence(";;;;") == 4 (anything that repeats) * maxLengthSequence(":;<=>") == 1 (ordered, but not composed of alphas or digits) * * @param string the pass * @param bytes the pass * @return the number of sequential letters or digits */ public static int maxLengthSequence(@NonNull String string) { if (string.length() == 0) return 0; char previousChar = string.charAt(0); public static int maxLengthSequence(@NonNull byte[] bytes) { if (bytes.length == 0) return 0; char previousChar = (char) bytes[0]; @CharacterCatagory int category = categoryChar(previousChar); //current sequence category int diff = 0; //difference between two consecutive characters boolean hasDiff = false; //if we are currently targeting a sequence int maxLength = 0; //maximum length of a sequence already found int startSequence = 0; //where the current sequence started for (int current = 1; current < string.length(); current++) { char currentChar = string.charAt(current); for (int current = 1; current < bytes.length; current++) { char currentChar = (char) bytes[current]; @CharacterCatagory int categoryCurrent = categoryChar(currentChar); int currentDiff = (int) currentChar - (int) previousChar; if (categoryCurrent != category || Math.abs(currentDiff) > maxDiffCategory(category)) { Loading @@ -341,7 +344,7 @@ public class PasswordMetrics implements Parcelable { } previousChar = currentChar; } maxLength = Math.max(maxLength, string.length() - startSequence); maxLength = Math.max(maxLength, bytes.length - startSequence); return maxLength; } Loading core/java/com/android/internal/widget/ILockSettings.aidl +6 −6 Original line number Diff line number Diff line Loading @@ -36,17 +36,17 @@ interface ILockSettings { boolean getBoolean(in String key, in boolean defaultValue, in int userId); long getLong(in String key, in long defaultValue, in int userId); String getString(in String key, in String defaultValue, in int userId); void setLockCredential(in String credential, int type, in String savedCredential, int requestedQuality, int userId); void setLockCredential(in byte[] credential, int type, in byte[] savedCredential, int requestedQuality, int userId); void resetKeyStore(int userId); VerifyCredentialResponse checkCredential(in String credential, int type, int userId, VerifyCredentialResponse checkCredential(in byte[] credential, int type, int userId, in ICheckCredentialProgressCallback progressCallback); VerifyCredentialResponse verifyCredential(in String credential, int type, long challenge, int userId); VerifyCredentialResponse verifyTiedProfileChallenge(String credential, int type, long challenge, int userId); VerifyCredentialResponse verifyCredential(in byte[] credential, int type, long challenge, int userId); VerifyCredentialResponse verifyTiedProfileChallenge(in byte[] credential, int type, long challenge, int userId); boolean checkVoldPassword(int userId); boolean havePattern(int userId); boolean havePassword(int userId); byte[] getHashFactor(String currentCredential, int userId); void setSeparateProfileChallengeEnabled(int userId, boolean enabled, String managedUserPassword); byte[] getHashFactor(in byte[] currentCredential, int userId); void setSeparateProfileChallengeEnabled(int userId, boolean enabled, in byte[] managedUserPassword); boolean getSeparateProfileChallengeEnabled(int userId); void registerStrongAuthTracker(in IStrongAuthTracker tracker); void unregisterStrongAuthTracker(in IStrongAuthTracker tracker); Loading core/java/com/android/internal/widget/LockPatternChecker.java +41 −2 Original line number Diff line number Diff line Loading @@ -150,12 +150,33 @@ public final class LockPatternChecker { * @param challenge The challenge to verify against the pattern. * @param userId The user to check against the pattern. * @param callback The callback to be invoked with the verification result. * * @deprecated Pass the password as a byte array. */ @Deprecated public static AsyncTask<?, ?, ?> verifyPassword(final LockPatternUtils utils, final String password, final long challenge, final int userId, final OnVerifyCallback callback) { byte[] passwordBytes = password != null ? password.getBytes() : null; return verifyPassword(utils, passwordBytes, challenge, userId, callback); } /** * Verify a password asynchronously. * * @param utils The LockPatternUtils instance to use. * @param password The password to check. * @param challenge The challenge to verify against the pattern. * @param userId The user to check against the pattern. * @param callback The callback to be invoked with the verification result. */ public static AsyncTask<?, ?, ?> verifyPassword(final LockPatternUtils utils, final byte[] password, final long challenge, final int userId, final OnVerifyCallback callback) { AsyncTask<Void, Void, byte[]> task = new AsyncTask<Void, Void, byte[]>() { private int mThrottleTimeout; Loading Loading @@ -188,7 +209,7 @@ public final class LockPatternChecker { * @param callback The callback to be invoked with the verification result. */ public static AsyncTask<?, ?, ?> verifyTiedProfileChallenge(final LockPatternUtils utils, final String password, final byte[] password, final boolean isPattern, final long challenge, final int userId, Loading Loading @@ -222,18 +243,36 @@ public final class LockPatternChecker { * @param password The password to check. * @param userId The user to check against the pattern. * @param callback The callback to be invoked with the check result. * @deprecated Pass passwords as byte[] */ @Deprecated public static AsyncTask<?, ?, ?> checkPassword(final LockPatternUtils utils, final String password, final int userId, final OnCheckCallback callback) { byte[] passwordBytes = password != null ? password.getBytes() : null; return checkPassword(utils, passwordBytes, userId, callback); } /** * Checks a password asynchronously. * * @param utils The LockPatternUtils instance to use. * @param passwordBytes The password to check. * @param userId The user to check against the pattern. * @param callback The callback to be invoked with the check result. */ public static AsyncTask<?, ?, ?> checkPassword(final LockPatternUtils utils, final byte[] passwordBytes, final int userId, final OnCheckCallback callback) { AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() { private int mThrottleTimeout; @Override protected Boolean doInBackground(Void... args) { try { return utils.checkPassword(password, userId, callback::onEarlyMatched); return utils.checkPassword(passwordBytes, userId, callback::onEarlyMatched); } catch (RequestThrottledException ex) { mThrottleTimeout = ex.getTimeoutMs(); return false; Loading core/java/com/android/internal/widget/LockPatternUtils.java +164 −52 File changed.Preview size limit exceeded, changes collapsed. Show changes core/java/com/android/internal/widget/LockPatternView.java +3 −1 Original line number Diff line number Diff line Loading @@ -1273,8 +1273,10 @@ public class LockPatternView extends View { @Override protected Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); byte[] patternBytes = LockPatternUtils.patternToByteArray(mPattern); String patternString = patternBytes != null ? new String(patternBytes) : null; return new SavedState(superState, LockPatternUtils.patternToString(mPattern), patternString, mPatternDisplayMode.ordinal(), mInputEnabled, mInStealthMode, mEnableHapticFeedback); } Loading Loading
core/java/android/app/admin/PasswordMetrics.java +14 −11 Original line number Diff line number Diff line Loading @@ -221,7 +221,10 @@ public class PasswordMetrics implements Parcelable { } }; public static PasswordMetrics computeForPassword(@NonNull String password) { /** * Returns the {@code PasswordMetrics} for a given password */ public static PasswordMetrics computeForPassword(@NonNull byte[] password) { // Analyse the characters used int letters = 0; int upperCase = 0; Loading @@ -229,9 +232,9 @@ public class PasswordMetrics implements Parcelable { int numeric = 0; int symbols = 0; int nonLetter = 0; final int length = password.length(); final int length = password.length; for (int i = 0; i < length; i++) { switch (categoryChar(password.charAt(i))) { switch (categoryChar((char) password[i])) { case CHAR_LOWER_CASE: letters++; lowerCase++; Loading Loading @@ -296,7 +299,7 @@ public class PasswordMetrics implements Parcelable { return false; } /* /** * Returns the maximum length of a sequential characters. A sequence is defined as * monotonically increasing characters with a constant interval or the same character repeated. * Loading @@ -310,19 +313,19 @@ public class PasswordMetrics implements Parcelable { * maxLengthSequence(";;;;") == 4 (anything that repeats) * maxLengthSequence(":;<=>") == 1 (ordered, but not composed of alphas or digits) * * @param string the pass * @param bytes the pass * @return the number of sequential letters or digits */ public static int maxLengthSequence(@NonNull String string) { if (string.length() == 0) return 0; char previousChar = string.charAt(0); public static int maxLengthSequence(@NonNull byte[] bytes) { if (bytes.length == 0) return 0; char previousChar = (char) bytes[0]; @CharacterCatagory int category = categoryChar(previousChar); //current sequence category int diff = 0; //difference between two consecutive characters boolean hasDiff = false; //if we are currently targeting a sequence int maxLength = 0; //maximum length of a sequence already found int startSequence = 0; //where the current sequence started for (int current = 1; current < string.length(); current++) { char currentChar = string.charAt(current); for (int current = 1; current < bytes.length; current++) { char currentChar = (char) bytes[current]; @CharacterCatagory int categoryCurrent = categoryChar(currentChar); int currentDiff = (int) currentChar - (int) previousChar; if (categoryCurrent != category || Math.abs(currentDiff) > maxDiffCategory(category)) { Loading @@ -341,7 +344,7 @@ public class PasswordMetrics implements Parcelable { } previousChar = currentChar; } maxLength = Math.max(maxLength, string.length() - startSequence); maxLength = Math.max(maxLength, bytes.length - startSequence); return maxLength; } Loading
core/java/com/android/internal/widget/ILockSettings.aidl +6 −6 Original line number Diff line number Diff line Loading @@ -36,17 +36,17 @@ interface ILockSettings { boolean getBoolean(in String key, in boolean defaultValue, in int userId); long getLong(in String key, in long defaultValue, in int userId); String getString(in String key, in String defaultValue, in int userId); void setLockCredential(in String credential, int type, in String savedCredential, int requestedQuality, int userId); void setLockCredential(in byte[] credential, int type, in byte[] savedCredential, int requestedQuality, int userId); void resetKeyStore(int userId); VerifyCredentialResponse checkCredential(in String credential, int type, int userId, VerifyCredentialResponse checkCredential(in byte[] credential, int type, int userId, in ICheckCredentialProgressCallback progressCallback); VerifyCredentialResponse verifyCredential(in String credential, int type, long challenge, int userId); VerifyCredentialResponse verifyTiedProfileChallenge(String credential, int type, long challenge, int userId); VerifyCredentialResponse verifyCredential(in byte[] credential, int type, long challenge, int userId); VerifyCredentialResponse verifyTiedProfileChallenge(in byte[] credential, int type, long challenge, int userId); boolean checkVoldPassword(int userId); boolean havePattern(int userId); boolean havePassword(int userId); byte[] getHashFactor(String currentCredential, int userId); void setSeparateProfileChallengeEnabled(int userId, boolean enabled, String managedUserPassword); byte[] getHashFactor(in byte[] currentCredential, int userId); void setSeparateProfileChallengeEnabled(int userId, boolean enabled, in byte[] managedUserPassword); boolean getSeparateProfileChallengeEnabled(int userId); void registerStrongAuthTracker(in IStrongAuthTracker tracker); void unregisterStrongAuthTracker(in IStrongAuthTracker tracker); Loading
core/java/com/android/internal/widget/LockPatternChecker.java +41 −2 Original line number Diff line number Diff line Loading @@ -150,12 +150,33 @@ public final class LockPatternChecker { * @param challenge The challenge to verify against the pattern. * @param userId The user to check against the pattern. * @param callback The callback to be invoked with the verification result. * * @deprecated Pass the password as a byte array. */ @Deprecated public static AsyncTask<?, ?, ?> verifyPassword(final LockPatternUtils utils, final String password, final long challenge, final int userId, final OnVerifyCallback callback) { byte[] passwordBytes = password != null ? password.getBytes() : null; return verifyPassword(utils, passwordBytes, challenge, userId, callback); } /** * Verify a password asynchronously. * * @param utils The LockPatternUtils instance to use. * @param password The password to check. * @param challenge The challenge to verify against the pattern. * @param userId The user to check against the pattern. * @param callback The callback to be invoked with the verification result. */ public static AsyncTask<?, ?, ?> verifyPassword(final LockPatternUtils utils, final byte[] password, final long challenge, final int userId, final OnVerifyCallback callback) { AsyncTask<Void, Void, byte[]> task = new AsyncTask<Void, Void, byte[]>() { private int mThrottleTimeout; Loading Loading @@ -188,7 +209,7 @@ public final class LockPatternChecker { * @param callback The callback to be invoked with the verification result. */ public static AsyncTask<?, ?, ?> verifyTiedProfileChallenge(final LockPatternUtils utils, final String password, final byte[] password, final boolean isPattern, final long challenge, final int userId, Loading Loading @@ -222,18 +243,36 @@ public final class LockPatternChecker { * @param password The password to check. * @param userId The user to check against the pattern. * @param callback The callback to be invoked with the check result. * @deprecated Pass passwords as byte[] */ @Deprecated public static AsyncTask<?, ?, ?> checkPassword(final LockPatternUtils utils, final String password, final int userId, final OnCheckCallback callback) { byte[] passwordBytes = password != null ? password.getBytes() : null; return checkPassword(utils, passwordBytes, userId, callback); } /** * Checks a password asynchronously. * * @param utils The LockPatternUtils instance to use. * @param passwordBytes The password to check. * @param userId The user to check against the pattern. * @param callback The callback to be invoked with the check result. */ public static AsyncTask<?, ?, ?> checkPassword(final LockPatternUtils utils, final byte[] passwordBytes, final int userId, final OnCheckCallback callback) { AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() { private int mThrottleTimeout; @Override protected Boolean doInBackground(Void... args) { try { return utils.checkPassword(password, userId, callback::onEarlyMatched); return utils.checkPassword(passwordBytes, userId, callback::onEarlyMatched); } catch (RequestThrottledException ex) { mThrottleTimeout = ex.getTimeoutMs(); return false; Loading
core/java/com/android/internal/widget/LockPatternUtils.java +164 −52 File changed.Preview size limit exceeded, changes collapsed. Show changes
core/java/com/android/internal/widget/LockPatternView.java +3 −1 Original line number Diff line number Diff line Loading @@ -1273,8 +1273,10 @@ public class LockPatternView extends View { @Override protected Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); byte[] patternBytes = LockPatternUtils.patternToByteArray(mPattern); String patternString = patternBytes != null ? new String(patternBytes) : null; return new SavedState(superState, LockPatternUtils.patternToString(mPattern), patternString, mPatternDisplayMode.ordinal(), mInputEnabled, mInStealthMode, mEnableHapticFeedback); } Loading