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


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


    // Cancel enrollment in progress
    // Cancel enrollment in progress
    void cancelEnrollment(IBinder token);
    void cancelEnrollment(IBinder token);
@@ -98,9 +98,9 @@ interface IFaceService {
    // Enumerate all faces
    // Enumerate all faces
    void enumerate(IBinder token, int userId, IFaceServiceReceiver receiver);
    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();
    void userActivity();
}
}
+6 −3
Original line number Original line Diff line number Diff line
@@ -282,9 +282,11 @@ public abstract class BiometricServiceBase extends SystemService


        public EnrollClientImpl(Context context, DaemonWrapper daemon, long halDeviceId,
        public EnrollClientImpl(Context context, DaemonWrapper daemon, long halDeviceId,
                IBinder token, ServiceListener listener, int userId, int groupId,
                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,
            super(context, getMetrics(), daemon, halDeviceId, token, listener,
                    userId, groupId, cryptoToken, restricted, owner, getBiometricUtils());
                    userId, groupId, cryptoToken, restricted, owner, getBiometricUtils(),
                    disabledFeatures);
        }
        }


        @Override
        @Override
@@ -408,7 +410,8 @@ public abstract class BiometricServiceBase extends SystemService
        int cancel() throws RemoteException;
        int cancel() throws RemoteException;
        int remove(int groupId, int biometricId) throws RemoteException;
        int remove(int groupId, int biometricId) throws RemoteException;
        int enumerate() 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 Original line 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 static final int ENROLLMENT_TIMEOUT_MS = 60 * 1000; // 1 minute
    private final byte[] mCryptoToken;
    private final byte[] mCryptoToken;
    private final BiometricUtils mBiometricUtils;
    private final BiometricUtils mBiometricUtils;
    private final int[] mDisabledFeatures;


    public EnrollClient(Context context, Metrics metrics,
    public EnrollClient(Context context, Metrics metrics,
            BiometricServiceBase.DaemonWrapper daemon, long halDeviceId, IBinder token,
            BiometricServiceBase.DaemonWrapper daemon, long halDeviceId, IBinder token,
            BiometricServiceBase.ServiceListener listener, int userId, int groupId,
            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,
        super(context, metrics, daemon, halDeviceId, token, listener, userId, groupId, restricted,
                owner, 0 /* cookie */);
                owner, 0 /* cookie */);
        mBiometricUtils = utils;
        mBiometricUtils = utils;
        mCryptoToken = Arrays.copyOf(cryptoToken, cryptoToken.length);
        mCryptoToken = Arrays.copyOf(cryptoToken, cryptoToken.length);
        mDisabledFeatures = Arrays.copyOf(disabledFeatures, disabledFeatures.length);
    }
    }


    @Override
    @Override
@@ -74,7 +77,13 @@ public abstract class EnrollClient extends ClientMonitor {
    public int start() {
    public int start() {
        final int timeout = (int) (ENROLLMENT_TIMEOUT_MS / MS_PER_SEC);
        final int timeout = (int) (ENROLLMENT_TIMEOUT_MS / MS_PER_SEC);
        try {
        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) {
            if (result != 0) {
                Slog.w(getLogTag(), "startEnroll failed, result=" + result);
                Slog.w(getLogTag(), "startEnroll failed, result=" + result);
                mMetricsLogger.histogram(mMetrics.tagEnrollStartError(), result);
                mMetricsLogger.histogram(mMetrics.tagEnrollStartError(), result);
Loading