From fee56b731150fe4ee2dbf434e8327da48f8fa940 Mon Sep 17 00:00:00 2001 From: Steve Pfetsch Date: Wed, 2 Aug 2017 01:43:06 -0700 Subject: [PATCH] wahoo: toggle special touch mode when VR mode is active Bug: 37515573 Change-Id: I5b741323f97f7d4713636a1688f50c9459d2764f --- dumpstate/DumpstateDevice.cpp | 2 ++ init.hardware.rc | 3 +++ sepolicy/vendor/hal_vr.te | 4 ++++ vr/VrDevice.cpp | 10 ++++++++++ 4 files changed, 19 insertions(+) diff --git a/dumpstate/DumpstateDevice.cpp b/dumpstate/DumpstateDevice.cpp index 1200ca41..cfe9e76a 100755 --- a/dumpstate/DumpstateDevice.cpp +++ b/dumpstate/DumpstateDevice.cpp @@ -153,6 +153,8 @@ static void DumpTouch(int fd) { if (!access("/sys/class/input/ftm4_touch", R_OK)) { DumpFileToFd(fd, "STM touch firmware config", "/sys/class/input/ftm4_touch/version"); + DumpFileToFd(fd, "STM touch VR Mode", + "/sys/class/input/ftm4_touch/vrmode"); } } diff --git a/init.hardware.rc b/init.hardware.rc index e703ef3f..a87ea654 100644 --- a/init.hardware.rc +++ b/init.hardware.rc @@ -484,6 +484,9 @@ on boot # Make the ftm4 command node writeable from dumpstate chown system system /sys/devices/virtual/input/ftm4_touch/cmd + # ftm4 VR mode + chown system system /sys/devices/virtual/input/ftm4_touch/vrmode + service init-elabel-sh /system/bin/init.elabel.sh class late_start user system diff --git a/sepolicy/vendor/hal_vr.te b/sepolicy/vendor/hal_vr.te index f3f0546c..a88dcb82 100644 --- a/sepolicy/vendor/hal_vr.te +++ b/sepolicy/vendor/hal_vr.te @@ -1,2 +1,6 @@ # interact with thermal_config set_prop(hal_vr, thermal_prop) + +# Access to touch vrmode node +allow hal_vr sysfs_touch:dir r_dir_perms; +allow hal_vr sysfs_touch:file rw_file_perms; diff --git a/vr/VrDevice.cpp b/vr/VrDevice.cpp index 262e5e26..d33398f9 100644 --- a/vr/VrDevice.cpp +++ b/vr/VrDevice.cpp @@ -48,6 +48,16 @@ Return VrDevice::setVrMode(bool enabled) { if (!android::base::SetProperty("ctl.restart", "thermal-engine")) { LOG(ERROR) << "Couldn't set thermal_engine restart property"; } + if (!access("/sys/class/input/ftm4_touch", R_OK)) { + FILE *f = fopen("/sys/class/input/ftm4_touch/vrmode", "w"); + if (f) { + fprintf(f, "%d", (enabled ? 1 : 0)); + fclose(f); + } + else { + LOG(ERROR) << "Couldn't open vrmode sysfs node"; + } + } return Void(); }