1 /* 2 * Copyright (c) 2025-2025 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 #include "cust_state_collection.h" 17 #include "constants.h" 18 #include "string_operation.h" 19 #include "thermal_service.h" 20 21 namespace OHOS { 22 namespace PowerMgr { 23 namespace { 24 } Init()25bool CustStateCollection::Init() 26 { 27 return true; 28 } 29 InitParam(std::string & params)30bool CustStateCollection::InitParam(std::string& params) 31 { 32 return true; 33 } 34 GetState()35std::string CustStateCollection::GetState() 36 { 37 return ToString(state_); 38 } 39 SetState(const std::string & stateValue)40void CustStateCollection::SetState(const std::string& stateValue) 41 { 42 unsigned long result = 0; 43 if (!StringOperation::ParseStrtoulResult(stateValue, result)) { 44 return; 45 } 46 state_ = result; 47 THERMAL_HILOGI(COMP_SVC, "cust state has set to %{public}s", stateValue.c_str()); 48 } 49 DecideState(const std::string & value)50bool CustStateCollection::DecideState(const std::string& value) 51 { 52 unsigned long result = 0; 53 if (!StringOperation::ParseStrtoulResult(value, result)) { 54 return false; 55 } 56 if (state_ & result) { 57 return true; 58 } else { 59 return false; 60 } 61 } 62 } //namespace PowerMgr 63 } //namespace OHOS