From 44fb545545b93552c04fdfa9dcb12246ee2f12c6 Mon Sep 17 00:00:00 2001 From: Beverly Date: Wed, 29 Jun 2022 20:32:12 +0000 Subject: [PATCH] For devices w/o haptics, show bouncer on biometric fail When the device is showing a dreaming (includes default dozing component when registered for DozeSensors and when showing AoD) or the screen is off (device isn't interactive). Fixes: 232021812 Test: atest BiometricsUnlockControllerTest Test: on device that doesn't support haptics, fail fingerprint when a screensaver is set => bouncer appears. Test: on device that doesn't support haptics, fail fingerprint when the device has doze gestures registered (ie: tap to wake) and the device is asleep (press power button for blank screen) => bouncer appears on fp failure Test: on device that doesn't support haptics, fail fingerprint when the device doesn't have eany doze gestures registered (tap to wake, lift to wake, wake for notifications, etc) and the device is asleep (press power button for blank screen) => bouncer appears on fp failure Change-Id: I8af8a1d5bcf28d7c8de456888f66d4b243b1e3b2 --- .../keyguard/KeyguardUpdateMonitor.java | 6 ++++ .../phone/BiometricUnlockController.java | 6 ++-- .../phone/BiometricsUnlockControllerTest.java | 32 +++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 727d108df339d..ede62437e5a02 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -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)); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java index 39620ac231173..a0f386ff0b5ee 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java @@ -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) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java index e5b6286fcd7ca..272ef3ddc64ed 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java @@ -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); + } }