Loading packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java +19 −3 Original line number Diff line number Diff line Loading @@ -38,12 +38,15 @@ public class KeyguardPinViewController private LockPatternUtils mLockPatternUtils; private final FeatureFlags mFeatureFlags; private static final int DEFAULT_PIN_LENGTH = 6; private static final int MIN_FAILED_PIN_ATTEMPTS = 5; private NumPadButton mBackspaceKey; private View mOkButton = mView.findViewById(R.id.key_enter); private int mUserId; private long mPinLength; private int mPasswordFailedAttempts; protected KeyguardPinViewController(KeyguardPINView view, KeyguardUpdateMonitor keyguardUpdateMonitor, SecurityMode securityMode, LockPatternUtils lockPatternUtils, Loading Loading @@ -82,8 +85,10 @@ public class KeyguardPinViewController protected void onUserInput() { super.onUserInput(); if (isAutoConfirmation()) { updateOKButtonVisibility(); updateBackSpaceVisibility(); if (mPasswordEntry.getText().length() == mPinLength) { if (mPasswordEntry.getText().length() == mPinLength && mOkButton.getVisibility() == View.INVISIBLE) { verifyPasswordAndUnlock(); } } Loading @@ -101,7 +106,7 @@ public class KeyguardPinViewController mUserId = KeyguardUpdateMonitor.getCurrentUser(); mPinLength = mLockPatternUtils.getPinLength(mUserId); mBackspaceKey.setTransparentMode(/* isTransparentMode= */ isAutoConfirmation()); mOkButton.setVisibility(isAutoConfirmation() ? View.INVISIBLE : View.VISIBLE); updateOKButtonVisibility(); updateBackSpaceVisibility(); mPasswordEntry.setUsePinShapes(true); mPasswordEntry.setIsPinHinting(isAutoConfirmation() && isPinHinting()); Loading @@ -115,7 +120,18 @@ public class KeyguardPinViewController mKeyguardUpdateMonitor.needsSlowUnlockTransition(), finishRunnable); } // /** * Updates the visibility of the OK button for auto confirm feature */ private void updateOKButtonVisibility() { mPasswordFailedAttempts = mLockPatternUtils.getCurrentFailedPasswordAttempts(mUserId); if (isAutoConfirmation() && mPasswordFailedAttempts < MIN_FAILED_PIN_ATTEMPTS) { mOkButton.setVisibility(View.INVISIBLE); } else { mOkButton.setVisibility(View.VISIBLE); } } /** * Updates the visibility and the enabled state of the backspace. Loading packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt +17 −1 Original line number Diff line number Diff line Loading @@ -129,10 +129,11 @@ class KeyguardPinViewControllerTest : SysuiTestCase() { } @Test fun startAppearAnimation_withAutoPinConfirmation() { fun startAppearAnimation_withAutoPinConfirmationFailedPasswordAttemptsLessThan5() { `when`(featureFlags.isEnabled(Flags.AUTO_PIN_CONFIRMATION)).thenReturn(true) `when`(lockPatternUtils.getPinLength(anyInt())).thenReturn(6) `when`(lockPatternUtils.isAutoPinConfirmEnabled(anyInt())).thenReturn(true) `when`(lockPatternUtils.getCurrentFailedPasswordAttempts(anyInt())).thenReturn(3) `when`(passwordTextView.text).thenReturn("") pinViewController.startAppearAnimation() Loading @@ -141,4 +142,19 @@ class KeyguardPinViewControllerTest : SysuiTestCase() { verify(passwordTextView).setUsePinShapes(true) verify(passwordTextView).setIsPinHinting(true) } @Test fun startAppearAnimation_withAutoPinConfirmationFailedPasswordAttemptsMoreThan5() { `when`(featureFlags.isEnabled(Flags.AUTO_PIN_CONFIRMATION)).thenReturn(true) `when`(lockPatternUtils.getPinLength(anyInt())).thenReturn(6) `when`(lockPatternUtils.isAutoPinConfirmEnabled(anyInt())).thenReturn(true) `when`(lockPatternUtils.getCurrentFailedPasswordAttempts(anyInt())).thenReturn(6) `when`(passwordTextView.text).thenReturn("") pinViewController.startAppearAnimation() verify(deleteButton).visibility = View.INVISIBLE verify(enterButton).visibility = View.VISIBLE verify(passwordTextView).setUsePinShapes(true) verify(passwordTextView).setIsPinHinting(true) } } Loading
packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java +19 −3 Original line number Diff line number Diff line Loading @@ -38,12 +38,15 @@ public class KeyguardPinViewController private LockPatternUtils mLockPatternUtils; private final FeatureFlags mFeatureFlags; private static final int DEFAULT_PIN_LENGTH = 6; private static final int MIN_FAILED_PIN_ATTEMPTS = 5; private NumPadButton mBackspaceKey; private View mOkButton = mView.findViewById(R.id.key_enter); private int mUserId; private long mPinLength; private int mPasswordFailedAttempts; protected KeyguardPinViewController(KeyguardPINView view, KeyguardUpdateMonitor keyguardUpdateMonitor, SecurityMode securityMode, LockPatternUtils lockPatternUtils, Loading Loading @@ -82,8 +85,10 @@ public class KeyguardPinViewController protected void onUserInput() { super.onUserInput(); if (isAutoConfirmation()) { updateOKButtonVisibility(); updateBackSpaceVisibility(); if (mPasswordEntry.getText().length() == mPinLength) { if (mPasswordEntry.getText().length() == mPinLength && mOkButton.getVisibility() == View.INVISIBLE) { verifyPasswordAndUnlock(); } } Loading @@ -101,7 +106,7 @@ public class KeyguardPinViewController mUserId = KeyguardUpdateMonitor.getCurrentUser(); mPinLength = mLockPatternUtils.getPinLength(mUserId); mBackspaceKey.setTransparentMode(/* isTransparentMode= */ isAutoConfirmation()); mOkButton.setVisibility(isAutoConfirmation() ? View.INVISIBLE : View.VISIBLE); updateOKButtonVisibility(); updateBackSpaceVisibility(); mPasswordEntry.setUsePinShapes(true); mPasswordEntry.setIsPinHinting(isAutoConfirmation() && isPinHinting()); Loading @@ -115,7 +120,18 @@ public class KeyguardPinViewController mKeyguardUpdateMonitor.needsSlowUnlockTransition(), finishRunnable); } // /** * Updates the visibility of the OK button for auto confirm feature */ private void updateOKButtonVisibility() { mPasswordFailedAttempts = mLockPatternUtils.getCurrentFailedPasswordAttempts(mUserId); if (isAutoConfirmation() && mPasswordFailedAttempts < MIN_FAILED_PIN_ATTEMPTS) { mOkButton.setVisibility(View.INVISIBLE); } else { mOkButton.setVisibility(View.VISIBLE); } } /** * Updates the visibility and the enabled state of the backspace. Loading
packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt +17 −1 Original line number Diff line number Diff line Loading @@ -129,10 +129,11 @@ class KeyguardPinViewControllerTest : SysuiTestCase() { } @Test fun startAppearAnimation_withAutoPinConfirmation() { fun startAppearAnimation_withAutoPinConfirmationFailedPasswordAttemptsLessThan5() { `when`(featureFlags.isEnabled(Flags.AUTO_PIN_CONFIRMATION)).thenReturn(true) `when`(lockPatternUtils.getPinLength(anyInt())).thenReturn(6) `when`(lockPatternUtils.isAutoPinConfirmEnabled(anyInt())).thenReturn(true) `when`(lockPatternUtils.getCurrentFailedPasswordAttempts(anyInt())).thenReturn(3) `when`(passwordTextView.text).thenReturn("") pinViewController.startAppearAnimation() Loading @@ -141,4 +142,19 @@ class KeyguardPinViewControllerTest : SysuiTestCase() { verify(passwordTextView).setUsePinShapes(true) verify(passwordTextView).setIsPinHinting(true) } @Test fun startAppearAnimation_withAutoPinConfirmationFailedPasswordAttemptsMoreThan5() { `when`(featureFlags.isEnabled(Flags.AUTO_PIN_CONFIRMATION)).thenReturn(true) `when`(lockPatternUtils.getPinLength(anyInt())).thenReturn(6) `when`(lockPatternUtils.isAutoPinConfirmEnabled(anyInt())).thenReturn(true) `when`(lockPatternUtils.getCurrentFailedPasswordAttempts(anyInt())).thenReturn(6) `when`(passwordTextView.text).thenReturn("") pinViewController.startAppearAnimation() verify(deleteButton).visibility = View.INVISIBLE verify(enterButton).visibility = View.VISIBLE verify(passwordTextView).setUsePinShapes(true) verify(passwordTextView).setIsPinHinting(true) } }