1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #define LOG_TAG "VrDevice" 18 19 #include <android-base/logging.h> 20 #include <android-base/properties.h> 21 #include "VrDevice.h" 22 23 namespace android { 24 namespace hardware { 25 namespace vr { 26 namespace V1_0 { 27 namespace implementation { 28 29 VrDevice::VrDevice() {} 30 31 Return<void> VrDevice::init() { 32 // NOOP 33 return Void(); 34 } 35 36 Return<void> VrDevice::setVrMode(bool enabled) { 37 if (enabled) { 38 if (!android::base::SetProperty("sys.qcom.thermalcfg", "/vendor/etc/thermal-engine-vr.conf")) { 39 LOG(ERROR) << "Couldn't set thermal_engine enable property"; 40 return Void(); 41 } 42 } else { 43 if (!android::base::SetProperty("sys.qcom.thermalcfg", "/vendor/etc/thermal-engine.conf")) { 44 LOG(ERROR) << "Couldn't set thermal_engine disable property"; 45 return Void(); 46 } 47 } 48 if (!android::base::SetProperty("ctl.restart", "thermal-engine")) { 49 LOG(ERROR) << "Couldn't set thermal_engine restart property"; 50 } 51 if (!access("/sys/devices/virtual/input/ftm4_touch/vrmode", W_OK)) { 52 FILE *f = fopen("/sys/devices/virtual/input/ftm4_touch/vrmode", "w"); 53 if (f) { 54 fprintf(f, "%d", (enabled ? 1 : 0)); 55 fclose(f); 56 } 57 else { 58 LOG(ERROR) << "Couldn't open vrmode sysfs node"; 59 } 60 } 61 return Void(); 62 } 63 64 } // namespace implementation 65 } // namespace V1_0 66 } // namespace vr 67 } // namespace hardware 68 } // namespace android 69