Include huawei gesture daemon
diff --git a/Huawei/Fingerprint/Android.mk b/Huawei/Fingerprint/Android.mk
new file mode 100644
index 0000000..7133fe4
--- /dev/null
+++ b/Huawei/Fingerprint/Android.mk
@@ -0,0 +1,14 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := hw-fpnav-daemon
+LOCAL_SRC_FILES := \
+ input.cpp
+
+LOCAL_CLANG := true
+LOCAL_CFLAGS := -Wall -Werror -Wextra
+
+LOCAL_INIT_RC := hw-fingerprint.rc
+
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_EXECUTABLE)
diff --git a/Huawei/Fingerprint/README b/Huawei/Fingerprint/README
new file mode 100644
index 0000000..4063780
--- /dev/null
+++ b/Huawei/Fingerprint/README
@@ -0,0 +1 @@
+out.dex has been generated from https://github.com/phhusson/treble_experimentations/tree/master/vendor-HAL/Huawei/fingerprint-nav
diff --git a/Huawei/Fingerprint/hw-fingerprint.rc b/Huawei/Fingerprint/hw-fingerprint.rc
new file mode 100644
index 0000000..1401e18
--- /dev/null
+++ b/Huawei/Fingerprint/hw-fingerprint.rc
@@ -0,0 +1,7 @@
+service hw-fpnav /system/bin/hw-fpnav
+ user root
+ disabled
+
+on property:sys.boot_completed=1
+ start hw-fpnav
+
diff --git a/Huawei/Fingerprint/hw-fpnav b/Huawei/Fingerprint/hw-fpnav
new file mode 100644
index 0000000..b4e70c6
--- /dev/null
+++ b/Huawei/Fingerprint/hw-fpnav
@@ -0,0 +1,15 @@
+#!/system/bin/sh
+
+set -x
+
+#Do this only on devices with huawei fingerprint HAL
+lshal |grep -qF vendor.huawei.hardware.biometrics.fingerprint || ( while true;do sleep 3600;done; exit 0)
+
+#Ask fingerprint hardware service to enable navigation
+CLASSPATH=/system/phh/hw-fpnav.dex \
+ /system/bin/app_process \
+ /data/local/tmp/ \
+ Test
+
+#Start input redirector
+/system/bin/hw-fpnav-daemon
diff --git a/Huawei/Fingerprint/hw-fpnav.dex b/Huawei/Fingerprint/hw-fpnav.dex
new file mode 100644
index 0000000..649569e
--- /dev/null
+++ b/Huawei/Fingerprint/hw-fpnav.dex
Binary files differ
diff --git a/Huawei/Fingerprint/input.cpp b/Huawei/Fingerprint/input.cpp
new file mode 100644
index 0000000..dcc01d0
--- /dev/null
+++ b/Huawei/Fingerprint/input.cpp
@@ -0,0 +1,84 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <linux/input.h>
+
+int open_fingerprint() {
+ DIR *dir=opendir("/dev/input");
+ if(!dir) {
+ return -1;
+ }
+ int fd;
+ struct dirent *entry;
+ while( (entry=readdir(dir))!=NULL) {
+ if(entry->d_type!=DT_CHR)
+ continue;
+ if(strncmp(entry->d_name, "event", 5)==0) {
+ fd = openat(dirfd(dir), entry->d_name, O_RDONLY);
+ if(fd < 0) continue;
+
+ char buf[64];
+ int ret = ioctl(fd, EVIOCGNAME(sizeof(buf)), buf);
+ if(ret < 0) {
+ close(fd);
+ continue;
+ }
+
+ if(strcmp(buf, "fingerprint") != 0) {
+ close(fd);
+ continue;
+ }
+
+ ioctl(fd, EVIOCGRAB, 1);
+ closedir(dir);
+ return fd;
+ break;
+ }
+ }
+ closedir(dir);
+ return -1;
+}
+
+#define FINGERPRINT_CLICK 0xae
+#define FINGERPRINT_LONGPRESS 0x1c
+#define FINGERPRINT_RIGHT 0x6a
+#define FINGERPRINT_LEFT 0x69
+#define FINGERPRINT_UP 0x67
+#define FINGERPRINT_DOWN 0x6c
+#define FINGERPRINT_DOUBLECLICK 0x6f
+int main() {
+ int fd = open_fingerprint();
+ if(fd<0) return 1;
+
+ struct input_event ev;
+ while(read(fd, &ev, sizeof(ev)) == sizeof(ev)) {
+ if(ev.type != EV_KEY) continue;
+ //Huawei kernel code automatically generates both up and down events, just take one
+ if(ev.value != 1) continue;
+
+ switch(ev.code) {
+ case FINGERPRINT_CLICK:
+ system("input keyevent KEYCODE_HOME");
+ break;
+ case FINGERPRINT_LEFT:
+ system("input keyevent KEYCODE_BACK");
+ break;
+ case FINGERPRINT_RIGHT:
+ system("input keyevent KEYCODE_VOICE_ASSIST");
+ break;
+ case FINGERPRINT_UP:
+ system("cmd statusbar expand-settings");
+ break;
+ case FINGERPRINT_DOWN:
+ system("cmd statusbar expand-notifications");
+ break;
+ case FINGERPRINT_LONGPRESS:
+ system("input keyevent APP_APP_SWITCH");
+ break;
+ };
+ }
+}
diff --git a/overlay.mk b/overlay.mk
index 6473fb8..0bd6af6 100644
--- a/overlay.mk
+++ b/overlay.mk
@@ -4,3 +4,10 @@
treble-overlay-Essential_PH1 \
treble-overlay-Telephony-LTE \
HardwareOverlayPicker
+
+
+PRODUCT_PACKAGES += \
+ hw-fpnav-daemon
+PRODUCT_COPY_FILES += \
+ vendor/hardware_overlay/Huawei/Fingerprint/hw-fpnav:system/bin/hw-fpnav \
+ vendor/hardware_overlay/Huawei/Fingerprint/hw-fpnav.dex:system/phh/hw-fpnav.dex