From c58ae4e91923b94e285d7a58ade4577392b93a98 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Mon, 29 Jan 2018 12:34:14 -0800 Subject: [PATCH] wahoo: VR: Reset setting in runtime crash and add dumpstate support Reset thermal setting after runtime reboot in VR Reset touch setting after runtime reboot in VR Add dump support in VR Test: Kill system_server during VR session and check thermal and touch settings Test: Capture bugreport and look at: lshal-debug/android.hardware.vr@1.0::IVr_default.txt Bug: 72644266 Bug: 72071908 Change-Id: I752c98ec88975a45eda19e72aed24df1a9fef2ba --- sepolicy/vendor/vendor_init.te | 1 + vr/VrDevice.cpp | 46 ++++++++++++++++----- vr/VrDevice.h | 5 +++ vr/android.hardware.vr@1.0-service.wahoo.rc | 6 +++ 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/sepolicy/vendor/vendor_init.te b/sepolicy/vendor/vendor_init.te index 3cbe3e507..dbc566730 100644 --- a/sepolicy/vendor/vendor_init.te +++ b/sepolicy/vendor/vendor_init.te @@ -25,3 +25,4 @@ set_prop(vendor_init, modem_diag_prop) set_prop(vendor_init, power_prop) set_prop(vendor_init, public_vendor_default_prop) set_prop(vendor_init, vendor_radio_prop) +set_prop(vendor_init, thermal_prop) diff --git a/vr/VrDevice.cpp b/vr/VrDevice.cpp index 75ac436c6..e5cd94dd8 100644 --- a/vr/VrDevice.cpp +++ b/vr/VrDevice.cpp @@ -16,8 +16,11 @@ #define LOG_TAG "VrDevice" +#include #include #include +#include + #include "VrDevice.h" namespace android { @@ -26,7 +29,16 @@ namespace vr { namespace V1_0 { namespace implementation { -VrDevice::VrDevice() {} +constexpr char kTouchVRModeSysfs[] = "/sys/devices/virtual/input/ftm4_touch/vrmode"; + +VrDevice::VrDevice() : mVRmode(false) { + std::string hardware = android::base::GetProperty("ro.hardware", ""); + if (hardware == "taimen") { + mFtm4Touch = true; + } else { + mFtm4Touch = false; + } +} Return VrDevice::init() { // NOOP @@ -34,13 +46,16 @@ Return VrDevice::init() { } Return VrDevice::setVrMode(bool enabled) { + mVRmode = enabled; if (enabled) { - if (!android::base::SetProperty("sys.qcom.thermalcfg", "/vendor/etc/thermal-engine-vr.conf")) { + if (!android::base::SetProperty("sys.qcom.thermalcfg", + "/vendor/etc/thermal-engine-vr.conf")) { LOG(ERROR) << "Couldn't set thermal_engine enable property"; return Void(); } } else { - if (!android::base::SetProperty("sys.qcom.thermalcfg", "/vendor/etc/thermal-engine.conf")) { + if (!android::base::SetProperty("sys.qcom.thermalcfg", + "/vendor/etc/thermal-engine.conf")) { LOG(ERROR) << "Couldn't set thermal_engine disable property"; return Void(); } @@ -48,15 +63,24 @@ Return VrDevice::setVrMode(bool enabled) { if (!android::base::SetProperty("ctl.restart", "vendor.thermal-engine")) { LOG(ERROR) << "Couldn't set thermal_engine restart property"; } - if (!access("/sys/devices/virtual/input/ftm4_touch/vrmode", W_OK)) { - FILE *f = fopen("/sys/devices/virtual/input/ftm4_touch/vrmode", "w"); - if (f) { - fprintf(f, "%d", (enabled ? 1 : 0)); - fclose(f); - } - else { - LOG(ERROR) << "Couldn't open vrmode sysfs node"; + + if (mFtm4Touch && + !android::base::WriteStringToFile((enabled ? "1" : "0"), kTouchVRModeSysfs)) { + PLOG(ERROR) << "Failed to write to vrmode sysfs node with :" << enabled; + } + + return Void(); +} + +Return VrDevice::debug(const hidl_handle& handle, const hidl_vec&) { + if (handle != nullptr && handle->numFds >= 1) { + int fd = handle->data[0]; + std::string buf(android::base::StringPrintf("VRMode: %s\n", + (mVRmode ? "true" : "false"))); + if (!android::base::WriteStringToFd(buf, fd)) { + PLOG(ERROR) << "Failed to dump state to fd"; } + fsync(fd); } return Void(); } diff --git a/vr/VrDevice.h b/vr/VrDevice.h index cd7545089..7bc3e1496 100644 --- a/vr/VrDevice.h +++ b/vr/VrDevice.h @@ -32,6 +32,11 @@ struct VrDevice : public IVr { Return init() override; Return setVrMode(bool enabled) override; + Return debug(const hidl_handle& handle, const hidl_vec&) override; + private: + // Taimen display touch sensitivity for VR Mode (b/37515573) + bool mFtm4Touch; + bool mVRmode; }; } // namespace implementation diff --git a/vr/android.hardware.vr@1.0-service.wahoo.rc b/vr/android.hardware.vr@1.0-service.wahoo.rc index 3f34675dd..10f3ac960 100644 --- a/vr/android.hardware.vr@1.0-service.wahoo.rc +++ b/vr/android.hardware.vr@1.0-service.wahoo.rc @@ -2,3 +2,9 @@ service vendor.vr-wahoo-1-0 /vendor/bin/hw/android.hardware.vr@1.0-service.wahoo class hal user system group system + +# reset touch and thermal-engine when framework died and thermal-engine is in VR mode +on property:init.svc.zygote=restarting && property:sys.qcom.thermalcfg=/vendor/etc/thermal-engine-vr.conf + write /sys/devices/virtual/input/ftm4_touch/vrmode 0 + setprop sys.qcom.thermalcfg "/vendor/etc/thermal-engine.conf" + restart vendor.thermal-engine