From 8ed0d525afc9efb076d337ffe3b10b9336f49bba Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Wed, 19 Oct 2022 10:36:54 -0700 Subject: [PATCH] [Bouncer] Fix MODERN BOUNCER issues. Fixes a CTS failure by ensuring that isShowing is false when we are invoking our disappear animation finish runnable. We do this buy setting the state flow to null after we run the runnable. Fix an instance where we are calling bouncer.isShowing and transition it to the correct method. Fix BouncerView implementation. We set the delegate after the constructor of the StatusBarkeyguardViewManager so holding it in reference makes it null. Bug: 240299776 Test: Manual and atest KeyguardLockedTests#testEnterPipOverKeyguard --verbose Change-Id: I62f24e06481fcabfcfe6f5d5469b2513fef0ec83 --- .../domain/interactor/BouncerInteractor.kt | 2 +- .../phone/StatusBarKeyguardViewManager.java | 25 +++++++++---------- .../StatusBarKeyguardViewManagerTest.java | 1 - 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/BouncerInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/BouncerInteractor.kt index 7d4db37c6b0f4..2af9318d92ec3 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/BouncerInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/BouncerInteractor.kt @@ -273,8 +273,8 @@ constructor( /** Tell the bouncer to start the pre hide animation. */ fun startDisappearAnimation(runnable: Runnable) { val finishRunnable = Runnable { - repository.setStartDisappearAnimation(null) runnable.run() + repository.setStartDisappearAnimation(null) } repository.setStartDisappearAnimation(finishRunnable) } 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 3a1c03d72a7e9..5c8e32506c9cb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -60,7 +60,6 @@ import com.android.systemui.dreams.DreamOverlayStateController; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.flags.Flags; import com.android.systemui.keyguard.data.BouncerView; -import com.android.systemui.keyguard.data.BouncerViewDelegate; import com.android.systemui.keyguard.domain.interactor.BouncerCallbackInteractor; import com.android.systemui.keyguard.domain.interactor.BouncerInteractor; import com.android.systemui.navigationbar.NavigationBarView; @@ -136,7 +135,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb private KeyguardMessageAreaController mKeyguardMessageAreaController; private final BouncerCallbackInteractor mBouncerCallbackInteractor; private final BouncerInteractor mBouncerInteractor; - private final BouncerViewDelegate mBouncerViewDelegate; + private final BouncerView mBouncerView; private final Lazy mShadeController; private final BouncerExpansionCallback mExpansionCallback = new BouncerExpansionCallback() { @@ -327,7 +326,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mKeyguardSecurityModel = keyguardSecurityModel; mBouncerCallbackInteractor = bouncerCallbackInteractor; mBouncerInteractor = bouncerInteractor; - mBouncerViewDelegate = bouncerView.getDelegate(); + mBouncerView = bouncerView; mFoldAodAnimationController = sysUIUnfoldComponent .map(SysUIUnfoldComponent::getFoldAodAnimationController).orElse(null); mIsModernBouncerEnabled = featureFlags.isEnabled(Flags.MODERN_BOUNCER); @@ -804,7 +803,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb private void setDozing(boolean dozing) { if (mDozing != dozing) { mDozing = dozing; - if (dozing || mBouncer.needsFullscreenBouncer() + if (dozing || needsFullscreenBouncer() || mKeyguardStateController.isOccluded()) { reset(dozing /* hideBouncerWhenShowing */); } @@ -1082,7 +1081,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb * @return whether a back press can be handled right now. */ public boolean canHandleBackPressed() { - return mBouncer.isShowing(); + return bouncerIsShowing(); } /** @@ -1125,8 +1124,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } public boolean isFullscreenBouncer() { - if (mBouncerViewDelegate != null) { - return mBouncerViewDelegate.isFullScreenBouncer(); + if (mBouncerView.getDelegate() != null) { + return mBouncerView.getDelegate().isFullScreenBouncer(); } return mBouncer != null && mBouncer.isFullscreenBouncer(); } @@ -1285,15 +1284,15 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } public boolean shouldDismissOnMenuPressed() { - if (mBouncerViewDelegate != null) { - return mBouncerViewDelegate.shouldDismissOnMenuPressed(); + if (mBouncerView.getDelegate() != null) { + return mBouncerView.getDelegate().shouldDismissOnMenuPressed(); } return mBouncer != null && mBouncer.shouldDismissOnMenuPressed(); } public boolean interceptMediaKey(KeyEvent event) { - if (mBouncerViewDelegate != null) { - return mBouncerViewDelegate.interceptMediaKey(event); + if (mBouncerView.getDelegate() != null) { + return mBouncerView.getDelegate().interceptMediaKey(event); } return mBouncer != null && mBouncer.interceptMediaKey(event); } @@ -1302,8 +1301,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb * @return true if the pre IME back event should be handled */ public boolean dispatchBackKeyEventPreIme() { - if (mBouncerViewDelegate != null) { - return mBouncerViewDelegate.dispatchBackKeyEventPreIme(); + if (mBouncerView.getDelegate() != null) { + return mBouncerView.getDelegate().dispatchBackKeyEventPreIme(); } return mBouncer != null && mBouncer.dispatchBackKeyEventPreIme(); } 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 8da8d049516ee..0c35659b458ad 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 @@ -117,7 +117,6 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { @Mock private BouncerCallbackInteractor mBouncerCallbackInteractor; @Mock private BouncerInteractor mBouncerInteractor; @Mock private BouncerView mBouncerView; -// @Mock private WeakReference mBouncerViewDelegateWeakReference; @Mock private BouncerViewDelegate mBouncerViewDelegate; private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;