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

Commit 247d8b08 authored by Danielle Millett's avatar Danielle Millett Committed by Android (Google) Code Review
Browse files

Merge "isPasswordEnabled and isPatternEnabled return true if used as backup method"

parents 6ba3ff72 73da5fe0
Loading
Loading
Loading
Loading
+22 −11
Original line number Diff line number Diff line
@@ -756,24 +756,36 @@ public class LockPatternUtils {
    }

    /**
     * @return Whether the lock password is enabled.
     * @return Whether the lock password is enabled, or if it is set as a backup for biometric weak
     */
    public boolean isLockPasswordEnabled() {
        long mode = getLong(PASSWORD_TYPE_KEY, 0);
        return savedPasswordExists() &&
                (mode == DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC
        long backupMode = getLong(PASSWORD_TYPE_ALTERNATE_KEY, 0);
        final boolean passwordEnabled = mode == DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC
                || mode == DevicePolicyManager.PASSWORD_QUALITY_NUMERIC
                || mode == DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC
                        || mode == DevicePolicyManager.PASSWORD_QUALITY_COMPLEX);
                || mode == DevicePolicyManager.PASSWORD_QUALITY_COMPLEX;
        final boolean backupEnabled = backupMode == DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC
                || backupMode == DevicePolicyManager.PASSWORD_QUALITY_NUMERIC
                || backupMode == DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC
                || backupMode == DevicePolicyManager.PASSWORD_QUALITY_COMPLEX;

        return savedPasswordExists() && (passwordEnabled ||
                (isBiometricEnabled() && backupEnabled));
    }

    /**
     * @return Whether the lock pattern is enabled.
     * @return Whether the lock pattern is enabled, or if it is set as a backup for biometric weak
     */
    public boolean isLockPatternEnabled() {
        return getBoolean(Settings.Secure.LOCK_PATTERN_ENABLED)
                && getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING)
        final boolean backupEnabled =
                getLong(PASSWORD_TYPE_ALTERNATE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING)
                == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING;

        return getBoolean(Settings.Secure.LOCK_PATTERN_ENABLED)
                && (getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING)
                        == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING ||
                        (isBiometricEnabled() && backupEnabled));
    }

    /**
@@ -923,8 +935,7 @@ public class LockPatternUtils {
                || mode == DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC
                || mode == DevicePolicyManager.PASSWORD_QUALITY_COMPLEX;
        final boolean secure = isPattern && isLockPatternEnabled() && savedPatternExists()
                || isPassword && savedPasswordExists()
                || usingBiometricWeak() && isBiometricEnabled();
                || isPassword && savedPasswordExists();
        return secure;
    }

+0 −4
Original line number Diff line number Diff line
@@ -593,10 +593,6 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
    }

    private boolean isSecure() {
        // TODO: make this work with SIM and Account cases below.
        boolean usingBiometric = mLockPatternUtils.usingBiometricWeak();
        if (usingBiometric && mLockPatternUtils.isBiometricEnabled())
            return true;
        UnlockMode unlockMode = getUnlockMode();
        boolean secure = false;
        switch (unlockMode) {