diff options
| author | 2023-02-08 10:34:02 -0800 | |
|---|---|---|
| committer | 2023-02-10 19:31:02 -0800 | |
| commit | 028de77c85d23d27f9a4f387fcadf380c35f90da (patch) | |
| tree | a403e3ea52aa14dbb68e1333f556078ae6b0ad1c | |
| parent | a882d8bf564cf01de6959731666db5c7eabf0b3e (diff) | |
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.
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: I8d7a906866888ad292bd8f813cdba99920a56884
4 files changed, 33 insertions, 34 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java index 61394035d731..1051de358f98 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java @@ -202,8 +202,11 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView> mKeyguardSecurityContainerController.onPause(); } - public void resetSecurityContainer() { - mKeyguardSecurityContainerController.reset(); + /** + * Reinflate the view flipper child view. + */ + public void reinflateViewFlipper() { + mKeyguardSecurityContainerController.reinflateViewFlipper(); } /** @@ -232,23 +235,19 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView> /** * 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 9fcacce311d1..5476a0c40bda 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<Keyguard } private void reloadColors() { - resetViewFlipper(); + reinflateViewFlipper(); mView.reloadColors(); } /** Handles density or font scale changes. */ private void onDensityOrFontScaleChanged() { - resetViewFlipper(); + reinflateViewFlipper(); mView.onDensityOrFontScaleChanged(); } - private void resetViewFlipper() { + /** + * Reinflate the view flipper child view. + */ + public void reinflateViewFlipper() { mSecurityViewFlipperController.clearViews(); mSecurityViewFlipperController.getSecurityView(mCurrentSecurityMode, mKeyguardSecurityCallback); diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBouncerViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBouncerViewBinder.kt index 9f09d53c99f3..bb0d260f8b7a 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBouncerViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBouncerViewBinder.kt @@ -22,7 +22,6 @@ import android.view.ViewGroup import android.window.OnBackAnimationCallback import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle -import com.android.internal.policy.SystemBarUtils import com.android.keyguard.KeyguardHostViewController import com.android.keyguard.KeyguardSecurityModel import com.android.keyguard.KeyguardUpdateMonitor @@ -98,14 +97,14 @@ object KeyguardBouncerViewBinder { viewModel.setBouncerViewDelegate(delegate) launch { viewModel.show.collect { + // Reset Security Container entirely. + hostViewController.reinflateViewFlipper() hostViewController.showPromptReason(it.promptReason) it.errorMessage?.let { errorMessage -> hostViewController.showErrorMessage(errorMessage) } hostViewController.showPrimarySecurityScreen() - hostViewController.appear( - SystemBarUtils.getStatusBarHeight(view.context) - ) + hostViewController.appear() hostViewController.onResume() } } @@ -114,7 +113,6 @@ object KeyguardBouncerViewBinder { viewModel.hide.collect { hostViewController.cancelDismissAction() hostViewController.cleanUp() - hostViewController.resetSecurityContainer() } } @@ -160,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 075ef9df9664..885920bbc2c3 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()); |