From 4c49b01855ac0767736a609ef46c8233b7487dd1 Mon Sep 17 00:00:00 2001 From: kxxt Date: Fri, 15 Mar 2024 08:13:52 +0800 Subject: [PATCH] sm6225-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 | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/udfps/UdfpsHandler.cpp b/udfps/UdfpsHandler.cpp index 3f465cc..aa16d66 100644 --- a/udfps/UdfpsHandler.cpp +++ b/udfps/UdfpsHandler.cpp @@ -7,6 +7,7 @@ #define LOG_TAG "UdfpsHandler.xiaomi_sm6225" #include +#include #include #include @@ -90,6 +91,10 @@ class XiaomiSm6225UdfpsHander : 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); @@ -175,6 +180,16 @@ class XiaomiSm6225UdfpsHander : public UdfpsHandler { void onFingerDown(uint32_t /*x*/, uint32_t /*y*/, float /*minor*/, float /*major*/) { LOG(INFO) << __func__; + + /* + * 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); + } + setFingerDown(true); } @@ -197,12 +212,17 @@ class XiaomiSm6225UdfpsHander : 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); } } @@ -235,6 +255,7 @@ class XiaomiSm6225UdfpsHander : public UdfpsHandler { android::base::unique_fd touch_fd_; android::base::unique_fd disp_fd_; bool enrolling = false; + bool isFpcFod; void setFodStatus(int value) { int buf[MAX_BUF_SIZE] = {MI_DISP_PRIMARY, Touch_Fod_Enable, value};