power: Refactor TARGET_TAP_TO_WAKE_NODE

Add TARGET_POWER_SET_FEATURE_LIB, since other devices
are not simply writing a 0/1 to a device node.
TARGET_TAP_TO_WAKE_NODE is still valid and both
TARGET_TAP_TO_WAKE_NODE and TARGET_POWER_SET_FEATURE_LIB are
allowed to coexist. (Currently set_feature only has double tap
to wake, but it may be extended in future)

Change-Id: I5c6204fd38a6fbe48e8aac49843bfa047c4b6436
diff --git a/Android.mk b/Android.mk
index a633927..9d00f89 100644
--- a/Android.mk
+++ b/Android.mk
@@ -72,6 +72,10 @@
 LOCAL_SRC_FILES += power-msmnile.c
 endif
 
+ifneq ($(TARGET_POWER_SET_FEATURE_LIB),)
+    LOCAL_STATIC_LIBRARIES += $(TARGET_POWER_SET_FEATURE_LIB)
+endif
+
 ifneq ($(TARGET_TAP_TO_WAKE_NODE),)
     LOCAL_CFLAGS += -DTAP_TO_WAKE_NODE=\"$(TARGET_TAP_TO_WAKE_NODE)\"
 endif
diff --git a/Power.cpp b/Power.cpp
index ebdc60a..2caeaca 100644
--- a/Power.cpp
+++ b/Power.cpp
@@ -33,6 +33,7 @@
 #include <log/log.h>
 #include "Power.h"
 #include "power-common.h"
+#include "power-feature.h"
 
 namespace android {
 namespace hardware {
@@ -74,6 +75,7 @@
         default:
             break;
     }
+    set_device_specific_feature(static_cast<feature_t>(feature), activate ? 1 : 0);
     return Void();
 }
 
diff --git a/power-common.c b/power-common.c
index 1a03c77..e52881f 100644
--- a/power-common.c
+++ b/power-common.c
@@ -47,6 +47,7 @@
 #include "hint-data.h"
 #include "performance.h"
 #include "power-common.h"
+#include "power-feature.h"
 
 static struct hint_handles handles[NUM_HINTS];
 
@@ -134,3 +135,7 @@
 
     ALOGI("Got set_interactive hint");
 }
+
+void __attribute__((weak)) set_device_specific_feature(feature_t UNUSED(feature), int UNUSED(state))
+{
+}
diff --git a/power-feature.h b/power-feature.h
new file mode 100644
index 0000000..abf0d4e
--- /dev/null
+++ b/power-feature.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2015 The CyanogenMod Project
+ * Copyright (C) 2019 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _QCOM_POWER_FEATURE_H
+#define _QCOM_POWER_FEATURE_H
+
+#include <hardware/power.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void set_device_specific_feature(feature_t feature, int state);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif