Sasha Levitskiy | 965bd32 | 2016-10-21 10:55:25 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
Sasha Levitskiy | 52640ee | 2016-11-10 14:15:33 -0800 | [diff] [blame] | 17 | #ifndef ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H |
| 18 | #define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H |
Sasha Levitskiy | 965bd32 | 2016-10-21 10:55:25 -0700 | [diff] [blame] | 19 | |
Yifan Hong | f9d3034 | 2016-11-30 13:45:34 -0800 | [diff] [blame^] | 20 | #include <android/log.h> |
Sasha Levitskiy | 52640ee | 2016-11-10 14:15:33 -0800 | [diff] [blame] | 21 | #include <hidl/MQDescriptor.h> |
Sasha Levitskiy | 965bd32 | 2016-10-21 10:55:25 -0700 | [diff] [blame] | 22 | #include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h> |
| 23 | #include <hidl/Status.h> |
| 24 | |
Sasha Levitskiy | 965bd32 | 2016-10-21 10:55:25 -0700 | [diff] [blame] | 25 | namespace android { |
| 26 | namespace hardware { |
| 27 | namespace biometrics { |
| 28 | namespace fingerprint { |
| 29 | namespace V2_1 { |
| 30 | namespace implementation { |
| 31 | |
Sasha Levitskiy | 965bd32 | 2016-10-21 10:55:25 -0700 | [diff] [blame] | 32 | using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint; |
| 33 | using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback; |
Sasha Levitskiy | 52640ee | 2016-11-10 14:15:33 -0800 | [diff] [blame] | 34 | using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus; |
Sasha Levitskiy | 965bd32 | 2016-10-21 10:55:25 -0700 | [diff] [blame] | 35 | using ::android::hardware::Return; |
| 36 | using ::android::hardware::Void; |
| 37 | using ::android::hardware::hidl_vec; |
| 38 | using ::android::hardware::hidl_string; |
| 39 | using ::android::sp; |
| 40 | |
| 41 | struct BiometricsFingerprint : public IBiometricsFingerprint { |
| 42 | public: |
| 43 | BiometricsFingerprint(fingerprint_device_t *device); |
| 44 | ~BiometricsFingerprint(); |
| 45 | // Methods from ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint follow. |
Sasha Levitskiy | 52640ee | 2016-11-10 14:15:33 -0800 | [diff] [blame] | 46 | Return<RequestStatus> setNotify(const sp<IBiometricsFingerprintClientCallback>& clientCallback) override; |
| 47 | Return<uint64_t> preEnroll() override; |
| 48 | Return<RequestStatus> enroll(const hidl_array<uint8_t, 69>& hat, uint32_t gid, uint32_t timeoutSec) override; |
| 49 | Return<RequestStatus> postEnroll() override; |
| 50 | Return<uint64_t> getAuthenticatorId() override; |
| 51 | Return<RequestStatus> cancel() override; |
| 52 | Return<RequestStatus> enumerate() override; |
| 53 | Return<RequestStatus> remove(uint32_t gid, uint32_t fid) override; |
| 54 | Return<RequestStatus> setActiveGroup(uint32_t gid, const hidl_string& storePath) override; |
| 55 | Return<RequestStatus> authenticate(uint64_t operationId, uint32_t gid) override; |
Sasha Levitskiy | 965bd32 | 2016-10-21 10:55:25 -0700 | [diff] [blame] | 56 | static void notify(const fingerprint_msg_t *notify_msg) { |
| 57 | if (mClientCallback == nullptr) { |
| 58 | ALOGE("Receiving callbacks before the client callback is registered."); |
| 59 | return; |
| 60 | } |
| 61 | FingerprintMsg msg = {}; |
| 62 | memcpy(&msg, notify_msg, sizeof(msg)); |
| 63 | mClientCallback->notify(msg); |
| 64 | } |
| 65 | private: |
Sasha Levitskiy | 52640ee | 2016-11-10 14:15:33 -0800 | [diff] [blame] | 66 | Return<RequestStatus> ErrorFilter(int32_t error); |
Sasha Levitskiy | 965bd32 | 2016-10-21 10:55:25 -0700 | [diff] [blame] | 67 | static sp<IBiometricsFingerprintClientCallback> mClientCallback; |
| 68 | fingerprint_device_t *mDevice; |
| 69 | }; |
| 70 | |
| 71 | extern "C" IBiometricsFingerprint* HIDL_FETCH_IBiometricsFingerprint(const char* name); |
| 72 | |
| 73 | } // namespace implementation |
| 74 | } // namespace V2_1 |
| 75 | } // namespace fingerprint |
| 76 | } // namespace biometrics |
| 77 | } // namespace hardware |
| 78 | } // namespace android |
| 79 | |
Sasha Levitskiy | 52640ee | 2016-11-10 14:15:33 -0800 | [diff] [blame] | 80 | #endif // ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H |