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 I_NET_STATS_SERVICE_H 17 #define I_NET_STATS_SERVICE_H 18 19 #include <string> 20 21 #include "i_net_stats_callback.h" 22 #include "iremote_broker.h" 23 #include "net_stats_constants.h" 24 #include "net_stats_info.h" 25 26 namespace OHOS { 27 namespace NetManagerStandard { 28 class INetStatsService : public IRemoteBroker { 29 public: 30 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.NetManagerStandard.INetStatsService"); 31 enum { 32 CMD_START = 0, 33 CMD_SYSTEM_READY = 1, 34 CMD_GET_IFACE_STATS_DETAIL = 2, 35 CMD_GET_UID_STATS_DETAIL = 3, 36 CMD_UPDATE_IFACES_STATS = 4, 37 CMD_UPDATE_STATS_DATA = 5, 38 CMD_NSM_REGISTER_NET_STATS_CALLBACK = 6, 39 CMD_NSM_UNREGISTER_NET_STATS_CALLBACK = 7, 40 CMD_NSM_RESET_FACTORY = 8, 41 CMD_GET_IFACE_RXBYTES = 9, 42 CMD_GET_IFACE_TXBYTES = 10, 43 CMD_GET_CELLULAR_RXBYTES = 11, 44 CMD_GET_CELLULAR_TXBYTES = 12, 45 CMD_GET_ALL_RXBYTES = 13, 46 CMD_GET_ALL_TXBYTES = 14, 47 CMD_GET_UID_RXBYTES = 15, 48 CMD_GET_UID_TXBYTES = 16, 49 CMD_END = 100, 50 }; 51 52 public: 53 virtual int32_t RegisterNetStatsCallback(const sptr<INetStatsCallback> &callback) = 0; 54 virtual int32_t UnregisterNetStatsCallback(const sptr<INetStatsCallback> &callback) = 0; 55 virtual int64_t GetIfaceRxBytes(const std::string &interfaceName) = 0; 56 virtual int64_t GetIfaceTxBytes(const std::string &interfaceName) = 0; 57 virtual int64_t GetCellularRxBytes() = 0; 58 virtual int64_t GetCellularTxBytes() = 0; 59 virtual int64_t GetAllRxBytes() = 0; 60 virtual int64_t GetAllTxBytes() = 0; 61 virtual int64_t GetUidRxBytes(uint32_t uid) = 0; 62 virtual int64_t GetUidTxBytes(uint32_t uid) = 0; 63 }; 64 } // namespace NetManagerStandard 65 } // namespace OHOS 66 #endif // I_NET_STATS_SERVICE_H