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 #include "hal.h"
18 #include "session.h"
19 #include "storage.h"
20 
21 namespace aidl::android::hardware::biometrics::fingerprint {
22 namespace {
23 constexpr char HW_COMPONENT_ID[] = "FingerprintSensor";
24 constexpr char XW_VERSION[] = "ranchu/fingerprint/aidl";
25 constexpr char FW_VERSION[] = "1";
26 constexpr char SERIAL_NUMBER[] = "00000001";
27 constexpr char SW_COMPONENT_ID[] = "matchingAlgorithm";
28 } // namespace
29 
getSensorProps(std::vector<SensorProps> * out)30 ndk::ScopedAStatus Hal::getSensorProps(std::vector<SensorProps>* out) {
31     std::vector<common::ComponentInfo> componentInfo = {
32         {
33             HW_COMPONENT_ID,
34             XW_VERSION,
35             FW_VERSION,
36             SERIAL_NUMBER,
37             "" /* softwareVersion */
38         },
39         {
40             SW_COMPONENT_ID,
41             "" /* hardwareVersion */,
42             "" /* firmwareVersion */,
43             "" /* serialNumber */,
44             XW_VERSION
45         }
46     };
47 
48     SensorLocation sensorLocation;
49     sensorLocation.sensorLocationX = 0;
50     sensorLocation.sensorLocationY = 0;
51     sensorLocation.sensorRadius = 0;
52     sensorLocation.display = "";
53 
54     TouchDetectionParameters touchDetectionParameters;
55     touchDetectionParameters.targetSize = 1.0;
56     touchDetectionParameters.minOverlap = 0.2;
57 
58     SensorProps props;
59     props.commonProps.sensorId = 0;
60     props.commonProps.sensorStrength = common::SensorStrength::STRONG;
61     props.commonProps.maxEnrollmentsPerUser = Storage::getMaxEnrollmentsPerUser();
62     props.commonProps.componentInfo = std::move(componentInfo);
63     props.sensorType = FingerprintSensorType::REAR;
64     props.sensorLocations.push_back(std::move(sensorLocation));
65     props.supportsNavigationGestures = false;
66     props.supportsDetectInteraction = true;
67     props.halHandlesDisplayTouches = false;
68     props.halControlsIllumination = false;
69     props.touchDetectionParameters = touchDetectionParameters;
70 
71     out->push_back(std::move(props));
72     return ndk::ScopedAStatus::ok();
73 }
74 
createSession(const int32_t sensorId,const int32_t userId,const std::shared_ptr<ISessionCallback> & cb,std::shared_ptr<ISession> * out)75 ndk::ScopedAStatus Hal::createSession(const int32_t sensorId,
76                                       const int32_t userId,
77                                       const std::shared_ptr<ISessionCallback>& cb,
78                                       std::shared_ptr<ISession>* out) {
79     *out = SharedRefBase::make<Session>(sensorId, userId, cb);
80     return ndk::ScopedAStatus::ok();
81 }
82 
83 } // namespace aidl::android::hardware::biometrics::fingerprint
84