diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.kt index cee228252da97..63a1b76b8103b 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.kt @@ -32,6 +32,7 @@ import com.android.systemui.dump.DumpManager import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags import com.android.systemui.keyguard.domain.interactor.AlternateBouncerInteractor +import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerInteractor import com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants import com.android.systemui.lifecycle.repeatWhenAttached @@ -41,7 +42,6 @@ import com.android.systemui.shade.ShadeExpansionStateManager import com.android.systemui.statusbar.LockscreenShadeTransitionController import com.android.systemui.statusbar.StatusBarState import com.android.systemui.statusbar.notification.stack.StackStateAnimator -import com.android.systemui.statusbar.phone.KeyguardBouncer.PrimaryBouncerExpansionCallback import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.KeyguardViewManagerCallback import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.LegacyAlternateBouncer diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java index 3106173d81b22..33c8379d2e5cc 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java @@ -38,6 +38,7 @@ import com.android.systemui.dreams.complication.ComplicationHostViewController; import com.android.systemui.dreams.dagger.DreamOverlayComponent; import com.android.systemui.dreams.dagger.DreamOverlayModule; import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor; +import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback; import com.android.systemui.statusbar.BlurUtils; import com.android.systemui.statusbar.phone.KeyguardBouncer; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; @@ -85,8 +86,9 @@ public class DreamOverlayContainerViewController extends ViewController() - private var expansionCallbacks = ArrayList() + private var resetCallbacks = ListenerSet() + private var expansionCallbacks = ArrayList() + /** Add a KeyguardResetCallback. */ - fun addKeyguardResetCallback(callback: KeyguardBouncer.KeyguardResetCallback) { + fun addKeyguardResetCallback(callback: KeyguardResetCallback) { resetCallbacks.addIfAbsent(callback) } /** Remove a KeyguardResetCallback. */ - fun removeKeyguardResetCallback(callback: KeyguardBouncer.KeyguardResetCallback) { + fun removeKeyguardResetCallback(callback: KeyguardResetCallback) { resetCallbacks.remove(callback) } /** Adds a callback to listen to bouncer expansion updates. */ - fun addBouncerExpansionCallback(callback: KeyguardBouncer.PrimaryBouncerExpansionCallback) { + fun addBouncerExpansionCallback(callback: PrimaryBouncerExpansionCallback) { if (!expansionCallbacks.contains(callback)) { expansionCallbacks.add(callback) } @@ -48,7 +50,7 @@ class PrimaryBouncerCallbackInteractor @Inject constructor() { * Removes a previously added callback. If the callback was never added, this method does * nothing. */ - fun removeBouncerExpansionCallback(callback: KeyguardBouncer.PrimaryBouncerExpansionCallback) { + fun removeBouncerExpansionCallback(callback: PrimaryBouncerExpansionCallback) { expansionCallbacks.remove(callback) } @@ -99,4 +101,40 @@ class PrimaryBouncerCallbackInteractor @Inject constructor() { callback.onKeyguardReset() } } + + /** Callback updated when the primary bouncer's show and hide states change. */ + interface PrimaryBouncerExpansionCallback { + /** + * Invoked when the bouncer expansion reaches [EXPANSION_VISIBLE]. This is NOT called each + * time the bouncer is shown, but rather only when the fully shown amount has changed based + * on the panel expansion. The bouncer's visibility can still change when the expansion + * amount hasn't changed. See [PrimaryBouncerInteractor.isFullyShowing] for the checks for + * the bouncer showing state. + */ + fun onFullyShown() {} + + /** Invoked when the bouncer is starting to transition to a hidden state. */ + fun onStartingToHide() {} + + /** Invoked when the bouncer is starting to transition to a visible state. */ + fun onStartingToShow() {} + + /** Invoked when the bouncer expansion reaches [EXPANSION_HIDDEN]. */ + fun onFullyHidden() {} + + /** + * From 0f [EXPANSION_VISIBLE] when fully visible to 1f [EXPANSION_HIDDEN] when fully hidden + */ + fun onExpansionChanged(bouncerHideAmount: Float) {} + + /** + * Invoked when visibility of KeyguardBouncer has changed. Note the bouncer expansion can be + * [EXPANSION_VISIBLE], but the view's visibility can be [View.INVISIBLE]. + */ + fun onVisibilityChanged(isVisible: Boolean) {} + } + + interface KeyguardResetCallback { + fun onKeyguardReset() + } } 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 f08de85ec02c3..d31875935dd3f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java @@ -46,6 +46,8 @@ import com.android.systemui.DejankUtils; import com.android.systemui.classifier.FalsingCollector; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.keyguard.DismissCallbackRegistry; +import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.KeyguardResetCallback; +import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback; import com.android.systemui.shared.system.SysUiStatsLog; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.util.ListenerSet; @@ -658,56 +660,6 @@ public class KeyguardBouncer { mExpansionCallbacks.remove(callback); } - /** - * Callback updated when the primary bouncer's show and hide states change. - */ - public interface PrimaryBouncerExpansionCallback { - /** - * Invoked when the bouncer expansion reaches {@link KeyguardBouncer#EXPANSION_VISIBLE}. - * This is NOT called each time the bouncer is shown, but rather only when the fully - * shown amount has changed based on the panel expansion. The bouncer's visibility - * can still change when the expansion amount hasn't changed. - * See {@link KeyguardBouncer#isShowing()} for the checks for the bouncer showing state. - */ - default void onFullyShown() { - } - - /** - * Invoked when the bouncer is starting to transition to a hidden state. - */ - default void onStartingToHide() { - } - - /** - * Invoked when the bouncer is starting to transition to a visible state. - */ - default void onStartingToShow() { - } - - /** - * Invoked when the bouncer expansion reaches {@link KeyguardBouncer#EXPANSION_HIDDEN}. - */ - default void onFullyHidden() { - } - - /** - * From 0f {@link KeyguardBouncer#EXPANSION_VISIBLE} when fully visible - * to 1f {@link KeyguardBouncer#EXPANSION_HIDDEN} when fully hidden - */ - default void onExpansionChanged(float bouncerHideAmount) {} - - /** - * Invoked when visibility of KeyguardBouncer has changed. - * Note the bouncer expansion can be {@link KeyguardBouncer#EXPANSION_VISIBLE}, but the - * view's visibility can be {@link View.INVISIBLE}. - */ - default void onVisibilityChanged(boolean isVisible) {} - } - - public interface KeyguardResetCallback { - void onKeyguardReset(); - } - /** Create a {@link KeyguardBouncer} once a container and bouncer callback are available. */ public static class Factory { private final Context mContext; 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 1dc34fad532a5..be06b05fc1361 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -62,6 +62,7 @@ import com.android.systemui.flags.Flags; import com.android.systemui.keyguard.data.BouncerView; import com.android.systemui.keyguard.domain.interactor.AlternateBouncerInteractor; import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor; +import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback; import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerInteractor; import com.android.systemui.navigationbar.NavigationBarView; import com.android.systemui.navigationbar.NavigationModeController; @@ -78,7 +79,6 @@ import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.RemoteInputController; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.SysuiStatusBarStateController; -import com.android.systemui.statusbar.phone.KeyguardBouncer.PrimaryBouncerExpansionCallback; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.unfold.FoldAodAnimationController; diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java index 813eeeb557b84..7715f7fc5dc90 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java @@ -32,9 +32,9 @@ import android.view.MotionEvent; import androidx.test.filters.SmallTest; +import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback; import com.android.systemui.shade.ShadeExpansionListener; import com.android.systemui.statusbar.StatusBarState; -import com.android.systemui.statusbar.phone.KeyguardBouncer; import org.junit.Test; import org.junit.runner.RunWith; @@ -46,9 +46,9 @@ import org.mockito.Captor; @TestableLooper.RunWithLooper(setAsMainLooper = true) public class UdfpsKeyguardViewControllerTest extends UdfpsKeyguardViewControllerBaseTest { - private @Captor ArgumentCaptor + private @Captor ArgumentCaptor mBouncerExpansionCallbackCaptor; - private KeyguardBouncer.PrimaryBouncerExpansionCallback mBouncerExpansionCallback; + private PrimaryBouncerExpansionCallback mBouncerExpansionCallback; @Override public UdfpsKeyguardViewController createUdfpsKeyguardViewController() { diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java index 2799a25316d06..ff883eb16bdec 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java @@ -37,9 +37,9 @@ import com.android.keyguard.BouncerPanelExpansionCalculator; import com.android.systemui.SysuiTestCase; import com.android.systemui.dreams.complication.ComplicationHostViewController; import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor; +import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback; import com.android.systemui.statusbar.BlurUtils; import com.android.systemui.statusbar.phone.KeyguardBouncer; -import com.android.systemui.statusbar.phone.KeyguardBouncer.PrimaryBouncerExpansionCallback; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import org.junit.Before; diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerCallbackInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerCallbackInteractorTest.kt index db9c4e713e377..fbfeca9c2a25b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerCallbackInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerCallbackInteractorTest.kt @@ -19,7 +19,6 @@ package com.android.systemui.keyguard.domain.interactor import android.view.View import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.statusbar.phone.KeyguardBouncer import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -34,8 +33,10 @@ class PrimaryBouncerCallbackInteractorTest : SysuiTestCase() { private val mPrimaryBouncerCallbackInteractor = PrimaryBouncerCallbackInteractor() @Mock private lateinit var mPrimaryBouncerExpansionCallback: - KeyguardBouncer.PrimaryBouncerExpansionCallback - @Mock private lateinit var keyguardResetCallback: KeyguardBouncer.KeyguardResetCallback + PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback + @Mock + private lateinit var keyguardResetCallback: + PrimaryBouncerCallbackInteractor.KeyguardResetCallback @Before fun setup() { 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 7ad9cc27982a3..2f495355df407 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 @@ -58,8 +58,8 @@ import com.android.systemui.DejankUtils; import com.android.systemui.SysuiTestCase; import com.android.systemui.classifier.FalsingCollector; import com.android.systemui.keyguard.DismissCallbackRegistry; +import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback; import com.android.systemui.plugins.ActivityStarter.OnDismissAction; -import com.android.systemui.statusbar.phone.KeyguardBouncer.PrimaryBouncerExpansionCallback; import com.android.systemui.statusbar.policy.KeyguardStateController; import org.junit.Assert; @@ -87,7 +87,7 @@ public class KeyguardBouncerTest extends SysuiTestCase { @Mock private KeyguardHostViewController mKeyguardHostViewController; @Mock - private KeyguardBouncer.PrimaryBouncerExpansionCallback mExpansionCallback; + private PrimaryBouncerExpansionCallback mExpansionCallback; @Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor; @Mock 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 dea4a7d19dcbc..1ba0a36fb05dc 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 @@ -63,6 +63,7 @@ import com.android.systemui.keyguard.data.BouncerView; import com.android.systemui.keyguard.data.BouncerViewDelegate; import com.android.systemui.keyguard.domain.interactor.AlternateBouncerInteractor; import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor; +import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback; import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerInteractor; import com.android.systemui.navigationbar.NavigationModeController; import com.android.systemui.plugins.ActivityStarter.OnDismissAction; @@ -126,7 +127,8 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { @Mock private OnBackAnimationCallback mBouncerViewDelegateBackCallback; private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; - private KeyguardBouncer.PrimaryBouncerExpansionCallback mBouncerExpansionCallback; + private PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback + mBouncerExpansionCallback; private FakeKeyguardStateController mKeyguardStateController = spy(new FakeKeyguardStateController()); @@ -193,8 +195,8 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { mNotificationContainer, mBypassController); mStatusBarKeyguardViewManager.show(null); - ArgumentCaptor callbackArgumentCaptor = - ArgumentCaptor.forClass(KeyguardBouncer.PrimaryBouncerExpansionCallback.class); + ArgumentCaptor callbackArgumentCaptor = + ArgumentCaptor.forClass(PrimaryBouncerExpansionCallback.class); verify(mPrimaryBouncerCallbackInteractor).addBouncerExpansionCallback( callbackArgumentCaptor.capture()); mBouncerExpansionCallback = callbackArgumentCaptor.getValue(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest_Old.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest_Old.java index 0605b8d43f659..55ab6812da911 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest_Old.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest_Old.java @@ -60,6 +60,7 @@ import com.android.systemui.keyguard.data.BouncerView; import com.android.systemui.keyguard.data.BouncerViewDelegate; import com.android.systemui.keyguard.domain.interactor.AlternateBouncerInteractor; import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor; +import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback; import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerInteractor; import com.android.systemui.navigationbar.NavigationModeController; import com.android.systemui.plugins.ActivityStarter.OnDismissAction; @@ -126,7 +127,8 @@ public class StatusBarKeyguardViewManagerTest_Old extends SysuiTestCase { @Mock private BouncerViewDelegate mBouncerViewDelegate; private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; - private KeyguardBouncer.PrimaryBouncerExpansionCallback mBouncerExpansionCallback; + private PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback + mBouncerExpansionCallback; private FakeKeyguardStateController mKeyguardStateController = spy(new FakeKeyguardStateController()); @@ -141,7 +143,7 @@ public class StatusBarKeyguardViewManagerTest_Old extends SysuiTestCase { MockitoAnnotations.initMocks(this); when(mKeyguardBouncerFactory.create( any(ViewGroup.class), - any(KeyguardBouncer.PrimaryBouncerExpansionCallback.class))) + any(PrimaryBouncerExpansionCallback.class))) .thenReturn(mPrimaryBouncer); when(mCentralSurfaces.getBouncerContainer()).thenReturn(mContainer); when(mContainer.findViewById(anyInt())).thenReturn(mKeyguardMessageArea); @@ -189,8 +191,8 @@ public class StatusBarKeyguardViewManagerTest_Old extends SysuiTestCase { mNotificationContainer, mBypassController); mStatusBarKeyguardViewManager.show(null); - ArgumentCaptor callbackArgumentCaptor = - ArgumentCaptor.forClass(KeyguardBouncer.PrimaryBouncerExpansionCallback.class); + ArgumentCaptor callbackArgumentCaptor = + ArgumentCaptor.forClass(PrimaryBouncerExpansionCallback.class); verify(mKeyguardBouncerFactory).create(any(ViewGroup.class), callbackArgumentCaptor.capture()); mBouncerExpansionCallback = callbackArgumentCaptor.getValue();