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

Commit 48283ec4 authored by Rubin Xu's avatar Rubin Xu Committed by Android (Google) Code Review
Browse files

Merge "Remove password blacklist check" into pi-dev

parents efa1cde0 9d2edcbc
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -241,7 +241,6 @@ public class ChooseLockPassword extends SettingsActivity {
        static final int NOT_ENOUGH_DIGITS = 1 << 9;
        static final int NOT_ENOUGH_SYMBOLS = 1 << 10;
        static final int NOT_ENOUGH_NON_LETTER = 1 << 11;
        static final int BLACKLISTED = 1 << 12;

        /**
         * Keep track internally of where the user is in choosing a pattern.
@@ -728,16 +727,6 @@ public class ChooseLockPassword extends SettingsActivity {
                }
            }

            // Only check the blacklist if the password is otherwise valid. Checking the blacklist
            // can be expensive and it is not useful to report the fact it is on a blacklist if it
            // couldn't be set anyway.
            if (errorCode == NO_ERROR) {
                if (mLockPatternUtils.getDevicePolicyManager()
                        .isPasswordBlacklisted(mUserId, password)) {
                    errorCode |= BLACKLISTED;
                }
            }

            return errorCode;
        }

@@ -856,11 +845,6 @@ public class ChooseLockPassword extends SettingsActivity {
                messages.add(getString((mIsAlphaMode) ? R.string.lockpassword_password_recently_used
                        : R.string.lockpassword_pin_recently_used));
            }
            if ((errorCode & BLACKLISTED) > 0) {
                messages.add(getString((mIsAlphaMode)
                        ? R.string.lockpassword_password_blacklisted_by_admin
                        : R.string.lockpassword_pin_blacklisted_by_admin));
            }
            return messages.toArray(new String[0]);
        }

+0 −30
Original line number Diff line number Diff line
@@ -120,36 +120,6 @@ public class ChooseLockPasswordTest {
                .isEqualTo(123);
    }

    @Test
    public void blacklist_addsErrorMessageForPin() {
        final ChooseLockPassword activity = buildChooseLockPasswordActivity(
                new IntentBuilder(application)
                        .setUserId(UserHandle.myUserId())
                        // Set to numeric for a PIN
                        .setPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_NUMERIC)
                        .build());
        final ChooseLockPasswordFragment fragment = getChooseLockPasswordFragment(activity);
        final int errors = ChooseLockPasswordFragment.BLACKLISTED;
        final String[] messages = fragment.convertErrorCodeToMessages(errors);
        assertThat(messages).isEqualTo(new String[] {
                activity.getString(R.string.lockpassword_pin_blacklisted_by_admin) });
    }

    @Test
    public void blacklist_addsErrorMessageForPassword() {
        final ChooseLockPassword activity = buildChooseLockPasswordActivity(
                new IntentBuilder(application)
                        .setUserId(UserHandle.myUserId())
                        // Set to alphabetic for a password
                        .setPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC)
                        .build());
        final ChooseLockPasswordFragment fragment = getChooseLockPasswordFragment(activity);
        final int errors = ChooseLockPasswordFragment.BLACKLISTED;
        final String[] messages = fragment.convertErrorCodeToMessages(errors);
        assertThat(messages).isEqualTo(new String[] {
                activity.getString(R.string.lockpassword_password_blacklisted_by_admin) });
    }

    @Test
    public void assertThat_chooseLockIconChanged_WhenFingerprintExtraSet() {
        ShadowDrawable drawable = setActivityAndGetIconDrawable(true);