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
This commit is contained in:
kxxt
2024-03-15 08:13:52 +08:00
committed by itsnouralawad
parent f6995e882e
commit 4c49b01855

View File

@@ -7,6 +7,7 @@
#define LOG_TAG "UdfpsHandler.xiaomi_sm6225"
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/unique_fd.h>
#include <poll.h>
@@ -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};