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

Commit 95ce6513 authored by Haining Chen's avatar Haining Chen Committed by Android (Google) Code Review
Browse files

Merge "Add onAuthenticationSucceeded and onAuthenticationFailed" into main

parents 75563382 a6d2a359
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -33,4 +33,20 @@ oneway interface AuthenticationStateListener {
     * Defines behavior in response to authentication stopping
     */
    void onAuthenticationStopped();

    /**
     * Defines behavior in response to a successful authentication
     * @param requestReason Reason from [BiometricRequestConstants.RequestReason] for the requested
     *                      authentication
     * @param userId The user Id for the requested authentication
     */
    void onAuthenticationSucceeded(int requestReason, int userId);

    /**
     * Defines behavior in response to a failed authentication
     * @param requestReason Reason from [BiometricRequestConstants.RequestReason] for the requested
     *                      authentication
     * @param userId The user Id for the requested authentication
     */
    void onAuthenticationFailed(int requestReason, int userId);
}
+9 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package android.hardware.face;

import android.hardware.biometrics.AuthenticationStateListener;
import android.hardware.biometrics.IBiometricSensorReceiver;
import android.hardware.biometrics.IBiometricServiceLockoutResetCallback;
import android.hardware.biometrics.IBiometricStateListener;
@@ -181,6 +182,14 @@ interface IFaceService {
    // authenticators. The callback is automatically removed after it's invoked.
    void addAuthenticatorsRegisteredCallback(IFaceAuthenticatorsRegisteredCallback callback);

    // Registers AuthenticationStateListener.
    @EnforcePermission("USE_BIOMETRIC_INTERNAL")
    void registerAuthenticationStateListener(AuthenticationStateListener listener);

    // Unregisters AuthenticationStateListener.
    @EnforcePermission("USE_BIOMETRIC_INTERNAL")
    void unregisterAuthenticationStateListener(AuthenticationStateListener listener);

    // Registers BiometricStateListener.
    void registerBiometricStateListener(IBiometricStateListener listener);

+4 −0
Original line number Diff line number Diff line
@@ -94,6 +94,10 @@ constructor(
                        override fun onAuthenticationStopped() {
                            updateFingerprintAuthenticateReason(AuthenticationReason.NotRunning)
                        }

                        override fun onAuthenticationSucceeded(requestReason: Int, userId: Int) {}

                        override fun onAuthenticationFailed(requestReason: Int, userId: Int) {}
                    }

                updateFingerprintAuthenticateReason(AuthenticationReason.NotRunning)
+8 −0
Original line number Diff line number Diff line
@@ -439,6 +439,10 @@ public class AuthService extends SystemService {
            if (fingerprintService != null) {
                fingerprintService.registerAuthenticationStateListener(listener);
            }
            final IFaceService faceService = mInjector.getFaceService();
            if (faceService != null) {
                faceService.registerAuthenticationStateListener(listener);
            }
        }

        @Override
@@ -449,6 +453,10 @@ public class AuthService extends SystemService {
            if (fingerprintService != null) {
                fingerprintService.unregisterAuthenticationStateListener(listener);
            }
            final IFaceService faceService = mInjector.getFaceService();
            if (faceService != null) {
                faceService.unregisterAuthenticationStateListener(listener);
            }
        }

        @Override
+34 −0
Original line number Diff line number Diff line
@@ -91,6 +91,40 @@ public class AuthenticationStateListeners implements IBinder.DeathRecipient {
        }
    }

    /**
     * Defines behavior in response to a successful authentication
     * @param requestReason Reason from [BiometricRequestConstants.RequestReason] for the requested
     *                      authentication
     * @param userId The user Id for the requested authentication
     */
    public void onAuthenticationSucceeded(int requestReason, int userId) {
        for (AuthenticationStateListener listener: mAuthenticationStateListeners) {
            try {
                listener.onAuthenticationSucceeded(requestReason, userId);
            } catch (RemoteException e) {
                Slog.e(TAG, "Remote exception in notifying listener that authentication "
                        + "succeeded", e);
            }
        }
    }

    /**
     * Defines behavior in response to a failed authentication
     * @param requestReason Reason from [BiometricRequestConstants.RequestReason] for the requested
     *                      authentication
     * @param userId The user Id for the requested authentication
     */
    public void onAuthenticationFailed(int requestReason, int userId) {
        for (AuthenticationStateListener listener: mAuthenticationStateListeners) {
            try {
                listener.onAuthenticationFailed(requestReason, userId);
            } catch (RemoteException e) {
                Slog.e(TAG, "Remote exception in notifying listener that authentication "
                        + "failed", e);
            }
        }
    }

    @Override
    public void binderDied() {
        // Do nothing, handled below
Loading