diff --git a/fod/FingerprintInscreen.cpp b/fod/FingerprintInscreen.cpp index c7fa643..b5db131 100644 --- a/fod/FingerprintInscreen.cpp +++ b/fod/FingerprintInscreen.cpp @@ -22,6 +22,8 @@ #include #include +#define FINGERPRINT_ACQUIRED_VENDOR 6 + #define COMMAND_NIT 10 #define PARAM_NIT_FOD 1 #define PARAM_NIT_NONE 0 @@ -101,7 +103,29 @@ Return FingerprintInscreen::onHideFODView() { } Return FingerprintInscreen::handleAcquired(int32_t acquiredInfo, int32_t vendorCode) { - LOG(ERROR) << "acquiredInfo: " << acquiredInfo << ", vendorCode: " << vendorCode; + std::lock_guard _lock(mCallbackLock); + if (mCallback == nullptr) { + return false; + } + + if (acquiredInfo == FINGERPRINT_ACQUIRED_VENDOR) { + if (vendorCode == 0) { + Return ret = mCallback->onFingerDown(); + if (!ret.isOk()) { + LOG(ERROR) << "FingerDown() error: " << ret.description(); + } + return true; + } + + if (vendorCode == 1) { + Return ret = mCallback->onFingerUp(); + if (!ret.isOk()) { + LOG(ERROR) << "FingerUp() error: " << ret.description(); + } + return true; + } + } + return false; } @@ -122,7 +146,10 @@ Return FingerprintInscreen::shouldBoostBrightness() { return false; } -Return FingerprintInscreen::setCallback(const sp& /* callback */) { +Return FingerprintInscreen::setCallback(const sp& callback) { + std::lock_guard _lock(mCallbackLock); + mCallback = callback; + return Void(); } diff --git a/fod/FingerprintInscreen.h b/fod/FingerprintInscreen.h index 9ee8ac4..8cad941 100644 --- a/fod/FingerprintInscreen.h +++ b/fod/FingerprintInscreen.h @@ -54,6 +54,9 @@ public: private: sp xiaomiFingerprintService; + + std::mutex mCallbackLock; + sp mCallback; }; } // namespace implementation