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 "thermal_config_base_info.h"
17 #include "string_operation.h"
18 #include "thermal_common.h"
19 
20 namespace OHOS {
21 namespace PowerMgr {
Init()22 bool ThermalConfigBaseInfo::Init()
23 {
24     SetSensorsType();
25     SetHistoryTempCount();
26     Dump();
27     return true;
28 }
29 
SetSensorsType()30 void ThermalConfigBaseInfo::SetSensorsType()
31 {
32     sensorsType_.clear();
33     auto typesIter = baseItems_.find(SENSORS_TYPE_TAG);
34     if (typesIter != baseItems_.end()) {
35         sensorType_ = typesIter->second;
36         StringOperation::SplitString(sensorType_, sensorsType_, ",");
37     }
38 }
39 
SetHistoryTempCount()40 void ThermalConfigBaseInfo::SetHistoryTempCount()
41 {
42     auto countIter = baseItems_.find(HISTORY_TEMP_COUNT_TAG);
43     if (countIter != baseItems_.end()) {
44         StringOperation::StrToUint(countIter->second, historyTempCount_);
45     }
46 }
47 
Dump()48 void ThermalConfigBaseInfo::Dump()
49 {
50     THERMAL_HILOGD(COMP_SVC, "type: %{public}s, count: %{public}d.",
51         sensorType_.c_str(), historyTempCount_);
52     uint32_t id = 0;
53     for (auto type : sensorsType_) {
54         THERMAL_HILOGI(COMP_SVC, "Dump: id=%{public}u, sensorType = %{public}s", id++, type.c_str());
55     }
56 }
57 } // namespace PowerMgr
58 } // namespace OHOS
59