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

Commit c07067d9 authored by Pavel Grafov's avatar Pavel Grafov
Browse files

Count incorrect password attempts from shell.

Test: adb shell cmd lock_settings verify --user 10 --old 12368
      and check device admin broadcast
Bug: 63295016

Change-Id: I19398eec9b324a061c4054d95dab12d047d501a5
parent 6bf39e5b
Loading
Loading
Loading
Loading
+15 −12
Original line number Diff line number Diff line
@@ -156,21 +156,24 @@ class LockSettingsShellCommand extends ShellCommand {
        getOutPrintWriter().println("Lock screen disabled set to " + disabled);
    }

    private boolean checkCredential() throws RemoteException, RequestThrottledException {
    private boolean checkCredential() throws RemoteException {
        final boolean havePassword = mLockPatternUtils.isLockPasswordEnabled(mCurrentUserId);
        final boolean havePattern = mLockPatternUtils.isLockPatternEnabled(mCurrentUserId);
        if (havePassword || havePattern) {
            boolean result;
            try {
                final boolean result;
                if (havePassword) {
                    result = mLockPatternUtils.checkPassword(mOld, mCurrentUserId);
                } else {
                result = mLockPatternUtils.checkPattern(stringToPattern(mOld),
                        mCurrentUserId);
                    result = mLockPatternUtils.checkPattern(stringToPattern(mOld), mCurrentUserId);
                }
            if (result) {
                return true;
            } else {
                if (!result) {
                    mLockPatternUtils.reportFailedPasswordAttempt(mCurrentUserId);
                    getOutPrintWriter().println("Old password '" + mOld + "' didn't match");
                }
                return result;
            } catch (RequestThrottledException e) {
                getOutPrintWriter().println("Request throttled");
                return false;
            }
        } else {