• 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_sensor_info.h"
17 #include "thermal_common.h"
18 #include "thermal_service.h"
19 
20 namespace OHOS {
21 namespace PowerMgr {
22 namespace {
23 auto g_service = DelayedSpSingleton<ThermalService>::GetInstance();
24 }
25 
GetTypeTempMap()26 TypeTempMap ThermalSensorInfo::GetTypeTempMap()
27 {
28     return this->typeTempMap_;
29 }
30 
SetTypeTempMap(TypeTempMap & typeTempMap)31 void ThermalSensorInfo::SetTypeTempMap(TypeTempMap &typeTempMap)
32 {
33     this->typeTempMap_ = typeTempMap;
34 }
35 
GetTemp(std::string type)36 int32_t ThermalSensorInfo::GetTemp(std::string type)
37 {
38     TypeTempMap::iterator iter = this->typeTempMap_.find(type);
39     if (iter == this->typeTempMap_.end()) {
40         THERMAL_HILOGW(COMP_SVC, "failed to find sensor info");
41         return ERR_INVALID_VALUE;
42     }
43     temp_ = (int32_t) this->typeTempMap_[type];
44     return temp_;
45 }
46 
GetHistoryTemperature(std::string type)47 std::list<int> ThermalSensorInfo::GetHistoryTemperature(std::string type)
48 {
49     historyMap_ = typeHistoryMap_[type];
50     return historyMap_;
51 }
52 
NotifyObserver()53 void ThermalSensorInfo::NotifyObserver()
54 {
55     g_service->GetObserver()->OnReceivedSensorInfo(GetTypeTempMap());
56 }
57 } // PowerMgr
58 } // OHOS