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 package android.hardware.face;
17 
18 import android.hardware.biometrics.IBiometricServiceReceiverInternal;
19 import android.hardware.biometrics.IBiometricServiceLockoutResetCallback;
20 import android.hardware.face.IFaceServiceReceiver;
21 import android.hardware.face.Face;
22 
23 /**
24  * Communication channel from client to the face service. These methods are all require the
25  * MANAGE_BIOMETRIC signature permission.
26  * @hide
27  */
28 interface IFaceService {
29     // Authenticate the given sessionId with a face
authenticate(IBinder token, long sessionId, int userid, IFaceServiceReceiver receiver, int flags, String opPackageName)30     void authenticate(IBinder token, long sessionId, int userid,
31             IFaceServiceReceiver receiver, int flags, String opPackageName);
32 
33     // This method prepares the service to start authenticating, but doesn't start authentication.
34     // This is protected by the MANAGE_BIOMETRIC signatuer permission. This method should only be
35     // called from BiometricService. The additional uid, pid, userId arguments should be determined
36     // by BiometricService. To start authentication after the clients are ready, use
37     // startPreparedClient().
prepareForAuthentication(boolean requireConfirmation, IBinder token, long sessionId, int userId, IBiometricServiceReceiverInternal wrapperReceiver, String opPackageName, int cookie, int callingUid, int callingPid, int callingUserId)38     void prepareForAuthentication(boolean requireConfirmation, IBinder token, long sessionId,
39             int userId, IBiometricServiceReceiverInternal wrapperReceiver, String opPackageName,
40             int cookie, int callingUid, int callingPid, int callingUserId);
41 
42     // Starts authentication with the previously prepared client.
startPreparedClient(int cookie)43     void startPreparedClient(int cookie);
44 
45     // Cancel authentication for the given sessionId
cancelAuthentication(IBinder token, String opPackageName)46     void cancelAuthentication(IBinder token, String opPackageName);
47 
48     // Same as above, with extra arguments.
cancelAuthenticationFromService(IBinder token, String opPackageName, int callingUid, int callingPid, int callingUserId, boolean fromClient)49     void cancelAuthenticationFromService(IBinder token, String opPackageName,
50             int callingUid, int callingPid, int callingUserId, boolean fromClient);
51 
52     // Start face enrollment
enroll(int userId, IBinder token, in byte [] cryptoToken, IFaceServiceReceiver receiver, String opPackageName, in int [] disabledFeatures)53     void enroll(int userId, IBinder token, in byte [] cryptoToken, IFaceServiceReceiver receiver,
54             String opPackageName, in int [] disabledFeatures);
55 
56     // Cancel enrollment in progress
cancelEnrollment(IBinder token)57     void cancelEnrollment(IBinder token);
58 
59     // Any errors resulting from this call will be returned to the listener
remove(IBinder token, int faceId, int userId, IFaceServiceReceiver receiver, String opPackageName)60     void remove(IBinder token, int faceId, int userId, IFaceServiceReceiver receiver,
61             String opPackageName);
62 
63     // Rename the face specified by faceId to the given name
rename(int faceId, String name)64     void rename(int faceId, String name);
65 
66     // Get the enrolled face for user.
getEnrolledFaces(int userId, String opPackageName)67     List<Face> getEnrolledFaces(int userId, String opPackageName);
68 
69     // Determine if HAL is loaded and ready
isHardwareDetected(long deviceId, String opPackageName)70     boolean isHardwareDetected(long deviceId, String opPackageName);
71 
72     // Get a pre-enrollment authentication token
generateChallenge(IBinder token)73     long generateChallenge(IBinder token);
74 
75     // Finish an enrollment sequence and invalidate the authentication token
revokeChallenge(IBinder token)76     int revokeChallenge(IBinder token);
77 
78     // Determine if a user has at least one enrolled face
hasEnrolledFaces(int userId, String opPackageName)79     boolean hasEnrolledFaces(int userId, String opPackageName);
80 
81     // Gets the number of hardware devices
82     // int getHardwareDeviceCount();
83 
84     // Gets the unique device id for hardware enumerated at i
85     // long getHardwareDevice(int i);
86 
87     // Gets the authenticator ID for face
getAuthenticatorId(String opPackageName)88     long getAuthenticatorId(String opPackageName);
89 
90     // Reset the lockout when user authenticates with strong auth (e.g. PIN, pattern or password)
resetLockout(in byte [] token)91     void resetLockout(in byte [] token);
92 
93     // Add a callback which gets notified when the face lockout period expired.
addLockoutResetCallback(IBiometricServiceLockoutResetCallback callback)94     void addLockoutResetCallback(IBiometricServiceLockoutResetCallback callback);
95 
96     // Explicitly set the active user (for enrolling work profile)
setActiveUser(int uid)97     void setActiveUser(int uid);
98 
99     // Enumerate all faces
enumerate(IBinder token, int userId, IFaceServiceReceiver receiver)100     void enumerate(IBinder token, int userId, IFaceServiceReceiver receiver);
101 
setFeature(int userId, int feature, boolean enabled, in byte [] token, IFaceServiceReceiver receiver, String opPackageName)102     void setFeature(int userId, int feature, boolean enabled, in byte [] token,
103             IFaceServiceReceiver receiver, String opPackageName);
104 
getFeature(int userId, int feature, IFaceServiceReceiver receiver, String opPackageName)105     void getFeature(int userId, int feature, IFaceServiceReceiver receiver, String opPackageName);
106 
userActivity()107     void userActivity();
108 }
109