dubai: Add sendFodEvent hooks to fingerprint wrapper

Co-authored-by: sb6596 <shubhamprince111@gmail.com>
Co-authored-by: AdarshGrewal <adarshgrewal@gmail.com>
Change-Id: I75d2f8c05533003ad3c2c3393e33c1ff6a7d34fc
This commit is contained in:
SagarMakhar 2022-09-23 16:03:31 +05:30 committed by Marc Bourgoin
commit 1b9b756685
3 changed files with 55 additions and 0 deletions

View file

@ -26,6 +26,11 @@
#include <poll.h>
#include <sys/stat.h>
#define NOTIFY_FINGER_UP IMotFodEventType::FINGER_UP
#define NOTIFY_FINGER_DOWN IMotFodEventType::FINGER_DOWN
#define FOD_UI_PATH "/sys/devices/platform/soc/soc:qcom,dsi-display-primary/fod_ui"
namespace android {
namespace hardware {
namespace biometrics {
@ -33,8 +38,52 @@ namespace fingerprint {
namespace V2_3 {
namespace implementation {
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';
}
BiometricsFingerprint::BiometricsFingerprint() {
biometrics_2_1_service = IBiometricsFingerprint_2_1::getService();
mMotoFingerprint = IMotoFingerPrint::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;
}
mMotoFingerprint->sendFodEvent(readBool(fd) ? NOTIFY_FINGER_DOWN : NOTIFY_FINGER_UP , {},
[](IMotFodEventResult, const hidl_vec<signed char>&) {});
}
}).detach();
}
Return<uint64_t> BiometricsFingerprint::setNotify(const sp<IBiometricsFingerprintClientCallback>& clientCallback) {