Merge "Added lockout callback to FaceAuthenticationClient" into sc-v2-dev

This commit is contained in:
Joshua Mccloskey
2021-10-20 18:03:54 +00:00
committed by Android (Google) Code Review
2 changed files with 39 additions and 0 deletions

View File

@@ -360,6 +360,43 @@ public abstract class AuthenticationClient<T> extends AcquisitionClient<T>
} }
} }
/**
* Only call this method on interfaces where lockout does not come from onError, I.E. the
* old HIDL implementation.
*/
protected void onLockoutTimed(long durationMillis) {
final ClientMonitorCallbackConverter listener = getListener();
final CoexCoordinator coordinator = CoexCoordinator.getInstance();
coordinator.onAuthenticationError(this, BiometricConstants.BIOMETRIC_ERROR_LOCKOUT,
new CoexCoordinator.ErrorCallback() {
@Override
public void sendHapticFeedback() {
if (listener != null && mShouldVibrate) {
vibrateError();
}
}
});
}
/**
* Only call this method on interfaces where lockout does not come from onError, I.E. the
* old HIDL implementation.
*/
protected void onLockoutPermanent() {
final ClientMonitorCallbackConverter listener = getListener();
final CoexCoordinator coordinator = CoexCoordinator.getInstance();
coordinator.onAuthenticationError(this,
BiometricConstants.BIOMETRIC_ERROR_LOCKOUT_PERMANENT,
new CoexCoordinator.ErrorCallback() {
@Override
public void sendHapticFeedback() {
if (listener != null && mShouldVibrate) {
vibrateError();
}
}
});
}
private void sendCancelOnly(@Nullable ClientMonitorCallbackConverter listener) { private void sendCancelOnly(@Nullable ClientMonitorCallbackConverter listener) {
if (listener == null) { if (listener == null) {
Slog.e(TAG, "Unable to sendAuthenticationCanceled, listener null"); Slog.e(TAG, "Unable to sendAuthenticationCanceled, listener null");

View File

@@ -225,6 +225,7 @@ class FaceAuthenticationClient extends AuthenticationClient<ISession> implements
@Override @Override
public void onLockoutTimed(long durationMillis) { public void onLockoutTimed(long durationMillis) {
super.onLockoutTimed(durationMillis);
mLockoutCache.setLockoutModeForUser(getTargetUserId(), LockoutTracker.LOCKOUT_TIMED); mLockoutCache.setLockoutModeForUser(getTargetUserId(), LockoutTracker.LOCKOUT_TIMED);
// Lockout metrics are logged as an error code. // Lockout metrics are logged as an error code.
final int error = BiometricFaceConstants.FACE_ERROR_LOCKOUT; final int error = BiometricFaceConstants.FACE_ERROR_LOCKOUT;
@@ -239,6 +240,7 @@ class FaceAuthenticationClient extends AuthenticationClient<ISession> implements
@Override @Override
public void onLockoutPermanent() { public void onLockoutPermanent() {
super.onLockoutPermanent();
mLockoutCache.setLockoutModeForUser(getTargetUserId(), LockoutTracker.LOCKOUT_PERMANENT); mLockoutCache.setLockoutModeForUser(getTargetUserId(), LockoutTracker.LOCKOUT_PERMANENT);
// Lockout metrics are logged as an error code. // Lockout metrics are logged as an error code.
final int error = BiometricFaceConstants.FACE_ERROR_LOCKOUT_PERMANENT; final int error = BiometricFaceConstants.FACE_ERROR_LOCKOUT_PERMANENT;