Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f16c2db authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Update framework together with HIDL for accessibility

Bug: 120578823

Test: Builds
Change-Id: Idbd097bbf9d5c08dbab614d5f30ec66631b6b0f5
parent 9bb51e76
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -27,6 +27,21 @@ import android.hardware.face.FaceManager;
 * @hide
 */
public interface BiometricFaceConstants {
    //
    // Accessibility constants
    //
    /**
     * Require the user to look at the device during enrollment and
     * authentication. Note this is to accommodate people who have limited
     * vision.
     */
    public static final int FEATURE_REQUIRE_ATTENTION = 1;
    /**
     * Require a diverse set of poses during enrollment. Note this is to
     * accommodate people with limited mobility.
     */
    public static final int FEATURE_REQUIRE_REQUIRE_DIVERSITY = 2;

    //
    // Error messages from face authentication hardware during initialization, enrollment,
    // authentication or removal. Must agree with the list in HAL h file
+8 −11
Original line number Diff line number Diff line
@@ -207,11 +207,8 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
     * @hide
     */
    @RequiresPermission(MANAGE_BIOMETRIC)
    public void enroll(byte[] token, CancellationSignal cancel, int flags,
            int userId, EnrollmentCallback callback) {
        if (userId == UserHandle.USER_CURRENT) {
            userId = getCurrentUserId();
        }
    public void enroll(byte[] token, CancellationSignal cancel,
            EnrollmentCallback callback, int[] disabledFeatures) {
        if (callback == null) {
            throw new IllegalArgumentException("Must supply an enrollment callback");
        }
@@ -228,8 +225,8 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
        if (mService != null) {
            try {
                mEnrollmentCallback = callback;
                mService.enroll(mToken, token, userId, mServiceReceiver, flags,
                        mContext.getOpPackageName());
                mService.enroll(mToken, token, mServiceReceiver,
                        mContext.getOpPackageName(), disabledFeatures);
            } catch (RemoteException e) {
                Log.w(TAG, "Remote exception in enroll: ", e);
                if (callback != null) {
@@ -284,10 +281,10 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
     * @hide
     */
    @RequiresPermission(MANAGE_BIOMETRIC)
    public void setRequireAttention(boolean requireAttention, byte[] token) {
    public void setFeature(int feature, boolean enabled, byte[] token) {
        if (mService != null) {
            try {
                mService.setRequireAttention(requireAttention, token);
                mService.setFeature(feature, enabled, token);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
@@ -298,11 +295,11 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
     * @hide
     */
    @RequiresPermission(MANAGE_BIOMETRIC)
    public boolean getRequireAttention(byte[] token) {
    public boolean getFeature(int feature) {
        boolean result = true;
        if (mService != null) {
            try {
                mService.getRequireAttention(token);
                result = mService.getFeature(feature);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
+4 −4
Original line number Diff line number Diff line
@@ -50,8 +50,8 @@ interface IFaceService {
            int callingUid, int callingPid, int callingUserId, boolean fromClient);

    // Start face enrollment
    void enroll(IBinder token, in byte [] cryptoToken, int userId, IFaceServiceReceiver receiver,
                int flags, String opPackageName);
    void enroll(IBinder token, in byte [] cryptoToken, IFaceServiceReceiver receiver,
                String opPackageName, in int [] disabledFeatures);

    // Cancel enrollment in progress
    void cancelEnrollment(IBinder token);
@@ -98,9 +98,9 @@ interface IFaceService {
    // Enumerate all faces
    void enumerate(IBinder token, int userId, IFaceServiceReceiver receiver);

    int setRequireAttention(boolean requireAttention, in byte [] token);
    int setFeature(int feature, boolean enabled, in byte [] token);

    boolean getRequireAttention(in byte [] token);
    boolean getFeature(int feature);

    void userActivity();
}
+6 −3
Original line number Diff line number Diff line
@@ -282,9 +282,11 @@ public abstract class BiometricServiceBase extends SystemService

        public EnrollClientImpl(Context context, DaemonWrapper daemon, long halDeviceId,
                IBinder token, ServiceListener listener, int userId, int groupId,
                byte[] cryptoToken, boolean restricted, String owner) {
                byte[] cryptoToken, boolean restricted, String owner,
                final int[] disabledFeatures) {
            super(context, getMetrics(), daemon, halDeviceId, token, listener,
                    userId, groupId, cryptoToken, restricted, owner, getBiometricUtils());
                    userId, groupId, cryptoToken, restricted, owner, getBiometricUtils(),
                    disabledFeatures);
        }

        @Override
@@ -408,7 +410,8 @@ public abstract class BiometricServiceBase extends SystemService
        int cancel() throws RemoteException;
        int remove(int groupId, int biometricId) throws RemoteException;
        int enumerate() throws RemoteException;
        int enroll(byte[] cryptoToken, int groupId, int timeout) throws RemoteException;
        int enroll(byte[] cryptoToken, int groupId, int timeout,
                ArrayList<Integer> disabledFeatures) throws RemoteException;
    }

    /**
+11 −2
Original line number Diff line number Diff line
@@ -34,15 +34,18 @@ public abstract class EnrollClient extends ClientMonitor {
    private static final int ENROLLMENT_TIMEOUT_MS = 60 * 1000; // 1 minute
    private final byte[] mCryptoToken;
    private final BiometricUtils mBiometricUtils;
    private final int[] mDisabledFeatures;

    public EnrollClient(Context context, Metrics metrics,
            BiometricServiceBase.DaemonWrapper daemon, long halDeviceId, IBinder token,
            BiometricServiceBase.ServiceListener listener, int userId, int groupId,
            byte[] cryptoToken, boolean restricted, String owner, BiometricUtils utils) {
            byte[] cryptoToken, boolean restricted, String owner, BiometricUtils utils,
            final int[] disabledFeatures) {
        super(context, metrics, daemon, halDeviceId, token, listener, userId, groupId, restricted,
                owner, 0 /* cookie */);
        mBiometricUtils = utils;
        mCryptoToken = Arrays.copyOf(cryptoToken, cryptoToken.length);
        mDisabledFeatures = Arrays.copyOf(disabledFeatures, disabledFeatures.length);
    }

    @Override
@@ -74,7 +77,13 @@ public abstract class EnrollClient extends ClientMonitor {
    public int start() {
        final int timeout = (int) (ENROLLMENT_TIMEOUT_MS / MS_PER_SEC);
        try {
            final int result = getDaemonWrapper().enroll(mCryptoToken, getGroupId(), timeout);
            final ArrayList<Integer> disabledFeatures = new ArrayList<>();
            for (int i = 0; i < mDisabledFeatures.length; i++) {
                disabledFeatures.add(mDisabledFeatures[i]);
            }

            final int result = getDaemonWrapper().enroll(mCryptoToken, getGroupId(), timeout,
                    disabledFeatures);
            if (result != 0) {
                Slog.w(getLogTag(), "startEnroll failed, result=" + result);
                mMetricsLogger.histogram(mMetrics.tagEnrollStartError(), result);
Loading