1 /*
2  * Copyright (C) 2020 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.biometrics;
17 
18 import android.hardware.biometrics.SensorPropertiesInternal;
19 
20 /**
21  * A test service for FingerprintManager and BiometricManager.
22  * @hide
23  */
24 interface ITestSession {
25     // Switches the specified sensor to use a test HAL. In this mode, the framework will not invoke
26     // any methods on the real HAL implementation. This allows the framework to test a substantial
27     // portion of the framework code that would otherwise require human interaction. Note that
28     // secure pathways such as HAT/Keystore are not testable, since they depend on the TEE or its
29     // equivalent for the secret key.
30     @EnforcePermission("TEST_BIOMETRIC")
setTestHalEnabled(boolean enableTestHal)31     void setTestHalEnabled(boolean enableTestHal);
32 
33     // Starts the enrollment process. This should generally be used when the test HAL is enabled.
34     @EnforcePermission("TEST_BIOMETRIC")
startEnroll(int userId)35     void startEnroll(int userId);
36 
37     // Finishes the enrollment process. Simulates the HAL's callback.
38     @EnforcePermission("TEST_BIOMETRIC")
finishEnroll(int userId)39     void finishEnroll(int userId);
40 
41     // Simulates a successful authentication, but does not provide a valid HAT.
42     @EnforcePermission("TEST_BIOMETRIC")
acceptAuthentication(int userId)43     void acceptAuthentication(int userId);
44 
45     // Simulates a rejected attempt.
46     @EnforcePermission("TEST_BIOMETRIC")
rejectAuthentication(int userId)47     void rejectAuthentication(int userId);
48 
49     // Simulates an acquired message from the HAL.
50     @EnforcePermission("TEST_BIOMETRIC")
notifyAcquired(int userId, int acquireInfo)51     void notifyAcquired(int userId, int acquireInfo);
52 
53     // Simulates an error message from the HAL.
54     @EnforcePermission("TEST_BIOMETRIC")
notifyError(int userId, int errorCode)55     void notifyError(int userId, int errorCode);
56 
57     // Matches the framework's cached enrollments against the HAL's enrollments. Any enrollment
58     // that isn't known by both sides are deleted. This should generally be used when the test
59     // HAL is disabled (e.g. to clean up after a test).
60     @EnforcePermission("TEST_BIOMETRIC")
cleanupInternalState(int userId)61     void cleanupInternalState(int userId);
62 }
63