1 /*
2  * Copyright (c) 2021-2022 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 BATTERY_STATS_LISTENER_H
17 #define BATTERY_STATS_LISTENER_H
18 
19 #include <memory>
20 
21 #include "hisysevent_listener.h"
22 #include "json/json.h"
23 #include "stats_utils.h"
24 
25 namespace OHOS {
26 namespace PowerMgr {
27 class BatteryStatsListener : public HiviewDFX::HiSysEventListener {
28 public:
BatteryStatsListener()29     explicit BatteryStatsListener() : HiviewDFX::HiSysEventListener() {}
~BatteryStatsListener()30     virtual ~BatteryStatsListener() {}
31     void OnEvent(std::shared_ptr<HiviewDFX::HiSysEventRecord> sysEvent) override;
32     void OnServiceDied() override;
33 private:
34     void ProcessHiSysEvent(const std::string& eventName, const Json::Value& root);
35     void ProcessPhoneEvent(StatsUtils::StatsData& data, const Json::Value& root, const std::string& eventName);
36     void ProcessWakelockEvent(StatsUtils::StatsData& data, const Json::Value& root);
37     void ProcessDispalyEvent(StatsUtils::StatsData& data, const Json::Value& root, const std::string& eventName);
38     void ProcessBatteryEvent(StatsUtils::StatsData& data, const Json::Value& root);
39     void ProcessThermalEvent(StatsUtils::StatsData& data, const Json::Value& root);
40     void ProcessPowerWorkschedulerEvent(StatsUtils::StatsData& data, const Json::Value& root);
41     void ProcessOthersWorkschedulerEvent(StatsUtils::StatsData& data, const Json::Value& root);
42     void ProcessWorkschedulerEvent(StatsUtils::StatsData& data, const Json::Value& root);
43     void ProcessFlashlightEvent(StatsUtils::StatsData& data, const Json::Value& root);
44     void ProcessCameraEvent(StatsUtils::StatsData& data, const Json::Value& root, const std::string& eventName);
45     void ProcessAudioEvent(StatsUtils::StatsData& data, const Json::Value& root);
46     void ProcessSensorEvent(StatsUtils::StatsData& data, const Json::Value& root, const std::string& eventName);
47     void ProcessGnssEvent(StatsUtils::StatsData& data, const Json::Value& root);
48     void ProcessBluetoothBrEvent(StatsUtils::StatsData& data, const Json::Value& root, const std::string& eventName);
49     void ProcessBluetoothBleEvent(StatsUtils::StatsData& data, const Json::Value& root, const std::string& eventName);
50     void ProcessBluetoothEvent(StatsUtils::StatsData& data, const Json::Value& root, const std::string& eventName);
51     void ProcessWifiEvent(StatsUtils::StatsData& data, const Json::Value& root, const std::string& eventName);
52     void ProcessDistributedSchedulerEvent(StatsUtils::StatsData& data, const Json::Value& root);
53     void ProcessAlarmEvent(StatsUtils::StatsData& data, const Json::Value& root);
54     void ProcessDispalyDebugInfo(StatsUtils::StatsData& data, const Json::Value& root);
55     void ProcessPhoneDebugInfo(StatsUtils::StatsData& data, const Json::Value& root);
56 };
57 } // namespace PowerMgr
58 } // namespace OHOS
59 #endif // BATTERY_STATS 4_LISTENER_H