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

Commit e0516d5a authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Fix issue where auth wouldn't be triggered

An auth interrupt should trigger authentication even if the device
is in non-interactive state.

Bug: 123581946
Test: manual, simulating auth interrupt
Test: atest StatusBarTest
Change-Id: Ib9113bdda40f309b4289e72dd6133f0b04aa23d9
parent 027b668b
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -205,6 +205,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    private boolean mKeyguardGoingAway;
    private boolean mGoingToSleep;
    private boolean mBouncer;
    private boolean mAuthInterruptActive;
    private boolean mBootCompleted;
    private boolean mNeedsSlowUnlockTransition;
    private boolean mHasLockscreenWallpaper;
@@ -1565,10 +1566,15 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    }

    /**
     * Request passive authentication, when sensors detect that a user might be present.
     * Called whenever passive authentication is requested or aborted by a sensor.
     * @param active If the interrupt started or ended.
     */
    public void onAuthInterruptDetected() {
        if (DEBUG) Log.d(TAG, "onAuthInterruptDetected()");
    public void onAuthInterruptDetected(boolean active) {
        if (DEBUG) Log.d(TAG, "onAuthInterruptDetected(" + active + ")");
        if (mAuthInterruptActive == active) {
            return;
        }
        mAuthInterruptActive = active;
        updateFaceListeningState();
    }

@@ -1612,7 +1618,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        final boolean awakeKeyguard = mKeyguardIsVisible && mDeviceInteractive && !mGoingToSleep;
        final int user = getCurrentUser();

        return (mBouncer || awakeKeyguard || shouldListenForFaceAssistant())
        return (mBouncer || mAuthInterruptActive || awakeKeyguard || shouldListenForFaceAssistant())
                && !mSwitchingUser && !getUserCanSkipBouncer(user) && !isFaceDisabled(user)
                && !mKeyguardGoingAway && !mFaceLockedOut && mFaceSettingEnabledForUser
                && mUserManager.isUserUnlocked(user);
+4 −5
Original line number Diff line number Diff line
@@ -3895,11 +3895,7 @@ public class StatusBar extends SystemUI implements DemoMode,
                return;
            }

            if (mKeyguardUpdateMonitor != null
                    && reason == DozeLog.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN) {
                mKeyguardUpdateMonitor.onAuthInterruptDetected();
            }

            boolean passiveAuthInterrupt = reason == DozeLog.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN;
            // Set the state to pulsing, so ScrimController will know what to do once we ask it to
            // execute the transition. The pulse callback will then be invoked when the scrims
            // are black, indicating that StatusBar is ready to present the rest of the UI.
@@ -3925,6 +3921,9 @@ public class StatusBar extends SystemUI implements DemoMode,
                    mNotificationPanel.setPulsing(pulsing);
                    mVisualStabilityManager.setPulsing(pulsing);
                    mIgnoreTouchWhilePulsing = false;
                    if (mKeyguardUpdateMonitor != null && passiveAuthInterrupt) {
                        mKeyguardUpdateMonitor.onAuthInterruptDetected(pulsing /* active */);
                    }
                    updateScrimController();
                }
            }, reason);
+8 −2
Original line number Diff line number Diff line
@@ -655,13 +655,19 @@ public class StatusBarTest extends SysuiTestCase {
                        DozeLog.REASON_SENSOR_DOUBLE_TAP,
                        DozeLog.REASON_SENSOR_TAP));

        doAnswer(invocation -> {
            DozeHost.PulseCallback callback = invocation.getArgument(0);
            callback.onPulseStarted();
            return null;
        }).when(mDozeScrimController).pulse(any(), anyInt());

        for (int i = 0; i < DozeLog.REASONS; i++) {
            reset(mKeyguardUpdateMonitor);
            mStatusBar.mDozeServiceHost.pulseWhileDozing(mock(DozeHost.PulseCallback.class), i);
            if (reasonsWantingAuth.contains(i)) {
                verify(mKeyguardUpdateMonitor).onAuthInterruptDetected();
                verify(mKeyguardUpdateMonitor).onAuthInterruptDetected(eq(true));
            } else if (reasonsSkippingAuth.contains(i) || reasonsThatDontPulse.contains(i)) {
                verify(mKeyguardUpdateMonitor, never()).onAuthInterruptDetected();
                verify(mKeyguardUpdateMonitor, never()).onAuthInterruptDetected(eq(true));
            } else {
                throw new AssertionError("Reason " + i + " isn't specified as wanting or skipping"
                        + " passive auth. Please consider how this pulse reason should behave.");