diff options
10 files changed, 110 insertions, 47 deletions
diff --git a/core/java/android/hardware/biometrics/BiometricFingerprintConstants.java b/core/java/android/hardware/biometrics/BiometricFingerprintConstants.java index abdc64c56ead..d8ebb628452a 100644 --- a/core/java/android/hardware/biometrics/BiometricFingerprintConstants.java +++ b/core/java/android/hardware/biometrics/BiometricFingerprintConstants.java @@ -298,4 +298,33 @@ public interface BiometricFingerprintConstants { * @hide */ int FINGERPRINT_ACQUIRED_VENDOR_BASE = 1000; + + /** + * Whether the FingerprintAcquired message is a signal to turn off HBM + */ + static boolean shouldTurnOffHbm(@FingerprintAcquired int acquiredInfo) { + switch (acquiredInfo) { + case FINGERPRINT_ACQUIRED_START: + // Authentication just began + return false; + case FINGERPRINT_ACQUIRED_GOOD: + // Good image captured. Turn off HBM. Success/Reject comes after, which is when + // hideUdfpsOverlay will be called. + return true; + case FINGERPRINT_ACQUIRED_PARTIAL: + case FINGERPRINT_ACQUIRED_INSUFFICIENT: + case FINGERPRINT_ACQUIRED_IMAGER_DIRTY: + case FINGERPRINT_ACQUIRED_TOO_SLOW: + case FINGERPRINT_ACQUIRED_TOO_FAST: + case FINGERPRINT_ACQUIRED_IMMOBILE: + case FINGERPRINT_ACQUIRED_TOO_BRIGHT: + case FINGERPRINT_ACQUIRED_VENDOR: + // Bad image captured. Turn off HBM. Matcher will not run, so there's no need to + // keep HBM on. + return true; + case FINGERPRINT_ACQUIRED_UNKNOWN: + default: + return false; + } + } } diff --git a/core/java/android/hardware/fingerprint/IUdfpsOverlayController.aidl b/core/java/android/hardware/fingerprint/IUdfpsOverlayController.aidl index 648edda62171..3cca1b38e5e2 100644 --- a/core/java/android/hardware/fingerprint/IUdfpsOverlayController.aidl +++ b/core/java/android/hardware/fingerprint/IUdfpsOverlayController.aidl @@ -28,9 +28,10 @@ oneway interface IUdfpsOverlayController { // Hides the overlay. void hideUdfpsOverlay(int sensorId); - // Good image captured. Turn off HBM. Success/Reject comes after, which is when hideUdfpsOverlay - // will be called. - void onAcquiredGood(int sensorId); + // Check acquiredInfo for the acquired type (BiometricFingerprintConstants#FingerprintAcquired). + // Check BiometricFingerprintConstants#shouldTurnOffHbm for whether the acquiredInfo + // should turn off HBM. + void onAcquired(int sensorId, int acquiredInfo); // Notifies of enrollment progress changes. void onEnrollmentProgress(int sensorId, int remaining); diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 37f45644fa68..1ef6dea4e680 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -52,6 +52,7 @@ import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; import android.database.ContentObserver; import android.hardware.SensorPrivacyManager; +import android.hardware.biometrics.BiometricFingerprintConstants; import android.hardware.biometrics.BiometricManager; import android.hardware.biometrics.BiometricSourceType; import android.hardware.biometrics.IBiometricEnabledOnKeyguardCallback; @@ -752,15 +753,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } } - private void handleFingerprintAcquired(int acquireInfo) { + private void handleFingerprintAcquired( + @BiometricFingerprintConstants.FingerprintAcquired int acquireInfo) { Assert.isMainThread(); - if (acquireInfo != FingerprintManager.FINGERPRINT_ACQUIRED_GOOD) { - return; - } for (int i = 0; i < mCallbacks.size(); i++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); if (cb != null) { - cb.onBiometricAcquired(BiometricSourceType.FINGERPRINT); + cb.onBiometricAcquired(BiometricSourceType.FINGERPRINT, acquireInfo); } } } @@ -960,14 +959,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab private void handleFaceAcquired(int acquireInfo) { Assert.isMainThread(); - if (acquireInfo != FaceManager.FACE_ACQUIRED_GOOD) { - return; - } - if (DEBUG_FACE) Log.d(TAG, "Face acquired"); + if (DEBUG_FACE) Log.d(TAG, "Face acquired acquireInfo=" + acquireInfo); for (int i = 0; i < mCallbacks.size(); i++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); if (cb != null) { - cb.onBiometricAcquired(BiometricSourceType.FACE); + cb.onBiometricAcquired(BiometricSourceType.FACE, acquireInfo); } } } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java index 8d5603dc1563..ad2053cbc31b 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java @@ -206,8 +206,10 @@ public class KeyguardUpdateMonitorCallback { * It is guaranteed that either {@link #onBiometricAuthenticated} or * {@link #onBiometricAuthFailed(BiometricSourceType)} is called after this method eventually. * @param biometricSourceType + * @param acquireInfo see {@link android.hardware.biometrics.BiometricFaceConstants} and + * {@link android.hardware.biometrics.BiometricFingerprintConstants} */ - public void onBiometricAcquired(BiometricSourceType biometricSourceType) { } + public void onBiometricAcquired(BiometricSourceType biometricSourceType, int acquireInfo) { } /** * Called when a biometric couldn't be authenticated. diff --git a/packages/SystemUI/src/com/android/systemui/LatencyTester.java b/packages/SystemUI/src/com/android/systemui/LatencyTester.java index bc2a1ff24235..7afd43d1cb06 100644 --- a/packages/SystemUI/src/com/android/systemui/LatencyTester.java +++ b/packages/SystemUI/src/com/android/systemui/LatencyTester.java @@ -20,6 +20,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.hardware.biometrics.BiometricConstants; import android.hardware.biometrics.BiometricSourceType; import android.os.Build; @@ -78,7 +79,8 @@ public class LatencyTester extends CoreStartable { } private void fakeWakeAndUnlock(BiometricSourceType type) { - mBiometricUnlockController.onBiometricAcquired(type); + mBiometricUnlockController.onBiometricAcquired(type, + BiometricConstants.BIOMETRIC_ACQUIRED_GOOD); mBiometricUnlockController.onBiometricAuthenticated( KeyguardUpdateMonitor.getCurrentUser(), type, true /* isStrongBiometric */); } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt index 99f27d7f48e7..a27b9cd357f4 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt @@ -21,6 +21,7 @@ import android.animation.AnimatorListenerAdapter import android.animation.ValueAnimator import android.content.Context import android.graphics.PointF +import android.hardware.biometrics.BiometricFingerprintConstants import android.hardware.biometrics.BiometricSourceType import android.util.DisplayMetrics import android.util.Log @@ -39,8 +40,8 @@ import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.statusbar.commandline.Command import com.android.systemui.statusbar.commandline.CommandRegistry import com.android.systemui.statusbar.phone.BiometricUnlockController -import com.android.systemui.statusbar.phone.KeyguardBypassController import com.android.systemui.statusbar.phone.CentralSurfaces +import com.android.systemui.statusbar.phone.KeyguardBypassController import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent.CentralSurfacesScope import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.statusbar.policy.KeyguardStateController @@ -257,6 +258,16 @@ class AuthRippleController @Inject constructor( override fun onBiometricAuthFailed(biometricSourceType: BiometricSourceType?) { mView.retractRipple() } + + override fun onBiometricAcquired( + biometricSourceType: BiometricSourceType?, + acquireInfo: Int + ) { + if (biometricSourceType == BiometricSourceType.FINGERPRINT && + acquireInfo == BiometricFingerprintConstants.FINGERPRINT_ACQUIRED_PARTIAL) { + mView.retractRipple() + } + } } private val configurationChangedListener = diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java index 8052c2071d86..bf42db53d3d8 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java @@ -16,6 +16,7 @@ package com.android.systemui.biometrics; +import static android.hardware.biometrics.BiometricFingerprintConstants.FINGERPRINT_ACQUIRED_GOOD; import static android.hardware.biometrics.BiometricOverlayConstants.REASON_AUTH_KEYGUARD; import static com.android.internal.util.Preconditions.checkArgument; @@ -30,6 +31,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.graphics.Point; import android.graphics.RectF; +import android.hardware.biometrics.BiometricFingerprintConstants; import android.hardware.biometrics.SensorLocationInternal; import android.hardware.display.DisplayManager; import android.hardware.fingerprint.FingerprintManager; @@ -141,11 +143,11 @@ public class UdfpsController implements DozeReceiver { private int mActivePointerId = -1; // The timestamp of the most recent touch log. private long mTouchLogTime; - // Sensor has a good capture for this touch. Do not need to illuminate for this particular - // touch event anymore. In other words, do not illuminate until user lifts and touches the - // sensor area again. + // Sensor has a capture (good or bad) for this touch. Do not need to illuminate for this + // particular touch event anymore. In other words, do not illuminate until user lifts and + // touches the sensor area again. // TODO: We should probably try to make touch/illumination things more of a FSM - private boolean mGoodCaptureReceived; + private boolean mAcquiredReceived; // The current request from FingerprintService. Null if no current request. @Nullable UdfpsControllerOverlay mOverlay; @@ -221,19 +223,28 @@ public class UdfpsController implements DozeReceiver { } @Override - public void onAcquiredGood(int sensorId) { - mFgExecutor.execute(() -> { - if (mOverlay == null) { - Log.e(TAG, "Null request when onAcquiredGood for sensorId: " + sensorId); - return; - } - mGoodCaptureReceived = true; - final UdfpsView view = mOverlay.getOverlayView(); - if (view != null) { - view.stopIllumination(); - } - mOverlay.onAcquiredGood(); - }); + public void onAcquired( + int sensorId, + @BiometricFingerprintConstants.FingerprintAcquired int acquiredInfo + ) { + if (BiometricFingerprintConstants.shouldTurnOffHbm(acquiredInfo)) { + boolean acquiredGood = acquiredInfo == FINGERPRINT_ACQUIRED_GOOD; + mFgExecutor.execute(() -> { + if (mOverlay == null) { + Log.e(TAG, "Null request when onAcquired for sensorId: " + sensorId + + " acquiredInfo=" + acquiredInfo); + return; + } + mAcquiredReceived = true; + final UdfpsView view = mOverlay.getOverlayView(); + if (view != null) { + view.stopIllumination(); // turn off HBM + } + if (acquiredGood) { + mOverlay.onAcquiredGood(); + } + }); + } } @Override @@ -414,8 +425,8 @@ public class UdfpsController implements DozeReceiver { "minor: %.1f, major: %.1f, v: %.1f, exceedsVelocityThreshold: %b", minor, major, v, exceedsVelocityThreshold); final long sinceLastLog = mSystemClock.elapsedRealtime() - mTouchLogTime; - if (!isIlluminationRequested && !mGoodCaptureReceived && - !exceedsVelocityThreshold) { + if (!isIlluminationRequested && !mAcquiredReceived + && !exceedsVelocityThreshold) { final int rawX = (int) event.getRawX(); final int rawY = (int) event.getRawY(); // Default coordinates assume portrait mode. @@ -799,7 +810,7 @@ public class UdfpsController implements DozeReceiver { private void onFingerUp(@NonNull UdfpsView view) { mExecution.assertIsMainThread(); mActivePointerId = -1; - mGoodCaptureReceived = false; + mAcquiredReceived = false; if (mOnFingerDown) { mFingerprintManager.onPointerUp(mSensorProps.sensorId); for (Callback cb : mCallbacks) { 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 fe637c14ee33..4bf944ae13c9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java @@ -20,6 +20,8 @@ import static android.app.StatusBarManager.SESSION_KEYGUARD; import android.annotation.IntDef; import android.content.res.Resources; +import android.hardware.biometrics.BiometricFaceConstants; +import android.hardware.biometrics.BiometricFingerprintConstants; import android.hardware.biometrics.BiometricSourceType; import android.hardware.fingerprint.FingerprintManager; import android.metrics.LogMaker; @@ -344,7 +346,15 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp } @Override - public void onBiometricAcquired(BiometricSourceType biometricSourceType) { + public void onBiometricAcquired(BiometricSourceType biometricSourceType, + int acquireInfo) { + if (BiometricSourceType.FINGERPRINT == biometricSourceType + && acquireInfo != BiometricFingerprintConstants.FINGERPRINT_ACQUIRED_GOOD) { + return; + } else if (BiometricSourceType.FACE == biometricSourceType + && acquireInfo != BiometricFaceConstants.FACE_ACQUIRED_GOOD) { + return; + } Trace.beginSection("BiometricUnlockController#onBiometricAcquired"); releaseBiometricWakeLock(); if (isWakeAndUnlock()) { diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintAuthenticationClient.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintAuthenticationClient.java index 653776b3ca65..79e3bf53acd3 100644 --- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintAuthenticationClient.java +++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintAuthenticationClient.java @@ -140,12 +140,9 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession> @Override public void onAcquired(@FingerprintAcquired int acquiredInfo, int vendorCode) { - // For UDFPS, notify SysUI that the illumination can be turned off. - // See AcquiredInfo#GOOD and AcquiredInfo#RETRYING_CAPTURE - if (acquiredInfo == BiometricFingerprintConstants.FINGERPRINT_ACQUIRED_GOOD) { - mSensorOverlays.ifUdfps(controller -> controller.onAcquiredGood(getSensorId())); - } - + // For UDFPS, notify SysUI with acquiredInfo, so that the illumination can be turned off + // for most ACQUIRED messages. See BiometricFingerprintConstants#FingerprintAcquired + mSensorOverlays.ifUdfps(controller -> controller.onAcquired(getSensorId(), acquiredInfo)); super.onAcquired(acquiredInfo, vendorCode); } diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintEnrollClient.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintEnrollClient.java index c92d599d68e6..bb1fed0bfecc 100644 --- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintEnrollClient.java +++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintEnrollClient.java @@ -114,12 +114,16 @@ class FingerprintEnrollClient extends EnrollClient<AidlSession> implements Udfps @Override public void onAcquired(@FingerprintAcquired int acquiredInfo, int vendorCode) { + boolean acquiredGood = + acquiredInfo == BiometricFingerprintConstants.FINGERPRINT_ACQUIRED_GOOD; // For UDFPS, notify SysUI that the illumination can be turned off. // See AcquiredInfo#GOOD and AcquiredInfo#RETRYING_CAPTURE - if (acquiredInfo == BiometricFingerprintConstants.FINGERPRINT_ACQUIRED_GOOD - && mSensorProps.isAnyUdfpsType()) { - vibrateSuccess(); - mSensorOverlays.ifUdfps(controller -> controller.onAcquiredGood(getSensorId())); + if (mSensorProps.isAnyUdfpsType()) { + if (acquiredGood) { + vibrateSuccess(); + } + mSensorOverlays.ifUdfps( + controller -> controller.onAcquired(getSensorId(), acquiredInfo)); } mSensorOverlays.ifUdfps(controller -> { |