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.hardware.biometrics.IBiometricEnabledOnKeyguardCallback;
20 import android.hardware.biometrics.IBiometricServiceReceiver;
21 import android.hardware.biometrics.IBiometricAuthenticator;
22 import android.hardware.biometrics.IInvalidationCallback;
23 import android.hardware.biometrics.ITestSession;
24 import android.hardware.biometrics.ITestSessionCallback;
25 import android.hardware.biometrics.PromptInfo;
26 import android.hardware.biometrics.SensorPropertiesInternal;
27 
28 /**
29  * Communication channel from AuthService to BiometricService.
30  * @hide
31  */
32 interface IBiometricService {
33     // Creates a test session with the specified sensorId
createTestSession(int sensorId, ITestSessionCallback callback, String opPackageName)34     ITestSession createTestSession(int sensorId, ITestSessionCallback callback, String opPackageName);
35 
36     // Retrieve static sensor properties for all biometric sensors
getSensorProperties(String opPackageName)37     List<SensorPropertiesInternal> getSensorProperties(String opPackageName);
38 
39     // Requests authentication. The service chooses the appropriate biometric to use, and shows
40     // the corresponding BiometricDialog. A requestId is returned that can be used to cancel
41     // this operation.
authenticate(IBinder token, long operationId, int userId, IBiometricServiceReceiver receiver, String opPackageName, in PromptInfo promptInfo)42     long authenticate(IBinder token, long operationId, int userId,
43             IBiometricServiceReceiver receiver, String opPackageName, in PromptInfo promptInfo);
44 
45     // Cancel authentication for the given requestId.
cancelAuthentication(IBinder token, String opPackageName, long requestId)46     void cancelAuthentication(IBinder token, String opPackageName, long requestId);
47 
48     // Checks if biometrics can be used.
canAuthenticate(String opPackageName, int userId, int callingUserId, int authenticators)49     int canAuthenticate(String opPackageName, int userId, int callingUserId, int authenticators);
50 
51     // Checks if any biometrics are enrolled.
hasEnrolledBiometrics(int userId, String opPackageName)52     boolean hasEnrolledBiometrics(int userId, String opPackageName);
53 
54     // Registers an authenticator (e.g. face, fingerprint, iris).
55     // Id must be unique, whereas strength and modality don't need to be.
56     // TODO(b/123321528): Turn strength and modality into enums.
registerAuthenticator(int id, int modality, int strength, IBiometricAuthenticator authenticator)57     void registerAuthenticator(int id, int modality, int strength,
58             IBiometricAuthenticator authenticator);
59 
60     // Register callback for when keyguard biometric eligibility changes.
registerEnabledOnKeyguardCallback(IBiometricEnabledOnKeyguardCallback callback, int callingUserId)61     void registerEnabledOnKeyguardCallback(IBiometricEnabledOnKeyguardCallback callback,
62             int callingUserId);
63 
64     // Notify BiometricService when <Biometric>Service is ready to start the prepared client.
65     // Client lifecycle is still managed in <Biometric>Service.
onReadyForAuthentication(int cookie)66     void onReadyForAuthentication(int cookie);
67 
68     // Requests all BIOMETRIC_STRONG sensors to have their authenticatorId invalidated for the
69     // specified user. This happens when enrollments have been added on devices with multiple
70     // biometric sensors.
invalidateAuthenticatorIds(int userId, int fromSensorId, IInvalidationCallback callback)71     void invalidateAuthenticatorIds(int userId, int fromSensorId, IInvalidationCallback callback);
72 
73     // Get a list of AuthenticatorIDs for authenticators which have enrolled templates and meet
74     // the requirements for integrating with Keystore. The AuthenticatorID are known in Keystore
75     // land as SIDs, and are used during key generation.
getAuthenticatorIds(int callingUserId)76     long[] getAuthenticatorIds(int callingUserId);
77 
78     // See documentation in BiometricManager.
resetLockoutTimeBound(IBinder token, String opPackageName, int fromSensorId, int userId, in byte[] hardwareAuthToken)79     void resetLockoutTimeBound(IBinder token, String opPackageName, int fromSensorId, int userId,
80             in byte[] hardwareAuthToken);
81 
getCurrentStrength(int sensorId)82     int getCurrentStrength(int sensorId);
83 
84     // Returns a bit field of the modality (or modalities) that are will be used for authentication.
getCurrentModality(String opPackageName, int userId, int callingUserId, int authenticators)85     int getCurrentModality(String opPackageName, int userId, int callingUserId, int authenticators);
86 
87     // Returns a bit field of the authentication modalities that are supported by this device.
getSupportedModalities(int authenticators)88     int getSupportedModalities(int authenticators);
89 }
90