BiometricsFingerprint.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (C) 2017 The Android Open Source Project
  3. * Copyright (C) 2021 The LineageOS Project
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. #ifndef ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
  18. #define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
  19. #include <log/log.h>
  20. #include <android/log.h>
  21. #include "xiaomi_fingerprint.h"
  22. #include <hidl/MQDescriptor.h>
  23. #include <hidl/Status.h>
  24. #include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h>
  25. #include <vendor/xiaomi/hardware/fingerprintextension/1.0/IXiaomiFingerprint.h>
  26. namespace android {
  27. namespace hardware {
  28. namespace biometrics {
  29. namespace fingerprint {
  30. namespace V2_1 {
  31. namespace implementation {
  32. using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
  33. using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback;
  34. using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
  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. using ::vendor::xiaomi::hardware::fingerprintextension::V1_0::IXiaomiFingerprint;
  41. struct BiometricsFingerprint : public IBiometricsFingerprint, public IXiaomiFingerprint {
  42. public:
  43. BiometricsFingerprint();
  44. ~BiometricsFingerprint();
  45. // Method to wrap legacy HAL with BiometricsFingerprint class
  46. static IBiometricsFingerprint* getInstance();
  47. static IXiaomiFingerprint* getXiaomiInstance();
  48. // Methods from ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint follow.
  49. Return<uint64_t> setNotify(const sp<IBiometricsFingerprintClientCallback>& clientCallback) override;
  50. Return<uint64_t> preEnroll() override;
  51. Return<RequestStatus> enroll(const hidl_array<uint8_t, 69>& hat, uint32_t gid, uint32_t timeoutSec) override;
  52. Return<RequestStatus> postEnroll() override;
  53. Return<uint64_t> getAuthenticatorId() override;
  54. Return<RequestStatus> cancel() override;
  55. Return<RequestStatus> enumerate() override;
  56. Return<RequestStatus> remove(uint32_t gid, uint32_t fid) override;
  57. Return<RequestStatus> setActiveGroup(uint32_t gid, const hidl_string& storePath) override;
  58. Return<RequestStatus> authenticate(uint64_t operationId, uint32_t gid) override;
  59. // Methods from ::vendor::xiaomi::hardware::fingerprintextension::V1_0::IXiaomiFingerprint follow.
  60. Return<int32_t> extCmd(int32_t cmd, int32_t param) override;
  61. private:
  62. static xiaomi_fingerprint_device_t* openHal(const char *class_name);
  63. static void notify(const fingerprint_msg_t *msg); /* Static callback for legacy HAL implementation */
  64. static Return<RequestStatus> ErrorFilter(int32_t error);
  65. static FingerprintError VendorErrorFilter(int32_t error, int32_t* vendorCode);
  66. static FingerprintAcquiredInfo VendorAcquiredFilter(int32_t error, int32_t* vendorCode);
  67. static BiometricsFingerprint* sInstance;
  68. std::mutex mClientCallbackMutex;
  69. sp<IBiometricsFingerprintClientCallback> mClientCallback;
  70. xiaomi_fingerprint_device_t *mDevice;
  71. };
  72. } // namespace implementation
  73. } // namespace V2_1
  74. } // namespace fingerprint
  75. } // namespace biometrics
  76. } // namespace hardware
  77. } // namespace android
  78. #endif // ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H