• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 STATS_SERVICE_TEST_PROXY_H
17 #define STATS_SERVICE_TEST_PROXY_H
18 
19 #include <cstdint>
20 #include <vector>
21 
22 #include "battery_stats_info.h"
23 #include "battery_stats_service.h"
24 #include "battery_stats_stub.h"
25 #include "hilog/log.h"
26 
27 namespace OHOS {
28 namespace PowerMgr {
29 class StatsServiceTestProxy {
30 public:
31     StatsServiceTestProxy(const sptr<BatteryStatsService>& service);
32     ~StatsServiceTestProxy() = default;
33 
34     int32_t GetBatteryStatsIpc(ParcelableBatteryStatsList& batteryStats, int32_t& tempError);
35     int32_t SetOnBatteryIpc(bool isOnBattery);
36     int32_t GetAppStatsMahIpc(int32_t uid, double& appStatsMah, int32_t& tempError);
37     int32_t GetAppStatsPercentIpc(int32_t uid, double& appStatsPercent, int32_t& tempError);
38     int32_t GetPartStatsMahIpc(int32_t type, double& partStatsMah, int32_t& tempError);
39     int32_t GetPartStatsPercentIpc(int32_t type, double& partStatsPercent, int32_t& tempError);
40     int32_t GetTotalTimeSecondIpc(int32_t statsType, int32_t uid, uint64_t& totalTimeSecond);
41     int32_t GetTotalDataBytesIpc(int32_t statsType, int32_t uid, uint64_t& totalDataBytes);
42     int32_t ResetIpc();
43     int32_t ShellDumpIpc(const std::vector<std::string>& args, uint32_t argc, std::string& dumpShell);
44 
45 private:
46     static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0xD000F00, "StatsTest"};
47     sptr<BatteryStatsStub> stub_ {nullptr};
48     const int VECTOR_MAX_SIZE = 102400;
49 };
50 } // namespace PowerMgr
51 } // namespace OHOS
52 #endif // STATS_SERVICE_TEST_PROXY_H