From d7e5b006af7b8f69674c6ca0d15e13251922f7c3 Mon Sep 17 00:00:00 2001 From: Tim Zimmermann Date: Sun, 28 Jan 2024 06:18:55 +0100 Subject: [PATCH] aidl: fingerprint: When force calibrating wait for sensor to become ready * Otherwise on first enrollment user might get an error dialog if the sensor is used too early Change-Id: If526bbe6d8dc355b85b828dc6ff33db4057cdd5c --- aidl/fingerprint/Fingerprint.cpp | 9 +++++++-- aidl/fingerprint/Session.cpp | 12 ++++++++++++ aidl/fingerprint/Session.h | 2 ++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/aidl/fingerprint/Fingerprint.cpp b/aidl/fingerprint/Fingerprint.cpp index 4ca160d..21d16f5 100644 --- a/aidl/fingerprint/Fingerprint.cpp +++ b/aidl/fingerprint/Fingerprint.cpp @@ -174,7 +174,7 @@ void Fingerprint::notify(const fingerprint_msg_t* msg) { void Fingerprint::handleEvent(int eventCode) { switch (eventCode) { case SEM_FINGERPRINT_EVENT_GESTURE_SWIPE_DOWN: - case SEM_FINGERPRINT_EVENT_GESTURE_SWIPE_UP: + case SEM_FINGERPRINT_EVENT_GESTURE_SWIPE_UP: { if (!mSupportsGestures) return; struct input_event event {}; @@ -216,7 +216,12 @@ void Fingerprint::handleEvent(int eventCode) { LOG(ERROR) << "Write EV_SYN to uinput node failed"; return; } - break; + } break; + case SEM_FINGERPRINT_EVENT_CAPTURE_READY: { + if (mSession != nullptr && !mSession->isClosed()) { + mSession->onCaptureReady(); + } + } break; } } diff --git a/aidl/fingerprint/Session.cpp b/aidl/fingerprint/Session.cpp index e5429f6..aa4bdae 100644 --- a/aidl/fingerprint/Session.cpp +++ b/aidl/fingerprint/Session.cpp @@ -17,6 +17,7 @@ #include using namespace ::android::fingerprint::samsung; +using namespace ::std::chrono_literals; namespace aidl { namespace android { @@ -68,6 +69,7 @@ ndk::ScopedAStatus Session::enroll(const HardwareAuthToken& hat, LOG(INFO) << "enroll"; if (FingerprintHalProperties::force_calibrate().value_or(false)) { + mCaptureReady = false; mHal.request(SEM_REQUEST_FORCE_CBGE, 1); } @@ -80,6 +82,12 @@ ndk::ScopedAStatus Session::enroll(const HardwareAuthToken& hat, mCb->onError(Error::UNABLE_TO_PROCESS, error); } + if (FingerprintHalProperties::force_calibrate().value_or(false)) { + while (!mCaptureReady) { + std::this_thread::sleep_for(100ms); + } + } + *out = SharedRefBase::make(this); return ndk::ScopedAStatus::ok(); } @@ -422,6 +430,10 @@ void Session::notify(const fingerprint_msg_t* msg) { } } +void Session::onCaptureReady() { + mCaptureReady = true; +} + } // namespace fingerprint } // namespace biometrics } // namespace hardware diff --git a/aidl/fingerprint/Session.h b/aidl/fingerprint/Session.h index 15dfdcb..dc3bd3d 100644 --- a/aidl/fingerprint/Session.h +++ b/aidl/fingerprint/Session.h @@ -69,11 +69,13 @@ public: bool isClosed(); void notify( const fingerprint_msg_t* msg); + void onCaptureReady(); private: LegacyHAL mHal; LockoutTracker mLockoutTracker; bool mClosed = false; + bool mCaptureReady = false; Error VendorErrorFilter(int32_t error, int32_t* vendorCode); AcquiredInfo VendorAcquiredFilter(int32_t info, int32_t* vendorCode); -- 2.20.1