From bd8f4dac1bd864195e4a6c6072dc3d8c42b437a3 Mon Sep 17 00:00:00 2001 From: Josh Tsuji Date: Fri, 29 Apr 2022 16:45:45 -0400 Subject: [PATCH] Add bouncer state to KeyguardStateController; disable smartspace transition if bouncer is showing. Bug: 197636887 Test: atest SystemUITests Change-Id: I361625a2072a3e9bdf1cddffe94c6716b519b971 --- .../keyguard/ViewMediatorCallback.java | 6 ----- .../KeyguardUnlockAnimationController.kt | 5 ++++ .../keyguard/KeyguardViewMediator.java | 24 +++++++++++-------- .../statusbar/phone/KeyguardBouncer.java | 4 ++-- .../policy/KeyguardStateController.java | 12 ++++++++++ .../policy/KeyguardStateControllerImpl.java | 15 ++++++++++++ .../statusbar/phone/KeyguardBouncerTest.java | 4 ++-- .../leaks/FakeKeyguardStateController.java | 5 ++++ 8 files changed, 55 insertions(+), 20 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/ViewMediatorCallback.java b/packages/SystemUI/src/com/android/keyguard/ViewMediatorCallback.java index 6e06130366787..334bb1ec12cb9 100644 --- a/packages/SystemUI/src/com/android/keyguard/ViewMediatorCallback.java +++ b/packages/SystemUI/src/com/android/keyguard/ViewMediatorCallback.java @@ -75,12 +75,6 @@ public interface ViewMediatorCallback { */ void playTrustedSound(); - /** - * When the bouncer is shown or hides - * @param shown - */ - void onBouncerVisiblityChanged(boolean shown); - /** * @return true if the screen is on */ diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt index fb09132684ebc..9aebb9d3d822d 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt @@ -813,6 +813,11 @@ class KeyguardUnlockAnimationController @Inject constructor( return false } + // The smartspace is not visible if the bouncer is showing, so don't shared element it. + if (keyguardStateController.isBouncerShowing) { + return false + } + // We started to swipe to dismiss, but now we're doing a fling animation to complete the // dismiss. In this case, the smartspace swiped away with the rest of the keyguard, so don't // do the shared element transition. diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 10ea1e06c6d7f..7becc82edc99b 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -778,16 +778,6 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable, mKeyguardViewControllerLazy.get().onCancelClicked(); } - @Override - public void onBouncerVisiblityChanged(boolean shown) { - synchronized (KeyguardViewMediator.this) { - if (shown) { - mPendingPinLock = false; - } - adjustStatusBarLocked(shown, false); - } - } - @Override public void playTrustedSound() { KeyguardViewMediator.this.playTrustedSound(); @@ -989,6 +979,19 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable, private DozeParameters mDozeParameters; private final KeyguardStateController mKeyguardStateController; + private final KeyguardStateController.Callback mKeyguardStateControllerCallback = + new KeyguardStateController.Callback() { + @Override + public void onBouncerShowingChanged() { + synchronized (KeyguardViewMediator.this) { + if (mKeyguardStateController.isBouncerShowing()) { + mPendingPinLock = false; + } + adjustStatusBarLocked(mKeyguardStateController.isBouncerShowing(), false); + } + } + }; + private final Lazy mKeyguardUnlockAnimationControllerLazy; private final InteractionJankMonitor mInteractionJankMonitor; private boolean mWallpaperSupportsAmbientMode; @@ -1059,6 +1062,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable, statusBarStateController.addCallback(this); mKeyguardStateController = keyguardStateController; + keyguardStateController.addCallback(mKeyguardStateControllerCallback); mKeyguardUnlockAnimationControllerLazy = keyguardUnlockAnimationControllerLazy; mScreenOffAnimationController = screenOffAnimationController; mInteractionJankMonitor = interactionJankMonitor; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java index 69beaf56519f6..0b721383e2d19 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java @@ -220,7 +220,7 @@ public class KeyguardBouncer { DejankUtils.postAfterTraversal(mShowRunnable); } - mCallback.onBouncerVisiblityChanged(true /* shown */); + mKeyguardStateController.notifyBouncerShowing(true /* showing */); dispatchStartingToShow(); } finally { Trace.endSection(); @@ -334,7 +334,7 @@ public class KeyguardBouncer { } mIsScrimmed = false; mFalsingCollector.onBouncerHidden(); - mCallback.onBouncerVisiblityChanged(false /* shown */); + mKeyguardStateController.notifyBouncerShowing(false /* showing */); cancelShowRunnable(); if (mKeyguardViewController != null) { mKeyguardViewController.cancelDismissAction(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateController.java index 233778dbfeb65..15ee553da4573 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateController.java @@ -45,6 +45,11 @@ public interface KeyguardStateController extends CallbackController { */ boolean isShowing(); + /** + * Whether the bouncer (PIN/password entry) is currently visible. + */ + boolean isBouncerShowing(); + /** * If swiping up will unlock without asking for a password. * @see #isUnlocked() @@ -186,6 +191,8 @@ public interface KeyguardStateController extends CallbackController { default void notifyKeyguardDoneFading() {} /** **/ default void notifyKeyguardState(boolean showing, boolean occluded) {} + /** **/ + default void notifyBouncerShowing(boolean showing) {} /** * Updates the keyguard state to reflect that it's in the process of being dismissed, either by @@ -230,6 +237,11 @@ public interface KeyguardStateController extends CallbackController { */ default void onKeyguardShowingChanged() {} + /** + * Called when the bouncer (PIN/password entry) is shown or hidden. + */ + default void onBouncerShowingChanged() {} + /** * Triggered when the device was just unlocked and the lock screen is being dismissed. */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateControllerImpl.java index be5da377e4963..77e285d1e15dc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateControllerImpl.java @@ -63,6 +63,7 @@ public class KeyguardStateControllerImpl implements KeyguardStateController, Dum private boolean mCanDismissLockScreen; private boolean mShowing; + private boolean mBouncerShowing; private boolean mSecure; private boolean mOccluded; @@ -152,6 +153,11 @@ public class KeyguardStateControllerImpl implements KeyguardStateController, Dum return mShowing; } + @Override + public boolean isBouncerShowing() { + return mBouncerShowing; + } + @Override public boolean isMethodSecure() { return mSecure; @@ -327,6 +333,15 @@ public class KeyguardStateControllerImpl implements KeyguardStateController, Dum } } + @Override + public void notifyBouncerShowing(boolean showing) { + if (mBouncerShowing != showing) { + mBouncerShowing = showing; + + new ArrayList<>(mCallbacks).forEach(Callback::onBouncerShowingChanged); + } + } + @Override public void notifyPanelFlingEnd() { mFlingingToDismissKeyguard = false; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java index 4986792373dbc..f43c2a1834657 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java @@ -160,7 +160,7 @@ public class KeyguardBouncerTest extends SysuiTestCase { @Test public void testShow_notifiesVisibility() { mBouncer.show(true); - verify(mViewMediatorCallback).onBouncerVisiblityChanged(eq(true)); + verify(mKeyguardStateController).notifyBouncerShowing(eq(true)); verify(mExpansionCallback).onStartingToShow(); // Not called again when visible @@ -238,7 +238,7 @@ public class KeyguardBouncerTest extends SysuiTestCase { @Test public void testHide_notifiesVisibility() { mBouncer.hide(false); - verify(mViewMediatorCallback).onBouncerVisiblityChanged(eq(false)); + verify(mKeyguardStateController).notifyBouncerShowing(eq(false)); } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/utils/leaks/FakeKeyguardStateController.java b/packages/SystemUI/tests/src/com/android/systemui/utils/leaks/FakeKeyguardStateController.java index aaea4ecdc08dd..95b62a12c621d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/utils/leaks/FakeKeyguardStateController.java +++ b/packages/SystemUI/tests/src/com/android/systemui/utils/leaks/FakeKeyguardStateController.java @@ -48,6 +48,11 @@ public class FakeKeyguardStateController implements KeyguardStateController { return false; } + @Override + public boolean isBouncerShowing() { + return false; + } + @Override public boolean canDismissLockScreen() { return false;