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
This commit is contained in:
Beverly
2022-06-29 20:32:12 +00:00
committed by Beverly Tai
parent 35dfc1e31d
commit 44fb545545
3 changed files with 42 additions and 2 deletions

View File

@@ -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));

View File

@@ -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) {

View File

@@ -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);
}
}