Include huawei gesture daemon
This commit is contained in:
parent
80c4f40d67
commit
d1cf8d8cbf
14
Huawei/Fingerprint/Android.mk
Normal file
14
Huawei/Fingerprint/Android.mk
Normal file
|
@ -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)
|
1
Huawei/Fingerprint/README
Normal file
1
Huawei/Fingerprint/README
Normal file
|
@ -0,0 +1 @@
|
|||
out.dex has been generated from https://github.com/phhusson/treble_experimentations/tree/master/vendor-HAL/Huawei/fingerprint-nav
|
7
Huawei/Fingerprint/hw-fingerprint.rc
Normal file
7
Huawei/Fingerprint/hw-fingerprint.rc
Normal file
|
@ -0,0 +1,7 @@
|
|||
service hw-fpnav /system/bin/hw-fpnav
|
||||
user root
|
||||
disabled
|
||||
|
||||
on property:sys.boot_completed=1
|
||||
start hw-fpnav
|
||||
|
15
Huawei/Fingerprint/hw-fpnav
Normal file
15
Huawei/Fingerprint/hw-fpnav
Normal file
|
@ -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
|
BIN
Huawei/Fingerprint/hw-fpnav.dex
Normal file
BIN
Huawei/Fingerprint/hw-fpnav.dex
Normal file
Binary file not shown.
84
Huawei/Fingerprint/input.cpp
Normal file
84
Huawei/Fingerprint/input.cpp
Normal file
|
@ -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;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -4,3 +4,10 @@ PRODUCT_PACKAGES += \
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue