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:
parent
133ccc02c9
commit
1b9b756685
3 changed files with 55 additions and 0 deletions
|
@ -17,6 +17,7 @@ cc_binary {
|
||||||
"android.hardware.biometrics.fingerprint@2.1",
|
"android.hardware.biometrics.fingerprint@2.1",
|
||||||
"android.hardware.biometrics.fingerprint@2.2",
|
"android.hardware.biometrics.fingerprint@2.2",
|
||||||
"android.hardware.biometrics.fingerprint@2.3",
|
"android.hardware.biometrics.fingerprint@2.3",
|
||||||
|
"com.motorola.hardware.biometric.fingerprint@1.0",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,11 @@
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <sys/stat.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 android {
|
||||||
namespace hardware {
|
namespace hardware {
|
||||||
namespace biometrics {
|
namespace biometrics {
|
||||||
|
@ -33,8 +38,52 @@ namespace fingerprint {
|
||||||
namespace V2_3 {
|
namespace V2_3 {
|
||||||
namespace implementation {
|
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() {
|
BiometricsFingerprint::BiometricsFingerprint() {
|
||||||
biometrics_2_1_service = IBiometricsFingerprint_2_1::getService();
|
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) {
|
Return<uint64_t> BiometricsFingerprint::setNotify(const sp<IBiometricsFingerprintClientCallback>& clientCallback) {
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <android/hardware/biometrics/fingerprint/2.3/IBiometricsFingerprint.h>
|
#include <android/hardware/biometrics/fingerprint/2.3/IBiometricsFingerprint.h>
|
||||||
#include <hidl/MQDescriptor.h>
|
#include <hidl/MQDescriptor.h>
|
||||||
#include <hidl/Status.h>
|
#include <hidl/Status.h>
|
||||||
|
#include <com/motorola/hardware/biometric/fingerprint/1.0/IMotoFingerPrint.h>
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
namespace hardware {
|
namespace hardware {
|
||||||
|
@ -38,6 +39,9 @@ using ::android::hardware::hidl_vec;
|
||||||
using ::android::hardware::Return;
|
using ::android::hardware::Return;
|
||||||
using ::android::hardware::Void;
|
using ::android::hardware::Void;
|
||||||
using ::android::sp;
|
using ::android::sp;
|
||||||
|
using ::com::motorola::hardware::biometric::fingerprint::V1_0::IMotoFingerPrint;
|
||||||
|
using ::com::motorola::hardware::biometric::fingerprint::V1_0::IMotFodEventType;
|
||||||
|
using ::com::motorola::hardware::biometric::fingerprint::V1_0::IMotFodEventResult;
|
||||||
|
|
||||||
struct BiometricsFingerprint : public IBiometricsFingerprint {
|
struct BiometricsFingerprint : public IBiometricsFingerprint {
|
||||||
BiometricsFingerprint();
|
BiometricsFingerprint();
|
||||||
|
@ -60,6 +64,7 @@ struct BiometricsFingerprint : public IBiometricsFingerprint {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sp<IBiometricsFingerprint_2_1> biometrics_2_1_service;
|
sp<IBiometricsFingerprint_2_1> biometrics_2_1_service;
|
||||||
|
sp<IMotoFingerPrint> mMotoFingerprint;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace implementation
|
} // namespace implementation
|
||||||
|
|
Loading…
Reference in a new issue