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 c009837b..76e114ac 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(); }