1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef THERMAL_DEVICE_MITIGATION_H 17 #define THERMAL_DEVICE_MITIGATION_H 18 19 #include <mutex> 20 #include <string> 21 22 namespace OHOS { 23 namespace HDI { 24 namespace Thermal { 25 namespace V1_1 { 26 class ThermalDeviceMitigation { 27 public: ThermalDeviceMitigation()28 ThermalDeviceMitigation() {}; ~ThermalDeviceMitigation()29 ~ThermalDeviceMitigation() {}; 30 int32_t ExecuteCpuRequest(uint32_t freq, const std::string &path); 31 int32_t CpuRequest(uint32_t freq); 32 int32_t GpuRequest(uint32_t freq); 33 int32_t IsolateCpu(int32_t num); 34 35 int32_t ChargerRequest(uint32_t current); 36 int32_t ExecuteChargerRequest(uint32_t current, const std::string &path); 37 int32_t BatteryCurrentRequest(uint32_t current); 38 int32_t BatteryVoltageRequest(uint32_t voltage); 39 int32_t WriteSysfsFd(int32_t fd, std::string buf, size_t bytesSize); 40 int32_t OpenSysfsFile(std::string filePath, int32_t flags); 41 int32_t WriteSysfsFile(std::string filePath, std::string buf, size_t bytesSize); 42 int32_t SetFlag(bool flag); 43 private: 44 bool flag_ {false}; 45 std::mutex mutex_; 46 }; 47 } // V1_1 48 } // Thermal 49 } // HDI 50 } // OHOS 51 #endif // THERMAL_DEVICE_MITIGATION_H