diff --git a/init.hardware.rc b/init.hardware.rc index 8135652b..2eefbc44 100644 --- a/init.hardware.rc +++ b/init.hardware.rc @@ -394,7 +394,7 @@ service perfd /vendor/bin/perfd group root readproc socket perfd seqpacket 0666 root system -service thermal-engine /vendor/bin/thermal-engine -c /vendor/etc/thermal-engine.conf +service thermal-engine /vendor/bin/thermal-engine -c ${sys.qcom.thermalcfg:-/vendor/etc/thermal-engine.conf} class main user root group root system diff --git a/sepolicy/hal_vr.te b/sepolicy/hal_vr.te new file mode 100644 index 00000000..f3f0546c --- /dev/null +++ b/sepolicy/hal_vr.te @@ -0,0 +1,2 @@ +# interact with thermal_config +set_prop(hal_vr, thermal_prop) diff --git a/sepolicy/property.te b/sepolicy/property.te index e9149331..1444c033 100644 --- a/sepolicy/property.te +++ b/sepolicy/property.te @@ -8,3 +8,4 @@ type ssr_prop, property_type; type cnss_diag_prop, property_type; type tee_listener_prop, property_type; type wc_prop, property_type; +type thermal_prop, property_type; diff --git a/sepolicy/property_contexts b/sepolicy/property_contexts index 4e71679b..50819449 100644 --- a/sepolicy/property_contexts +++ b/sepolicy/property_contexts @@ -11,3 +11,5 @@ debug.ssrdump u:object_r:ssr_prop:s0 persist.sys.cnss. u:object_r:cnss_diag_prop:s0 sys.listeners.registered u:object_r:tee_listener_prop:s0 wc_transport. u:object_r:wc_prop:s0 +sys.qcom.thermalcfg u:object_r:thermal_prop:s0 +ctl.thermal-engine u:object_r:thermal_prop:s0 diff --git a/vr/VrDevice.cpp b/vr/VrDevice.cpp index 2be95840..262e5e26 100644 --- a/vr/VrDevice.cpp +++ b/vr/VrDevice.cpp @@ -16,6 +16,8 @@ #define LOG_TAG "VrDevice" +#include +#include #include "VrDevice.h" namespace android { @@ -31,8 +33,21 @@ Return VrDevice::init() { return Void(); } -Return VrDevice::setVrMode(bool /* enabled */) { - // TODO(b/36514493): start or stop using thermal engine VR profile. +Return VrDevice::setVrMode(bool enabled) { + if (enabled) { + 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")) { + LOG(ERROR) << "Couldn't set thermal_engine disable property"; + return Void(); + } + } + if (!android::base::SetProperty("ctl.restart", "thermal-engine")) { + LOG(ERROR) << "Couldn't set thermal_engine restart property"; + } return Void(); }