Jeff Pu | 6ccd956 | 2024-02-21 10:46:35 -0500 | [diff] [blame] | 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 "FingerprintConfig" |
| 18 | |
| 19 | #include "FingerprintConfig.h" |
| 20 | |
| 21 | #include <android-base/logging.h> |
| 22 | |
| 23 | #include <fingerprint.sysprop.h> |
| 24 | |
| 25 | using namespace ::android::fingerprint::virt; |
| 26 | |
| 27 | namespace 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 | |
| 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(sensor_id, OptInt32) |
| 45 | CREATE_GETTER_SETTER_WRAPPER(sensor_location, OptString) |
| 46 | CREATE_GETTER_SETTER_WRAPPER(sensor_strength, OptInt32) |
| 47 | CREATE_GETTER_SETTER_WRAPPER(operation_authenticate_fails, OptBool) |
| 48 | CREATE_GETTER_SETTER_WRAPPER(operation_authenticate_latency, OptIntVec) |
| 49 | CREATE_GETTER_SETTER_WRAPPER(operation_authenticate_duration, OptInt32) |
| 50 | CREATE_GETTER_SETTER_WRAPPER(operation_authenticate_error, OptInt32) |
| 51 | CREATE_GETTER_SETTER_WRAPPER(operation_authenticate_acquired, OptString) |
| 52 | CREATE_GETTER_SETTER_WRAPPER(operation_enroll_error, OptInt32) |
| 53 | CREATE_GETTER_SETTER_WRAPPER(operation_enroll_latency, OptIntVec) |
| 54 | CREATE_GETTER_SETTER_WRAPPER(operation_detect_interaction_error, OptInt32) |
| 55 | CREATE_GETTER_SETTER_WRAPPER(operation_detect_interaction_latency, OptIntVec) |
| 56 | CREATE_GETTER_SETTER_WRAPPER(operation_detect_interaction_duration, OptInt32) |
| 57 | CREATE_GETTER_SETTER_WRAPPER(operation_detect_interaction_acquired, OptString) |
| 58 | CREATE_GETTER_SETTER_WRAPPER(max_enrollments, OptBool) |
| 59 | CREATE_GETTER_SETTER_WRAPPER(navigation_guesture, OptBool) |
| 60 | CREATE_GETTER_SETTER_WRAPPER(detect_interaction, OptBool) |
| 61 | CREATE_GETTER_SETTER_WRAPPER(display_touch, OptBool) |
| 62 | CREATE_GETTER_SETTER_WRAPPER(control_illumination, OptBool) |
| 63 | CREATE_GETTER_SETTER_WRAPPER(lockout, OptBool) |
| 64 | CREATE_GETTER_SETTER_WRAPPER(lockout_enable, OptBool) |
| 65 | CREATE_GETTER_SETTER_WRAPPER(lockout_timed_threshold, OptInt32) |
| 66 | CREATE_GETTER_SETTER_WRAPPER(lockout_timed_duration, OptInt32) |
| 67 | CREATE_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 |
| 71 | static 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 | |
| 104 | Config::Data* FingerprintConfig::getConfigData(int* size) { |
| 105 | *size = sizeof(configData) / sizeof(configData[0]); |
| 106 | return configData; |
| 107 | } |
| 108 | |
| 109 | } // namespace aidl::android::hardware::biometrics::fingerprint |