blob: 4848a33c2805c056853cd836573763b3ad3a7e78 [file] [log] [blame]
Jan Altensen1813ff92019-08-20 23:20:25 +02001/*
2 * Copyright (C) 2019 The LineageOS 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 <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h>
21#include <hardware/fingerprint.h>
22#include <hardware/hardware.h>
23#include <hidl/MQDescriptor.h>
24#include <hidl/Status.h>
25
26namespace android {
27namespace hardware {
28namespace biometrics {
29namespace fingerprint {
30namespace V2_1 {
31namespace implementation {
32
33using ::android::sp;
34using ::android::hardware::hidl_string;
35using ::android::hardware::hidl_vec;
36using ::android::hardware::Return;
37using ::android::hardware::Void;
38using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
39using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback;
40using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
41
42struct BiometricsFingerprint : public IBiometricsFingerprint {
43 BiometricsFingerprint();
44 ~BiometricsFingerprint();
45
46 // Method to wrap legacy HAL with BiometricsFingerprint class
47 static IBiometricsFingerprint* getInstance();
48
49 // Methods from ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint follow.
50 Return<uint64_t> setNotify(
51 const sp<IBiometricsFingerprintClientCallback>& clientCallback) override;
52 Return<uint64_t> preEnroll() override;
53 Return<RequestStatus> enroll(const hidl_array<uint8_t, 69>& hat, uint32_t gid,
54 uint32_t timeoutSec) override;
55 Return<RequestStatus> postEnroll() override;
56 Return<uint64_t> getAuthenticatorId() override;
57 Return<RequestStatus> cancel() override;
58 Return<RequestStatus> enumerate() override;
59 Return<RequestStatus> remove(uint32_t gid, uint32_t fid) override;
60 Return<RequestStatus> setActiveGroup(uint32_t gid, const hidl_string& storePath) override;
61 Return<RequestStatus> authenticate(uint64_t operationId, uint32_t gid) override;
62
63 private:
64 bool openHal();
65 static void notify(
66 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
75 int (*ss_fingerprint_close)();
76 int (*ss_fingerprint_open)(const char* id);
77
78 int (*ss_set_notify_callback)(fingerprint_notify_t notify);
79 uint64_t (*ss_fingerprint_pre_enroll)();
80 int (*ss_fingerprint_enroll)(const hw_auth_token_t* hat, uint32_t gid, uint32_t timeout_sec);
81 int (*ss_fingerprint_post_enroll)();
82 uint64_t (*ss_fingerprint_get_auth_id)();
83 int (*ss_fingerprint_cancel)();
84 int (*ss_fingerprint_enumerate)();
85 int (*ss_fingerprint_remove)(uint32_t gid, uint32_t fid);
86 int (*ss_fingerprint_set_active_group)(uint32_t gid, const char* store_path);
87 int (*ss_fingerprint_authenticate)(uint64_t operation_id, uint32_t gid);
88};
89
90} // namespace implementation
91} // namespace V2_1
92} // namespace fingerprint
93} // namespace biometrics
94} // namespace hardware
95} // namespace android
96
97#endif // ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H