Merge "Ensure that input is disabled when locked out." into udc-dev

This commit is contained in:
Aaron Liu
2023-06-16 18:41:18 +00:00
committed by Android (Google) Code Review
2 changed files with 17 additions and 0 deletions

View File

@@ -53,6 +53,7 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
private boolean mDismissing;
protected AsyncTask<?, ?, ?> mPendingLockCheck;
protected boolean mResumed;
protected boolean mLockedOut;
private final KeyDownListener mKeyDownListener = (keyCode, keyEvent) -> {
// Fingerprint sensor sends a KeyEvent.KEYCODE_UNKNOWN.
@@ -137,6 +138,8 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
// Prevent user from using the PIN/Password entry until scheduled deadline.
protected void handleAttemptLockout(long elapsedRealtimeDeadline) {
mView.setPasswordEntryEnabled(false);
mView.setPasswordEntryInputEnabled(false);
mLockedOut = true;
long elapsedRealtime = SystemClock.elapsedRealtime();
long secondsInFuture = (long) Math.ceil(
(elapsedRealtimeDeadline - elapsedRealtime) / 1000.0);
@@ -158,6 +161,7 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
@Override
public void onFinish() {
mMessageAreaController.setMessage("");
mLockedOut = false;
resetState();
}
}.start();
@@ -193,6 +197,7 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
protected void verifyPasswordAndUnlock() {
if (mDismissing) return; // already verified but haven't been dismissed; don't do it again.
if (mLockedOut) return;
final LockscreenCredential password = mView.getEnteredCredential();
mView.setPasswordEntryInputEnabled(false);

View File

@@ -26,6 +26,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import android.os.SystemClock;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
import android.view.KeyEvent;
@@ -183,4 +184,15 @@ public class KeyguardAbsKeyInputViewControllerTest extends SysuiTestCase {
mKeyguardAbsKeyInputViewController.onResume(KeyguardSecurityView.VIEW_REVEALED);
verify(mLockPatternUtils).getLockoutAttemptDeadline(anyInt());
}
@Test
public void testLockedOut_verifyPasswordAndUnlock_doesNotEnableViewInput() {
mKeyguardAbsKeyInputViewController.handleAttemptLockout(
SystemClock.elapsedRealtime() + 1000);
mKeyguardAbsKeyInputViewController.verifyPasswordAndUnlock();
verify(mAbsKeyInputView).setPasswordEntryInputEnabled(false);
verify(mAbsKeyInputView).setPasswordEntryEnabled(false);
verify(mAbsKeyInputView, never()).setPasswordEntryInputEnabled(true);
verify(mAbsKeyInputView, never()).setPasswordEntryEnabled(true);
}
}