Skip to content

Commit

Permalink
wahoo: VR: Reset setting in runtime crash and add dumpstate support
Browse files Browse the repository at this point in the history
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/[email protected]::IVr_default.txt
Bug: 72644266
Bug: 72071908
Change-Id: I752c98ec88975a45eda19e72aed24df1a9fef2ba
  • Loading branch information
weivincewang committed Jan 30, 2018
1 parent 353ce79 commit c58ae4e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 11 deletions.
1 change: 1 addition & 0 deletions sepolicy/vendor/vendor_init.te
Original file line number Diff line number Diff line change
Expand Up @@ -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)
46 changes: 35 additions & 11 deletions vr/VrDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@

#define LOG_TAG "VrDevice"

#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>

#include "VrDevice.h"

namespace android {
Expand All @@ -26,37 +29,58 @@ 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<void> VrDevice::init() {
// NOOP
return Void();
}

Return<void> 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();
}
}
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<void> VrDevice::debug(const hidl_handle& handle, const hidl_vec<hidl_string>&) {
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();
}
Expand Down
5 changes: 5 additions & 0 deletions vr/VrDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ struct VrDevice : public IVr {

Return<void> init() override;
Return<void> setVrMode(bool enabled) override;
Return<void> debug(const hidl_handle& handle, const hidl_vec<hidl_string>&) override;
private:
// Taimen display touch sensitivity for VR Mode (b/37515573)
bool mFtm4Touch;
bool mVRmode;
};

} // namespace implementation
Expand Down
6 changes: 6 additions & 0 deletions vr/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ service vendor.vr-wahoo-1-0 /vendor/bin/hw/[email protected]
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

0 comments on commit c58ae4e

Please sign in to comment.