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

Commit 1c0ca5ca authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "For devices w/o haptics, show bouncer on biometric fail" into tm-qpr-dev

parents 6e5aa44a 44fb5455
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -3643,6 +3643,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        mHandler.sendEmptyMessage(MSG_KEYGUARD_DISMISS_ANIMATION_FINISHED);
    }

    /**
     * @return true when the screen is on (including when a screensaver is showing),
     * false when the screen is OFF or DOZE (including showing AOD UI)
     */
    public boolean isDeviceInteractive() {
        return mDeviceInteractive;
    }
@@ -3785,6 +3789,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            pw.println("    mFingerprintLockedOut=" + mFingerprintLockedOut);
            pw.println("    mFingerprintLockedOutPermanent=" + mFingerprintLockedOutPermanent);
            pw.println("    enabledByUser=" + mBiometricEnabledForUser.get(userId));
            pw.println("    mKeyguardOccluded=" + mKeyguardOccluded);
            pw.println("    mIsDreaming=" + mIsDreaming);
            if (isUdfpsSupported()) {
                pw.println("        udfpsEnrolled=" + isUdfpsEnrolled());
                pw.println("        shouldListenForUdfps=" + shouldListenForFingerprint(true));
+4 −2
Original line number Diff line number Diff line
@@ -448,7 +448,6 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
        }
        // During wake and unlock, we need to draw black before waking up to avoid abrupt
        // brightness changes due to display state transitions.
        boolean alwaysOnEnabled = mDozeParameters.getAlwaysOn();
        Runnable wakeUp = ()-> {
            if (!wasDeviceInteractive) {
                if (DEBUG_BIO_WAKELOCK) {
@@ -659,7 +658,10 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
            mLatencyTracker.onActionCancel(action);
        }

        if (biometricSourceType == BiometricSourceType.FINGERPRINT
        if (!mVibratorHelper.hasVibrator()
                && (!mUpdateMonitor.isDeviceInteractive() || mUpdateMonitor.isDreaming())) {
            startWakeAndUnlock(MODE_SHOW_BOUNCER);
        } else if (biometricSourceType == BiometricSourceType.FINGERPRINT
                && mUpdateMonitor.isUdfpsSupported()) {
            long currUptimeMillis = SystemClock.uptimeMillis();
            if (currUptimeMillis - mLastFpFailureUptimeMillis < mConsecutiveFpFailureThreshold) {
+32 −0
Original line number Diff line number Diff line
@@ -131,6 +131,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
        when(mKeyguardBypassController.onBiometricAuthenticated(any(), anyBoolean()))
                .thenReturn(true);
        when(mAuthController.isUdfpsFingerDown()).thenReturn(false);
        when(mVibratorHelper.hasVibrator()).thenReturn(true);
        mDependency.injectTestDependency(NotificationMediaManager.class, mMediaManager);
        mBiometricUnlockController = new BiometricUnlockController(mDozeScrimController,
                mKeyguardViewMediator, mScrimController, mShadeController,
@@ -423,4 +424,35 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
        verify(mHandler).post(captor.capture());
        captor.getValue().run();
    }

    @Test
    public void onFPFailureNoHaptics_notDeviceInteractive_showBouncer() {
        // GIVEN no vibrator and the screen is off
        when(mVibratorHelper.hasVibrator()).thenReturn(false);
        when(mUpdateMonitor.isDeviceInteractive()).thenReturn(false);
        when(mUpdateMonitor.isDreaming()).thenReturn(false);

        // WHEN FP fails
        mBiometricUnlockController.onBiometricAuthFailed(BiometricSourceType.FINGERPRINT);

        // after device is finished waking up
        mBiometricUnlockController.mWakefulnessObserver.onFinishedWakingUp();

        // THEN show the bouncer
        verify(mStatusBarKeyguardViewManager).showBouncer(true);
    }

    @Test
    public void onFPFailureNoHaptics_dreaming_showBouncer() {
        // GIVEN no vibrator and device is dreaming
        when(mVibratorHelper.hasVibrator()).thenReturn(false);
        when(mUpdateMonitor.isDeviceInteractive()).thenReturn(true);
        when(mUpdateMonitor.isDreaming()).thenReturn(true);

        // WHEN FP fails
        mBiometricUnlockController.onBiometricAuthFailed(BiometricSourceType.FINGERPRINT);

        // THEN show the bouncer
        verify(mStatusBarKeyguardViewManager).showBouncer(true);
    }
}