davinci: fod: Set nit value on sysfs notification

Change-Id: I78069d10677c6704b0bb080ecf76ecbbfd0b2212
This commit is contained in:
Demon000
2020-05-29 00:03:15 +02:00
committed by Arian
parent e83427491a
commit 86826edb8d
3 changed files with 55 additions and 2 deletions

View File

@@ -21,6 +21,11 @@
#include <android-base/logging.h>
#include <fstream>
#include <cmath>
#include <thread>
#include <fcntl.h>
#include <poll.h>
#include <sys/stat.h>
#define FINGERPRINT_ACQUIRED_VENDOR 6
@@ -32,6 +37,8 @@
#define FOD_STATUS_ON 1
#define FOD_STATUS_OFF 0
#define FOD_UI_PATH "/sys/devices/platform/soc/soc:qcom,dsi-display/fod_ui"
#define FOD_SENSOR_X 445
#define FOD_SENSOR_Y 1931
#define FOD_SENSOR_SIZE 190
@@ -44,6 +51,25 @@ static void set(const std::string& path, const T& value) {
file << value;
}
static bool readBool(int fd) {
char c;
int rc;
rc = lseek(fd, 0, SEEK_SET);
if (rc) {
LOG(ERROR) << "failed to seek fd, err: " << rc;
return false;
}
rc = read(fd, &c, sizeof(char));
if (rc != 1) {
LOG(ERROR) << "failed to read bool from fd, err: " << rc;
return false;
}
return c != '0';
}
} // anonymous namespace
namespace vendor {
@@ -56,6 +82,31 @@ namespace implementation {
FingerprintInscreen::FingerprintInscreen() {
xiaomiFingerprintService = IXiaomiFingerprint::getService();
std::thread([this]() {
int fd = open(FOD_UI_PATH, O_RDONLY);
if (fd < 0) {
LOG(ERROR) << "failed to open fd, err: " << fd;
return;
}
struct pollfd fodUiPoll = {
.fd = fd,
.events = POLLERR | POLLPRI,
.revents = 0,
};
while (true) {
int rc = poll(&fodUiPoll, 1, -1);
if (rc < 0) {
LOG(ERROR) << "failed to poll fd, err: " << rc;
continue;
}
xiaomiFingerprintService->extCmd(COMMAND_NIT,
readBool(fd) ? PARAM_NIT_FOD : PARAM_NIT_NONE);
}
}).detach();
}
Return<int32_t> FingerprintInscreen::getPositionX() {
@@ -79,12 +130,10 @@ Return<void> FingerprintInscreen::onFinishEnroll() {
}
Return<void> FingerprintInscreen::onPress() {
xiaomiFingerprintService->extCmd(COMMAND_NIT, PARAM_NIT_FOD);
return Void();
}
Return<void> FingerprintInscreen::onRelease() {
xiaomiFingerprintService->extCmd(COMMAND_NIT, PARAM_NIT_NONE);
return Void();
}

View File

@@ -1,5 +1,8 @@
on boot
chown system system /sys/devices/platform/soc/soc:qcom,dsi-display/fod_ui
chown system system /sys/devices/virtual/touch/tp_dev/fod_status
chmod 0444 /sys/devices/platform/soc/soc:qcom,dsi-display/fod_ui
chmod 0644 /sys/devices/virtual/touch/tp_dev/fod_status
service vendor.fingerprint-inscreen-1-0 /vendor/bin/hw/vendor.lineage.biometrics.fingerprint.inscreen@1.0-service.davinci

View File

@@ -9,6 +9,7 @@
/data/vendor/goodix(/.*)? u:object_r:fingerprint_data_file:s0
# FOD
/sys/devices/platform/soc/soc:qcom,dsi-display/fod_ui u:object_r:sysfs_fod:s0
/sys/devices/virtual/touch/tp_dev/fod_status u:object_r:sysfs_fod:s0
# HALs