From 20d4c6a6c8cc9e55b6a24a3f8846faabaf04265b Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Mon, 13 Feb 2023 12:25:12 -0800 Subject: [PATCH] Destroy and reinflate bouncer before showing Due to various bugs and settingns changes, it makes sense to entirely refresh the bouncer view before showing. This should significantly reduce the number of incoming bugs where bouncer is not showing or is not responding to settings changes. **Ensure that password view shows by ensuring that mDisappearAnimation running is set back to false. Fixes: 260958175 Fixes: 266840428 Fixes: 268226007 Fixes: 267363062 Test: open sim pin, sim puk, password, pattern, pin. Test: change pattern visible to see changes reflected on screen. Test: change show password characters to see changes reflected on screen. Change-Id: Ib2b0ab829eb2eaff6de0dea1268fd934f30e645f --- .../keyguard/KeyguardHostViewController.java | 33 ++++++++++--------- .../KeyguardSecurityContainerController.java | 9 +++-- .../ui/binder/KeyguardBouncerViewBinder.kt | 16 ++------- ...yguardSecurityContainerControllerTest.java | 8 +++++ 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java index 61394035d731b..77f6318738a79 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java @@ -206,6 +206,13 @@ public class KeyguardHostViewController extends ViewController mKeyguardSecurityContainerController.reset(); } + /** + * Reinflate the view flipper child view. + */ + public void reinflateViewFlipper() { + mKeyguardSecurityContainerController.reinflateViewFlipper(); + } + /** * Dismisses the keyguard by going to the next screen or making it gone. * @param targetUserId a user that needs to be the foreground user at the dismissal completion. @@ -232,23 +239,19 @@ public class KeyguardHostViewController extends ViewController /** * Starts the animation when the Keyguard gets shown. */ - public void appear(int statusBarHeight) { + public void appear() { // We might still be collapsed and the view didn't have time to layout yet or still // be small, let's wait on the predraw to do the animation in that case. - if (mView.getHeight() != 0 && mView.getHeight() != statusBarHeight) { - mKeyguardSecurityContainerController.startAppearAnimation(); - } else { - mView.getViewTreeObserver().addOnPreDrawListener( - new ViewTreeObserver.OnPreDrawListener() { - @Override - public boolean onPreDraw() { - mView.getViewTreeObserver().removeOnPreDrawListener(this); - mKeyguardSecurityContainerController.startAppearAnimation(); - return true; - } - }); - mView.requestLayout(); - } + mView.getViewTreeObserver().addOnPreDrawListener( + new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + mView.getViewTreeObserver().removeOnPreDrawListener(this); + mKeyguardSecurityContainerController.startAppearAnimation(); + return true; + } + }); + mView.requestLayout(); } /** diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java index 9fcacce311d1b..5476a0c40bdaa 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java @@ -743,17 +743,20 @@ public class KeyguardSecurityContainerController extends ViewController hostViewController.showErrorMessage(errorMessage) } hostViewController.showPrimarySecurityScreen() - hostViewController.appear( - SystemBarUtils.getStatusBarHeight(view.context) - ) + hostViewController.appear() hostViewController.onResume() } } @@ -159,15 +158,6 @@ object KeyguardBouncerViewBinder { } } - launch { - viewModel.isBouncerVisible - .filter { !it } - .collect { - // Remove existing input for security reasons. - hostViewController.resetSecurityContainer() - } - } - launch { viewModel.keyguardPosition.collect { position -> hostViewController.updateKeyguardPosition(position) diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java index 075ef9df9664d..885920bbc2c3c 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java @@ -600,6 +600,14 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase { any(KeyguardSecurityCallback.class)); } + @Test + public void testReinflateViewFlipper() { + mKeyguardSecurityContainerController.reinflateViewFlipper(); + verify(mKeyguardSecurityViewFlipperController).clearViews(); + verify(mKeyguardSecurityViewFlipperController).getSecurityView(any(SecurityMode.class), + any(KeyguardSecurityCallback.class)); + } + private KeyguardSecurityContainer.SwipeListener getRegisteredSwipeListener() { mKeyguardSecurityContainerController.onViewAttached(); verify(mView).setSwipeListener(mSwipeListenerArgumentCaptor.capture());