• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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     auto typesIter = baseItems_.find(SENSORS_TYPE_TAG);
33     if (typesIter != baseItems_.end()) {
34         sensorType_ = typesIter->second;
35         StringOperation::SplitString(sensorType_, sensorsType_, ",");
36     }
37 }
38 
SetHistoryTempCount()39 void ThermalConfigBaseInfo::SetHistoryTempCount()
40 {
41     auto countIter = baseItems_.find(HISTORY_TEMP_COUNT_TAG);
42     if (countIter != baseItems_.end()) {
43         historyTempCount_ = static_cast<uint32_t>(atoi(countIter->second.c_str()));
44     }
45 }
46 
Dump()47 void ThermalConfigBaseInfo::Dump()
48 {
49     THERMAL_HILOGD(COMP_SVC, "type: %{public}s, count: %{public}d.",
50         sensorType_.c_str(), historyTempCount_);
51     for (auto type : sensorsType_) {
52         THERMAL_HILOGI(COMP_SVC, "sensorType = %{public}s", type.c_str());
53     }
54 }
55 } // namespace PowerMgr
56 } // namespace OHOS
57