From aba98c92b97b0feb747c1fe34e77de3d0378f285 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Tue, 2 Jul 2019 15:05:43 +0200 Subject: [PATCH] sm8350-common: fod: Implement handleAcquire() Change-Id: Ica796fbd468e2df0ee666a0d0c6cbde628d6989f --- fod/FingerprintInscreen.cpp | 31 +++++++++++++++++++++++++++++-- fod/FingerprintInscreen.h | 3 +++ 2 files changed, 32 insertions(+), 2 deletions(-) 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