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

Commit fc7dc9b4 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

22/n: Remove "flags" parameter from authenticate and enroll

Not used and ambiguous. Also fixed naming for hardwareAuthToken param
in areas that were previously missed.

Bug: 157790417

Test: Builds
Change-Id: I55f73d519cd3c69c4c03b6408588e793c8553869
parent 624bfe12
Loading
Loading
Loading
Loading
+14 −18
Original line number Diff line number Diff line
@@ -165,7 +165,6 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
     *
     * @param crypto   object associated with the call or null if none required.
     * @param cancel   an object that can be used to cancel authentication
     * @param flags    optional flags; should be 0
     * @param callback an object to receive authentication events
     * @param handler  an optional handler to handle callback events
     * @throws IllegalArgumentException if the crypto operation is not supported or is not backed
@@ -177,8 +176,8 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
     */
    @RequiresPermission(USE_BIOMETRIC_INTERNAL)
    public void authenticate(@Nullable CryptoObject crypto, @Nullable CancellationSignal cancel,
            int flags, @NonNull AuthenticationCallback callback, @Nullable Handler handler) {
        authenticate(crypto, cancel, flags, callback, handler, mContext.getUserId());
            @NonNull AuthenticationCallback callback, @Nullable Handler handler) {
        authenticate(crypto, cancel, callback, handler, mContext.getUserId());
    }

    /**
@@ -202,7 +201,6 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
     *
     * @param crypto   object associated with the call or null if none required.
     * @param cancel   an object that can be used to cancel authentication
     * @param flags    optional flags; should be 0
     * @param callback an object to receive authentication events
     * @param handler  an optional handler to handle callback events
     * @param userId   userId to authenticate for
@@ -214,8 +212,7 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
     * @hide
     */
    public void authenticate(@Nullable CryptoObject crypto, @Nullable CancellationSignal cancel,
            int flags, @NonNull AuthenticationCallback callback, @Nullable Handler handler,
            int userId) {
            @NonNull AuthenticationCallback callback, @Nullable Handler handler, int userId) {
        if (callback == null) {
            throw new IllegalArgumentException("Must supply an authentication callback");
        }
@@ -237,7 +234,7 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
                final long operationId = crypto != null ? crypto.getOpId() : 0;
                Trace.beginSection("FaceManager#authenticate");
                mService.authenticate(mToken, operationId, userId, mServiceReceiver,
                        flags, mContext.getOpPackageName());
                        mContext.getOpPackageName());
            } catch (RemoteException e) {
                Slog.w(TAG, "Remote exception while authenticating: ", e);
                if (callback != null) {
@@ -260,9 +257,9 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
     * @see FaceManager#enroll(int, byte[], CancellationSignal, EnrollmentCallback, int[], Surface)
     */
    @RequiresPermission(MANAGE_BIOMETRIC)
    public void enroll(int userId, byte[] token, CancellationSignal cancel,
    public void enroll(int userId, byte[] hardwareAuthToken, CancellationSignal cancel,
            EnrollmentCallback callback, int[] disabledFeatures) {
        enroll(userId, token, cancel, callback, disabledFeatures, null /* surface */);
        enroll(userId, hardwareAuthToken, cancel, callback, disabledFeatures, null /* surface */);
    }

    /**
@@ -277,7 +274,6 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
     * @param token    a unique token provided by a recent creation or verification of device
     *                 credentials (e.g. pin, pattern or password).
     * @param cancel   an object that can be used to cancel enrollment
     * @param flags    optional flags
     * @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. Must be null if
@@ -285,7 +281,7 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
     * @hide
     */
    @RequiresPermission(MANAGE_BIOMETRIC)
    public void enroll(int userId, byte[] token, CancellationSignal cancel,
    public void enroll(int userId, byte[] hardwareAuthToken, CancellationSignal cancel,
            EnrollmentCallback callback, int[] disabledFeatures, @Nullable Surface surface) {
        if (callback == null) {
            throw new IllegalArgumentException("Must supply an enrollment callback");
@@ -304,7 +300,7 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
            try {
                mEnrollmentCallback = callback;
                Trace.beginSection("FaceManager#enroll");
                mService.enroll(userId, mToken, token, mServiceReceiver,
                mService.enroll(userId, mToken, hardwareAuthToken, mServiceReceiver,
                        mContext.getOpPackageName(), disabledFeatures, surface);
            } catch (RemoteException e) {
                Slog.w(TAG, "Remote exception in enroll: ", e);
@@ -329,15 +325,15 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
     * which point the object is no longer valid. The operation can be canceled by using the
     * provided cancel object.
     *
     * @param token    a unique token provided by a recent creation or verification of device
     *                 credentials (e.g. pin, pattern or password).
     * @param hardwareAuthToken    a unique token provided by a recent creation or verification of
     *                 device credentials (e.g. pin, pattern or password).
     * @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
     * @hide
     */
    @RequiresPermission(MANAGE_BIOMETRIC)
    public void enrollRemotely(int userId, byte[] token, CancellationSignal cancel,
    public void enrollRemotely(int userId, byte[] hardwareAuthToken, CancellationSignal cancel,
            EnrollmentCallback callback, int[] disabledFeatures) {
        if (callback == null) {
            throw new IllegalArgumentException("Must supply an enrollment callback");
@@ -356,7 +352,7 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
            try {
                mEnrollmentCallback = callback;
                Trace.beginSection("FaceManager#enrollRemotely");
                mService.enrollRemotely(userId, mToken, token, mServiceReceiver,
                mService.enrollRemotely(userId, mToken, hardwareAuthToken, mServiceReceiver,
                        mContext.getOpPackageName(), disabledFeatures);
            } catch (RemoteException e) {
                Slog.w(TAG, "Remote exception in enrollRemotely: ", e);
@@ -444,12 +440,12 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
     * @hide
     */
    @RequiresPermission(MANAGE_BIOMETRIC)
    public void setFeature(int userId, int feature, boolean enabled, byte[] token,
    public void setFeature(int userId, int feature, boolean enabled, byte[] hardwareAuthToken,
            SetFeatureCallback callback) {
        if (mService != null) {
            try {
                mSetFeatureCallback = callback;
                mService.setFeature(mToken, userId, feature, enabled, token,
                mService.setFeature(mToken, userId, feature, enabled, hardwareAuthToken,
                        mServiceReceiver, mContext.getOpPackageName());
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
+5 −5
Original line number Diff line number Diff line
@@ -28,8 +28,8 @@ import android.view.Surface;
 */
interface IFaceService {
    // Authenticate the given sessionId with a face
    void authenticate(IBinder token, long operationId, int userid,
            IFaceServiceReceiver receiver, int flags, String opPackageName);
    void authenticate(IBinder token, long operationId, int userid, IFaceServiceReceiver receiver,
            String opPackageName);

    // This method prepares the service to start authenticating, but doesn't start authentication.
    // This is protected by the MANAGE_BIOMETRIC signatuer permission. This method should only be
@@ -51,11 +51,11 @@ interface IFaceService {
            int callingUid, int callingPid, int callingUserId);

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

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

    // Cancel enrollment in progress
@@ -87,7 +87,7 @@ interface IFaceService {
    long getAuthenticatorId(int callingUserId);

    // Reset the lockout when user authenticates with strong auth (e.g. PIN, pattern or password)
    void resetLockout(int userId, in byte [] token);
    void resetLockout(int userId, in byte [] hardwareAuthToken);

    // Add a callback which gets notified when the face lockout period expired.
    void addLockoutResetCallback(IBiometricServiceLockoutResetCallback callback);
+16 −17
Original line number Diff line number Diff line
@@ -277,7 +277,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing

    /**
     * Callback structure provided to {@link FingerprintManager#enroll(byte[], CancellationSignal,
     * int, int, EnrollmentCallback)} must provide an implementation of this for listening to
     * int, EnrollmentCallback)} must provide an implementation of this for listening to
     * fingerprint events.
     *
     * @hide
@@ -387,7 +387,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
    @RequiresPermission(anyOf = {USE_BIOMETRIC, USE_FINGERPRINT})
    public void authenticate(@Nullable CryptoObject crypto, @Nullable CancellationSignal cancel,
            int flags, @NonNull AuthenticationCallback callback, @Nullable Handler handler) {
        authenticate(crypto, cancel, flags, callback, handler, mContext.getUserId());
        authenticate(crypto, cancel, callback, handler, mContext.getUserId());
    }

    /**
@@ -403,18 +403,18 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
    }

    /**
     * Defaults to {@link FingerprintManager#authenticate(CryptoObject, CancellationSignal, int,
     * Defaults to {@link FingerprintManager#authenticate(CryptoObject, CancellationSignal,
     * AuthenticationCallback, Handler, int, Surface)} with {@code surface} set to null.
     *
     * @see FingerprintManager#authenticate(CryptoObject, CancellationSignal, int,
     * @see FingerprintManager#authenticate(CryptoObject, CancellationSignal,
     * AuthenticationCallback, Handler, int, Surface)
     *
     * @hide
     */
    @RequiresPermission(anyOf = {USE_BIOMETRIC, USE_FINGERPRINT})
    public void authenticate(@Nullable CryptoObject crypto, @Nullable CancellationSignal cancel,
            int flags, @NonNull AuthenticationCallback callback, Handler handler, int userId) {
        authenticate(crypto, cancel, flags, callback, handler, userId, null /* surface */);
            @NonNull AuthenticationCallback callback, Handler handler, int userId) {
        authenticate(crypto, cancel, callback, handler, userId, null /* surface */);
    }

    /**
@@ -428,7 +428,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
     */
    @RequiresPermission(anyOf = {USE_BIOMETRIC, USE_FINGERPRINT})
    public void authenticate(@Nullable CryptoObject crypto, @Nullable CancellationSignal cancel,
            int flags, @NonNull AuthenticationCallback callback, Handler handler, int userId,
            @NonNull AuthenticationCallback callback, Handler handler, int userId,
            @Nullable Surface surface) {
        if (callback == null) {
            throw new IllegalArgumentException("Must supply an authentication callback");
@@ -449,7 +449,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
                mAuthenticationCallback = callback;
                mCryptoObject = crypto;
                final long operationId = crypto != null ? crypto.getOpId() : 0;
                mService.authenticate(mToken, operationId, userId, mServiceReceiver, flags,
                mService.authenticate(mToken, operationId, userId, mServiceReceiver,
                        mContext.getOpPackageName(), surface);
            } catch (RemoteException e) {
                Slog.w(TAG, "Remote exception while authenticating: ", e);
@@ -463,18 +463,18 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
    }

    /**
     * Defaults to {@link FingerprintManager#enroll(byte[], CancellationSignal, int, int,
     * Defaults to {@link FingerprintManager#enroll(byte[], CancellationSignal, int,
     * EnrollmentCallback, Surface)} with {@code surface} set to null.
     *
     * @see FingerprintManager#enroll(byte[], CancellationSignal, int, int, EnrollmentCallback,
     * @see FingerprintManager#enroll(byte[], CancellationSignal, int, EnrollmentCallback,
     * Surface)
     *
     * @hide
     */
    @RequiresPermission(MANAGE_FINGERPRINT)
    public void enroll(byte [] token, CancellationSignal cancel, int flags,
            int userId, EnrollmentCallback callback) {
        enroll(token, cancel, flags, userId, callback, null /* surface */);
    public void enroll(byte [] hardwareAuthToken, CancellationSignal cancel, int userId,
            EnrollmentCallback callback) {
        enroll(hardwareAuthToken, cancel, userId, callback, null /* surface */);
    }

    /**
@@ -488,14 +488,13 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
     * @param token a unique token provided by a recent creation or verification of device
     * credentials (e.g. pin, pattern or password).
     * @param cancel an object that can be used to cancel enrollment
     * @param flags optional flags
     * @param userId the user to whom this fingerprint will belong to
     * @param callback an object to receive enrollment events
     * @hide
     */
    @RequiresPermission(MANAGE_FINGERPRINT)
    public void enroll(byte [] token, CancellationSignal cancel, int flags,
            int userId, EnrollmentCallback callback, @Nullable Surface surface) {
    public void enroll(byte [] hardwareAuthToken, CancellationSignal cancel, int userId,
            EnrollmentCallback callback, @Nullable Surface surface) {
        if (userId == UserHandle.USER_CURRENT) {
            userId = getCurrentUserId();
        }
@@ -515,7 +514,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        if (mService != null) {
            try {
                mEnrollmentCallback = callback;
                mService.enroll(mToken, token, userId, mServiceReceiver, flags,
                mService.enroll(mToken, hardwareAuthToken, userId, mServiceReceiver,
                        mContext.getOpPackageName(), surface);
            } catch (RemoteException e) {
                Slog.w(TAG, "Remote exception in enroll: ", e);
+4 −5
Original line number Diff line number Diff line
@@ -32,8 +32,7 @@ interface IFingerprintService {
    // USE_FINGERPRINT/USE_BIOMETRIC permission. This is effectively deprecated, since it only comes
    // through FingerprintManager now.
    void authenticate(IBinder token, long operationId, int userId,
            IFingerprintServiceReceiver receiver, int flags, String opPackageName,
            in Surface surface);
            IFingerprintServiceReceiver receiver, String opPackageName, in Surface surface);

    // This method prepares the service to start authenticating, but doesn't start authentication.
    // This is protected by the MANAGE_BIOMETRIC signatuer permission. This method should only be
@@ -56,8 +55,8 @@ interface IFingerprintService {
            int callingUid, int callingPid, int callingUserId);

    // Start fingerprint enrollment
    void enroll(IBinder token, in byte [] cryptoToken, int userId, IFingerprintServiceReceiver receiver,
            int flags, String opPackageName, in Surface surface);
    void enroll(IBinder token, in byte [] hardwareAuthToken, int userId, IFingerprintServiceReceiver receiver,
            String opPackageName, in Surface surface);

    // Cancel enrollment in progress
    void cancelEnrollment(IBinder token);
@@ -91,7 +90,7 @@ interface IFingerprintService {
    long getAuthenticatorId(int callingUserId);

    // Reset the timeout when user authenticates with strong auth (e.g. PIN, pattern or password)
    void resetLockout(int userId, in byte [] cryptoToken);
    void resetLockout(int userId, in byte [] hardwareAuthToken);

    // Add a callback which gets notified when the fingerprint lockout period expired.
    void addLockoutResetCallback(IBiometricServiceLockoutResetCallback callback);
+4 −4
Original line number Diff line number Diff line
@@ -2026,8 +2026,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                mFingerprintCancelSignal.cancel();
            }
            mFingerprintCancelSignal = new CancellationSignal();
            mFpm.authenticate(null, mFingerprintCancelSignal, 0, mFingerprintAuthenticationCallback,
                    null, userId);
            mFpm.authenticate(null /* crypto */, mFingerprintCancelSignal,
                    mFingerprintAuthenticationCallback, null /* handler */, userId);
            setFingerprintRunningState(BIOMETRIC_STATE_RUNNING);
        }
    }
@@ -2044,8 +2044,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                mFaceCancelSignal.cancel();
            }
            mFaceCancelSignal = new CancellationSignal();
            mFaceManager.authenticate(null, mFaceCancelSignal, 0,
                    mFaceAuthenticationCallback, null, userId);
            mFaceManager.authenticate(null /* crypto */, mFaceCancelSignal,
                    mFaceAuthenticationCallback, null /* handler */, userId);
            setFaceRunningState(BIOMETRIC_STATE_RUNNING);
        }
    }
Loading