Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/AlternateBouncerInteractor.kt +10 −14 Original line number Diff line number Diff line Loading @@ -41,17 +41,6 @@ constructor( var receivedDownTouch = false val isVisible: Flow<Boolean> = bouncerRepository.alternateBouncerVisible private val keyguardStateControllerCallback: KeyguardStateController.Callback = object : KeyguardStateController.Callback { override fun onUnlockedChanged() { maybeHide() } } init { keyguardStateController.addCallback(keyguardStateControllerCallback) } /** * Sets the correct bouncer states to show the alternate bouncer if it can show. * Loading Loading @@ -102,11 +91,18 @@ constructor( return (systemClock.uptimeMillis() - bouncerRepository.lastAlternateBouncerVisibleTime) > MIN_VISIBILITY_DURATION_UNTIL_TOUCHES_DISMISS_ALTERNATE_BOUNCER_MS } private fun maybeHide() { /** * Should only be called through StatusBarKeyguardViewManager which propagates the source of * truth to other concerned controllers. Will hide the alternate bouncer if it's no longer * allowed to show. * * @return true if the alternate bouncer was newly hidden, else false. */ fun maybeHide(): Boolean { if (isVisibleState() && !canShowAlternateBouncerForFingerprint()) { hide() return hide() } return false } companion object { Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +10 −1 Original line number Diff line number Diff line Loading @@ -136,7 +136,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb private final DreamOverlayStateController mDreamOverlayStateController; @Nullable private final FoldAodAnimationController mFoldAodAnimationController; private KeyguardMessageAreaController<AuthKeyguardMessageArea> mKeyguardMessageAreaController; KeyguardMessageAreaController<AuthKeyguardMessageArea> mKeyguardMessageAreaController; private final PrimaryBouncerCallbackInteractor mPrimaryBouncerCallbackInteractor; private final PrimaryBouncerInteractor mPrimaryBouncerInteractor; private final AlternateBouncerInteractor mAlternateBouncerInteractor; Loading Loading @@ -430,6 +430,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mDockManager.addListener(mDockEventListener); mIsDocked = mDockManager.isDocked(); } mKeyguardStateController.addCallback(mKeyguardStateControllerCallback); } /** Register a callback, to be invoked by the Predictive Back system. */ Loading Loading @@ -1564,6 +1565,14 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb || mode == KeyguardSecurityModel.SecurityMode.SimPuk; } private KeyguardStateController.Callback mKeyguardStateControllerCallback = new KeyguardStateController.Callback() { @Override public void onUnlockedChanged() { updateAlternateBouncerShowing(mAlternateBouncerInteractor.maybeHide()); } }; /** * Delegate used to send show and hide events to an alternate authentication method instead of * the regular pin/pattern/password bouncer. Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java +26 −1 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.unfold.SysUIUnfoldComponent; import com.google.common.truth.Truth; Loading Loading @@ -151,13 +152,15 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { private WindowOnBackInvokedDispatcher mOnBackInvokedDispatcher; @Captor private ArgumentCaptor<OnBackInvokedCallback> mBackCallbackCaptor; @Captor private ArgumentCaptor<KeyguardStateController.Callback> mKeyguardStateControllerCallback; @Before public void setUp() { MockitoAnnotations.initMocks(this); when(mContainer.findViewById(anyInt())).thenReturn(mKeyguardMessageArea); when(mKeyguardMessageAreaFactory.create(any(KeyguardMessageArea.class))) when(mKeyguardMessageAreaFactory.create(any())) .thenReturn(mKeyguardMessageAreaController); when(mBouncerView.getDelegate()).thenReturn(mBouncerViewDelegate); when(mBouncerViewDelegate.getBackCallback()).thenReturn(mBouncerViewDelegateBackCallback); Loading Loading @@ -909,4 +912,26 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { // THEN the alternateBouncer doesn't hide verify(mAlternateBouncerInteractor, never()).hide(); } @Test public void onDeviceUnlocked_hideAlternateBouncerAndClearMessageArea() { reset(mKeyguardUpdateMonitor); reset(mKeyguardMessageAreaController); // GIVEN keyguard state controller callback is registered verify(mKeyguardStateController).addCallback(mKeyguardStateControllerCallback.capture()); // GIVEN alternate bouncer state = not visible when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(false); // WHEN the device is unlocked mKeyguardStateControllerCallback.getValue().onUnlockedChanged(); // THEN the false visibility state is propagated to the keyguardUpdateMonitor verify(mKeyguardUpdateMonitor).setAlternateBouncerShowing(eq(false)); // THEN message area visibility updated to FALSE with empty message verify(mKeyguardMessageAreaController).setIsVisible(eq(false)); verify(mKeyguardMessageAreaController).setMessage(eq("")); } } Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/AlternateBouncerInteractor.kt +10 −14 Original line number Diff line number Diff line Loading @@ -41,17 +41,6 @@ constructor( var receivedDownTouch = false val isVisible: Flow<Boolean> = bouncerRepository.alternateBouncerVisible private val keyguardStateControllerCallback: KeyguardStateController.Callback = object : KeyguardStateController.Callback { override fun onUnlockedChanged() { maybeHide() } } init { keyguardStateController.addCallback(keyguardStateControllerCallback) } /** * Sets the correct bouncer states to show the alternate bouncer if it can show. * Loading Loading @@ -102,11 +91,18 @@ constructor( return (systemClock.uptimeMillis() - bouncerRepository.lastAlternateBouncerVisibleTime) > MIN_VISIBILITY_DURATION_UNTIL_TOUCHES_DISMISS_ALTERNATE_BOUNCER_MS } private fun maybeHide() { /** * Should only be called through StatusBarKeyguardViewManager which propagates the source of * truth to other concerned controllers. Will hide the alternate bouncer if it's no longer * allowed to show. * * @return true if the alternate bouncer was newly hidden, else false. */ fun maybeHide(): Boolean { if (isVisibleState() && !canShowAlternateBouncerForFingerprint()) { hide() return hide() } return false } companion object { Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +10 −1 Original line number Diff line number Diff line Loading @@ -136,7 +136,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb private final DreamOverlayStateController mDreamOverlayStateController; @Nullable private final FoldAodAnimationController mFoldAodAnimationController; private KeyguardMessageAreaController<AuthKeyguardMessageArea> mKeyguardMessageAreaController; KeyguardMessageAreaController<AuthKeyguardMessageArea> mKeyguardMessageAreaController; private final PrimaryBouncerCallbackInteractor mPrimaryBouncerCallbackInteractor; private final PrimaryBouncerInteractor mPrimaryBouncerInteractor; private final AlternateBouncerInteractor mAlternateBouncerInteractor; Loading Loading @@ -430,6 +430,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mDockManager.addListener(mDockEventListener); mIsDocked = mDockManager.isDocked(); } mKeyguardStateController.addCallback(mKeyguardStateControllerCallback); } /** Register a callback, to be invoked by the Predictive Back system. */ Loading Loading @@ -1564,6 +1565,14 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb || mode == KeyguardSecurityModel.SecurityMode.SimPuk; } private KeyguardStateController.Callback mKeyguardStateControllerCallback = new KeyguardStateController.Callback() { @Override public void onUnlockedChanged() { updateAlternateBouncerShowing(mAlternateBouncerInteractor.maybeHide()); } }; /** * Delegate used to send show and hide events to an alternate authentication method instead of * the regular pin/pattern/password bouncer. Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java +26 −1 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.unfold.SysUIUnfoldComponent; import com.google.common.truth.Truth; Loading Loading @@ -151,13 +152,15 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { private WindowOnBackInvokedDispatcher mOnBackInvokedDispatcher; @Captor private ArgumentCaptor<OnBackInvokedCallback> mBackCallbackCaptor; @Captor private ArgumentCaptor<KeyguardStateController.Callback> mKeyguardStateControllerCallback; @Before public void setUp() { MockitoAnnotations.initMocks(this); when(mContainer.findViewById(anyInt())).thenReturn(mKeyguardMessageArea); when(mKeyguardMessageAreaFactory.create(any(KeyguardMessageArea.class))) when(mKeyguardMessageAreaFactory.create(any())) .thenReturn(mKeyguardMessageAreaController); when(mBouncerView.getDelegate()).thenReturn(mBouncerViewDelegate); when(mBouncerViewDelegate.getBackCallback()).thenReturn(mBouncerViewDelegateBackCallback); Loading Loading @@ -909,4 +912,26 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { // THEN the alternateBouncer doesn't hide verify(mAlternateBouncerInteractor, never()).hide(); } @Test public void onDeviceUnlocked_hideAlternateBouncerAndClearMessageArea() { reset(mKeyguardUpdateMonitor); reset(mKeyguardMessageAreaController); // GIVEN keyguard state controller callback is registered verify(mKeyguardStateController).addCallback(mKeyguardStateControllerCallback.capture()); // GIVEN alternate bouncer state = not visible when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(false); // WHEN the device is unlocked mKeyguardStateControllerCallback.getValue().onUnlockedChanged(); // THEN the false visibility state is propagated to the keyguardUpdateMonitor verify(mKeyguardUpdateMonitor).setAlternateBouncerShowing(eq(false)); // THEN message area visibility updated to FALSE with empty message verify(mKeyguardMessageAreaController).setIsVisible(eq(false)); verify(mKeyguardMessageAreaController).setMessage(eq("")); } }