zenfone8: Enable/Disable FOD on demande

Change-Id: I170667b89e3c7518b9433758089c89af63934b42
diff --git a/fod/FingerprintInscreen.cpp b/fod/FingerprintInscreen.cpp
index 3d3762f..7ffd8da 100644
--- a/fod/FingerprintInscreen.cpp
+++ b/fod/FingerprintInscreen.cpp
@@ -24,6 +24,10 @@
 #define GLOBAL_HBM_ON "1"
 #define GLOBAL_HBM_OFF "0"
 
+#define FOD_ENABLE_PATH "/proc/driver/fts_fp_mode"
+#define FOD_ENABLE_ON "1"
+#define FOD_ENABLE_OFF "0"
+
 #define FOD_TOUCHED_PATH "/sys/class/drm/fod_touched"
 #define FOD_TOUCHED_ON "1"
 #define FOD_TOUCHED_OFF "0"
@@ -66,12 +70,14 @@
 }
 
 Return<void> FingerprintInscreen::onShowFODView() {
+    android::base::WriteStringToFile(FOD_ENABLE_ON, FOD_ENABLE_PATH);
     return Void();
 }
 
 Return<void> FingerprintInscreen::onHideFODView() {
     android::base::WriteStringToFile(GLOBAL_HBM_OFF, GLOBAL_HBM_PATH);
     android::base::WriteStringToFile(FOD_TOUCHED_OFF, FOD_TOUCHED_PATH);
+    android::base::WriteStringToFile(FOD_ENABLE_OFF, FOD_ENABLE_PATH);
     return Void();
 }
 
diff --git a/sepolicy/private/file.te b/sepolicy/private/file.te
index 5a906c6..9419398 100644
--- a/sepolicy/private/file.te
+++ b/sepolicy/private/file.te
@@ -13,6 +13,7 @@
 type vendor_qmipriod_data_file, file_type, data_file_type;
 
 # FOD
+type proc_fod, proc_type, fs_type;
 type vendor_sysfs_graphics, sysfs_type, fs_type;
 
 # Offscreen Gestures
diff --git a/sepolicy/private/genfs_contexts b/sepolicy/private/genfs_contexts
index 13366e3..905f8d7 100644
--- a/sepolicy/private/genfs_contexts
+++ b/sepolicy/private/genfs_contexts
@@ -2,5 +2,6 @@
 genfscon proc /driver/swipeup           u:object_r:sysfs_touchscreen:s0
 genfscon proc /driver/gesture_type      u:object_r:sysfs_touchscreen:s0
 genfscon proc /driver/glove             u:object_r:sysfs_touchscreen:s0
+genfscon proc /driver/fts_fp_mode       u:object_r:proc_fod:s0
 genfscon proc /globalHbm                u:object_r:asus_display_proc_exec:s0
 genfscon sysfs /class/drm/fod_touched   u:object_r:vendor_sysfs_graphics:s0
diff --git a/sepolicy/private/hal_fod_asus_lahaina.te b/sepolicy/private/hal_fod_asus_lahaina.te
index 31c428b..5ada126 100644
--- a/sepolicy/private/hal_fod_asus_lahaina.te
+++ b/sepolicy/private/hal_fod_asus_lahaina.te
@@ -7,6 +7,7 @@
 # Allow hal_fod_asus_lahaina to read and write to asus_display_proc_exec and vendor_sysfs_graphics
 allow hal_fod_asus_lahaina asus_display_proc_exec:file w_file_perms;
 allow hal_fod_asus_lahaina vendor_sysfs_graphics:file w_file_perms;
+allow hal_fod_asus_lahaina proc_fod:file w_file_perms;
 
 # Allow access to the HALs
 hal_client_domain(hal_fod_asus_lahaina, hal_fingerprint)
diff --git a/system.prop b/system.prop
index 1f0a6ed..4ce2b7d 100644
--- a/system.prop
+++ b/system.prop
@@ -179,7 +179,7 @@
 
 # ASUS_BSP AustinT "FP wakeup property"+++
 persist.vendor.asus.fp.wakeup_support=true
-persist.vendor.asus.fp.wakeup=false
+#persist.vendor.asus.fp.wakeup=false
 # ASUS_BSP AustinT "FP wakeup property"---
 
 # ASUS_BSP AustinC Dirac +++