Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d0f9c7c0 authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "Always go through StatusBarKeyguardViewManager for altBouncer updates" into udc-dev

parents 3a2bda18 19b19cd4
Loading
Loading
Loading
Loading
+10 −14
Original line number Diff line number Diff line
@@ -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.
     *
@@ -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 {
+10 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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. */
@@ -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.
+26 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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);
@@ -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(""));
    }
}