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.hardware.biometrics.IBiometricServiceReceiverInternal;
19 import android.hardware.biometrics.IBiometricServiceLockoutResetCallback;
20 import android.hardware.fingerprint.IFingerprintClientActiveCallback;
21 import android.hardware.fingerprint.IFingerprintServiceReceiver;
22 import android.hardware.fingerprint.Fingerprint;
23 import java.util.List;
24 
25 /**
26  * Communication channel from client to the fingerprint service.
27  * @hide
28  */
29 interface IFingerprintService {
30     // Authenticate the given sessionId with a fingerprint. This is protected by
31     // USE_FINGERPRINT/USE_BIOMETRIC permission. This is effectively deprecated, since it only comes
32     // through FingerprintManager now.
authenticate(IBinder token, long sessionId, int userId, IFingerprintServiceReceiver receiver, int flags, String opPackageName)33     void authenticate(IBinder token, long sessionId, int userId,
34             IFingerprintServiceReceiver receiver, int flags, String opPackageName);
35 
36     // This method prepares the service to start authenticating, but doesn't start authentication.
37     // This is protected by the MANAGE_BIOMETRIC signatuer permission. This method should only be
38     // called from BiometricService. The additional uid, pid, userId arguments should be determined
39     // by BiometricService. To start authentication after the clients are ready, use
40     // startPreparedClient().
prepareForAuthentication(IBinder token, long sessionId, int userId, IBiometricServiceReceiverInternal wrapperReceiver, String opPackageName, int cookie, int callingUid, int callingPid, int callingUserId)41     void prepareForAuthentication(IBinder token, long sessionId, int userId,
42             IBiometricServiceReceiverInternal wrapperReceiver, String opPackageName, int cookie,
43             int callingUid, int callingPid, int callingUserId);
44 
45     // Starts authentication with the previously prepared client.
startPreparedClient(int cookie)46     void startPreparedClient(int cookie);
47 
48     // Cancel authentication for the given sessionId
cancelAuthentication(IBinder token, String opPackageName)49     void cancelAuthentication(IBinder token, String opPackageName);
50 
51     // Same as above, except this is protected by the MANAGE_BIOMETRIC signature permission. Takes
52     // an additional uid, pid, userid.
cancelAuthenticationFromService(IBinder token, String opPackageName, int callingUid, int callingPid, int callingUserId, boolean fromClient)53     void cancelAuthenticationFromService(IBinder token, String opPackageName,
54             int callingUid, int callingPid, int callingUserId, boolean fromClient);
55 
56     // Start fingerprint enrollment
enroll(IBinder token, in byte [] cryptoToken, int groupId, IFingerprintServiceReceiver receiver, int flags, String opPackageName)57     void enroll(IBinder token, in byte [] cryptoToken, int groupId, IFingerprintServiceReceiver receiver,
58             int flags, String opPackageName);
59 
60     // Cancel enrollment in progress
cancelEnrollment(IBinder token)61     void cancelEnrollment(IBinder token);
62 
63     // Any errors resulting from this call will be returned to the listener
remove(IBinder token, int fingerId, int groupId, int userId, IFingerprintServiceReceiver receiver)64     void remove(IBinder token, int fingerId, int groupId, int userId,
65             IFingerprintServiceReceiver receiver);
66 
67     // Rename the fingerprint specified by fingerId and groupId to the given name
rename(int fingerId, int groupId, String name)68     void rename(int fingerId, int groupId, String name);
69 
70     // Get a list of enrolled fingerprints in the given group.
getEnrolledFingerprints(int groupId, String opPackageName)71     List<Fingerprint> getEnrolledFingerprints(int groupId, String opPackageName);
72 
73     // Determine if HAL is loaded and ready
isHardwareDetected(long deviceId, String opPackageName)74     boolean isHardwareDetected(long deviceId, String opPackageName);
75 
76     // Get a pre-enrollment authentication token
preEnroll(IBinder token)77     long preEnroll(IBinder token);
78 
79     // Finish an enrollment sequence and invalidate the authentication token
postEnroll(IBinder token)80     int postEnroll(IBinder token);
81 
82     // Determine if a user has at least one enrolled fingerprint
hasEnrolledFingerprints(int groupId, String opPackageName)83     boolean hasEnrolledFingerprints(int groupId, String opPackageName);
84 
85     // Gets the number of hardware devices
86     // int getHardwareDeviceCount();
87 
88     // Gets the unique device id for hardware enumerated at i
89     // long getHardwareDevice(int i);
90 
91     // Gets the authenticator ID for fingerprint
getAuthenticatorId(String opPackageName)92     long getAuthenticatorId(String opPackageName);
93 
94     // Reset the timeout when user authenticates with strong auth (e.g. PIN, pattern or password)
resetTimeout(in byte [] cryptoToken)95     void resetTimeout(in byte [] cryptoToken);
96 
97     // Add a callback which gets notified when the fingerprint lockout period expired.
addLockoutResetCallback(IBiometricServiceLockoutResetCallback callback)98     void addLockoutResetCallback(IBiometricServiceLockoutResetCallback callback);
99 
100     // Explicitly set the active user (for enrolling work profile)
setActiveUser(int uid)101     void setActiveUser(int uid);
102 
103     // Enumerate all fingerprints
enumerate(IBinder token, int userId, IFingerprintServiceReceiver receiver)104     void enumerate(IBinder token, int userId, IFingerprintServiceReceiver receiver);
105 
106     // Check if a client request is currently being handled
isClientActive()107     boolean isClientActive();
108 
109     // Add a callback which gets notified when the service starts and stops handling client requests
addClientActiveCallback(IFingerprintClientActiveCallback callback)110     void addClientActiveCallback(IFingerprintClientActiveCallback callback);
111 
112     // Removes a callback set by addClientActiveCallback
removeClientActiveCallback(IFingerprintClientActiveCallback callback)113     void removeClientActiveCallback(IFingerprintClientActiveCallback callback);
114 }
115