161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit NetworkKit 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ciimport type { AsyncCallback, Callback } from './@ohos.base'; 2261847f8eSopenharmony_ciimport type connection from './@ohos.net.connection'; 2361847f8eSopenharmony_ci 2461847f8eSopenharmony_ci/** 2561847f8eSopenharmony_ci * Obtains traffic statistics. 2661847f8eSopenharmony_ci * @namespace statistics 2761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 2861847f8eSopenharmony_ci * @since 10 2961847f8eSopenharmony_ci */ 3061847f8eSopenharmony_cideclare namespace statistics { 3161847f8eSopenharmony_ci /** 3261847f8eSopenharmony_ci * @typedef NetBearType 3361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 3461847f8eSopenharmony_ci * @since 12 3561847f8eSopenharmony_ci */ 3661847f8eSopenharmony_ci type NetBearType = connection.NetBearType; 3761847f8eSopenharmony_ci 3861847f8eSopenharmony_ci /** 3961847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) received through a specified NIC. 4061847f8eSopenharmony_ci * @param { string } nic - Network interface card. 4161847f8eSopenharmony_ci * @param { AsyncCallback<number> } callback - Returns the data traffic received through the specified NIC. 4261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 4361847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 4461847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 4561847f8eSopenharmony_ci * @throws { BusinessError } 2103005 - Failed to read the system map. 4661847f8eSopenharmony_ci * @throws { BusinessError } 2103011 - Failed to create a system map. 4761847f8eSopenharmony_ci * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. 4861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 4961847f8eSopenharmony_ci * @since 10 5061847f8eSopenharmony_ci */ 5161847f8eSopenharmony_ci function getIfaceRxBytes(nic: string, callback: AsyncCallback<number>): void; 5261847f8eSopenharmony_ci 5361847f8eSopenharmony_ci /** 5461847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) received through a specified NIC. 5561847f8eSopenharmony_ci * @param { string } nic - Network interface card. 5661847f8eSopenharmony_ci * @returns { Promise<number> } The promise returned by the function. 5761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 5861847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 5961847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 6061847f8eSopenharmony_ci * @throws { BusinessError } 2103005 - Failed to read the system map. 6161847f8eSopenharmony_ci * @throws { BusinessError } 2103011 - Failed to create a system map. 6261847f8eSopenharmony_ci * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. 6361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 6461847f8eSopenharmony_ci * @since 10 6561847f8eSopenharmony_ci */ 6661847f8eSopenharmony_ci function getIfaceRxBytes(nic: string): Promise<number>; 6761847f8eSopenharmony_ci 6861847f8eSopenharmony_ci /** 6961847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) sent through a specified NIC. 7061847f8eSopenharmony_ci * @param { string } nic - Network interface card. 7161847f8eSopenharmony_ci * @param { AsyncCallback<number> } callback - Returns the data traffic sent through the specified NIC. 7261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 7361847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 7461847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 7561847f8eSopenharmony_ci * @throws { BusinessError } 2103005 - Failed to read the system map. 7661847f8eSopenharmony_ci * @throws { BusinessError } 2103011 - Failed to create a system map. 7761847f8eSopenharmony_ci * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. 7861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 7961847f8eSopenharmony_ci * @since 10 8061847f8eSopenharmony_ci */ 8161847f8eSopenharmony_ci function getIfaceTxBytes(nic: string, callback: AsyncCallback<number>): void; 8261847f8eSopenharmony_ci 8361847f8eSopenharmony_ci /** 8461847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) sent through a specified NIC. 8561847f8eSopenharmony_ci * @param { string } nic - Network interface card. 8661847f8eSopenharmony_ci * @returns { Promise<number> } The promise returned by the function. 8761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 8861847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 8961847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 9061847f8eSopenharmony_ci * @throws { BusinessError } 2103005 - Failed to read the system map. 9161847f8eSopenharmony_ci * @throws { BusinessError } 2103011 - Failed to create a system map. 9261847f8eSopenharmony_ci * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. 9361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 9461847f8eSopenharmony_ci * @since 10 9561847f8eSopenharmony_ci */ 9661847f8eSopenharmony_ci function getIfaceTxBytes(nic: string): Promise<number>; 9761847f8eSopenharmony_ci 9861847f8eSopenharmony_ci /** 9961847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) received through the cellular network. 10061847f8eSopenharmony_ci * @param { AsyncCallback<number> } callback - Returns the data traffic received through the cellular network. 10161847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 10261847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 10361847f8eSopenharmony_ci * @throws { BusinessError } 2103005 - Failed to read the system map. 10461847f8eSopenharmony_ci * @throws { BusinessError } 2103011 - Failed to create a system map. 10561847f8eSopenharmony_ci * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. 10661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 10761847f8eSopenharmony_ci * @since 10 10861847f8eSopenharmony_ci */ 10961847f8eSopenharmony_ci function getCellularRxBytes(callback: AsyncCallback<number>): void; 11061847f8eSopenharmony_ci 11161847f8eSopenharmony_ci /** 11261847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) received through the cellular network. 11361847f8eSopenharmony_ci * @returns { Promise<number> } The promise returned by the function. 11461847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 11561847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 11661847f8eSopenharmony_ci * @throws { BusinessError } 2103005 - Failed to read the system map. 11761847f8eSopenharmony_ci * @throws { BusinessError } 2103011 - Failed to create a system map. 11861847f8eSopenharmony_ci * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. 11961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 12061847f8eSopenharmony_ci * @since 10 12161847f8eSopenharmony_ci */ 12261847f8eSopenharmony_ci function getCellularRxBytes(): Promise<number>; 12361847f8eSopenharmony_ci 12461847f8eSopenharmony_ci /** 12561847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) sent through the cellular network. 12661847f8eSopenharmony_ci * @param { AsyncCallback<number> } callback - Returns the data traffic sent through the cellular network. 12761847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 12861847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 12961847f8eSopenharmony_ci * @throws { BusinessError } 2103005 - Failed to read the system map. 13061847f8eSopenharmony_ci * @throws { BusinessError } 2103011 - Failed to create a system map. 13161847f8eSopenharmony_ci * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. 13261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 13361847f8eSopenharmony_ci * @since 10 13461847f8eSopenharmony_ci */ 13561847f8eSopenharmony_ci function getCellularTxBytes(callback: AsyncCallback<number>): void; 13661847f8eSopenharmony_ci 13761847f8eSopenharmony_ci /** 13861847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) sent through the cellular network. 13961847f8eSopenharmony_ci * @returns { Promise<number> } The promise returned by the function. 14061847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 14161847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 14261847f8eSopenharmony_ci * @throws { BusinessError } 2103005 - Failed to read the system map. 14361847f8eSopenharmony_ci * @throws { BusinessError } 2103011 - Failed to create a system map. 14461847f8eSopenharmony_ci * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. 14561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 14661847f8eSopenharmony_ci * @since 10 14761847f8eSopenharmony_ci */ 14861847f8eSopenharmony_ci function getCellularTxBytes(): Promise<number>; 14961847f8eSopenharmony_ci 15061847f8eSopenharmony_ci /** 15161847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) received through all NICs. 15261847f8eSopenharmony_ci * @param { AsyncCallback<number> } callback - Returns the data traffic received through all NICs. 15361847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 15461847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 15561847f8eSopenharmony_ci * @throws { BusinessError } 2103005 - Failed to read the system map. 15661847f8eSopenharmony_ci * @throws { BusinessError } 2103011 - Failed to create a system map. 15761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 15861847f8eSopenharmony_ci * @since 10 15961847f8eSopenharmony_ci */ 16061847f8eSopenharmony_ci function getAllRxBytes(callback: AsyncCallback<number>): void; 16161847f8eSopenharmony_ci 16261847f8eSopenharmony_ci /** 16361847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) received through all NICs. 16461847f8eSopenharmony_ci * @returns { Promise<number> } The promise returned by the function. 16561847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 16661847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 16761847f8eSopenharmony_ci * @throws { BusinessError } 2103005 - Failed to read the system map. 16861847f8eSopenharmony_ci * @throws { BusinessError } 2103011 - Failed to create a system map. 16961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 17061847f8eSopenharmony_ci * @since 10 17161847f8eSopenharmony_ci */ 17261847f8eSopenharmony_ci function getAllRxBytes(): Promise<number>; 17361847f8eSopenharmony_ci 17461847f8eSopenharmony_ci /** 17561847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) sent through all NICs. 17661847f8eSopenharmony_ci * @param { AsyncCallback<number> } callback - Returns the data traffic sent through all NICs. 17761847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 17861847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 17961847f8eSopenharmony_ci * @throws { BusinessError } 2103005 - Failed to read the system map. 18061847f8eSopenharmony_ci * @throws { BusinessError } 2103011 - Failed to create a system map. 18161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 18261847f8eSopenharmony_ci * @since 10 18361847f8eSopenharmony_ci */ 18461847f8eSopenharmony_ci function getAllTxBytes(callback: AsyncCallback<number>): void; 18561847f8eSopenharmony_ci 18661847f8eSopenharmony_ci /** 18761847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) sent through all NICs. 18861847f8eSopenharmony_ci * @returns { Promise<number> } The promise returned by the function. 18961847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 19061847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 19161847f8eSopenharmony_ci * @throws { BusinessError } 2103005 - Failed to read the system map. 19261847f8eSopenharmony_ci * @throws { BusinessError } 2103011 - Failed to create a system map. 19361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 19461847f8eSopenharmony_ci * @since 10 19561847f8eSopenharmony_ci */ 19661847f8eSopenharmony_ci function getAllTxBytes(): Promise<number>; 19761847f8eSopenharmony_ci 19861847f8eSopenharmony_ci /** 19961847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) received by a specified application. 20061847f8eSopenharmony_ci * @param { number } uid - Indicates the process ID of the application. 20161847f8eSopenharmony_ci * @param { AsyncCallback<number> } callback - Returns the data traffic received by the specified application. 20261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 20361847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 20461847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 20561847f8eSopenharmony_ci * @throws { BusinessError } 2103005 - Failed to read the system map. 20661847f8eSopenharmony_ci * @throws { BusinessError } 2103011 - Failed to create a system map. 20761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 20861847f8eSopenharmony_ci * @since 10 20961847f8eSopenharmony_ci */ 21061847f8eSopenharmony_ci function getUidRxBytes(uid: number, callback: AsyncCallback<number>): void; 21161847f8eSopenharmony_ci 21261847f8eSopenharmony_ci /** 21361847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) received by a specified application. 21461847f8eSopenharmony_ci * @param { number } uid - Indicates the process ID of the application. 21561847f8eSopenharmony_ci * @returns { Promise<number> } The promise returned by the function. 21661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 21761847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 21861847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 21961847f8eSopenharmony_ci * @throws { BusinessError } 2103005 - Failed to read the system map. 22061847f8eSopenharmony_ci * @throws { BusinessError } 2103011 - Failed to create a system map. 22161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 22261847f8eSopenharmony_ci * @since 10 22361847f8eSopenharmony_ci */ 22461847f8eSopenharmony_ci function getUidRxBytes(uid: number): Promise<number>; 22561847f8eSopenharmony_ci 22661847f8eSopenharmony_ci /** 22761847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) sent by a specified application. 22861847f8eSopenharmony_ci * @param { number } uid - Indicates the process ID of the application. 22961847f8eSopenharmony_ci * @param { AsyncCallback<number> } callback - Returns the data traffic sent by the specified application. 23061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 23161847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 23261847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 23361847f8eSopenharmony_ci * @throws { BusinessError } 2103005 - Failed to read the system map. 23461847f8eSopenharmony_ci * @throws { BusinessError } 2103011 - Failed to create a system map. 23561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 23661847f8eSopenharmony_ci * @since 10 23761847f8eSopenharmony_ci */ 23861847f8eSopenharmony_ci function getUidTxBytes(uid: number, callback: AsyncCallback<number>): void; 23961847f8eSopenharmony_ci 24061847f8eSopenharmony_ci /** 24161847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) sent by a specified application. 24261847f8eSopenharmony_ci * @param { number } uid - Indicates the process ID of the application. 24361847f8eSopenharmony_ci * @returns { Promise<number> } The promise returned by the function. 24461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 24561847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 24661847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 24761847f8eSopenharmony_ci * @throws { BusinessError } 2103005 - Failed to read the system map. 24861847f8eSopenharmony_ci * @throws { BusinessError } 2103011 - Failed to create a system map. 24961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 25061847f8eSopenharmony_ci * @since 10 25161847f8eSopenharmony_ci */ 25261847f8eSopenharmony_ci function getUidTxBytes(uid: number): Promise<number>; 25361847f8eSopenharmony_ci 25461847f8eSopenharmony_ci /** 25561847f8eSopenharmony_ci * Register notifications of network traffic updates. 25661847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_STATS 25761847f8eSopenharmony_ci * @param { 'netStatsChange' } type - Indicates Event name. 25861847f8eSopenharmony_ci * @param { Callback<{ iface: string, uid?: number }> } callback - The callback of on. 25961847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 26061847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 26161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 26261847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 26361847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 26461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 26561847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 26661847f8eSopenharmony_ci * @since 10 26761847f8eSopenharmony_ci */ 26861847f8eSopenharmony_ci /** 26961847f8eSopenharmony_ci * Register notifications of network traffic updates. 27061847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_STATS 27161847f8eSopenharmony_ci * @param { 'netStatsChange' } type - Indicates Event name. 27261847f8eSopenharmony_ci * @param { Callback<NetStatsChangeInfo> } callback - The callback of on. 27361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 27461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 27561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 27661847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 27761847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 27861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 27961847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 28061847f8eSopenharmony_ci * @since 11 28161847f8eSopenharmony_ci */ 28261847f8eSopenharmony_ci function on(type: 'netStatsChange', callback: Callback<NetStatsChangeInfo>): void; 28361847f8eSopenharmony_ci 28461847f8eSopenharmony_ci /** 28561847f8eSopenharmony_ci * Unregister notifications of network traffic updates. 28661847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_STATS 28761847f8eSopenharmony_ci * @param { 'netStatsChange' } type - Indicates Event name. 28861847f8eSopenharmony_ci * @param { Callback<{ iface: string, uid?: number }> } callback - The callback of off. 28961847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 29061847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 29161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 29261847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 29361847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 29461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 29561847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 29661847f8eSopenharmony_ci * @since 10 29761847f8eSopenharmony_ci */ 29861847f8eSopenharmony_ci /** 29961847f8eSopenharmony_ci * Unregister notifications of network traffic updates. 30061847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_STATS 30161847f8eSopenharmony_ci * @param { 'netStatsChange' } type - Indicates Event name. 30261847f8eSopenharmony_ci * @param { Callback<NetStatsChangeInfo> } callback - The callback of off. 30361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 30461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 30561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 30661847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 30761847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 30861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 30961847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 31061847f8eSopenharmony_ci * @since 11 31161847f8eSopenharmony_ci */ 31261847f8eSopenharmony_ci function off(type: 'netStatsChange', callback?: Callback<NetStatsChangeInfo>): void; 31361847f8eSopenharmony_ci 31461847f8eSopenharmony_ci /** 31561847f8eSopenharmony_ci * Get the traffic usage details of the network interface in the specified time period. 31661847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_STATS 31761847f8eSopenharmony_ci * @param { IfaceInfo } ifaceInfo - Detailed query content. See {@link IfaceInfo}. 31861847f8eSopenharmony_ci * @param { AsyncCallback<NetStatsInfo> } callback - Returns the {@link NetStatsInfo} object; 31961847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 32061847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 32161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 32261847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 32361847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 32461847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 32561847f8eSopenharmony_ci * @throws { BusinessError } 2103017 - Failed to read the database. 32661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 32761847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 32861847f8eSopenharmony_ci * @since 10 32961847f8eSopenharmony_ci */ 33061847f8eSopenharmony_ci function getTrafficStatsByIface(ifaceInfo: IfaceInfo, callback: AsyncCallback<NetStatsInfo>): void; 33161847f8eSopenharmony_ci 33261847f8eSopenharmony_ci /** 33361847f8eSopenharmony_ci * Get the traffic usage details of the network interface in the specified time period. 33461847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_STATS 33561847f8eSopenharmony_ci * @param { IfaceInfo } ifaceInfo - Detailed query content. See {@link IfaceInfo}. 33661847f8eSopenharmony_ci * @returns { Promise<NetStatsInfo> } The promise returned by the function. 33761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 33861847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 33961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 34061847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 34161847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 34261847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 34361847f8eSopenharmony_ci * @throws { BusinessError } 2103017 - Failed to read the database. 34461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 34561847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 34661847f8eSopenharmony_ci * @since 10 34761847f8eSopenharmony_ci */ 34861847f8eSopenharmony_ci function getTrafficStatsByIface(ifaceInfo: IfaceInfo): Promise<NetStatsInfo>; 34961847f8eSopenharmony_ci 35061847f8eSopenharmony_ci /** 35161847f8eSopenharmony_ci * Get the traffic usage details of the specified time period of the application. 35261847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_STATS 35361847f8eSopenharmony_ci * @param { UidInfo } uidInfo - Detailed query content. See {@link UidInfo}. 35461847f8eSopenharmony_ci * @param { AsyncCallback<NetStatsInfo> } callback - Returns the {@link NetStatsInfo} object; 35561847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 35661847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 35761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 35861847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 35961847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 36061847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 36161847f8eSopenharmony_ci * @throws { BusinessError } 2103017 - Failed to read the database. 36261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 36361847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 36461847f8eSopenharmony_ci * @since 10 36561847f8eSopenharmony_ci */ 36661847f8eSopenharmony_ci function getTrafficStatsByUid(uidInfo: UidInfo, callback: AsyncCallback<NetStatsInfo>): void; 36761847f8eSopenharmony_ci 36861847f8eSopenharmony_ci /** 36961847f8eSopenharmony_ci * Get the traffic usage details of the specified time period of the application. 37061847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_STATS 37161847f8eSopenharmony_ci * @param { UidInfo } uidInfo - Detailed query content. See {@link UidInfo}. 37261847f8eSopenharmony_ci * @returns { Promise<NetStatsInfo> } The promise returned by the function. 37361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 37461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 37561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 37661847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 37761847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 37861847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 37961847f8eSopenharmony_ci * @throws { BusinessError } 2103017 - Failed to read the database. 38061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 38161847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 38261847f8eSopenharmony_ci * @since 10 38361847f8eSopenharmony_ci */ 38461847f8eSopenharmony_ci function getTrafficStatsByUid(uidInfo: UidInfo): Promise<NetStatsInfo>; 38561847f8eSopenharmony_ci 38661847f8eSopenharmony_ci /** 38761847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) received through a specified sockfd. 38861847f8eSopenharmony_ci * @param { number } sockfd - Indicates the file descriptor of the given socket. 38961847f8eSopenharmony_ci * @param { AsyncCallback<number> } callback - Returns the data traffic bytes received by the specified sockfd. 39061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 39161847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 39261847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 39361847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 39461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 39561847f8eSopenharmony_ci * @since 11 39661847f8eSopenharmony_ci */ 39761847f8eSopenharmony_ci function getSockfdRxBytes(sockfd: number, callback: AsyncCallback<number>): void; 39861847f8eSopenharmony_ci 39961847f8eSopenharmony_ci /** 40061847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) received through a specified sockfd. 40161847f8eSopenharmony_ci * @param { number } sockfd - Indicates the file descriptor of the given socket. 40261847f8eSopenharmony_ci * @returns { Promise<number> } Returns the data traffic bytes received by the specified sockfd. 40361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 40461847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 40561847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 40661847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 40761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 40861847f8eSopenharmony_ci * @since 11 40961847f8eSopenharmony_ci */ 41061847f8eSopenharmony_ci function getSockfdRxBytes(sockfd: number): Promise<number>; 41161847f8eSopenharmony_ci 41261847f8eSopenharmony_ci /** 41361847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) sent through a specified sockfd. 41461847f8eSopenharmony_ci * @param { number } sockfd - Indicates the file descriptor of the given socket. 41561847f8eSopenharmony_ci * @param { AsyncCallback<number> } callback - Returns the data traffic bytes sent by the specified sockfd. 41661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 41761847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value 41861847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 41961847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 42061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 42161847f8eSopenharmony_ci * @since 11 42261847f8eSopenharmony_ci */ 42361847f8eSopenharmony_ci function getSockfdTxBytes(sockfd: number, callback: AsyncCallback<number>): void; 42461847f8eSopenharmony_ci 42561847f8eSopenharmony_ci /** 42661847f8eSopenharmony_ci * Queries the data traffic (including all TCP and UDP data packets) sent through a specified sockfd. 42761847f8eSopenharmony_ci * @param { number } sockfd - Indicates the file descriptor of the given socket. 42861847f8eSopenharmony_ci * @returns { Promise<number> } Returns the data traffic bytes sent by the specified sockfd. 42961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 43061847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value 43161847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 43261847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 43361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 43461847f8eSopenharmony_ci * @since 11 43561847f8eSopenharmony_ci */ 43661847f8eSopenharmony_ci function getSockfdTxBytes(sockfd: number): Promise<number>; 43761847f8eSopenharmony_ci 43861847f8eSopenharmony_ci /** 43961847f8eSopenharmony_ci * Parameters for obtaining detailed information on network interface traffic usage. 44061847f8eSopenharmony_ci * @interface IfaceInfo 44161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 44261847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 44361847f8eSopenharmony_ci * @since 10 44461847f8eSopenharmony_ci */ 44561847f8eSopenharmony_ci export interface IfaceInfo { 44661847f8eSopenharmony_ci /** 44761847f8eSopenharmony_ci * Network interface for querying traffic. 44861847f8eSopenharmony_ci * @type {string} 44961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 45061847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 45161847f8eSopenharmony_ci * @since 10 45261847f8eSopenharmony_ci */ 45361847f8eSopenharmony_ci iface: string; 45461847f8eSopenharmony_ci 45561847f8eSopenharmony_ci /** 45661847f8eSopenharmony_ci * Start time for querying traffic. 45761847f8eSopenharmony_ci * @type {number} 45861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 45961847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 46061847f8eSopenharmony_ci * @since 10 46161847f8eSopenharmony_ci */ 46261847f8eSopenharmony_ci startTime: number; 46361847f8eSopenharmony_ci 46461847f8eSopenharmony_ci /** 46561847f8eSopenharmony_ci * End time for querying traffic. 46661847f8eSopenharmony_ci * @type {number} 46761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 46861847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 46961847f8eSopenharmony_ci * @since 10 47061847f8eSopenharmony_ci */ 47161847f8eSopenharmony_ci endTime: number; 47261847f8eSopenharmony_ci } 47361847f8eSopenharmony_ci 47461847f8eSopenharmony_ci /** 47561847f8eSopenharmony_ci * Parameters for obtaining detailed information on application traffic usage. 47661847f8eSopenharmony_ci * @interface UidInfo 47761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 47861847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 47961847f8eSopenharmony_ci * @since 10 48061847f8eSopenharmony_ci */ 48161847f8eSopenharmony_ci export interface UidInfo { 48261847f8eSopenharmony_ci /** 48361847f8eSopenharmony_ci * See {@link IfaceInfo} 48461847f8eSopenharmony_ci * @type {IfaceInfo} 48561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 48661847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 48761847f8eSopenharmony_ci * @since 10 48861847f8eSopenharmony_ci */ 48961847f8eSopenharmony_ci ifaceInfo: IfaceInfo; 49061847f8eSopenharmony_ci 49161847f8eSopenharmony_ci /** 49261847f8eSopenharmony_ci * Uid of app for querying traffic. 49361847f8eSopenharmony_ci * @type {number} 49461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 49561847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 49661847f8eSopenharmony_ci * @since 10 49761847f8eSopenharmony_ci */ 49861847f8eSopenharmony_ci uid: number; 49961847f8eSopenharmony_ci } 50061847f8eSopenharmony_ci 50161847f8eSopenharmony_ci /** 50261847f8eSopenharmony_ci * Detailed information of statistics. 50361847f8eSopenharmony_ci * @interface NetStatsInfo 50461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 50561847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 50661847f8eSopenharmony_ci * @since 10 50761847f8eSopenharmony_ci */ 50861847f8eSopenharmony_ci export interface NetStatsInfo { 50961847f8eSopenharmony_ci /** 51061847f8eSopenharmony_ci * Bytes of received. 51161847f8eSopenharmony_ci * @type {number} 51261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 51361847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 51461847f8eSopenharmony_ci * @since 10 51561847f8eSopenharmony_ci */ 51661847f8eSopenharmony_ci rxBytes: number; 51761847f8eSopenharmony_ci 51861847f8eSopenharmony_ci /** 51961847f8eSopenharmony_ci * Bytes of send. 52061847f8eSopenharmony_ci * @type {number} 52161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 52261847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 52361847f8eSopenharmony_ci * @since 10 52461847f8eSopenharmony_ci */ 52561847f8eSopenharmony_ci txBytes: number; 52661847f8eSopenharmony_ci 52761847f8eSopenharmony_ci /** 52861847f8eSopenharmony_ci * Packets of received. 52961847f8eSopenharmony_ci * @type {number} 53061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 53161847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 53261847f8eSopenharmony_ci * @since 10 53361847f8eSopenharmony_ci */ 53461847f8eSopenharmony_ci rxPackets: number; 53561847f8eSopenharmony_ci 53661847f8eSopenharmony_ci /** 53761847f8eSopenharmony_ci * Packets of send. 53861847f8eSopenharmony_ci * @type {number} 53961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 54061847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 54161847f8eSopenharmony_ci * @since 10 54261847f8eSopenharmony_ci */ 54361847f8eSopenharmony_ci txPackets: number; 54461847f8eSopenharmony_ci } 54561847f8eSopenharmony_ci 54661847f8eSopenharmony_ci /** 54761847f8eSopenharmony_ci * Used to monitor and manage the status and usage of network interfaces. 54861847f8eSopenharmony_ci * @interface NetStatsChangeInfo 54961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 55061847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 55161847f8eSopenharmony_ci * @since 11 55261847f8eSopenharmony_ci */ 55361847f8eSopenharmony_ci export interface NetStatsChangeInfo { 55461847f8eSopenharmony_ci /** 55561847f8eSopenharmony_ci * Network interface for querying traffic. 55661847f8eSopenharmony_ci * @type { string } 55761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 55861847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 55961847f8eSopenharmony_ci * @since 11 56061847f8eSopenharmony_ci */ 56161847f8eSopenharmony_ci iface: string; 56261847f8eSopenharmony_ci /** 56361847f8eSopenharmony_ci * Network interface for querying traffic. 56461847f8eSopenharmony_ci * @type { ?number } 56561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 56661847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 56761847f8eSopenharmony_ci * @since 11 56861847f8eSopenharmony_ci */ 56961847f8eSopenharmony_ci uid?: number; 57061847f8eSopenharmony_ci } 57161847f8eSopenharmony_ci 57261847f8eSopenharmony_ci /** 57361847f8eSopenharmony_ci * An {@link NetStatsInfo} array with start time and end time. 57461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 57561847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 57661847f8eSopenharmony_ci * @since 12 57761847f8eSopenharmony_ci */ 57861847f8eSopenharmony_ci export type NetStatsInfoSequence = { 57961847f8eSopenharmony_ci /** 58061847f8eSopenharmony_ci * Start time for querying traffic. 58161847f8eSopenharmony_ci * @type { number } 58261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 58361847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 58461847f8eSopenharmony_ci * @since 12 58561847f8eSopenharmony_ci */ 58661847f8eSopenharmony_ci startTime: number; 58761847f8eSopenharmony_ci /** 58861847f8eSopenharmony_ci * End time for querying traffic. 58961847f8eSopenharmony_ci * @type { number } 59061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 59161847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 59261847f8eSopenharmony_ci * @since 12 59361847f8eSopenharmony_ci */ 59461847f8eSopenharmony_ci endTime: number; 59561847f8eSopenharmony_ci /** 59661847f8eSopenharmony_ci * Detailed information of statistics. 59761847f8eSopenharmony_ci * @type { NetStatsInfo } 59861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 59961847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 60061847f8eSopenharmony_ci * @since 12 60161847f8eSopenharmony_ci */ 60261847f8eSopenharmony_ci info: NetStatsInfo; 60361847f8eSopenharmony_ci }[]; 60461847f8eSopenharmony_ci 60561847f8eSopenharmony_ci /** 60661847f8eSopenharmony_ci * {@link NetStatsInfo} for every UID. Key is UID. 60761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 60861847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 60961847f8eSopenharmony_ci * @since 12 61061847f8eSopenharmony_ci */ 61161847f8eSopenharmony_ci export type UidNetStatsInfo = { 61261847f8eSopenharmony_ci [uid: number]: NetStatsInfo; 61361847f8eSopenharmony_ci } 61461847f8eSopenharmony_ci 61561847f8eSopenharmony_ci /** 61661847f8eSopenharmony_ci * Parameters for obtaining detailed information on specified network traffic usage. 61761847f8eSopenharmony_ci * @interface NetworkInfo 61861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 61961847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 62061847f8eSopenharmony_ci * @since 12 62161847f8eSopenharmony_ci */ 62261847f8eSopenharmony_ci export interface NetworkInfo { 62361847f8eSopenharmony_ci /** 62461847f8eSopenharmony_ci * Network type for querying traffic. 62561847f8eSopenharmony_ci * @type { NetBearType } 62661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 62761847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 62861847f8eSopenharmony_ci * @since 12 62961847f8eSopenharmony_ci */ 63061847f8eSopenharmony_ci type: NetBearType; 63161847f8eSopenharmony_ci /** 63261847f8eSopenharmony_ci * Start time for querying traffic. 63361847f8eSopenharmony_ci * @type { number } 63461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 63561847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 63661847f8eSopenharmony_ci * @since 12 63761847f8eSopenharmony_ci */ 63861847f8eSopenharmony_ci startTime: number; 63961847f8eSopenharmony_ci /** 64061847f8eSopenharmony_ci * End time for querying traffic. 64161847f8eSopenharmony_ci * @type { number } 64261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 64361847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 64461847f8eSopenharmony_ci * @since 12 64561847f8eSopenharmony_ci */ 64661847f8eSopenharmony_ci endTime: number; 64761847f8eSopenharmony_ci /** 64861847f8eSopenharmony_ci * SIM card id for querying traffic. 64961847f8eSopenharmony_ci * @type { ?number } 65061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 65161847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 65261847f8eSopenharmony_ci * @since 12 65361847f8eSopenharmony_ci */ 65461847f8eSopenharmony_ci simId?: number; 65561847f8eSopenharmony_ci } 65661847f8eSopenharmony_ci 65761847f8eSopenharmony_ci /** 65861847f8eSopenharmony_ci * Get the traffic usage details of the specified network of all applications in the specified time period. 65961847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_STATS 66061847f8eSopenharmony_ci * @param { NetworkInfo } networkInfo - Information about the network to be queried. 66161847f8eSopenharmony_ci * @returns { Promise<UidNetStatsInfo> } The statistics of the sim card. 66261847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 66361847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 66461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 66561847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 66661847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 66761847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 66861847f8eSopenharmony_ci * @throws { BusinessError } 2103017 - Failed to read the database. 66961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 67061847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 67161847f8eSopenharmony_ci * @since 12 67261847f8eSopenharmony_ci */ 67361847f8eSopenharmony_ci function getTrafficStatsByNetwork(networkInfo: NetworkInfo): Promise<UidNetStatsInfo>; 67461847f8eSopenharmony_ci /** 67561847f8eSopenharmony_ci * Get the traffic usage sequence of the specified network of the application in the specified time period. 67661847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_STATS 67761847f8eSopenharmony_ci * @param { number } uid - UID with this parameter, get stats info of this UID. 67861847f8eSopenharmony_ci * @param { NetworkInfo } networkInfo - Information about the network to be queried. 67961847f8eSopenharmony_ci * @returns { Promise<NetStatsInfoSequence> } The statistics history of the sim card. 68061847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 68161847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 68261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 68361847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 68461847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 68561847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 68661847f8eSopenharmony_ci * @throws { BusinessError } 2103017 - Failed to read the database. 68761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 68861847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 68961847f8eSopenharmony_ci * @since 12 69061847f8eSopenharmony_ci */ 69161847f8eSopenharmony_ci function getTrafficStatsByUidNetwork(uid: number, networkInfo: NetworkInfo): Promise<NetStatsInfoSequence>; 69261847f8eSopenharmony_ci} 69361847f8eSopenharmony_ci 69461847f8eSopenharmony_ciexport default statistics;