xref: /aosp_15_r20/hardware/interfaces/biometrics/face/aidl/default/FaceConfig.cpp (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1 /*
2  * Copyright (C) 2024 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 #define LOG_TAG "FaceConfig"
18 
19 #include "FaceConfig.h"
20 
21 #include <android-base/logging.h>
22 
23 #include <face.sysprop.h>
24 
25 using namespace ::android::face::virt;
26 
27 namespace aidl::android::hardware::biometrics::face {
28 
29 // Wrapper to system property access functions
30 #define CREATE_GETTER_SETTER_WRAPPER(_NAME_, _T_)           \
31     ConfigValue _NAME_##Getter() {                          \
32         return FaceHalProperties::_NAME_();                 \
33     }                                                       \
34     bool _NAME_##Setter(const ConfigValue& v) {             \
35         return FaceHalProperties::_NAME_(std::get<_T_>(v)); \
36     }
37 
38 CREATE_GETTER_SETTER_WRAPPER(type, OptString)
39 CREATE_GETTER_SETTER_WRAPPER(enrollments, OptIntVec)
40 CREATE_GETTER_SETTER_WRAPPER(enrollment_hit, OptInt32)
41 CREATE_GETTER_SETTER_WRAPPER(next_enrollment, OptString)
42 CREATE_GETTER_SETTER_WRAPPER(authenticator_id, OptInt64)
43 CREATE_GETTER_SETTER_WRAPPER(challenge, OptInt64)
44 CREATE_GETTER_SETTER_WRAPPER(strength, OptString)
45 CREATE_GETTER_SETTER_WRAPPER(operation_authenticate_fails, OptBool)
46 CREATE_GETTER_SETTER_WRAPPER(operation_authenticate_latency, OptIntVec)
47 CREATE_GETTER_SETTER_WRAPPER(operation_authenticate_duration, OptInt32)
48 CREATE_GETTER_SETTER_WRAPPER(operation_authenticate_error, OptInt32)
49 CREATE_GETTER_SETTER_WRAPPER(operation_authenticate_acquired, OptString)
50 CREATE_GETTER_SETTER_WRAPPER(operation_enroll_latency, OptIntVec)
51 CREATE_GETTER_SETTER_WRAPPER(operation_detect_interaction_fails, OptBool)
52 CREATE_GETTER_SETTER_WRAPPER(operation_detect_interaction_latency, OptIntVec)
53 CREATE_GETTER_SETTER_WRAPPER(lockout, OptBool)
54 CREATE_GETTER_SETTER_WRAPPER(lockout_enable, OptBool)
55 CREATE_GETTER_SETTER_WRAPPER(lockout_timed_enable, OptBool)
56 CREATE_GETTER_SETTER_WRAPPER(lockout_timed_threshold, OptInt32)
57 CREATE_GETTER_SETTER_WRAPPER(lockout_timed_duration, OptInt32)
58 CREATE_GETTER_SETTER_WRAPPER(lockout_permanent_threshold, OptInt32)
59 CREATE_GETTER_SETTER_WRAPPER(features, OptIntVec)
60 
61 // Name, Getter, Setter, Parser and default value
62 #define NGS(_NAME_) #_NAME_, _NAME_##Getter, _NAME_##Setter
63 static Config::Data configData[] = {
64         {NGS(type), &Config::parseString, "rgb"},
65         {NGS(enrollments), &Config::parseIntVec, ""},
66         {NGS(enrollment_hit), &Config::parseInt32, "0"},
67         {NGS(next_enrollment), &Config::parseString,
68          "1:1000-[21,7,1,1103],1500-[1108,1],2000-[1113,1],2500-[1118,1]:true"},
69         {NGS(authenticator_id), &Config::parseInt64, "0"},
70         {NGS(challenge), &Config::parseInt64, ""},
71         {NGS(strength), &Config::parseString, "strong"},
72         {NGS(operation_authenticate_fails), &Config::parseBool, "false"},
73         {NGS(operation_authenticate_latency), &Config::parseIntVec, ""},
74         {NGS(operation_authenticate_duration), &Config::parseInt32, "500"},
75         {NGS(operation_authenticate_error), &Config::parseInt32, "0"},
76         {NGS(operation_authenticate_acquired), &Config::parseString, ""},
77         {NGS(operation_enroll_latency), &Config::parseIntVec, ""},
78         {NGS(operation_detect_interaction_latency), &Config::parseIntVec, ""},
79         {NGS(operation_detect_interaction_fails), &Config::parseBool, "false"},
80         {NGS(lockout), &Config::parseBool, "false"},
81         {NGS(lockout_enable), &Config::parseBool, "false"},
82         {NGS(lockout_timed_enable), &Config::parseBool, "false"},
83         {NGS(lockout_timed_threshold), &Config::parseInt32, "3"},
84         {NGS(lockout_timed_duration), &Config::parseInt32, "10000"},
85         {NGS(lockout_permanent_threshold), &Config::parseInt32, "5"},
86         {NGS(features), &Config::parseIntVec, ""}};
87 
getConfigData(int * size)88 Config::Data* FaceConfig::getConfigData(int* size) {
89     *size = sizeof(configData) / sizeof(configData[0]);
90     return configData;
91 }
92 
93 }  // namespace aidl::android::hardware::biometrics::face
94