Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa91e77a authored by Rubin Xu's avatar Rubin Xu
Browse files

[DO NOT MERGE] resolve merge conflicts of...

[DO NOT MERGE] resolve merge conflicts of 157f05eb to pi-dev-plus-aosp

Test: I solemnly swear I tested this conflict resolution.
Bug: None
Change-Id: Idc78cfc626716becd634b985d3752ae8c5aadebf
parents de2654be 157f05eb
Loading
Loading
Loading
Loading
+14 −11
Original line number Original line Diff line number Diff line
@@ -107,7 +107,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
        // Analyse the characters used
        int letters = 0;
        int letters = 0;
        int upperCase = 0;
        int upperCase = 0;
@@ -115,9 +118,9 @@ public class PasswordMetrics implements Parcelable {
        int numeric = 0;
        int numeric = 0;
        int symbols = 0;
        int symbols = 0;
        int nonLetter = 0;
        int nonLetter = 0;
        final int length = password.length();
        final int length = password.length;
        for (int i = 0; i < length; i++) {
        for (int i = 0; i < length; i++) {
            switch (categoryChar(password.charAt(i))) {
            switch (categoryChar((char) password[i])) {
                case CHAR_LOWER_CASE:
                case CHAR_LOWER_CASE:
                    letters++;
                    letters++;
                    lowerCase++;
                    lowerCase++;
@@ -173,7 +176,7 @@ public class PasswordMetrics implements Parcelable {
                && this.nonLetter == o.nonLetter;
                && this.nonLetter == o.nonLetter;
    }
    }


    /*
    /**
     * Returns the maximum length of a sequential characters. A sequence is defined as
     * 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.
     * monotonically increasing characters with a constant interval or the same character repeated.
     *
     *
@@ -187,19 +190,19 @@ public class PasswordMetrics implements Parcelable {
     * maxLengthSequence(";;;;") == 4 (anything that repeats)
     * maxLengthSequence(";;;;") == 4 (anything that repeats)
     * maxLengthSequence(":;<=>") == 1  (ordered, but not composed of alphas or digits)
     * 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
     * @return the number of sequential letters or digits
     */
     */
    public static int maxLengthSequence(@NonNull String string) {
    public static int maxLengthSequence(@NonNull byte[] bytes) {
        if (string.length() == 0) return 0;
        if (bytes.length == 0) return 0;
        char previousChar = string.charAt(0);
        char previousChar = (char) bytes[0];
        @CharacterCatagory int category = categoryChar(previousChar); //current sequence category
        @CharacterCatagory int category = categoryChar(previousChar); //current sequence category
        int diff = 0; //difference between two consecutive characters
        int diff = 0; //difference between two consecutive characters
        boolean hasDiff = false; //if we are currently targeting a sequence
        boolean hasDiff = false; //if we are currently targeting a sequence
        int maxLength = 0; //maximum length of a sequence already found
        int maxLength = 0; //maximum length of a sequence already found
        int startSequence = 0; //where the current sequence started
        int startSequence = 0; //where the current sequence started
        for (int current = 1; current < string.length(); current++) {
        for (int current = 1; current < bytes.length; current++) {
            char currentChar = string.charAt(current);
            char currentChar = (char) bytes[current];
            @CharacterCatagory int categoryCurrent = categoryChar(currentChar);
            @CharacterCatagory int categoryCurrent = categoryChar(currentChar);
            int currentDiff = (int) currentChar - (int) previousChar;
            int currentDiff = (int) currentChar - (int) previousChar;
            if (categoryCurrent != category || Math.abs(currentDiff) > maxDiffCategory(category)) {
            if (categoryCurrent != category || Math.abs(currentDiff) > maxDiffCategory(category)) {
@@ -218,7 +221,7 @@ public class PasswordMetrics implements Parcelable {
            }
            }
            previousChar = currentChar;
            previousChar = currentChar;
        }
        }
        maxLength = Math.max(maxLength, string.length() - startSequence);
        maxLength = Math.max(maxLength, bytes.length - startSequence);
        return maxLength;
        return maxLength;
    }
    }


+6 −6
Original line number Original line Diff line number Diff line
@@ -42,19 +42,19 @@ interface ILockSettings {
    long getLong(in String key, in long defaultValue, in int userId);
    long getLong(in String key, in long defaultValue, in int userId);
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    String getString(in String key, in String 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);
    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);
            in ICheckCredentialProgressCallback progressCallback);
    VerifyCredentialResponse verifyCredential(in String credential, int type, long challenge, int userId);
    VerifyCredentialResponse verifyCredential(in byte[] credential, int type, long challenge, int userId);
    VerifyCredentialResponse verifyTiedProfileChallenge(String credential, int type, long challenge, int userId);
    VerifyCredentialResponse verifyTiedProfileChallenge(in byte[] credential, int type, long challenge, int userId);
    boolean checkVoldPassword(int userId);
    boolean checkVoldPassword(int userId);
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    boolean havePattern(int userId);
    boolean havePattern(int userId);
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    boolean havePassword(int userId);
    boolean havePassword(int userId);
    byte[] getHashFactor(String currentCredential, int userId);
    byte[] getHashFactor(in byte[] currentCredential, int userId);
    void setSeparateProfileChallengeEnabled(int userId, boolean enabled, String managedUserPassword);
    void setSeparateProfileChallengeEnabled(int userId, boolean enabled, in byte[] managedUserPassword);
    boolean getSeparateProfileChallengeEnabled(int userId);
    boolean getSeparateProfileChallengeEnabled(int userId);
    void registerStrongAuthTracker(in IStrongAuthTracker tracker);
    void registerStrongAuthTracker(in IStrongAuthTracker tracker);
    void unregisterStrongAuthTracker(in IStrongAuthTracker tracker);
    void unregisterStrongAuthTracker(in IStrongAuthTracker tracker);
+41 −2
Original line number Original line Diff line number Diff line
@@ -151,12 +151,33 @@ public final class LockPatternChecker {
     * @param challenge The challenge to verify against the pattern.
     * @param challenge The challenge to verify against the pattern.
     * @param userId The user to check against the pattern.
     * @param userId The user to check against the pattern.
     * @param callback The callback to be invoked with the verification result.
     * @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,
    public static AsyncTask<?, ?, ?> verifyPassword(final LockPatternUtils utils,
            final String password,
            final String password,
            final long challenge,
            final long challenge,
            final int userId,
            final int userId,
            final OnVerifyCallback callback) {
            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[]>() {
        AsyncTask<Void, Void, byte[]> task = new AsyncTask<Void, Void, byte[]>() {
            private int mThrottleTimeout;
            private int mThrottleTimeout;


@@ -189,7 +210,7 @@ public final class LockPatternChecker {
     * @param callback The callback to be invoked with the verification result.
     * @param callback The callback to be invoked with the verification result.
     */
     */
    public static AsyncTask<?, ?, ?> verifyTiedProfileChallenge(final LockPatternUtils utils,
    public static AsyncTask<?, ?, ?> verifyTiedProfileChallenge(final LockPatternUtils utils,
            final String password,
            final byte[] password,
            final boolean isPattern,
            final boolean isPattern,
            final long challenge,
            final long challenge,
            final int userId,
            final int userId,
@@ -223,19 +244,37 @@ public final class LockPatternChecker {
     * @param password The password to check.
     * @param password The password to check.
     * @param userId The user to check against the pattern.
     * @param userId The user to check against the pattern.
     * @param callback The callback to be invoked with the check result.
     * @param callback The callback to be invoked with the check result.
     * @deprecated Pass passwords as byte[]
     */
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    @Deprecated
    public static AsyncTask<?, ?, ?> checkPassword(final LockPatternUtils utils,
    public static AsyncTask<?, ?, ?> checkPassword(final LockPatternUtils utils,
            final String password,
            final String password,
            final int userId,
            final int userId,
            final OnCheckCallback callback) {
            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>() {
        AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {
            private int mThrottleTimeout;
            private int mThrottleTimeout;


            @Override
            @Override
            protected Boolean doInBackground(Void... args) {
            protected Boolean doInBackground(Void... args) {
                try {
                try {
                    return utils.checkPassword(password, userId, callback::onEarlyMatched);
                    return utils.checkPassword(passwordBytes, userId, callback::onEarlyMatched);
                } catch (RequestThrottledException ex) {
                } catch (RequestThrottledException ex) {
                    mThrottleTimeout = ex.getTimeoutMs();
                    mThrottleTimeout = ex.getTimeoutMs();
                    return false;
                    return false;
+163 −52

File changed.

Preview size limit exceeded, changes collapsed.

+3 −1
Original line number Original line Diff line number Diff line
@@ -1298,8 +1298,10 @@ public class LockPatternView extends View {
    @Override
    @Override
    protected Parcelable onSaveInstanceState() {
    protected Parcelable onSaveInstanceState() {
        Parcelable superState = super.onSaveInstanceState();
        Parcelable superState = super.onSaveInstanceState();
        byte[] patternBytes = LockPatternUtils.patternToByteArray(mPattern);
        String patternString = patternBytes != null ? new String(patternBytes) : null;
        return new SavedState(superState,
        return new SavedState(superState,
                LockPatternUtils.patternToString(mPattern),
                patternString,
                mPatternDisplayMode.ordinal(),
                mPatternDisplayMode.ordinal(),
                mInputEnabled, mInStealthMode, mEnableHapticFeedback);
                mInputEnabled, mInStealthMode, mEnableHapticFeedback);
    }
    }
Loading