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

Commit 2b897750 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Hide alternateBouncer onTrustChanges, not biometricAuth

The alternate bouncer can hide too early and not end up
running the dismiss action if hidden too early.

Test: atest StatusBarKeyguardViewManagerTest
Test: manually trigger trustGranted from the alternateBouncer
and see that the alternateBouncer dismisses on SFPS supported device
Bug: 289909028

Change-Id: Ibfea5aab7c7325e89c1c78e1566eed297adb22f7
parent 887c92c7
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import com.android.keyguard.KeyguardSecurityModel;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.keyguard.KeyguardViewController;
import com.android.keyguard.TrustGrantFlags;
import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.biometrics.domain.interactor.UdfpsOverlayInteractor;
import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor;
@@ -306,6 +307,16 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    @Nullable private TaskbarDelegate mTaskbarDelegate;
    private final KeyguardUpdateMonitorCallback mUpdateMonitorCallback =
            new KeyguardUpdateMonitorCallback() {
                @Override
                public void onTrustGrantedForCurrentUser(
                        boolean dismissKeyguard,
                        boolean newlyUnlocked,
                        @NonNull TrustGrantFlags flags,
                        @Nullable String message
                ) {
                    updateAlternateBouncerShowing(mAlternateBouncerInteractor.maybeHide());
                }

        @Override
        public void onEmergencyCallAction() {
            // Since we won't get a setOccluded call we have to reset the view manually such that
@@ -431,7 +442,6 @@ 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. */
@@ -1570,14 +1580,6 @@ 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.
+16 −8
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.service.trust.TrustAgentService;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.MotionEvent;
@@ -57,6 +58,8 @@ import com.android.keyguard.KeyguardMessageArea;
import com.android.keyguard.KeyguardMessageAreaController;
import com.android.keyguard.KeyguardSecurityModel;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.keyguard.TrustGrantFlags;
import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.biometrics.domain.interactor.UdfpsOverlayInteractor;
@@ -84,7 +87,6 @@ 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;
@@ -154,7 +156,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
    @Captor
    private ArgumentCaptor<OnBackInvokedCallback> mBackCallbackCaptor;
    @Captor
    private ArgumentCaptor<KeyguardStateController.Callback> mKeyguardStateControllerCallback;
    private ArgumentCaptor<KeyguardUpdateMonitorCallback> mKeyguardUpdateMonitorCallback;


    @Before
@@ -936,18 +938,24 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
    }

    @Test
    public void onDeviceUnlocked_hideAlternateBouncerAndClearMessageArea() {
    public void onTrustChanged_hideAlternateBouncerAndClearMessageArea() {
        // GIVEN keyguard update monitor callback is registered
        verify(mKeyguardUpdateMonitor).registerCallback(mKeyguardUpdateMonitorCallback.capture());

        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();
        // WHEN the device is trusted by active unlock
        mKeyguardUpdateMonitorCallback.getValue().onTrustGrantedForCurrentUser(
                true,
                true,
                new TrustGrantFlags(TrustAgentService.FLAG_GRANT_TRUST_DISMISS_KEYGUARD
                        | TrustAgentService.FLAG_GRANT_TRUST_TEMPORARY_AND_RENEWABLE),
                null
        );

        // THEN the false visibility state is propagated to the keyguardUpdateMonitor
        verify(mKeyguardUpdateMonitor).setAlternateBouncerShowing(eq(false));