From 42d82f76840b6ca989429cfdeb1c8ab28455c7dd Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Tue, 2 Jul 2019 15:05:43 +0200 Subject: [PATCH] davinci: fod: Implement handleAcquire() Change-Id: Ica796fbd468e2df0ee666a0d0c6cbde628d6989f --- fod/FingerprintInscreen.cpp | 33 +++++++++++++++++++++++++++++++-- fod/FingerprintInscreen.h | 3 +++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/fod/FingerprintInscreen.cpp b/fod/FingerprintInscreen.cpp index 2764212..e5be291 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 @@ -113,7 +115,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; } @@ -143,7 +167,12 @@ 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