mirror of
https://github.com/Evolution-X-Devices/device_xiaomi_sm6150-common
synced 2026-01-27 07:38:17 +00:00
davinci: fod: Set nit value on sysfs notification
Change-Id: I78069d10677c6704b0bb080ecf76ecbbfd0b2212
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user