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
diff --git a/services/core/java/com/android/server/locksettings/LockSettingsShellCommand.java b/services/core/java/com/android/server/locksettings/LockSettingsShellCommand.java
index 67ead6f..4facbb8 100644
--- a/services/core/java/com/android/server/locksettings/LockSettingsShellCommand.java
+++ b/services/core/java/com/android/server/locksettings/LockSettingsShellCommand.java
@@ -156,21 +156,24 @@
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;
- if (havePassword) {
- result = mLockPatternUtils.checkPassword(mOld, mCurrentUserId);
- } else {
- result = mLockPatternUtils.checkPattern(stringToPattern(mOld),
- mCurrentUserId);
- }
- if (result) {
- return true;
- } else {
- getOutPrintWriter().println("Old password '" + mOld + "' didn't match");
+ try {
+ final boolean result;
+ if (havePassword) {
+ result = mLockPatternUtils.checkPassword(mOld, mCurrentUserId);
+ } else {
+ result = mLockPatternUtils.checkPattern(stringToPattern(mOld), mCurrentUserId);
+ }
+ 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 {