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 #include "entities/battery_stats_entity.h"
17 #include "stats_log.h"
18
19 namespace OHOS {
20 namespace PowerMgr {
21 double BatteryStatsEntity::totalPowerMah_ = StatsUtils::DEFAULT_VALUE;
22 BatteryStatsInfoList BatteryStatsEntity::statsInfoList_;
23
AggregateUserPowerMah(int32_t userId,double power)24 void BatteryStatsEntity::AggregateUserPowerMah(int32_t userId, double power)
25 {
26 STATS_HILOGE(COMP_SVC, "No need to add app power to related user");
27 }
28
Calculate(int32_t uid)29 void BatteryStatsEntity::Calculate(int32_t uid)
30 {
31 STATS_HILOGE(COMP_SVC, "No need to calculate");
32 }
33
GetTrafficByte(StatsUtils::StatsType statsType,int32_t uid)34 int64_t BatteryStatsEntity::GetTrafficByte(StatsUtils::StatsType statsType, int32_t uid)
35 {
36 STATS_HILOGE(COMP_SVC, "No need to get traffic");
37 return StatsUtils::DEFAULT_VALUE;
38 }
39
GetConsumptionCount(StatsUtils::StatsType statsType,int32_t uid)40 int64_t BatteryStatsEntity::GetConsumptionCount(StatsUtils::StatsType statsType, int32_t uid)
41 {
42 STATS_HILOGE(COMP_SVC, "No need to consumption count");
43 return StatsUtils::DEFAULT_VALUE;
44 }
45
GetStatsInfoList()46 BatteryStatsInfoList BatteryStatsEntity::GetStatsInfoList()
47 {
48 return statsInfoList_;
49 }
50
UpdateStatsInfoList(std::shared_ptr<BatteryStatsInfo> info)51 void BatteryStatsEntity::UpdateStatsInfoList(std::shared_ptr<BatteryStatsInfo> info)
52 {
53 statsInfoList_.push_back(info);
54 }
55
GetActiveTimeMs(int32_t uid,StatsUtils::StatsType statsType,int16_t level)56 int64_t BatteryStatsEntity::GetActiveTimeMs(int32_t uid, StatsUtils::StatsType statsType, int16_t level)
57 {
58 STATS_HILOGE(COMP_SVC, "No need to get active time, return 0");
59 return StatsUtils::DEFAULT_VALUE;
60 }
61
GetActiveTimeMs(StatsUtils::StatsType statsType,int16_t level)62 int64_t BatteryStatsEntity::GetActiveTimeMs(StatsUtils::StatsType statsType, int16_t level)
63 {
64 STATS_HILOGE(COMP_SVC, "No need to get active time, return 0");
65 return StatsUtils::DEFAULT_VALUE;
66 }
67
DumpInfo(std::string & result,int32_t uid)68 void BatteryStatsEntity::DumpInfo(std::string& result, int32_t uid)
69 {
70 STATS_HILOGE(COMP_SVC, "No need to dump");
71 }
72
UpdateUidMap(int32_t uid)73 void BatteryStatsEntity::UpdateUidMap(int32_t uid)
74 {
75 STATS_HILOGE(COMP_SVC, "No need to update uid");
76 }
77
GetUids()78 std::vector<int32_t> BatteryStatsEntity::GetUids()
79 {
80 STATS_HILOGE(COMP_SVC, "No need to get uids");
81 std::vector<int32_t> empty;
82 return empty;
83 }
84
GetCpuTimeMs(int32_t uid)85 int64_t BatteryStatsEntity::GetCpuTimeMs(int32_t uid)
86 {
87 STATS_HILOGE(COMP_SVC, "No need to get cpu time, return 0");
88 return StatsUtils::DEFAULT_VALUE;
89 }
90
UpdateCpuTime()91 void BatteryStatsEntity::UpdateCpuTime()
92 {
93 STATS_HILOGE(COMP_SVC, "No need to update cpu time");
94 }
95
GetStatsPowerMah(StatsUtils::StatsType statsType,int32_t uid)96 double BatteryStatsEntity::GetStatsPowerMah(StatsUtils::StatsType statsType, int32_t uid)
97 {
98 STATS_HILOGE(COMP_SVC, "No need to get stats power, return 0");
99 return StatsUtils::DEFAULT_VALUE;
100 }
101
GetOrCreateTimer(StatsUtils::StatsType statsType,int16_t level)102 std::shared_ptr<StatsHelper::ActiveTimer> BatteryStatsEntity::GetOrCreateTimer(StatsUtils::StatsType statsType,
103 int16_t level)
104 {
105 STATS_HILOGE(COMP_SVC, "No need to get or create timer, return nullptr");
106 return nullptr;
107 }
108
GetOrCreateTimer(int32_t uid,StatsUtils::StatsType statsType,int16_t level)109 std::shared_ptr<StatsHelper::ActiveTimer> BatteryStatsEntity::GetOrCreateTimer(int32_t uid,
110 StatsUtils::StatsType statsType, int16_t level)
111 {
112 STATS_HILOGE(COMP_SVC, "No need to get or create timer, return nullptr");
113 return nullptr;
114 }
115
GetOrCreateTimer(const std::string & deviceId,int32_t uid,StatsUtils::StatsType statsType,int16_t level)116 std::shared_ptr<StatsHelper::ActiveTimer> BatteryStatsEntity::GetOrCreateTimer(const std::string& deviceId, int32_t uid,
117 StatsUtils::StatsType statsType, int16_t level)
118 {
119 STATS_HILOGE(COMP_SVC, "No need to get or create timer, return nullptr");
120 return nullptr;
121 }
122
GetOrCreateCounter(StatsUtils::StatsType statsType,int32_t uid)123 std::shared_ptr<StatsHelper::Counter> BatteryStatsEntity::GetOrCreateCounter(StatsUtils::StatsType statsType,
124 int32_t uid)
125 {
126 STATS_HILOGE(COMP_SVC, "No need to get or create counter, return nullptr");
127 return nullptr;
128 }
129
GetConsumptionType()130 BatteryStatsInfo::ConsumptionType BatteryStatsEntity::GetConsumptionType()
131 {
132 return consumptionType_;
133 }
134
GetTotalPowerMah()135 double BatteryStatsEntity::GetTotalPowerMah()
136 {
137 return totalPowerMah_;
138 }
139
ResetStatsEntity()140 void BatteryStatsEntity::ResetStatsEntity()
141 {
142 STATS_HILOGI(COMP_SVC, "Reset total consumption power and battery stats list");
143 totalPowerMah_ = StatsUtils::DEFAULT_VALUE;
144 statsInfoList_.clear();
145 }
146 } // namespace PowerMgr
147 } // namespace OHOS