Loading core/java/android/hardware/face/FaceManager.java +14 −13 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan private final IFaceService mService; private final Context mContext; private IBinder mToken = new Binder(); private final IBinder mToken = new Binder(); @Nullable private AuthenticationCallback mAuthenticationCallback; @Nullable private FaceDetectionCallback mFaceDetectionCallback; @Nullable private EnrollmentCallback mEnrollmentCallback; Loading @@ -86,7 +86,7 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan private Face mRemovalFace; private Handler mHandler; private IFaceServiceReceiver mServiceReceiver = new IFaceServiceReceiver.Stub() { private final IFaceServiceReceiver mServiceReceiver = new IFaceServiceReceiver.Stub() { @Override // binder call public void onEnrollResult(Face face, int remaining) { Loading Loading @@ -293,7 +293,7 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan /** * Defaults to {@link FaceManager#enroll(int, byte[], CancellationSignal, EnrollmentCallback, * int[], Surface)} with {@code surface} set to null. * int[], Surface)} with {@code previewSurface} set to null. * * @see FaceManager#enroll(int, byte[], CancellationSignal, EnrollmentCallback, int[], Surface) * @hide Loading @@ -301,8 +301,8 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan @RequiresPermission(MANAGE_BIOMETRIC) public void enroll(int userId, byte[] hardwareAuthToken, CancellationSignal cancel, EnrollmentCallback callback, int[] disabledFeatures) { enroll(userId, hardwareAuthToken, cancel, callback, disabledFeatures, null /* surface */, false /* debugConsent */); enroll(userId, hardwareAuthToken, cancel, callback, disabledFeatures, null /* previewSurface */, false /* debugConsent */); } /** Loading @@ -319,14 +319,14 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan * @param cancel an object that can be used to cancel enrollment * @param userId the user to whom this face will belong to * @param callback an object to receive enrollment events * @param surface optional camera preview surface for a single-camera device. * @param previewSurface optional camera preview surface for a single-camera device. * Must be null if not used. * @param debugConsent a feature flag that the user has consented to debug. * @hide */ @RequiresPermission(MANAGE_BIOMETRIC) public void enroll(int userId, byte[] hardwareAuthToken, CancellationSignal cancel, EnrollmentCallback callback, int[] disabledFeatures, @Nullable Surface surface, EnrollmentCallback callback, int[] disabledFeatures, @Nullable Surface previewSurface, boolean debugConsent) { if (callback == null) { throw new IllegalArgumentException("Must supply an enrollment callback"); Loading @@ -346,7 +346,8 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan mEnrollmentCallback = callback; Trace.beginSection("FaceManager#enroll"); mService.enroll(userId, mToken, hardwareAuthToken, mServiceReceiver, mContext.getOpPackageName(), disabledFeatures, surface, debugConsent); mContext.getOpPackageName(), disabledFeatures, previewSurface, debugConsent); } catch (RemoteException e) { Slog.w(TAG, "Remote exception in enroll: ", e); // Though this may not be a hardware issue, it will cause apps to give up or Loading Loading @@ -853,10 +854,10 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan * @hide */ public static class AuthenticationResult { private Face mFace; private CryptoObject mCryptoObject; private int mUserId; private boolean mIsStrongBiometric; private final Face mFace; private final CryptoObject mCryptoObject; private final int mUserId; private final boolean mIsStrongBiometric; /** * Authentication result Loading Loading @@ -1127,7 +1128,7 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan } private class OnAuthenticationCancelListener implements OnCancelListener { private CryptoObject mCrypto; private final CryptoObject mCrypto; OnAuthenticationCancelListener(CryptoObject crypto) { mCrypto = crypto; Loading core/java/android/hardware/face/IFaceService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ interface IFaceService { // Start face enrollment void enroll(int userId, IBinder token, in byte [] hardwareAuthToken, IFaceServiceReceiver receiver, String opPackageName, in int [] disabledFeatures, in Surface surface, boolean debugConsent); String opPackageName, in int [] disabledFeatures, in Surface previewSurface, boolean debugConsent); // Start remote face enrollment void enrollRemotely(int userId, IBinder token, in byte [] hardwareAuthToken, IFaceServiceReceiver receiver, Loading services/core/java/com/android/server/biometrics/sensors/face/FaceService.java +25 −4 Original line number Diff line number Diff line Loading @@ -215,7 +215,7 @@ public class FaceService extends SystemService { @Override // Binder call public void enroll(int userId, final IBinder token, final byte[] hardwareAuthToken, final IFaceServiceReceiver receiver, final String opPackageName, final int[] disabledFeatures, Surface surface, boolean debugConsent) { final int[] disabledFeatures, Surface previewSurface, boolean debugConsent) { Utils.checkPermission(getContext(), MANAGE_BIOMETRIC); final Pair<Integer, ServiceProvider> provider = getSingleProvider(); Loading @@ -225,8 +225,7 @@ public class FaceService extends SystemService { } provider.second.scheduleEnroll(provider.first, token, hardwareAuthToken, userId, receiver, opPackageName, disabledFeatures, convertSurfaceToNativeHandle(surface), debugConsent); receiver, opPackageName, disabledFeatures, previewSurface, debugConsent); } @Override // Binder call Loading Loading @@ -703,5 +702,27 @@ public class FaceService extends SystemService { publishBinderService(Context.FACE_SERVICE, mServiceWrapper); } private native NativeHandle convertSurfaceToNativeHandle(Surface surface); /** * Acquires a NativeHandle that can be used to access the provided surface. The returned handle * must be explicitly released with {@link #releaseSurfaceHandle(NativeHandle)} to avoid memory * leaks. * * The caller is responsible for ensuring that the surface is valid while using the handle. * This method provides no lifecycle synchronization between the surface and the handle. * * @param surface a valid Surface. * @return {@link android.os.NativeHandle} a NativeHandle for the provided surface. */ public static native NativeHandle acquireSurfaceHandle(@NonNull Surface surface); /** * Releases resources associated with a NativeHandle that was acquired with * {@link #acquireSurfaceHandle(Surface)}. * * This method has no affect on the surface for which the handle was acquired. It only frees up * the resources that are associated with the handle. * * @param handle a handle that was obtained from {@link #acquireSurfaceHandle(Surface)}. */ public static native void releaseSurfaceHandle(@NonNull NativeHandle handle); } services/core/java/com/android/server/biometrics/sensors/face/ServiceProvider.java +4 −4 Original line number Diff line number Diff line Loading @@ -26,8 +26,8 @@ import android.hardware.face.FaceManager; import android.hardware.face.FaceSensorPropertiesInternal; import android.hardware.face.IFaceServiceReceiver; import android.os.IBinder; import android.os.NativeHandle; import android.util.proto.ProtoOutputStream; import android.view.Surface; import com.android.server.biometrics.sensors.BaseClientMonitor; import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter; Loading Loading @@ -75,8 +75,8 @@ public interface ServiceProvider { int getLockoutModeForUser(int sensorId, int userId); /** * Requests for the authenticatorId (whose source of truth is in the TEE or equivalent) to * be invalidated. See {@link com.android.server.biometrics.sensors.InvalidationRequesterClient} * Requests for the authenticatorId (whose source of truth is in the TEE or equivalent) to be * invalidated. See {@link com.android.server.biometrics.sensors.InvalidationRequesterClient} */ default void scheduleInvalidateAuthenticatorId(int sensorId, int userId, @NonNull IInvalidationCallback callback) { Loading @@ -96,7 +96,7 @@ public interface ServiceProvider { void scheduleEnroll(int sensorId, @NonNull IBinder token, @NonNull byte[] hardwareAuthToken, int userId, @NonNull IFaceServiceReceiver receiver, @NonNull String opPackageName, @NonNull int[] disabledFeatures, @Nullable NativeHandle surfaceHandle, @NonNull int[] disabledFeatures, @Nullable Surface previewSurface, boolean debugConsent); void cancelEnrollment(int sensorId, @NonNull IBinder token); Loading services/core/java/com/android/server/biometrics/sensors/face/aidl/BiometricTestSessionImpl.java +2 −2 Original line number Diff line number Diff line Loading @@ -150,8 +150,8 @@ public class BiometricTestSessionImpl extends ITestSession.Stub { Utils.checkPermission(mContext, TEST_BIOMETRIC); mProvider.scheduleEnroll(mSensorId, new Binder(), new byte[69], userId, mReceiver, mContext.getOpPackageName(), new int[0] /* disabledFeatures */, null /* surface */, false /* debugConsent */); mContext.getOpPackageName(), new int[0] /* disabledFeatures */, null /* previewSurface */, false /* debugConsent */); } @Override Loading Loading
core/java/android/hardware/face/FaceManager.java +14 −13 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan private final IFaceService mService; private final Context mContext; private IBinder mToken = new Binder(); private final IBinder mToken = new Binder(); @Nullable private AuthenticationCallback mAuthenticationCallback; @Nullable private FaceDetectionCallback mFaceDetectionCallback; @Nullable private EnrollmentCallback mEnrollmentCallback; Loading @@ -86,7 +86,7 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan private Face mRemovalFace; private Handler mHandler; private IFaceServiceReceiver mServiceReceiver = new IFaceServiceReceiver.Stub() { private final IFaceServiceReceiver mServiceReceiver = new IFaceServiceReceiver.Stub() { @Override // binder call public void onEnrollResult(Face face, int remaining) { Loading Loading @@ -293,7 +293,7 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan /** * Defaults to {@link FaceManager#enroll(int, byte[], CancellationSignal, EnrollmentCallback, * int[], Surface)} with {@code surface} set to null. * int[], Surface)} with {@code previewSurface} set to null. * * @see FaceManager#enroll(int, byte[], CancellationSignal, EnrollmentCallback, int[], Surface) * @hide Loading @@ -301,8 +301,8 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan @RequiresPermission(MANAGE_BIOMETRIC) public void enroll(int userId, byte[] hardwareAuthToken, CancellationSignal cancel, EnrollmentCallback callback, int[] disabledFeatures) { enroll(userId, hardwareAuthToken, cancel, callback, disabledFeatures, null /* surface */, false /* debugConsent */); enroll(userId, hardwareAuthToken, cancel, callback, disabledFeatures, null /* previewSurface */, false /* debugConsent */); } /** Loading @@ -319,14 +319,14 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan * @param cancel an object that can be used to cancel enrollment * @param userId the user to whom this face will belong to * @param callback an object to receive enrollment events * @param surface optional camera preview surface for a single-camera device. * @param previewSurface optional camera preview surface for a single-camera device. * Must be null if not used. * @param debugConsent a feature flag that the user has consented to debug. * @hide */ @RequiresPermission(MANAGE_BIOMETRIC) public void enroll(int userId, byte[] hardwareAuthToken, CancellationSignal cancel, EnrollmentCallback callback, int[] disabledFeatures, @Nullable Surface surface, EnrollmentCallback callback, int[] disabledFeatures, @Nullable Surface previewSurface, boolean debugConsent) { if (callback == null) { throw new IllegalArgumentException("Must supply an enrollment callback"); Loading @@ -346,7 +346,8 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan mEnrollmentCallback = callback; Trace.beginSection("FaceManager#enroll"); mService.enroll(userId, mToken, hardwareAuthToken, mServiceReceiver, mContext.getOpPackageName(), disabledFeatures, surface, debugConsent); mContext.getOpPackageName(), disabledFeatures, previewSurface, debugConsent); } catch (RemoteException e) { Slog.w(TAG, "Remote exception in enroll: ", e); // Though this may not be a hardware issue, it will cause apps to give up or Loading Loading @@ -853,10 +854,10 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan * @hide */ public static class AuthenticationResult { private Face mFace; private CryptoObject mCryptoObject; private int mUserId; private boolean mIsStrongBiometric; private final Face mFace; private final CryptoObject mCryptoObject; private final int mUserId; private final boolean mIsStrongBiometric; /** * Authentication result Loading Loading @@ -1127,7 +1128,7 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan } private class OnAuthenticationCancelListener implements OnCancelListener { private CryptoObject mCrypto; private final CryptoObject mCrypto; OnAuthenticationCancelListener(CryptoObject crypto) { mCrypto = crypto; Loading
core/java/android/hardware/face/IFaceService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ interface IFaceService { // Start face enrollment void enroll(int userId, IBinder token, in byte [] hardwareAuthToken, IFaceServiceReceiver receiver, String opPackageName, in int [] disabledFeatures, in Surface surface, boolean debugConsent); String opPackageName, in int [] disabledFeatures, in Surface previewSurface, boolean debugConsent); // Start remote face enrollment void enrollRemotely(int userId, IBinder token, in byte [] hardwareAuthToken, IFaceServiceReceiver receiver, Loading
services/core/java/com/android/server/biometrics/sensors/face/FaceService.java +25 −4 Original line number Diff line number Diff line Loading @@ -215,7 +215,7 @@ public class FaceService extends SystemService { @Override // Binder call public void enroll(int userId, final IBinder token, final byte[] hardwareAuthToken, final IFaceServiceReceiver receiver, final String opPackageName, final int[] disabledFeatures, Surface surface, boolean debugConsent) { final int[] disabledFeatures, Surface previewSurface, boolean debugConsent) { Utils.checkPermission(getContext(), MANAGE_BIOMETRIC); final Pair<Integer, ServiceProvider> provider = getSingleProvider(); Loading @@ -225,8 +225,7 @@ public class FaceService extends SystemService { } provider.second.scheduleEnroll(provider.first, token, hardwareAuthToken, userId, receiver, opPackageName, disabledFeatures, convertSurfaceToNativeHandle(surface), debugConsent); receiver, opPackageName, disabledFeatures, previewSurface, debugConsent); } @Override // Binder call Loading Loading @@ -703,5 +702,27 @@ public class FaceService extends SystemService { publishBinderService(Context.FACE_SERVICE, mServiceWrapper); } private native NativeHandle convertSurfaceToNativeHandle(Surface surface); /** * Acquires a NativeHandle that can be used to access the provided surface. The returned handle * must be explicitly released with {@link #releaseSurfaceHandle(NativeHandle)} to avoid memory * leaks. * * The caller is responsible for ensuring that the surface is valid while using the handle. * This method provides no lifecycle synchronization between the surface and the handle. * * @param surface a valid Surface. * @return {@link android.os.NativeHandle} a NativeHandle for the provided surface. */ public static native NativeHandle acquireSurfaceHandle(@NonNull Surface surface); /** * Releases resources associated with a NativeHandle that was acquired with * {@link #acquireSurfaceHandle(Surface)}. * * This method has no affect on the surface for which the handle was acquired. It only frees up * the resources that are associated with the handle. * * @param handle a handle that was obtained from {@link #acquireSurfaceHandle(Surface)}. */ public static native void releaseSurfaceHandle(@NonNull NativeHandle handle); }
services/core/java/com/android/server/biometrics/sensors/face/ServiceProvider.java +4 −4 Original line number Diff line number Diff line Loading @@ -26,8 +26,8 @@ import android.hardware.face.FaceManager; import android.hardware.face.FaceSensorPropertiesInternal; import android.hardware.face.IFaceServiceReceiver; import android.os.IBinder; import android.os.NativeHandle; import android.util.proto.ProtoOutputStream; import android.view.Surface; import com.android.server.biometrics.sensors.BaseClientMonitor; import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter; Loading Loading @@ -75,8 +75,8 @@ public interface ServiceProvider { int getLockoutModeForUser(int sensorId, int userId); /** * Requests for the authenticatorId (whose source of truth is in the TEE or equivalent) to * be invalidated. See {@link com.android.server.biometrics.sensors.InvalidationRequesterClient} * Requests for the authenticatorId (whose source of truth is in the TEE or equivalent) to be * invalidated. See {@link com.android.server.biometrics.sensors.InvalidationRequesterClient} */ default void scheduleInvalidateAuthenticatorId(int sensorId, int userId, @NonNull IInvalidationCallback callback) { Loading @@ -96,7 +96,7 @@ public interface ServiceProvider { void scheduleEnroll(int sensorId, @NonNull IBinder token, @NonNull byte[] hardwareAuthToken, int userId, @NonNull IFaceServiceReceiver receiver, @NonNull String opPackageName, @NonNull int[] disabledFeatures, @Nullable NativeHandle surfaceHandle, @NonNull int[] disabledFeatures, @Nullable Surface previewSurface, boolean debugConsent); void cancelEnrollment(int sensorId, @NonNull IBinder token); Loading
services/core/java/com/android/server/biometrics/sensors/face/aidl/BiometricTestSessionImpl.java +2 −2 Original line number Diff line number Diff line Loading @@ -150,8 +150,8 @@ public class BiometricTestSessionImpl extends ITestSession.Stub { Utils.checkPermission(mContext, TEST_BIOMETRIC); mProvider.scheduleEnroll(mSensorId, new Binder(), new byte[69], userId, mReceiver, mContext.getOpPackageName(), new int[0] /* disabledFeatures */, null /* surface */, false /* debugConsent */); mContext.getOpPackageName(), new int[0] /* disabledFeatures */, null /* previewSurface */, false /* debugConsent */); } @Override Loading