1 /*
2  * Copyright (C) 2014 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 package android.hardware.fingerprint;
17 
18 import android.os.Bundle;
19 import android.hardware.biometrics.IBiometricPromptReceiver;
20 import android.hardware.fingerprint.IFingerprintClientActiveCallback;
21 import android.hardware.fingerprint.IFingerprintServiceReceiver;
22 import android.hardware.fingerprint.IFingerprintServiceLockoutResetCallback;
23 import android.hardware.fingerprint.Fingerprint;
24 import java.util.List;
25 
26 /**
27  * Communication channel from client to the fingerprint service.
28  * @hide
29  */
30 interface IFingerprintService {
31     // Authenticate the given sessionId with a fingerprint
authenticate(IBinder token, long sessionId, int userId, IFingerprintServiceReceiver receiver, int flags, String opPackageName, in Bundle bundle, IBiometricPromptReceiver dialogReceiver)32     void authenticate(IBinder token, long sessionId, int userId,
33             IFingerprintServiceReceiver receiver, int flags, String opPackageName,
34             in Bundle bundle, IBiometricPromptReceiver dialogReceiver);
35 
36     // Cancel authentication for the given sessionId
cancelAuthentication(IBinder token, String opPackageName)37     void cancelAuthentication(IBinder token, String opPackageName);
38 
39     // Start fingerprint enrollment
enroll(IBinder token, in byte [] cryptoToken, int groupId, IFingerprintServiceReceiver receiver, int flags, String opPackageName)40     void enroll(IBinder token, in byte [] cryptoToken, int groupId, IFingerprintServiceReceiver receiver,
41             int flags, String opPackageName);
42 
43     // Cancel enrollment in progress
cancelEnrollment(IBinder token)44     void cancelEnrollment(IBinder token);
45 
46     // Any errors resulting from this call will be returned to the listener
remove(IBinder token, int fingerId, int groupId, int userId, IFingerprintServiceReceiver receiver)47     void remove(IBinder token, int fingerId, int groupId, int userId,
48             IFingerprintServiceReceiver receiver);
49 
50     // Rename the fingerprint specified by fingerId and groupId to the given name
rename(int fingerId, int groupId, String name)51     void rename(int fingerId, int groupId, String name);
52 
53     // Get a list of enrolled fingerprints in the given group.
getEnrolledFingerprints(int groupId, String opPackageName)54     List<Fingerprint> getEnrolledFingerprints(int groupId, String opPackageName);
55 
56     // Determine if HAL is loaded and ready
isHardwareDetected(long deviceId, String opPackageName)57     boolean isHardwareDetected(long deviceId, String opPackageName);
58 
59     // Get a pre-enrollment authentication token
preEnroll(IBinder token)60     long preEnroll(IBinder token);
61 
62     // Finish an enrollment sequence and invalidate the authentication token
postEnroll(IBinder token)63     int postEnroll(IBinder token);
64 
65     // Determine if a user has at least one enrolled fingerprint
hasEnrolledFingerprints(int groupId, String opPackageName)66     boolean hasEnrolledFingerprints(int groupId, String opPackageName);
67 
68     // Gets the number of hardware devices
69     // int getHardwareDeviceCount();
70 
71     // Gets the unique device id for hardware enumerated at i
72     // long getHardwareDevice(int i);
73 
74     // Gets the authenticator ID for fingerprint
getAuthenticatorId(String opPackageName)75     long getAuthenticatorId(String opPackageName);
76 
77     // Reset the timeout when user authenticates with strong auth (e.g. PIN, pattern or password)
resetTimeout(in byte [] cryptoToken)78     void resetTimeout(in byte [] cryptoToken);
79 
80     // Add a callback which gets notified when the fingerprint lockout period expired.
addLockoutResetCallback(IFingerprintServiceLockoutResetCallback callback)81     void addLockoutResetCallback(IFingerprintServiceLockoutResetCallback callback);
82 
83     // Explicitly set the active user (for enrolling work profile)
setActiveUser(int uid)84     void setActiveUser(int uid);
85 
86     // Enumerate all fingerprints
enumerate(IBinder token, int userId, IFingerprintServiceReceiver receiver)87     void enumerate(IBinder token, int userId, IFingerprintServiceReceiver receiver);
88 
89     // Check if a client request is currently being handled
isClientActive()90     boolean isClientActive();
91 
92     // Add a callback which gets notified when the service starts and stops handling client requests
addClientActiveCallback(IFingerprintClientActiveCallback callback)93     void addClientActiveCallback(IFingerprintClientActiveCallback callback);
94 
95     // Removes a callback set by addClientActiveCallback
removeClientActiveCallback(IFingerprintClientActiveCallback callback)96     void removeClientActiveCallback(IFingerprintClientActiveCallback callback);
97 }
98