Merge "Immediately stop HBM & authRipple anim onAcquire" into tm-dev

This commit is contained in:
Beverly Tai
2022-03-08 13:03:55 +00:00
committed by Android (Google) Code Review
10 changed files with 110 additions and 47 deletions

View File

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

View File

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

View File

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

View File

@@ -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.

View File

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

View File

@@ -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 =

View File

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

View File

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

View File

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

View File

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