Alexander Martinz | 6b59526 | 2024-09-02 11:18:25 +0200 | [diff] [blame] | 1 | /* |
| 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 Jin | 3f11734 | 2024-08-31 14:09:43 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_3_BIOMETRICSFINGERPRINT_H |
| 18 | #define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_3_BIOMETRICSFINGERPRINT_H |
Alexander Martinz | 6b59526 | 2024-09-02 11:18:25 +0200 | [diff] [blame] | 19 | |
| 20 | #include <log/log.h> |
| 21 | #include <android/log.h> |
| 22 | #include <hardware/hardware.h> |
Michael Bestas | 845b8f5 | 2024-09-18 05:08:38 +0300 | [diff] [blame] | 23 | #include "fingerprint.h" |
Alexander Martinz | 6b59526 | 2024-09-02 11:18:25 +0200 | [diff] [blame] | 24 | #include <hidl/MQDescriptor.h> |
| 25 | #include <hidl/Status.h> |
Han Sol Jin | 3f11734 | 2024-08-31 14:09:43 -0700 | [diff] [blame] | 26 | #include <android/hardware/biometrics/fingerprint/2.3/IBiometricsFingerprint.h> |
Alexander Martinz | 6b59526 | 2024-09-02 11:18:25 +0200 | [diff] [blame] | 27 | |
| 28 | namespace android { |
| 29 | namespace hardware { |
| 30 | namespace biometrics { |
| 31 | namespace fingerprint { |
Han Sol Jin | 3f11734 | 2024-08-31 14:09:43 -0700 | [diff] [blame] | 32 | namespace V2_3 { |
Alexander Martinz | 6b59526 | 2024-09-02 11:18:25 +0200 | [diff] [blame] | 33 | namespace implementation { |
| 34 | |
Han Sol Jin | 3f11734 | 2024-08-31 14:09:43 -0700 | [diff] [blame] | 35 | using ::android::hardware::biometrics::fingerprint::V2_3::IBiometricsFingerprint; |
| 36 | using IBiometricsFingerprintClientCallback = |
| 37 | ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback; |
| 38 | using RequestStatus = |
| 39 | android::hardware::biometrics::fingerprint::V2_1::RequestStatus; |
| 40 | using FingerprintAcquiredInfo = |
| 41 | ::android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo; |
| 42 | using FingerprintError = |
| 43 | ::android::hardware::biometrics::fingerprint::V2_1::FingerprintError; |
| 44 | |
Alexander Martinz | 6b59526 | 2024-09-02 11:18:25 +0200 | [diff] [blame] | 45 | using ::android::hardware::Return; |
| 46 | using ::android::hardware::Void; |
| 47 | using ::android::hardware::hidl_vec; |
| 48 | using ::android::hardware::hidl_string; |
| 49 | using ::android::sp; |
| 50 | |
| 51 | struct BiometricsFingerprint : public IBiometricsFingerprint { |
| 52 | public: |
| 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 Jin | 3f11734 | 2024-08-31 14:09:43 -0700 | [diff] [blame] | 71 | // 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 Martinz | 6b59526 | 2024-09-02 11:18:25 +0200 | [diff] [blame] | 76 | private: |
| 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 Jin | 3f11734 | 2024-08-31 14:09:43 -0700 | [diff] [blame] | 90 | } // namespace V2_3 |
Alexander Martinz | 6b59526 | 2024-09-02 11:18:25 +0200 | [diff] [blame] | 91 | } // namespace fingerprint |
| 92 | } // namespace biometrics |
| 93 | } // namespace hardware |
| 94 | } // namespace android |
| 95 | |
Han Sol Jin | 3f11734 | 2024-08-31 14:09:43 -0700 | [diff] [blame] | 96 | #endif // ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_3_BIOMETRICSFINGERPRINT_H |