sm6150-common: fingerprint: Add thread listening for fod_ui sysfs event

Change-Id: I36f5789657daa70cf39fbdfe501392b9f96dbf2e
This commit is contained in:
Cosmin Tanislav 2021-09-24 16:08:16 +03:00 committed by Arian
parent 3cf7b626a4
commit bd7d6d7d59
4 changed files with 57 additions and 4 deletions

View File

@ -18,6 +18,8 @@
#define LOG_VERBOSE "android.hardware.biometrics.fingerprint@2.3-service.xiaomi_sm6150"
#include <log/log.h>
#include <poll.h>
#include <thread>
#include "BiometricsFingerprint.h"
@ -33,6 +35,31 @@
#define TOUCH_MAGIC 0x5400
#define TOUCH_IOC_SETMODE TOUCH_MAGIC + 0
#define FOD_UI_PATH "/sys/devices/platform/soc/soc:qcom,dsi-display/fod_ui"
#ifdef ENABLE_UDFPS
namespace {
static bool readBool(int fd) {
char c;
int rc;
rc = lseek(fd, 0, SEEK_SET);
if (rc) {
ALOGE("failed to seek fd, err: %d", rc);
return false;
}
rc = read(fd, &c, sizeof(char));
if (rc != 1) {
ALOGE("failed to read bool from fd, err: %d", rc);
return false;
}
return c != '0';
}
} // anonymous namespace
#endif
namespace android {
namespace hardware {
namespace biometrics {
@ -54,6 +81,30 @@ BiometricsFingerprint::BiometricsFingerprint() : mClientCallback(nullptr), mDevi
#ifdef ENABLE_UDFPS
touch_fd_ = android::base::unique_fd(open(TOUCH_DEV_PATH, O_RDWR));
std::thread([this]() {
int fd = open(FOD_UI_PATH, O_RDONLY);
if (fd < 0) {
ALOGE("failed to open fd, err: %d", fd);
return;
}
struct pollfd fodUiPoll = {
.fd = fd,
.events = POLLERR | POLLPRI,
.revents = 0,
};
while (true) {
int rc = poll(&fodUiPoll, 1, -1);
if (rc < 0) {
ALOGE("failed to poll fd, err: %d", rc);
continue;
}
mDevice->extCmd(mDevice, COMMAND_NIT, readBool(fd) ? PARAM_NIT_FOD : PARAM_NIT_NONE);
}
}).detach();
#endif
}
@ -425,8 +476,6 @@ Return<void> BiometricsFingerprint::onFingerDown(uint32_t /* x */, uint32_t /* y
#ifdef ENABLE_UDFPS
int arg[2] = {Touch_Fod_Enable, FOD_STATUS_ON};
ioctl(touch_fd_.get(), TOUCH_IOC_SETMODE, &arg);
mDevice->extCmd(mDevice, COMMAND_NIT, PARAM_NIT_FOD);
#endif
return Void();
@ -444,8 +493,6 @@ Return<void> BiometricsFingerprint::onFingerUp() {
#ifdef ENABLE_UDFPS
int arg[2] = {Touch_Fod_Enable, FOD_STATUS_OFF};
ioctl(touch_fd_.get(), TOUCH_IOC_SETMODE, &arg);
mDevice->extCmd(mDevice, COMMAND_NIT, PARAM_NIT_NONE);
#endif
return Void();

View File

@ -1,3 +1,6 @@
on boot
chown system system /sys/devices/platform/soc/soc:qcom,dsi-display/fod_ui
service vendor.fps_hal /vendor/bin/hw/android.hardware.biometrics.fingerprint@2.3-service.xiaomi_sm6150-udfps
# "class hal" causes a race condition on some devices due to files created
# in /data. As a workaround, postpone startup until later in boot once

View File

@ -11,6 +11,7 @@
/dev/xiaomi-touch u:object_r:touchfeature_device:s0
/sys/devices/platform/soc/[a-f0-9]+.qcom,mdss_mdp/drm/card([0-3])+/card([0-3])+-DSI-1/panel_info u:object_r:vendor_sysfs_graphics:s0
/sys/devices/platform/soc/soc:qcom,dsi-display/dc_enable u:object_r:sysfs_anti_flicker:s0
/sys/devices/platform/soc/soc:qcom,dsi-display/fod_ui u:object_r:vendor_sysfs_fod:s0
/sys/devices/platform/soc/soc:qcom,dsi-display/hbm u:object_r:sysfs_hbm:s0
/sys/devices/platform/soc/soc:qcom,dsi-display/doze_mode u:object_r:sysfs_doze:s0
/sys/devices/platform/soc/soc:qcom,dsi-display/doze_status u:object_r:sysfs_doze:s0

View File

@ -1,6 +1,7 @@
type hal_fingerprint_hwservice_xiaomi, hwservice_manager_type;
type fingerprint_device, dev_type;
type fingerprint_data_file, data_file_type, file_type;
type vendor_sysfs_fod, sysfs_type, fs_type;
type vendor_fp_prop, property_type;
allow hal_fingerprint_default fingerprint_device:chr_file rw_file_perms;
@ -12,6 +13,7 @@ allow hal_fingerprint_default tee_device:chr_file rw_file_perms;
allow hal_fingerprint_default touchfeature_device:chr_file rw_file_perms;
allow hal_fingerprint_default uhid_device:chr_file rw_file_perms;
allow hal_fingerprint_default vendor_qdsp_device:chr_file r_file_perms;
allow hal_fingerprint_default vendor_sysfs_fod:file rw_file_perms;
allow hal_fingerprint_default vendor_sysfs_graphics:file rw_file_perms;
allow hal_fingerprint_default vendor_xdsp_device:chr_file r_file_perms;