Update face for the new enrollment API

Bug: 174619156
Test: atest CtsBiometricsTestCases
Change-Id: I8098cdbefaafeabee8cf4bb940ecf7f574137833
This commit is contained in:
Ilya Matyukhin
2021-01-19 16:15:50 -08:00
parent 71a2c83af6
commit 9eae1727c3
5 changed files with 41 additions and 9 deletions

View File

@@ -21,6 +21,8 @@ import static android.Manifest.permission.TEST_BIOMETRIC;
import android.annotation.NonNull;
import android.content.Context;
import android.hardware.biometrics.ITestSession;
import android.hardware.biometrics.face.AuthenticationFrame;
import android.hardware.biometrics.face.BaseFrame;
import android.hardware.face.Face;
import android.hardware.face.IFaceServiceReceiver;
import android.os.Binder;
@@ -180,12 +182,21 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
mSensor.getSessionForUser(userId).mHalSessionCallback.onAuthenticationFailed();
}
// TODO(b/174619156): replace with notifyAuthenticationFrame and notifyEnrollmentFrame.
@Override
public void notifyAcquired(int userId, int acquireInfo) {
public void notifyAcquired(int userId, int acquireInfo) {
Utils.checkPermission(mContext, TEST_BIOMETRIC);
mSensor.getSessionForUser(userId).mHalSessionCallback
.onAcquired((byte) acquireInfo, 0 /* vendorCode */);
BaseFrame data = new BaseFrame();
data.acquiredInfo = (byte) acquireInfo;
AuthenticationFrame authenticationFrame = new AuthenticationFrame();
authenticationFrame.data = data;
// TODO(b/174619156): Currently onAuthenticationFrame and onEnrollmentFrame are the same.
// This will need to call the correct callback once the onAcquired callback is removed.
mSensor.getSessionForUser(userId).mHalSessionCallback.onAuthenticationFrame(
authenticationFrame);
}
@Override

View File

@@ -22,6 +22,7 @@ import android.content.Context;
import android.hardware.biometrics.BiometricFaceConstants;
import android.hardware.biometrics.BiometricsProtoEnums;
import android.hardware.biometrics.common.ICancellationSignal;
import android.hardware.biometrics.face.EnrollmentType;
import android.hardware.biometrics.face.IFace;
import android.hardware.biometrics.face.ISession;
import android.hardware.face.Face;
@@ -114,7 +115,8 @@ public class FaceEnrollClient extends EnrollClient<ISession> {
try {
// TODO(b/172593978): Pass features.
mCancellationSignal = getFreshDaemon().enroll(mSequentialId,
// TODO(b/174619156): Handle accessibility enrollment.
mCancellationSignal = getFreshDaemon().enroll(mSequentialId, EnrollmentType.DEFAULT,
HardwareAuthTokenUtils.toHardwareAuthToken(mHardwareAuthToken),
mPreviewSurface);
} catch (RemoteException e) {

View File

@@ -22,6 +22,8 @@ import android.content.Context;
import android.content.pm.UserInfo;
import android.hardware.biometrics.BiometricsProtoEnums;
import android.hardware.biometrics.ITestSession;
import android.hardware.biometrics.face.AuthenticationFrame;
import android.hardware.biometrics.face.EnrollmentFrame;
import android.hardware.biometrics.face.Error;
import android.hardware.biometrics.face.IFace;
import android.hardware.biometrics.face.ISession;
@@ -167,7 +169,8 @@ public class Sensor implements IBinder.DeathRecipient {
}
@Override
public void onAcquired(byte info, int vendorCode) {
public void onAuthenticationFrame(AuthenticationFrame frame) {
// TODO(b/174619156): propagate the frame to an AuthenticationClient
mHandler.post(() -> {
final BaseClientMonitor client = mScheduler.getCurrentClient();
if (!(client instanceof AcquisitionClient)) {
@@ -177,7 +180,23 @@ public class Sensor implements IBinder.DeathRecipient {
}
final AcquisitionClient<?> acquisitionClient = (AcquisitionClient<?>) client;
acquisitionClient.onAcquired(info, vendorCode);
acquisitionClient.onAcquired(frame.data.acquiredInfo, frame.data.vendorCode);
});
}
@Override
public void onEnrollmentFrame(EnrollmentFrame frame) {
// TODO(b/174619156): propagate the frame to an EnrollmentClient
mHandler.post(() -> {
final BaseClientMonitor client = mScheduler.getCurrentClient();
if (!(client instanceof AcquisitionClient)) {
Slog.e(mTag, "onAcquired for non-acquisition client: "
+ Utils.getClientName(client));
return;
}
final AcquisitionClient<?> acquisitionClient = (AcquisitionClient<?>) client;
acquisitionClient.onAcquired(frame.data.acquiredInfo, frame.data.vendorCode);
});
}

View File

@@ -49,8 +49,8 @@ public class TestHal extends IFace.Stub {
}
@Override
public ICancellationSignal enroll(int cookie, HardwareAuthToken hat,
NativeHandle previewSurface) {
public ICancellationSignal enroll(int cookie, byte enrollmentType,
HardwareAuthToken hat, NativeHandle previewSurface) {
return null;
}

View File

@@ -50,7 +50,7 @@ public class TestSession extends ISession.Stub {
}
@Override
public ICancellationSignal enroll(int cookie, HardwareAuthToken hat,
public ICancellationSignal enroll(int cookie, byte enrollmentType, HardwareAuthToken hat,
NativeHandle previewSurface) {
return null;
}