blob: 82c5403176b9f1b296a114c20401de2b12d3f462 [file] [log] [blame]
Jeff Pu6ccd9562024-02-21 10:46:35 -05001/*
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 "FingerprintConfig"
18
19#include "FingerprintConfig.h"
20
21#include <android-base/logging.h>
22
23#include <fingerprint.sysprop.h>
24
25using namespace ::android::fingerprint::virt;
26
27namespace aidl::android::hardware::biometrics::fingerprint {
28
29// Wrapper to system property access functions
30#define CREATE_GETTER_SETTER_WRAPPER(_NAME_, _T_) \
31 ConfigValue _NAME_##Getter() { \
32 return FingerprintHalProperties::_NAME_(); \
33 } \
34 bool _NAME_##Setter(const ConfigValue& v) { \
35 return FingerprintHalProperties::_NAME_(std::get<_T_>(v)); \
36 }
37
38CREATE_GETTER_SETTER_WRAPPER(type, OptString)
39CREATE_GETTER_SETTER_WRAPPER(enrollments, OptIntVec)
40CREATE_GETTER_SETTER_WRAPPER(enrollment_hit, OptInt32)
41CREATE_GETTER_SETTER_WRAPPER(next_enrollment, OptString)
42CREATE_GETTER_SETTER_WRAPPER(authenticator_id, OptInt64)
43CREATE_GETTER_SETTER_WRAPPER(challenge, OptInt64)
44CREATE_GETTER_SETTER_WRAPPER(sensor_id, OptInt32)
45CREATE_GETTER_SETTER_WRAPPER(sensor_location, OptString)
46CREATE_GETTER_SETTER_WRAPPER(sensor_strength, OptInt32)
47CREATE_GETTER_SETTER_WRAPPER(operation_authenticate_fails, OptBool)
48CREATE_GETTER_SETTER_WRAPPER(operation_authenticate_latency, OptIntVec)
49CREATE_GETTER_SETTER_WRAPPER(operation_authenticate_duration, OptInt32)
50CREATE_GETTER_SETTER_WRAPPER(operation_authenticate_error, OptInt32)
51CREATE_GETTER_SETTER_WRAPPER(operation_authenticate_acquired, OptString)
52CREATE_GETTER_SETTER_WRAPPER(operation_enroll_error, OptInt32)
53CREATE_GETTER_SETTER_WRAPPER(operation_enroll_latency, OptIntVec)
54CREATE_GETTER_SETTER_WRAPPER(operation_detect_interaction_error, OptInt32)
55CREATE_GETTER_SETTER_WRAPPER(operation_detect_interaction_latency, OptIntVec)
56CREATE_GETTER_SETTER_WRAPPER(operation_detect_interaction_duration, OptInt32)
57CREATE_GETTER_SETTER_WRAPPER(operation_detect_interaction_acquired, OptString)
58CREATE_GETTER_SETTER_WRAPPER(max_enrollments, OptBool)
59CREATE_GETTER_SETTER_WRAPPER(navigation_guesture, OptBool)
60CREATE_GETTER_SETTER_WRAPPER(detect_interaction, OptBool)
61CREATE_GETTER_SETTER_WRAPPER(display_touch, OptBool)
62CREATE_GETTER_SETTER_WRAPPER(control_illumination, OptBool)
63CREATE_GETTER_SETTER_WRAPPER(lockout, OptBool)
64CREATE_GETTER_SETTER_WRAPPER(lockout_enable, OptBool)
65CREATE_GETTER_SETTER_WRAPPER(lockout_timed_threshold, OptInt32)
66CREATE_GETTER_SETTER_WRAPPER(lockout_timed_duration, OptInt32)
67CREATE_GETTER_SETTER_WRAPPER(lockout_permanent_threshold, OptInt32)
68
69// Name, Getter, Setter, Parser and default value
70#define NGS(_NAME_) #_NAME_, _NAME_##Getter, _NAME_##Setter
71static Config::Data configData[] = {
72 {NGS(type), &Config::parseString, "rear"},
73 {NGS(enrollments), &Config::parseIntVec, ""},
74 {NGS(enrollment_hit), &Config::parseInt32, "0"},
75 {NGS(next_enrollment), &Config::parseString, ""},
76 {NGS(authenticator_id), &Config::parseInt64, "0"},
77 {NGS(challenge), &Config::parseInt64, ""},
78 {NGS(sensor_id), &Config::parseInt32, "5"},
79 {NGS(sensor_location), &Config::parseString, ""},
80 {NGS(sensor_strength), &Config::parseInt32, "2"}, // STRONG
81 {NGS(operation_authenticate_fails), &Config::parseBool, "false"},
82 {NGS(operation_authenticate_latency), &Config::parseIntVec, ""},
83 {NGS(operation_authenticate_duration), &Config::parseInt32, "10"},
84 {NGS(operation_authenticate_error), &Config::parseInt32, "0"},
85 {NGS(operation_authenticate_acquired), &Config::parseString, "1"},
86 {NGS(operation_enroll_error), &Config::parseInt32, "0"},
87 {NGS(operation_enroll_latency), &Config::parseIntVec, ""},
88 {NGS(operation_detect_interaction_latency), &Config::parseIntVec, ""},
89 {NGS(operation_detect_interaction_error), &Config::parseInt32, "0"},
90 {NGS(operation_detect_interaction_duration), &Config::parseInt32, "10"},
91 {NGS(operation_detect_interaction_acquired), &Config::parseString, "1"},
92 {NGS(max_enrollments), &Config::parseInt32, "5"},
93 {NGS(navigation_guesture), &Config::parseBool, "false"},
94 {NGS(detect_interaction), &Config::parseBool, "false"},
95 {NGS(display_touch), &Config::parseBool, "true"},
96 {NGS(control_illumination), &Config::parseBool, "false"},
97 {NGS(lockout), &Config::parseBool, "false"},
98 {NGS(lockout_enable), &Config::parseBool, "false"},
99 {NGS(lockout_timed_threshold), &Config::parseInt32, "5"},
100 {NGS(lockout_timed_duration), &Config::parseInt32, "10000"},
101 {NGS(lockout_permanent_threshold), &Config::parseInt32, "20"},
102};
103
104Config::Data* FingerprintConfig::getConfigData(int* size) {
105 *size = sizeof(configData) / sizeof(configData[0]);
106 return configData;
107}
108
109} // namespace aidl::android::hardware::biometrics::fingerprint