From f9ed23848ab59a3097c9953180859ee86f90e491 Mon Sep 17 00:00:00 2001
From: TheScarastic <warabhishek@gmail.com>
Date: Wed, 30 Jan 2019 11:00:27 +0100
Subject: [PATCH] onclite: Switch to more generic dt2w node

Signed-off-by: Dhina17 <dhinalogu@gmail.com>
---
 BoardConfig.mk       |  1 +
 power/Android.mk     |  1 +
 power/power-common.h |  3 +++
 power/power.c        | 13 ++++++++++---
 4 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/BoardConfig.mk b/BoardConfig.mk
index 584bdd2..730aa8d 100644
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -191,6 +191,7 @@ BOARD_ROOT_EXTRA_SYMLINKS := \
 TARGET_PER_MGR_ENABLED := true
 
 # Power
+TARGET_TAP_TO_WAKE_NODE := "/dev/input/event2"
 TARGET_USES_INTERACTION_BOOST := true
 
 # Qualcomm
diff --git a/power/Android.mk b/power/Android.mk
index bc3e58b..9e588a1 100644
--- a/power/Android.mk
+++ b/power/Android.mk
@@ -12,6 +12,7 @@ LOCAL_MODULE_RELATIVE_PATH := hw
 LOCAL_SHARED_LIBRARIES := liblog libcutils libdl libxml2
 LOCAL_HEADER_LIBRARIES += libutils_headers
 LOCAL_HEADER_LIBRARIES += libhardware_headers
+LOCAL_HEADER_LIBRARIES += generated_kernel_headers
 LOCAL_SRC_FILES := power-8953.c power.c metadata-parser.c utils.c list.c hint-data.c powerhintparser.c
 LOCAL_C_INCLUDES := external/libxml2/include \
                     external/icu/icu4c/source/common
diff --git a/power/power-common.h b/power/power-common.h
index e374e46..22e7d94 100644
--- a/power/power-common.h
+++ b/power/power-common.h
@@ -42,6 +42,9 @@
 #define HINT_HANDLED (0)
 #define HINT_NONE (-1)
 
+#define INPUT_EVENT_WAKUP_MODE_OFF 4
+#define INPUT_EVENT_WAKUP_MODE_ON 5
+
 enum CPU_GOV_CHECK {
     CPU0 = 0,
     CPU1 = 1,
diff --git a/power/power.c b/power/power.c
index ce547f6..97cc214 100644
--- a/power/power.c
+++ b/power/power.c
@@ -42,6 +42,7 @@
 #include <utils/Log.h>
 #include <hardware/hardware.h>
 #include <hardware/power.h>
+#include <linux/input.h>
 
 #include "utils.h"
 #include "hint-data.h"
@@ -145,9 +146,15 @@ void set_interactive(struct power_module *module, int on)
 void set_feature(struct power_module* module, feature_t feature, int state) {
     switch (feature) {
 #ifdef TAP_TO_WAKE_NODE
-        case POWER_FEATURE_DOUBLE_TAP_TO_WAKE:
-            sysfs_write(TAP_TO_WAKE_NODE, state ? "1" : "0");
-            break;
+         case POWER_FEATURE_DOUBLE_TAP_TO_WAKE: {
+            int fd = open(TAP_TO_WAKE_NODE, O_RDWR);
+            struct input_event ev;
+            ev.type = EV_SYN;
+            ev.code = SYN_CONFIG;
+            ev.value = state ? INPUT_EVENT_WAKUP_MODE_ON : INPUT_EVENT_WAKUP_MODE_OFF;
+            write(fd, &ev, sizeof(ev));
+            close(fd);
+          } break;
 #endif
         default:
             break;
-- 
GitLab