1 /*
2  * Copyright (c) 2021-2023 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 "extend_state_collection.h"
17 
18 #include "constants.h"
19 #include "securec.h"
20 #include "string_operation.h"
21 #include "thermal_service.h"
22 #include "thermal_common.h"
23 
24 namespace OHOS {
25 namespace PowerMgr {
26 namespace {
27 auto g_service = ThermalService::GetInstance();
28 }
ExtendStateCollection(const std::string & stateName)29 ExtendStateCollection::ExtendStateCollection(const std::string& stateName)
30 {
31     stateName_ = stateName;
32 }
Init()33 bool ExtendStateCollection::Init()
34 {
35     return true;
36 }
37 
InitParam(std::string & params)38 bool ExtendStateCollection::InitParam(std::string& params)
39 {
40     return true;
41 }
42 
GetState()43 std::string ExtendStateCollection::GetState()
44 {
45     return stateValue_;
46 }
47 
SetState(const std::string & stateValue)48 void ExtendStateCollection::SetState(const std::string& stateValue)
49 {
50     stateValue_ = stateValue;
51 }
52 
DecideState(const std::string & value)53 bool ExtendStateCollection::DecideState(const std::string& value)
54 {
55     std::vector<std::string> valList;
56     StringOperation::SplitString(value, valList, ",");
57     for (std::string val : valList) {
58         if (stateValue_ == val) {
59             THERMAL_HILOGD(COMP_SVC, "stateValue = %{public}s", stateValue_.c_str());
60             return true;
61         }
62     }
63     return false;
64 }
65 } // namespace PowerMgr
66 } // namespace OHOS