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

Commit a8f15a5d authored by joshmccloskey's avatar joshmccloskey Committed by Curtis Belmonte
Browse files

Configure BiometricPrompt to use AuthService.

BioetricPrompt was incorrectly using BiometricService directly. After
adding a few minor modifications, BiometricPrompt correctly goes through
AuthService.

Test: Verified that BiometricPromptDemo apk is able to authenticate.
Test: Verified that BiometricPromptDemo apk is able to cancel
authenticatoins.
Bug: 141025588

Change-Id: I29646c33a1904c6ad71f3ed2a4b02b6fe159517b
parent f873dd26
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -388,7 +388,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan

    private final IBinder mToken = new Binder();
    private final Context mContext;
    private final IBiometricService mService;
    private final IAuthService mService;
    private final Bundle mBundle;
    private final ButtonInfo mPositiveButtonInfo;
    private final ButtonInfo mNegativeButtonInfo;
@@ -466,8 +466,8 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
        mBundle = bundle;
        mPositiveButtonInfo = positiveButtonInfo;
        mNegativeButtonInfo = negativeButtonInfo;
        mService = IBiometricService.Stub.asInterface(
                ServiceManager.getService(Context.BIOMETRIC_SERVICE));
        mService = IAuthService.Stub.asInterface(
                ServiceManager.getService(Context.AUTH_SERVICE));
    }

    /**
+3 −0
Original line number Diff line number Diff line
@@ -33,6 +33,9 @@ interface IAuthService {
    void authenticate(IBinder token, long sessionId, int userId,
            IBiometricServiceReceiver receiver, String opPackageName, in Bundle bundle);

    // Cancel authentication for the given sessionId
    void cancelAuthentication(IBinder token, String opPackageName);

    // TODO(b/141025588): Make userId the first arg to be consistent with hasEnrolledBiometrics.
    // Checks if biometrics can be used.
    int canAuthenticate(String opPackageName, int userId, int authenticators);
+10 −1
Original line number Diff line number Diff line
@@ -150,11 +150,20 @@ public class AuthService extends SystemService {
                Slog.e(TAG, "Unable to authenticate, one or more null arguments");
                return;
            }

            mBiometricService.authenticate(token, sessionId, userId, receiver, opPackageName,
                    bundle);
        }

        public void cancelAuthentication(IBinder token, String opPackageName)
                throws RemoteException {
            checkPermission();
            if (token == null || opPackageName == null) {
                Slog.e(TAG, "Unable to authenticate, one or more null arguments");
                return;
            }
            mBiometricService.cancelAuthentication(token, opPackageName);
        }

        @Override
        public int canAuthenticate(String opPackageName, int userId,
                @Authenticators.Types int authenticators) throws RemoteException {