From 705b60c599d00c67a925be12cbb6bb494aa9282c Mon Sep 17 00:00:00 2001 From: kxxt Date: Fri, 15 Mar 2024 08:13:52 +0800 Subject: [PATCH] sm8450-common: udfps: Enable fod_status on finger down events instead for fpc_fod Unfortunately, the fpc_fod hwmodule does not send vendor messages when it starts to wait for fingerprints reliably... Change-Id: Ie66cbed024ce89092ecbb1bd9c965b35c59199f7 --- udfps/UdfpsHandler.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/udfps/UdfpsHandler.cpp b/udfps/UdfpsHandler.cpp index 71be4f8..0322204 100644 --- a/udfps/UdfpsHandler.cpp +++ b/udfps/UdfpsHandler.cpp @@ -7,6 +7,7 @@ #define LOG_TAG "UdfpsHandler.xiaomi_sm8450" #include +#include #include #include @@ -95,6 +96,10 @@ class XiaomiSm8450UdfpsHander : public UdfpsHandler { touch_fd_ = android::base::unique_fd(open(TOUCH_DEV_PATH, O_RDWR)); disp_fd_ = android::base::unique_fd(open(DISP_FEATURE_PATH, O_RDWR)); + std::string fpVendor = android::base::GetProperty("persist.vendor.sys.fp.vendor", "none"); + LOG(DEBUG) << __func__ << "fingerprint vendor is: " << fpVendor; + isFpcFod = fpVendor == "fpc_fod"; + // Thread to notify fingeprint hwmodule about fod presses std::thread([this]() { int fd = open(FOD_PRESS_STATUS_PATH, O_RDONLY); @@ -207,6 +212,15 @@ class XiaomiSm8450UdfpsHander : public UdfpsHandler { lastPressX = x; lastPressY = y; + /* + * On fpc_fod devices, the waiting for finger message is not reliably sent... + * The finger down message is only reliably sent when the screen is turned off, so enable + * fod_status better late than never. + */ + if (isFpcFod) { + setFodStatus(FOD_STATUS_ON); + } + // Ensure touchscreen is aware of the press state, ideally this is not needed setFingerDown(true); } @@ -232,12 +246,17 @@ class XiaomiSm8450UdfpsHander : public UdfpsHandler { } } - /* vendorCode + /* vendorCode for goodix_fod devices: * 21: waiting for finger * 22: finger down * 23: finger up + * On fpc_fod devices, the waiting for finger message is not reliably sent... + * The finger down message is only reliably sent when the screen is turned off, so enable + * fod_status better late than never. */ - if (vendorCode == 21) { + if (!isFpcFod && vendorCode == 21) { + setFodStatus(FOD_STATUS_ON); + } else if (isFpcFod && vendorCode == 22) { setFodStatus(FOD_STATUS_ON); } } @@ -270,6 +289,7 @@ class XiaomiSm8450UdfpsHander : public UdfpsHandler { fingerprint_device_t* mDevice; android::base::unique_fd touch_fd_; android::base::unique_fd disp_fd_; + bool isFpcFod; bool enrolling = false; uint32_t lastPressX, lastPressY;