blob: 6e599d1188705a45b68192d2312322b9db7c4735 [file] [log] [blame]
Sasha Levitskiy965bd322016-10-21 10:55:25 -07001/*
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 Levitskiy52640ee2016-11-10 14:15:33 -080017#ifndef ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
18#define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
Sasha Levitskiy965bd322016-10-21 10:55:25 -070019
Mark Salyzyn3ff52602017-01-10 10:16:48 -080020#include <log/log.h>
21
Sasha Levitskiy52640ee2016-11-10 14:15:33 -080022#include <hidl/MQDescriptor.h>
Sasha Levitskiy965bd322016-10-21 10:55:25 -070023#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h>
24#include <hidl/Status.h>
25
Sasha Levitskiy965bd322016-10-21 10:55:25 -070026namespace android {
27namespace hardware {
28namespace biometrics {
29namespace fingerprint {
30namespace V2_1 {
31namespace implementation {
32
Sasha Levitskiy965bd322016-10-21 10:55:25 -070033using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
34using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback;
Sasha Levitskiy52640ee2016-11-10 14:15:33 -080035using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
Sasha Levitskiy965bd322016-10-21 10:55:25 -070036using ::android::hardware::Return;
37using ::android::hardware::Void;
38using ::android::hardware::hidl_vec;
39using ::android::hardware::hidl_string;
40using ::android::sp;
41
42struct BiometricsFingerprint : public IBiometricsFingerprint {
43public:
44 BiometricsFingerprint(fingerprint_device_t *device);
45 ~BiometricsFingerprint();
46 // Methods from ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint follow.
Sasha Levitskiy52640ee2016-11-10 14:15:33 -080047 Return<RequestStatus> setNotify(const sp<IBiometricsFingerprintClientCallback>& clientCallback) override;
48 Return<uint64_t> preEnroll() override;
49 Return<RequestStatus> enroll(const hidl_array<uint8_t, 69>& hat, uint32_t gid, uint32_t timeoutSec) override;
50 Return<RequestStatus> postEnroll() override;
51 Return<uint64_t> getAuthenticatorId() override;
52 Return<RequestStatus> cancel() override;
53 Return<RequestStatus> enumerate() override;
54 Return<RequestStatus> remove(uint32_t gid, uint32_t fid) override;
55 Return<RequestStatus> setActiveGroup(uint32_t gid, const hidl_string& storePath) override;
56 Return<RequestStatus> authenticate(uint64_t operationId, uint32_t gid) override;
Sasha Levitskiy965bd322016-10-21 10:55:25 -070057 static void notify(const fingerprint_msg_t *notify_msg) {
58 if (mClientCallback == nullptr) {
59 ALOGE("Receiving callbacks before the client callback is registered.");
60 return;
61 }
62 FingerprintMsg msg = {};
63 memcpy(&msg, notify_msg, sizeof(msg));
64 mClientCallback->notify(msg);
65 }
66private:
Sasha Levitskiy52640ee2016-11-10 14:15:33 -080067 Return<RequestStatus> ErrorFilter(int32_t error);
Sasha Levitskiy965bd322016-10-21 10:55:25 -070068 static sp<IBiometricsFingerprintClientCallback> mClientCallback;
69 fingerprint_device_t *mDevice;
70};
71
72extern "C" IBiometricsFingerprint* HIDL_FETCH_IBiometricsFingerprint(const char* name);
73
74} // namespace implementation
75} // namespace V2_1
76} // namespace fingerprint
77} // namespace biometrics
78} // namespace hardware
79} // namespace android
80
Sasha Levitskiy52640ee2016-11-10 14:15:33 -080081#endif // ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H