• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 NET_STATS_SERVICE_PROXY_H
17 #define NET_STATS_SERVICE_PROXY_H
18 
19 #include "i_net_stats_service.h"
20 #include "iremote_proxy.h"
21 
22 namespace OHOS {
23 namespace NetManagerStandard {
24 class NetStatsServiceProxy : public IRemoteProxy<INetStatsService> {
25 public:
26     explicit NetStatsServiceProxy(const sptr<IRemoteObject> &impl);
27     virtual ~NetStatsServiceProxy();
28     int32_t RegisterNetStatsCallback(const sptr<INetStatsCallback> &callback) override;
29     int32_t UnregisterNetStatsCallback(const sptr<INetStatsCallback> &callback) override;
30     int32_t GetIfaceRxBytes(uint64_t &stats, const std::string &interfaceName) override;
31     int32_t GetIfaceTxBytes(uint64_t &stats, const std::string &interfaceName) override;
32     int32_t GetCellularRxBytes(uint64_t &stats) override;
33     int32_t GetCellularTxBytes(uint64_t &stats) override;
34     int32_t GetAllRxBytes(uint64_t &stats) override;
35     int32_t GetAllTxBytes(uint64_t &stats) override;
36     int32_t GetUidRxBytes(uint64_t &stats, uint32_t uid) override;
37     int32_t GetUidTxBytes(uint64_t &stats, uint32_t uid) override;
38     int32_t GetAllStatsInfo(std::vector<NetStatsInfo> &infos) override;
39     int32_t GetAllSimStatsInfo(std::vector<NetStatsInfo> &infos) override;
40     int32_t GetTrafficStatsByNetwork(std::unordered_map<uint32_t, NetStatsInfo> &infos,
41                                      const sptr<NetStatsNetwork> &network) override;
42     int32_t GetTrafficStatsByUidNetwork(std::vector<NetStatsInfoSequence> &infos, uint32_t uid,
43                                         const sptr<NetStatsNetwork> &network) override;
44     int32_t SetAppStats(const PushStatsInfo &info) override;
45     int32_t GetIfaceStatsDetail(const std::string &iface, uint64_t start, uint64_t end,
46                                 NetStatsInfo &statsInfo) override;
47     int32_t GetUidStatsDetail(const std::string &iface, uint32_t uid, uint64_t start, uint64_t end,
48                               NetStatsInfo &statsInfo) override;
49     int32_t UpdateIfacesStats(const std::string &iface, uint64_t start, uint64_t end,
50                               const NetStatsInfo &stats) override;
51     int32_t UpdateStatsData() override;
52     int32_t ResetFactory() override;
53     int32_t GetCookieRxBytes(uint64_t &stats, uint64_t cookie) override;
54     int32_t GetCookieTxBytes(uint64_t &stats, uint64_t cookie) override;
55 
56 private:
57     bool WriteInterfaceToken(MessageParcel &data);
58     int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply);
59 
60 private:
61     static inline BrokerDelegator<NetStatsServiceProxy> delegator_;
62 };
63 } // namespace NetManagerStandard
64 } // namespace OHOS
65 #endif // NET_STATS_SERVICE_PROXY_H
66