blob: 8e3e4fa9dccef3f0d6a589ce533eb2b9f093e820 [file] [log] [blame]
Alexander Martinz6b595262024-09-02 11:18:25 +02001/*
2 * Copyright (C) 2017 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
Han Sol Jin3f117342024-08-31 14:09:43 -070017#ifndef ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_3_BIOMETRICSFINGERPRINT_H
18#define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_3_BIOMETRICSFINGERPRINT_H
Alexander Martinz6b595262024-09-02 11:18:25 +020019
20#include <log/log.h>
21#include <android/log.h>
22#include <hardware/hardware.h>
Michael Bestas845b8f52024-09-18 05:08:38 +030023#include "fingerprint.h"
Alexander Martinz6b595262024-09-02 11:18:25 +020024#include <hidl/MQDescriptor.h>
25#include <hidl/Status.h>
Han Sol Jin3f117342024-08-31 14:09:43 -070026#include <android/hardware/biometrics/fingerprint/2.3/IBiometricsFingerprint.h>
Alexander Martinz6b595262024-09-02 11:18:25 +020027
28namespace android {
29namespace hardware {
30namespace biometrics {
31namespace fingerprint {
Han Sol Jin3f117342024-08-31 14:09:43 -070032namespace V2_3 {
Alexander Martinz6b595262024-09-02 11:18:25 +020033namespace implementation {
34
Han Sol Jin3f117342024-08-31 14:09:43 -070035using ::android::hardware::biometrics::fingerprint::V2_3::IBiometricsFingerprint;
36using IBiometricsFingerprintClientCallback =
37 ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback;
38using RequestStatus =
39 android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
40using FingerprintAcquiredInfo =
41 ::android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo;
42using FingerprintError =
43 ::android::hardware::biometrics::fingerprint::V2_1::FingerprintError;
44
Alexander Martinz6b595262024-09-02 11:18:25 +020045using ::android::hardware::Return;
46using ::android::hardware::Void;
47using ::android::hardware::hidl_vec;
48using ::android::hardware::hidl_string;
49using ::android::sp;
50
51struct BiometricsFingerprint : public IBiometricsFingerprint {
52public:
53 BiometricsFingerprint();
54 ~BiometricsFingerprint();
55
56 // Method to wrap legacy HAL with BiometricsFingerprint class
57 static IBiometricsFingerprint* getInstance();
58
59 // Methods from ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint follow.
60 Return<uint64_t> setNotify(const sp<IBiometricsFingerprintClientCallback>& clientCallback) override;
61 Return<uint64_t> preEnroll() override;
62 Return<RequestStatus> enroll(const hidl_array<uint8_t, 69>& hat, uint32_t gid, uint32_t timeoutSec) override;
63 Return<RequestStatus> postEnroll() override;
64 Return<uint64_t> getAuthenticatorId() override;
65 Return<RequestStatus> cancel() override;
66 Return<RequestStatus> enumerate() override;
67 Return<RequestStatus> remove(uint32_t gid, uint32_t fid) override;
68 Return<RequestStatus> setActiveGroup(uint32_t gid, const hidl_string& storePath) override;
69 Return<RequestStatus> authenticate(uint64_t operationId, uint32_t gid) override;
70
Han Sol Jin3f117342024-08-31 14:09:43 -070071 // Methods from ::android::hardware::biometrics::fingerprint::V2_3::IBiometricsFingerprint follow.
72 Return<bool> isUdfps(uint32_t sensorId) override;
73 Return<void> onFingerDown(uint32_t x, uint32_t y, float minor, float major) override;
74 Return<void> onFingerUp() override;
75
Alexander Martinz6b595262024-09-02 11:18:25 +020076private:
77 static fingerprint_device_t* openHal();
78 static void notify(const fingerprint_msg_t *msg); /* Static callback for legacy HAL implementation */
79 static Return<RequestStatus> ErrorFilter(int32_t error);
80 static FingerprintError VendorErrorFilter(int32_t error, int32_t* vendorCode);
81 static FingerprintAcquiredInfo VendorAcquiredFilter(int32_t error, int32_t* vendorCode);
82 static BiometricsFingerprint* sInstance;
83
84 std::mutex mClientCallbackMutex;
85 sp<IBiometricsFingerprintClientCallback> mClientCallback;
86 fingerprint_device_t *mDevice;
87};
88
89} // namespace implementation
Han Sol Jin3f117342024-08-31 14:09:43 -070090} // namespace V2_3
Alexander Martinz6b595262024-09-02 11:18:25 +020091} // namespace fingerprint
92} // namespace biometrics
93} // namespace hardware
94} // namespace android
95
Han Sol Jin3f117342024-08-31 14:09:43 -070096#endif // ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_3_BIOMETRICSFINGERPRINT_H