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