Merge "Ensure that input is disabled when locked out." into udc-dev
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user