blob: 79f48fe195aa67d4cc2298b839edb23a5d19265d [file] [log] [blame]
Ilya Matyukhina9a3c852020-08-18 03:09:41 -07001/*
2 * Copyright (C) 2020 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 "Fingerprint.h"
Ilya Matyukhin48ff8962021-02-22 13:13:13 -080018
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070019#include "Session.h"
20
21namespace aidl::android::hardware::biometrics::fingerprint {
Ilya Matyukhin124e70a2021-02-12 13:00:15 -080022namespace {
Ilya Matyukhin48ff8962021-02-22 13:13:13 -080023constexpr size_t MAX_WORKER_QUEUE_SIZE = 5;
Ilya Matyukhin124e70a2021-02-12 13:00:15 -080024constexpr int SENSOR_ID = 1;
25constexpr common::SensorStrength SENSOR_STRENGTH = common::SensorStrength::STRONG;
26constexpr int MAX_ENROLLMENTS_PER_USER = 5;
27constexpr FingerprintSensorType SENSOR_TYPE = FingerprintSensorType::REAR;
28constexpr bool SUPPORTS_NAVIGATION_GESTURES = true;
29constexpr char HW_DEVICE_NAME[] = "fingerprintSensor";
30constexpr char HW_VERSION[] = "vendor/model/revision";
Ilya Matyukhin124e70a2021-02-12 13:00:15 -080031constexpr char SERIAL_NUMBER[] = "00000001";
Haining Chen5feda3d2021-02-23 13:58:58 -080032constexpr char SW_VERSION[] = "vendor1/algorithm1/version;vendor2/algorithm2/version";
Kevin Chyn7d3fdf52020-09-15 13:01:40 -070033
Ilya Matyukhin124e70a2021-02-12 13:00:15 -080034} // namespace
Kevin Chync306b762020-09-17 12:40:09 -070035
Ilya Matyukhin48ff8962021-02-22 13:13:13 -080036Fingerprint::Fingerprint()
37 : mEngine(std::make_unique<FakeFingerprintEngine>()), mWorker(MAX_WORKER_QUEUE_SIZE) {}
Ilya Matyukhin124e70a2021-02-12 13:00:15 -080038
39ndk::ScopedAStatus Fingerprint::getSensorProps(std::vector<SensorProps>* out) {
Haining Chen5feda3d2021-02-23 13:58:58 -080040 std::vector<common::HardwareInfo> hardwareInfos = {{HW_DEVICE_NAME, HW_VERSION, SERIAL_NUMBER}};
Ilya Matyukhin124e70a2021-02-12 13:00:15 -080041
42 common::CommonProps commonProps = {SENSOR_ID, SENSOR_STRENGTH, MAX_ENROLLMENTS_PER_USER,
Haining Chen5feda3d2021-02-23 13:58:58 -080043 hardwareInfos, SW_VERSION};
Ilya Matyukhin124e70a2021-02-12 13:00:15 -080044
45 SensorLocation sensorLocation = {0 /* displayId */, 0 /* sensorLocationX */,
46 0 /* sensorLocationY */, 0 /* sensorRadius */};
47
48 *out = {{commonProps,
49 SENSOR_TYPE,
50 {sensorLocation},
51 SUPPORTS_NAVIGATION_GESTURES,
52 false /* supportsDetectInteraction */}};
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070053 return ndk::ScopedAStatus::ok();
54}
55
Ilya Matyukhin48ff8962021-02-22 13:13:13 -080056ndk::ScopedAStatus Fingerprint::createSession(int32_t sensorId, int32_t userId,
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070057 const std::shared_ptr<ISessionCallback>& cb,
Ilya Matyukhin124e70a2021-02-12 13:00:15 -080058 std::shared_ptr<ISession>* out) {
Ilya Matyukhinc605e0b2021-02-25 16:04:34 -080059 CHECK(mSession == nullptr || mSession->isClosed()) << "Open session already exists!";
Ilya Matyukhin48ff8962021-02-22 13:13:13 -080060
Ilya Matyukhinc605e0b2021-02-25 16:04:34 -080061 mSession = SharedRefBase::make<Session>(sensorId, userId, cb, mEngine.get(), &mWorker);
62 *out = mSession;
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070063 return ndk::ScopedAStatus::ok();
64}
Ilya Matyukhin71005c52021-02-17 12:44:14 -080065
Ilya Matyukhina9a3c852020-08-18 03:09:41 -070066} // namespace aidl::android::hardware::biometrics::fingerprint