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

Commit 73da5fe0 authored by Danielle Millett's avatar Danielle Millett
Browse files

isPasswordEnabled and isPatternEnabled return true if used as backup method

When facelock is enabled, isPasswordEnabled or isPatternEnabled will return true depending
on which one is set as the backup method. This is a cleaner way to handle things, rather than
specific cases for facelock in all the methods that call these functions.

Change-Id: Iacb802b89626dfc13f2306de1a2e622ca9b69427
parent 1fbe7a8e
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) {