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
This commit is contained in:
joshmccloskey
2020-02-04 13:27:03 -08:00
committed by Curtis Belmonte
parent f873dd267e
commit a8f15a5d2e
3 changed files with 16 additions and 4 deletions

View File

@@ -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));
}
/**

View File

@@ -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);

View File

@@ -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 {