1 /*
2  * Copyright (C) 2022 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 com.android.server.biometrics.sensors;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.hardware.biometrics.SensorPropertiesInternal;
22 import android.util.proto.ProtoOutputStream;
23 
24 import java.io.FileDescriptor;
25 import java.io.PrintWriter;
26 import java.util.List;
27 
28 /**
29  * Common attributes for all biometric service providers.
30  *
31  * @param <T> Internal settings type.
32  */
33 public interface BiometricServiceProvider<T extends SensorPropertiesInternal> {
34 
35     /** Checks if the specified sensor is owned by this provider. */
containsSensor(int sensorId)36     boolean containsSensor(int sensorId);
37 
38     /** All sensor properties. */
39     @NonNull
getSensorProperties()40     List<T> getSensorProperties();
41 
42     /** Properties for the given sensor id. */
43     @Nullable
getSensorProperties(int sensorId)44     T getSensorProperties(int sensorId);
45 
isHardwareDetected(int sensorId)46     boolean isHardwareDetected(int sensorId);
47 
48     /** If the user has any enrollments for the given sensor. */
hasEnrollments(int sensorId, int userId)49     boolean hasEnrollments(int sensorId, int userId);
50 
getAuthenticatorId(int sensorId, int userId)51     long getAuthenticatorId(int sensorId, int userId);
52 
53     @LockoutTracker.LockoutMode
getLockoutModeForUser(int sensorId, int userId)54     int getLockoutModeForUser(int sensorId, int userId);
55 
dumpProtoState(int sensorId, @NonNull ProtoOutputStream proto, boolean clearSchedulerBuffer)56     void dumpProtoState(int sensorId, @NonNull ProtoOutputStream proto,
57             boolean clearSchedulerBuffer);
58 
dumpProtoMetrics(int sensorId, @NonNull FileDescriptor fd)59     void dumpProtoMetrics(int sensorId, @NonNull FileDescriptor fd);
60 
dumpInternal(int sensorId, @NonNull PrintWriter pw)61     void dumpInternal(int sensorId, @NonNull PrintWriter pw);
62 }
63