From ce4653f7afa7c24cc34ba4d07974e0805dcdc783 Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Wed, 21 Jun 2023 12:32:55 -0700 Subject: [PATCH 1/3] Ensure that disappear animation callback is run. When we authenticate sim pin with a None security method, we are running into an issue where we are not running the "keyguardDone" runnable when the disappear animation completes. This is because when the sim state changes, we tell the statusbarkeyguardviewmanager to reset. This hides the bouncer and removes the disappear animation finish runnable. When we tell the statusbarkeguardviewmanager to reset, we only want to reset if we are not animating away. Fixes: 288099374 Test: add a unit test Test: unlock sim with none method. Test: disable esim with none method. Test: unlock sim with a pin method. Test: disable esim with pin method. Test: unlock pin method. Change-Id: I52783d0a0d92dbec4dfcfe171df512ec347e4bef --- .../statusbar/phone/StatusBarKeyguardViewManager.java | 2 +- .../phone/StatusBarKeyguardViewManagerTest.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index e63875b92b64a..cb2a78d8be357 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -703,7 +703,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb @Override public void reset(boolean hideBouncerWhenShowing) { - if (mKeyguardStateController.isShowing()) { + if (mKeyguardStateController.isShowing() && !bouncerIsAnimatingAway()) { final boolean isOccluded = mKeyguardStateController.isOccluded(); // Hide quick settings. mShadeViewController.resetViews(/* animate= */ !isOccluded); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java index 548e1b501d45e..c7143debf8a84 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java @@ -736,6 +736,16 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { verify(mAlternateBouncerInteractor, never()).hide(); } + @Test + public void testResetBouncerAnimatingAway() { + reset(mPrimaryBouncerInteractor); + when(mPrimaryBouncerInteractor.isAnimatingAway()).thenReturn(true); + + mStatusBarKeyguardViewManager.reset(true); + + verify(mPrimaryBouncerInteractor, never()).hide(); + } + @Test public void handleDispatchTouchEvent_alternateBouncerNotVisible() { mStatusBarKeyguardViewManager.addCallback(mCallback); From 15a27cdeafcde515623d378a74db3f2da0b111ec Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Thu, 22 Jun 2023 08:37:07 -0700 Subject: [PATCH 2/3] Do not refetch pin length Make sure to use cached pin length to save on performance cost. Fixes: 288308956 Test: authenticate via auto pin confirmation Test: test auto pin confirmation with deleting one char and full deltion Test: test non auto pin screen Change-Id: I9bc97666cd431ed31f933ea6006957f76e9014dc --- .../keyguard/KeyguardPinViewController.java | 41 ++++++++----------- .../keyguard/KeyguardPinViewControllerTest.kt | 38 ++++++++++------- 2 files changed, 41 insertions(+), 38 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java index 3e16d559742d9..6f596843bf9f6 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java @@ -43,6 +43,15 @@ public class KeyguardPinViewController private long mPinLength; private boolean mDisabledAutoConfirmation; + /** + * Responsible for identifying if PIN hinting is to be enabled or not + */ + private boolean mIsPinHinting; + + /** + * Responsible for identifying if auto confirm is enabled or not in Settings + */ + private boolean mIsAutoPinConfirmEnabledInSettings; protected KeyguardPinViewController(KeyguardPINView view, KeyguardUpdateMonitor keyguardUpdateMonitor, @@ -63,6 +72,9 @@ public class KeyguardPinViewController mFeatureFlags = featureFlags; mBackspaceKey = view.findViewById(R.id.delete_button); mPinLength = mLockPatternUtils.getPinLength(KeyguardUpdateMonitor.getCurrentUser()); + mIsPinHinting = mPinLength == DEFAULT_PIN_LENGTH; + mIsAutoPinConfirmEnabledInSettings = mLockPatternUtils.isAutoPinConfirmEnabled( + KeyguardUpdateMonitor.getCurrentUser()); } @Override @@ -82,7 +94,7 @@ public class KeyguardPinViewController protected void onUserInput() { super.onUserInput(); - if (isAutoPinConfirmEnabledInSettings()) { + if (mIsAutoPinConfirmEnabledInSettings) { updateAutoConfirmationState(); if (mPasswordEntry.getText().length() == mPinLength && mOkButton.getVisibility() == View.INVISIBLE) { @@ -130,7 +142,7 @@ public class KeyguardPinViewController * Updates the visibility of the OK button for auto confirm feature */ private void updateOKButtonVisibility() { - if (isAutoPinConfirmEnabledInSettings() && !mDisabledAutoConfirmation) { + if (mIsPinHinting && !mDisabledAutoConfirmation) { mOkButton.setVisibility(View.INVISIBLE); } else { mOkButton.setVisibility(View.VISIBLE); @@ -142,10 +154,9 @@ public class KeyguardPinViewController * Visibility changes are only for auto confirmation configuration. */ private void updateBackSpaceVisibility() { - boolean isAutoConfirmation = isAutoPinConfirmEnabledInSettings(); mBackspaceKey.setTransparentMode(/* isTransparentMode= */ - isAutoConfirmation && !mDisabledAutoConfirmation); - if (isAutoConfirmation) { + mIsAutoPinConfirmEnabledInSettings && !mDisabledAutoConfirmation); + if (mIsAutoPinConfirmEnabledInSettings) { if (mPasswordEntry.getText().length() > 0 || mDisabledAutoConfirmation) { mBackspaceKey.setVisibility(View.VISIBLE); @@ -155,24 +166,8 @@ public class KeyguardPinViewController } } /** Updates whether to use pin hinting or not. */ - void updatePinHinting() { - mPasswordEntry.setIsPinHinting(isAutoPinConfirmEnabledInSettings() && isPinHinting() + private void updatePinHinting() { + mPasswordEntry.setIsPinHinting(mIsAutoPinConfirmEnabledInSettings && mIsPinHinting && !mDisabledAutoConfirmation); } - - /** - * Responsible for identifying if PIN hinting is to be enabled or not - */ - private boolean isPinHinting() { - return mLockPatternUtils.getPinLength(KeyguardUpdateMonitor.getCurrentUser()) - == DEFAULT_PIN_LENGTH; - } - - /** - * Responsible for identifying if auto confirm is enabled or not in Settings - */ - private boolean isAutoPinConfirmEnabledInSettings() { - //Checks if user has enabled the auto confirm in Settings - return mLockPatternUtils.isAutoPinConfirmEnabled(KeyguardUpdateMonitor.getCurrentUser()); - } } diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt index d3b41902499c7..5a56bafc19927 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt @@ -97,21 +97,7 @@ class KeyguardPinViewControllerTest : SysuiTestCase() { `when`(keyguardPinView.findViewById(R.id.delete_button)) .thenReturn(deleteButton) `when`(keyguardPinView.findViewById(R.id.key_enter)).thenReturn(enterButton) - pinViewController = - KeyguardPinViewController( - keyguardPinView, - keyguardUpdateMonitor, - securityMode, - lockPatternUtils, - mKeyguardSecurityCallback, - keyguardMessageAreaControllerFactory, - mLatencyTracker, - liftToActivateListener, - mEmergencyButtonController, - falsingCollector, - postureController, - featureFlags - ) + constructViewController() } @Test @@ -135,8 +121,10 @@ class KeyguardPinViewControllerTest : SysuiTestCase() { `when`(lockPatternUtils.isAutoPinConfirmEnabled(anyInt())).thenReturn(true) `when`(lockPatternUtils.getCurrentFailedPasswordAttempts(anyInt())).thenReturn(3) `when`(passwordTextView.text).thenReturn("") + constructViewController() pinViewController.startAppearAnimation() + verify(deleteButton).visibility = View.INVISIBLE verify(enterButton).visibility = View.INVISIBLE verify(passwordTextView).setUsePinShapes(true) @@ -150,8 +138,10 @@ class KeyguardPinViewControllerTest : SysuiTestCase() { `when`(lockPatternUtils.isAutoPinConfirmEnabled(anyInt())).thenReturn(true) `when`(lockPatternUtils.getCurrentFailedPasswordAttempts(anyInt())).thenReturn(6) `when`(passwordTextView.text).thenReturn("") + constructViewController() pinViewController.startAppearAnimation() + verify(deleteButton).visibility = View.VISIBLE verify(enterButton).visibility = View.VISIBLE verify(passwordTextView).setUsePinShapes(true) @@ -163,4 +153,22 @@ class KeyguardPinViewControllerTest : SysuiTestCase() { pinViewController.handleAttemptLockout(0) verify(lockPatternUtils).getCurrentFailedPasswordAttempts(anyInt()) } + + fun constructViewController() { + pinViewController = + KeyguardPinViewController( + keyguardPinView, + keyguardUpdateMonitor, + securityMode, + lockPatternUtils, + mKeyguardSecurityCallback, + keyguardMessageAreaControllerFactory, + mLatencyTracker, + liftToActivateListener, + mEmergencyButtonController, + falsingCollector, + postureController, + featureFlags + ) + } } From 3bb092b408363e94eb15ce44cce41da5ede3c1d6 Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Thu, 22 Jun 2023 09:46:33 -0700 Subject: [PATCH 3/3] Ensure swipe down works for bouncer to dismiss Also ensure that we don't set translation for sim screens. The translation is causing some nasty flickering and the translation does not serve any purpose. Fixes: 191211136 Test: swipe down to dismiss from sim pin/puk view. Test: swipe down to dismiss from pin view. Test: swipe down to dismis from pattern/password view. Change-Id: I8c2d2ccd7907fa732551fbecb8f0a7c37d4c4755 --- .../com/android/keyguard/KeyguardSecurityContainer.java | 7 +++++++ .../keyguard/KeyguardSecurityContainerController.java | 7 ++++++- .../src/com/android/keyguard/ViewMediatorCallback.java | 5 +++++ .../android/systemui/keyguard/KeyguardViewMediator.java | 5 +++++ .../systemui/keyguard/KeyguardViewMediatorTest.java | 5 +++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java index 841b5b3a1e82a..6853f815a1ffd 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java @@ -281,6 +281,8 @@ public class KeyguardSecurityContainer extends ConstraintLayout { public interface SwipeListener { void onSwipeUp(); + /** */ + void onSwipeDown(); } @VisibleForTesting @@ -543,6 +545,11 @@ public class KeyguardSecurityContainer extends ConstraintLayout { if (mSwipeListener != null) { mSwipeListener.onSwipeUp(); } + } else if (getTranslationY() > TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, + MIN_DRAG_SIZE, getResources().getDisplayMetrics())) { + if (mSwipeListener != null) { + mSwipeListener.onSwipeDown(); + } } } return true; diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java index 7c511a32bb365..880f242c59383 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java @@ -70,11 +70,11 @@ import com.android.systemui.Gefingerpoken; import com.android.systemui.R; import com.android.systemui.biometrics.SideFpsController; import com.android.systemui.biometrics.SideFpsUiRequestSource; +import com.android.systemui.bouncer.domain.interactor.BouncerMessageInteractor; import com.android.systemui.classifier.FalsingA11yDelegate; import com.android.systemui.classifier.FalsingCollector; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.flags.Flags; -import com.android.systemui.bouncer.domain.interactor.BouncerMessageInteractor; import com.android.systemui.keyguard.domain.interactor.KeyguardFaceAuthInteractor; import com.android.systemui.log.SessionTracker; import com.android.systemui.plugins.ActivityStarter; @@ -319,6 +319,11 @@ public class KeyguardSecurityContainerController extends ViewController