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 #ifndef THERMAL_SRV_SUBSCRIBER_H 17 #define THERMAL_SRV_SUBSCRIBER_H 18 19 #include <memory> 20 #include <mutex> 21 #include <time.h> 22 #include "thermal_sensor_info.h" 23 #include "thermal_observer.h" 24 25 namespace OHOS { 26 namespace PowerMgr { 27 class ThermalServiceSubscriber { 28 public: 29 ThermalServiceSubscriber(); 30 ~ThermalServiceSubscriber() = default; 31 bool Init(); 32 void OnTemperatureChanged(TypeTempMap typeTempMap); 33 void SetHistoryTypeTempMap(TypeTempMap typeTempMap); GetSensorsRate()34 const std::map<std::string, double>& GetSensorsRate() 35 { 36 return sensorsRateMap_; 37 } GetSubscriberInfo()38 TypeTempMap& GetSubscriberInfo() 39 { 40 return typeTempMap_; 41 } 42 private: 43 TypeTempMap typeTempMap_; 44 ThermalSensorInfo::TypeHistoryMap typeHistoryMap_; 45 uint32_t historyCount_ {0}; 46 time_t startTime_; 47 time_t endTime_; 48 std::map<std::string, double> sensorsRateMap_; 49 std::mutex mutex_; 50 int32_t count_ {0}; 51 int32_t magnification_ {0}; 52 }; 53 } // namespace PowerMgr 54 } // namespace OHOS 55 56 #endif // THERMAL_SRV_SUBSCRIBER_H