blob: 6d64e3d38db8939dc5796f93255d54028f640c43 [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
17#ifndef ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
18#define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
19
20#include <log/log.h>
21#include <android/log.h>
22#include <hardware/hardware.h>
23#include <hardware/fingerprint.h>
24#include <hidl/MQDescriptor.h>
25#include <hidl/Status.h>
26#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h>
27
28namespace android {
29namespace hardware {
30namespace biometrics {
31namespace fingerprint {
32namespace V2_1 {
33namespace implementation {
34
35using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
36using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback;
37using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
38using ::android::hardware::Return;
39using ::android::hardware::Void;
40using ::android::hardware::hidl_vec;
41using ::android::hardware::hidl_string;
42using ::android::sp;
43
44struct BiometricsFingerprint : public IBiometricsFingerprint {
45public:
46 BiometricsFingerprint();
47 ~BiometricsFingerprint();
48
49 // Method to wrap legacy HAL with BiometricsFingerprint class
50 static IBiometricsFingerprint* getInstance();
51
52 // Methods from ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint follow.
53 Return<uint64_t> setNotify(const sp<IBiometricsFingerprintClientCallback>& clientCallback) override;
54 Return<uint64_t> preEnroll() override;
55 Return<RequestStatus> enroll(const hidl_array<uint8_t, 69>& hat, uint32_t gid, uint32_t timeoutSec) override;
56 Return<RequestStatus> postEnroll() override;
57 Return<uint64_t> getAuthenticatorId() override;
58 Return<RequestStatus> cancel() override;
59 Return<RequestStatus> enumerate() override;
60 Return<RequestStatus> remove(uint32_t gid, uint32_t fid) override;
61 Return<RequestStatus> setActiveGroup(uint32_t gid, const hidl_string& storePath) override;
62 Return<RequestStatus> authenticate(uint64_t operationId, uint32_t gid) override;
63
64private:
65 static fingerprint_device_t* openHal();
66 static void notify(const fingerprint_msg_t *msg); /* Static callback for legacy HAL implementation */
67 static Return<RequestStatus> ErrorFilter(int32_t error);
68 static FingerprintError VendorErrorFilter(int32_t error, int32_t* vendorCode);
69 static FingerprintAcquiredInfo VendorAcquiredFilter(int32_t error, int32_t* vendorCode);
70 static BiometricsFingerprint* sInstance;
71
72 std::mutex mClientCallbackMutex;
73 sp<IBiometricsFingerprintClientCallback> mClientCallback;
74 fingerprint_device_t *mDevice;
75};
76
77} // namespace implementation
78} // namespace V2_1
79} // namespace fingerprint
80} // namespace biometrics
81} // namespace hardware
82} // namespace android
83
84#endif // ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H