1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.hardware.biometrics; 18 19 import android.os.Bundle; 20 import android.hardware.biometrics.IBiometricConfirmDeviceCredentialCallback; 21 import android.hardware.biometrics.IBiometricEnabledOnKeyguardCallback; 22 import android.hardware.biometrics.IBiometricServiceReceiver; 23 24 /** 25 * Communication channel from BiometricPrompt and BiometricManager to BiometricService. The 26 * interface does not expose specific biometric modalities. The system will use the default 27 * biometric for apps. On devices with more than one, the choice is dictated by user preference in 28 * Settings. 29 * @hide 30 */ 31 interface IBiometricService { 32 // Requests authentication. The service choose the appropriate biometric to use, and show 33 // the corresponding BiometricDialog. 34 // TODO(b/123378871): Remove callback when moved. authenticate(IBinder token, long sessionId, int userId, IBiometricServiceReceiver receiver, String opPackageName, in Bundle bundle, IBiometricConfirmDeviceCredentialCallback callback)35 void authenticate(IBinder token, long sessionId, int userId, 36 IBiometricServiceReceiver receiver, String opPackageName, in Bundle bundle, 37 IBiometricConfirmDeviceCredentialCallback callback); 38 39 // Cancel authentication for the given sessionId cancelAuthentication(IBinder token, String opPackageName)40 void cancelAuthentication(IBinder token, String opPackageName); 41 42 // Checks if biometrics can be used. canAuthenticate(String opPackageName, int userId)43 int canAuthenticate(String opPackageName, int userId); 44 45 // Checks if any biometrics are enrolled. hasEnrolledBiometrics(int userId)46 boolean hasEnrolledBiometrics(int userId); 47 48 // Register callback for when keyguard biometric eligibility changes. registerEnabledOnKeyguardCallback(IBiometricEnabledOnKeyguardCallback callback)49 void registerEnabledOnKeyguardCallback(IBiometricEnabledOnKeyguardCallback callback); 50 51 // Explicitly set the active user. setActiveUser(int userId)52 void setActiveUser(int userId); 53 54 // Notify BiometricService when <Biometric>Service is ready to start the prepared client. 55 // Client lifecycle is still managed in <Biometric>Service. onReadyForAuthentication(int cookie, boolean requireConfirmation, int userId)56 void onReadyForAuthentication(int cookie, boolean requireConfirmation, int userId); 57 58 // Reset the lockout when user authenticates with strong auth (e.g. PIN, pattern or password) resetLockout(in byte [] token)59 void resetLockout(in byte [] token); 60 61 // TODO(b/123378871): Remove when moved. 62 // CDCA needs to send results to BiometricService if it was invoked using BiometricPrompt's 63 // setAllowDeviceCredential method, since there's no way for us to intercept onActivityResult. 64 // CDCA is launched from BiometricService (startActivityAsUser) instead of *ForResult. onConfirmDeviceCredentialSuccess()65 void onConfirmDeviceCredentialSuccess(); 66 // TODO(b/123378871): Remove when moved. onConfirmDeviceCredentialError(int error, String message)67 void onConfirmDeviceCredentialError(int error, String message); 68 // TODO(b/123378871): Remove when moved. 69 // When ConfirmLock* is invoked from BiometricPrompt, it needs to register a callback so that 70 // it can receive the cancellation signal. registerCancellationCallback(IBiometricConfirmDeviceCredentialCallback callback)71 void registerCancellationCallback(IBiometricConfirmDeviceCredentialCallback callback); 72 } 73