• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 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/**
17 * @file
18 * @kit NetworkKit
19 */
20
21import type { AsyncCallback, Callback } from './@ohos.base';
22import type connection from './@ohos.net.connection';
23
24/**
25 * Obtains traffic statistics.
26 * @namespace statistics
27 * @syscap SystemCapability.Communication.NetManager.Core
28 * @since 10
29 */
30/**
31 * Obtains traffic statistics.
32 * @namespace statistics
33 * @syscap SystemCapability.Communication.NetManager.Core
34 * @atomicservice
35 * @since 15
36 */
37declare namespace statistics {
38  /**
39   * @typedef {connection.NetBearType}
40   * @syscap SystemCapability.Communication.NetManager.Core
41   * @since 12
42   */
43  type NetBearType = connection.NetBearType;
44
45  /**
46   * Queries the data traffic (including all TCP and UDP data packets) received through a specified NIC.
47   * @param { string } nic - Network interface card.
48   * @param { AsyncCallback<number> } callback - Returns the data traffic received through the specified NIC.
49   * @throws { BusinessError } 401 - Parameter error.
50   * @throws { BusinessError } 2100002 - Failed to connect to the service.
51   * @throws { BusinessError } 2100003 - System internal error.
52   * @throws { BusinessError } 2103005 - Failed to read the system map.
53   * @throws { BusinessError } 2103011 - Failed to create a system map.
54   * @throws { BusinessError } 2103012 - Failed to obtain the NIC name.
55   * @syscap SystemCapability.Communication.NetManager.Core
56   * @since 10
57   */
58  function getIfaceRxBytes(nic: string, callback: AsyncCallback<number>): void;
59
60  /**
61   * Queries the data traffic (including all TCP and UDP data packets) received through a specified NIC.
62   * @param { string } nic - Network interface card.
63   * @returns { Promise<number> } The promise returned by the function.
64   * @throws { BusinessError } 401 - Parameter error.
65   * @throws { BusinessError } 2100002 - Failed to connect to the service.
66   * @throws { BusinessError } 2100003 - System internal error.
67   * @throws { BusinessError } 2103005 - Failed to read the system map.
68   * @throws { BusinessError } 2103011 - Failed to create a system map.
69   * @throws { BusinessError } 2103012 - Failed to obtain the NIC name.
70   * @syscap SystemCapability.Communication.NetManager.Core
71   * @since 10
72   */
73  function getIfaceRxBytes(nic: string): Promise<number>;
74
75  /**
76   * Queries the data traffic (including all TCP and UDP data packets) sent through a specified NIC.
77   * @param { string } nic - Network interface card.
78   * @param { AsyncCallback<number> } callback - Returns the data traffic sent through the specified NIC.
79   * @throws { BusinessError } 401 - Parameter error.
80   * @throws { BusinessError } 2100002 - Failed to connect to the service.
81   * @throws { BusinessError } 2100003 - System internal error.
82   * @throws { BusinessError } 2103005 - Failed to read the system map.
83   * @throws { BusinessError } 2103011 - Failed to create a system map.
84   * @throws { BusinessError } 2103012 - Failed to obtain the NIC name.
85   * @syscap SystemCapability.Communication.NetManager.Core
86   * @since 10
87   */
88  function getIfaceTxBytes(nic: string, callback: AsyncCallback<number>): void;
89
90  /**
91   * Queries the data traffic (including all TCP and UDP data packets) sent through a specified NIC.
92   * @param { string } nic - Network interface card.
93   * @returns { Promise<number> } The promise returned by the function.
94   * @throws { BusinessError } 401 - Parameter error.
95   * @throws { BusinessError } 2100002 - Failed to connect to the service.
96   * @throws { BusinessError } 2100003 - System internal error.
97   * @throws { BusinessError } 2103005 - Failed to read the system map.
98   * @throws { BusinessError } 2103011 - Failed to create a system map.
99   * @throws { BusinessError } 2103012 - Failed to obtain the NIC name.
100   * @syscap SystemCapability.Communication.NetManager.Core
101   * @since 10
102   */
103  function getIfaceTxBytes(nic: string): Promise<number>;
104
105  /**
106   * Queries the data traffic (including all TCP and UDP data packets) received through the cellular network.
107   * @param { AsyncCallback<number> } callback - Returns the data traffic received through the cellular network.
108   * @throws { BusinessError } 2100002 - Failed to connect to the service.
109   * @throws { BusinessError } 2100003 - System internal error.
110   * @throws { BusinessError } 2103005 - Failed to read the system map.
111   * @throws { BusinessError } 2103011 - Failed to create a system map.
112   * @throws { BusinessError } 2103012 - Failed to obtain the NIC name.
113   * @syscap SystemCapability.Communication.NetManager.Core
114   * @since 10
115   */
116  function getCellularRxBytes(callback: AsyncCallback<number>): void;
117
118  /**
119   * Queries the data traffic (including all TCP and UDP data packets) received through the cellular network.
120   * @returns { Promise<number> } The promise returned by the function.
121   * @throws { BusinessError } 2100002 - Failed to connect to the service.
122   * @throws { BusinessError } 2100003 - System internal error.
123   * @throws { BusinessError } 2103005 - Failed to read the system map.
124   * @throws { BusinessError } 2103011 - Failed to create a system map.
125   * @throws { BusinessError } 2103012 - Failed to obtain the NIC name.
126   * @syscap SystemCapability.Communication.NetManager.Core
127   * @since 10
128   */
129  function getCellularRxBytes(): Promise<number>;
130
131  /**
132   * Queries the data traffic (including all TCP and UDP data packets) sent through the cellular network.
133   * @param { AsyncCallback<number> } callback - Returns the data traffic sent through the cellular network.
134   * @throws { BusinessError } 2100002 - Failed to connect to the service.
135   * @throws { BusinessError } 2100003 - System internal error.
136   * @throws { BusinessError } 2103005 - Failed to read the system map.
137   * @throws { BusinessError } 2103011 - Failed to create a system map.
138   * @throws { BusinessError } 2103012 - Failed to obtain the NIC name.
139   * @syscap SystemCapability.Communication.NetManager.Core
140   * @since 10
141   */
142  function getCellularTxBytes(callback: AsyncCallback<number>): void;
143
144  /**
145   * Queries the data traffic (including all TCP and UDP data packets) sent through the cellular network.
146   * @returns { Promise<number> } The promise returned by the function.
147   * @throws { BusinessError } 2100002 - Failed to connect to the service.
148   * @throws { BusinessError } 2100003 - System internal error.
149   * @throws { BusinessError } 2103005 - Failed to read the system map.
150   * @throws { BusinessError } 2103011 - Failed to create a system map.
151   * @throws { BusinessError } 2103012 - Failed to obtain the NIC name.
152   * @syscap SystemCapability.Communication.NetManager.Core
153   * @since 10
154   */
155  function getCellularTxBytes(): Promise<number>;
156
157  /**
158   * Queries the data traffic (including all TCP and UDP data packets) received through all NICs.
159   * @param { AsyncCallback<number> } callback - Returns the data traffic received through all NICs.
160   * @throws { BusinessError } 2100002 - Failed to connect to the service.
161   * @throws { BusinessError } 2100003 - System internal error.
162   * @throws { BusinessError } 2103005 - Failed to read the system map.
163   * @throws { BusinessError } 2103011 - Failed to create a system map.
164   * @syscap SystemCapability.Communication.NetManager.Core
165   * @since 10
166   */
167  /**
168   * Queries the data traffic (including all TCP and UDP data packets) received through all NICs.
169   * @param { AsyncCallback<number> } callback - Returns the data traffic received through all NICs.
170   * @throws { BusinessError } 2100002 - Failed to connect to the service.
171   * @throws { BusinessError } 2100003 - System internal error.
172   * @throws { BusinessError } 2103005 - Failed to read the system map.
173   * @throws { BusinessError } 2103011 - Failed to create a system map.
174   * @syscap SystemCapability.Communication.NetManager.Core
175   * @atomicservice
176   * @since 15
177   */
178  function getAllRxBytes(callback: AsyncCallback<number>): void;
179
180  /**
181   * Queries the data traffic (including all TCP and UDP data packets) received through all NICs.
182   * @returns { Promise<number> } The promise returned by the function.
183   * @throws { BusinessError } 2100002 - Failed to connect to the service.
184   * @throws { BusinessError } 2100003 - System internal error.
185   * @throws { BusinessError } 2103005 - Failed to read the system map.
186   * @throws { BusinessError } 2103011 - Failed to create a system map.
187   * @syscap SystemCapability.Communication.NetManager.Core
188   * @since 10
189   */
190  /**
191   * Queries the data traffic (including all TCP and UDP data packets) received through all NICs.
192   * @returns { Promise<number> } The promise returned by the function.
193   * @throws { BusinessError } 2100002 - Failed to connect to the service.
194   * @throws { BusinessError } 2100003 - System internal error.
195   * @throws { BusinessError } 2103005 - Failed to read the system map.
196   * @throws { BusinessError } 2103011 - Failed to create a system map.
197   * @syscap SystemCapability.Communication.NetManager.Core
198   * @atomicservice
199   * @since 15
200   */
201  function getAllRxBytes(): Promise<number>;
202
203  /**
204   * Queries the data traffic (including all TCP and UDP data packets) sent through all NICs.
205   * @param { AsyncCallback<number> } callback - Returns the data traffic sent through all NICs.
206   * @throws { BusinessError } 2100002 - Failed to connect to the service.
207   * @throws { BusinessError } 2100003 - System internal error.
208   * @throws { BusinessError } 2103005 - Failed to read the system map.
209   * @throws { BusinessError } 2103011 - Failed to create a system map.
210   * @syscap SystemCapability.Communication.NetManager.Core
211   * @since 10
212   */
213  /**
214   * Queries the data traffic (including all TCP and UDP data packets) sent through all NICs.
215   * @param { AsyncCallback<number> } callback - Returns the data traffic sent through all NICs.
216   * @throws { BusinessError } 2100002 - Failed to connect to the service.
217   * @throws { BusinessError } 2100003 - System internal error.
218   * @throws { BusinessError } 2103005 - Failed to read the system map.
219   * @throws { BusinessError } 2103011 - Failed to create a system map.
220   * @syscap SystemCapability.Communication.NetManager.Core
221   * @atomicservice
222   * @since 15
223   */
224  function getAllTxBytes(callback: AsyncCallback<number>): void;
225
226  /**
227   * Queries the data traffic (including all TCP and UDP data packets) sent through all NICs.
228   * @returns { Promise<number> } The promise returned by the function.
229   * @throws { BusinessError } 2100002 - Failed to connect to the service.
230   * @throws { BusinessError } 2100003 - System internal error.
231   * @throws { BusinessError } 2103005 - Failed to read the system map.
232   * @throws { BusinessError } 2103011 - Failed to create a system map.
233   * @syscap SystemCapability.Communication.NetManager.Core
234   * @since 10
235   */
236  /**
237   * Queries the data traffic (including all TCP and UDP data packets) sent through all NICs.
238   * @returns { Promise<number> } The promise returned by the function.
239   * @throws { BusinessError } 2100002 - Failed to connect to the service.
240   * @throws { BusinessError } 2100003 - System internal error.
241   * @throws { BusinessError } 2103005 - Failed to read the system map.
242   * @throws { BusinessError } 2103011 - Failed to create a system map.
243   * @syscap SystemCapability.Communication.NetManager.Core
244   * @atomicservice
245   * @since 15
246   */
247  function getAllTxBytes(): Promise<number>;
248
249  /**
250   * Queries the data traffic (including all TCP and UDP data packets) received by a specified application.
251   * @param { number } uid - Indicates the process ID of the application.
252   * @param { AsyncCallback<number> } callback - Returns the data traffic received by the specified application.
253   * @throws { BusinessError } 401 - Parameter error.
254   * @throws { BusinessError } 2100002 - Failed to connect to the service.
255   * @throws { BusinessError } 2100003 - System internal error.
256   * @throws { BusinessError } 2103005 - Failed to read the system map.
257   * @throws { BusinessError } 2103011 - Failed to create a system map.
258   * @syscap SystemCapability.Communication.NetManager.Core
259   * @since 10
260   */
261  function getUidRxBytes(uid: number, callback: AsyncCallback<number>): void;
262
263  /**
264   * Queries the data traffic (including all TCP and UDP data packets) received by a specified application.
265   * @param { number } uid - Indicates the process ID of the application.
266   * @returns { Promise<number> } The promise returned by the function.
267   * @throws { BusinessError } 401 - Parameter error.
268   * @throws { BusinessError } 2100002 - Failed to connect to the service.
269   * @throws { BusinessError } 2100003 - System internal error.
270   * @throws { BusinessError } 2103005 - Failed to read the system map.
271   * @throws { BusinessError } 2103011 - Failed to create a system map.
272   * @syscap SystemCapability.Communication.NetManager.Core
273   * @since 10
274   */
275  function getUidRxBytes(uid: number): Promise<number>;
276
277  /**
278   * Queries the data traffic (including all TCP and UDP data packets) sent by a specified application.
279   * @param { number } uid - Indicates the process ID of the application.
280   * @param { AsyncCallback<number> } callback - Returns the data traffic sent by the specified application.
281   * @throws { BusinessError } 401 - Parameter error.
282   * @throws { BusinessError } 2100002 - Failed to connect to the service.
283   * @throws { BusinessError } 2100003 - System internal error.
284   * @throws { BusinessError } 2103005 - Failed to read the system map.
285   * @throws { BusinessError } 2103011 - Failed to create a system map.
286   * @syscap SystemCapability.Communication.NetManager.Core
287   * @since 10
288   */
289  function getUidTxBytes(uid: number, callback: AsyncCallback<number>): void;
290
291  /**
292   * Queries the data traffic (including all TCP and UDP data packets) sent by a specified application.
293   * @param { number } uid - Indicates the process ID of the application.
294   * @returns { Promise<number> } The promise returned by the function.
295   * @throws { BusinessError } 401 - Parameter error.
296   * @throws { BusinessError } 2100002 - Failed to connect to the service.
297   * @throws { BusinessError } 2100003 - System internal error.
298   * @throws { BusinessError } 2103005 - Failed to read the system map.
299   * @throws { BusinessError } 2103011 - Failed to create a system map.
300   * @syscap SystemCapability.Communication.NetManager.Core
301   * @since 10
302   */
303  function getUidTxBytes(uid: number): Promise<number>;
304
305  /**
306   * Register notifications of network traffic updates.
307   * @permission ohos.permission.GET_NETWORK_STATS
308   * @param { 'netStatsChange' } type - Indicates Event name.
309   * @param { Callback<{ iface: string, uid?: number }> } callback - The callback of on.
310   * @throws { BusinessError } 201 - Permission denied.
311   * @throws { BusinessError } 202 - Non-system applications use system APIs.
312   * @throws { BusinessError } 401 - Parameter error.
313   * @throws { BusinessError } 2100002 - Failed to connect to the service.
314   * @throws { BusinessError } 2100003 - System internal error.
315   * @syscap SystemCapability.Communication.NetManager.Core
316   * @systemapi Hide this for inner system use.
317   * @since 10
318   */
319  /**
320   * Register notifications of network traffic updates.
321   * @permission ohos.permission.GET_NETWORK_STATS
322   * @param { 'netStatsChange' } type - Indicates Event name.
323   * @param { Callback<NetStatsChangeInfo> } callback - The callback of on.
324   * @throws { BusinessError } 201 - Permission denied.
325   * @throws { BusinessError } 202 - Non-system applications use system APIs.
326   * @throws { BusinessError } 401 - Parameter error.
327   * @throws { BusinessError } 2100002 - Failed to connect to the service.
328   * @throws { BusinessError } 2100003 - System internal error.
329   * @syscap SystemCapability.Communication.NetManager.Core
330   * @systemapi Hide this for inner system use.
331   * @since 11
332   */
333  function on(type: 'netStatsChange', callback: Callback<NetStatsChangeInfo>): void;
334
335  /**
336   * Unregister notifications of network traffic updates.
337   * @permission ohos.permission.GET_NETWORK_STATS
338   * @param { 'netStatsChange' } type - Indicates Event name.
339   * @param { Callback<{ iface: string, uid?: number }> } callback - The callback of off.
340   * @throws { BusinessError } 201 - Permission denied.
341   * @throws { BusinessError } 202 - Non-system applications use system APIs.
342   * @throws { BusinessError } 401 - Parameter error.
343   * @throws { BusinessError } 2100002 - Failed to connect to the service.
344   * @throws { BusinessError } 2100003 - System internal error.
345   * @syscap SystemCapability.Communication.NetManager.Core
346   * @systemapi Hide this for inner system use.
347   * @since 10
348   */
349  /**
350   * Unregister notifications of network traffic updates.
351   * @permission ohos.permission.GET_NETWORK_STATS
352   * @param { 'netStatsChange' } type - Indicates Event name.
353   * @param { Callback<NetStatsChangeInfo> } callback - The callback of off.
354   * @throws { BusinessError } 201 - Permission denied.
355   * @throws { BusinessError } 202 - Non-system applications use system APIs.
356   * @throws { BusinessError } 401 - Parameter error.
357   * @throws { BusinessError } 2100002 - Failed to connect to the service.
358   * @throws { BusinessError } 2100003 - System internal error.
359   * @syscap SystemCapability.Communication.NetManager.Core
360   * @systemapi Hide this for inner system use.
361   * @since 11
362   */
363  function off(type: 'netStatsChange', callback?: Callback<NetStatsChangeInfo>): void;
364
365  /**
366   * Get the traffic usage details of the network interface in the specified time period.
367   * @permission ohos.permission.GET_NETWORK_STATS
368   * @param { IfaceInfo } ifaceInfo - Detailed query content. See {@link IfaceInfo}.
369   * @param { AsyncCallback<NetStatsInfo> } callback - Returns the {@link NetStatsInfo} object;
370   * @throws { BusinessError } 201 - Permission denied.
371   * @throws { BusinessError } 202 - Non-system applications use system APIs.
372   * @throws { BusinessError } 401 - Parameter error.
373   * @throws { BusinessError } 2100001 - Invalid parameter value.
374   * @throws { BusinessError } 2100002 - Failed to connect to the service.
375   * @throws { BusinessError } 2100003 - System internal error.
376   * @throws { BusinessError } 2103017 - Failed to read the database.
377   * @syscap SystemCapability.Communication.NetManager.Core
378   * @systemapi Hide this for inner system use.
379   * @since 10
380   */
381  function getTrafficStatsByIface(ifaceInfo: IfaceInfo, callback: AsyncCallback<NetStatsInfo>): void;
382
383  /**
384   * Get the traffic usage details of the network interface in the specified time period.
385   * @permission ohos.permission.GET_NETWORK_STATS
386   * @param { IfaceInfo } ifaceInfo - Detailed query content. See {@link IfaceInfo}.
387   * @returns { Promise<NetStatsInfo> } The promise returned by the function.
388   * @throws { BusinessError } 201 - Permission denied.
389   * @throws { BusinessError } 202 - Non-system applications use system APIs.
390   * @throws { BusinessError } 401 - Parameter error.
391   * @throws { BusinessError } 2100001 - Invalid parameter value.
392   * @throws { BusinessError } 2100002 - Failed to connect to the service.
393   * @throws { BusinessError } 2100003 - System internal error.
394   * @throws { BusinessError } 2103017 - Failed to read the database.
395   * @syscap SystemCapability.Communication.NetManager.Core
396   * @systemapi Hide this for inner system use.
397   * @since 10
398   */
399  function getTrafficStatsByIface(ifaceInfo: IfaceInfo): Promise<NetStatsInfo>;
400
401  /**
402   * Get the traffic usage details of the specified time period of the application.
403   * @permission ohos.permission.GET_NETWORK_STATS
404   * @param { UidInfo } uidInfo - Detailed query content. See {@link UidInfo}.
405   * @param { AsyncCallback<NetStatsInfo> } callback - Returns the {@link NetStatsInfo} object;
406   * @throws { BusinessError } 201 - Permission denied.
407   * @throws { BusinessError } 202 - Non-system applications use system APIs.
408   * @throws { BusinessError } 401 - Parameter error.
409   * @throws { BusinessError } 2100001 - Invalid parameter value.
410   * @throws { BusinessError } 2100002 - Failed to connect to the service.
411   * @throws { BusinessError } 2100003 - System internal error.
412   * @throws { BusinessError } 2103017 - Failed to read the database.
413   * @syscap SystemCapability.Communication.NetManager.Core
414   * @systemapi Hide this for inner system use.
415   * @since 10
416   */
417  function getTrafficStatsByUid(uidInfo: UidInfo, callback: AsyncCallback<NetStatsInfo>): void;
418
419  /**
420   * Get the traffic usage details of the specified time period of the application.
421   * @permission ohos.permission.GET_NETWORK_STATS
422   * @param { UidInfo } uidInfo - Detailed query content. See {@link UidInfo}.
423   * @returns { Promise<NetStatsInfo> } The promise returned by the function.
424   * @throws { BusinessError } 201 - Permission denied.
425   * @throws { BusinessError } 202 - Non-system applications use system APIs.
426   * @throws { BusinessError } 401 - Parameter error.
427   * @throws { BusinessError } 2100001 - Invalid parameter value.
428   * @throws { BusinessError } 2100002 - Failed to connect to the service.
429   * @throws { BusinessError } 2100003 - System internal error.
430   * @throws { BusinessError } 2103017 - Failed to read the database.
431   * @syscap SystemCapability.Communication.NetManager.Core
432   * @systemapi Hide this for inner system use.
433   * @since 10
434   */
435  function getTrafficStatsByUid(uidInfo: UidInfo): Promise<NetStatsInfo>;
436
437  /**
438   * Queries the data traffic (including all TCP and UDP data packets) received through a specified sockfd.
439   * @param { number } sockfd - Indicates the file descriptor of the given socket.
440   * @param { AsyncCallback<number> } callback - Returns the data traffic bytes received by the specified sockfd.
441   * @throws { BusinessError } 401 - Parameter error.
442   * @throws { BusinessError } 2100001 - Invalid parameter value.
443   * @throws { BusinessError } 2100002 - Failed to connect to the service.
444   * @throws { BusinessError } 2100003 - System internal error.
445   * @syscap SystemCapability.Communication.NetManager.Core
446   * @since 11
447   */
448  function getSockfdRxBytes(sockfd: number, callback: AsyncCallback<number>): void;
449
450  /**
451   * Queries the data traffic (including all TCP and UDP data packets) received through a specified sockfd.
452   * @param { number } sockfd - Indicates the file descriptor of the given socket.
453   * @returns { Promise<number> } Returns the data traffic bytes received by the specified sockfd.
454   * @throws { BusinessError } 401 - Parameter error.
455   * @throws { BusinessError } 2100001 - Invalid parameter value.
456   * @throws { BusinessError } 2100002 - Failed to connect to the service.
457   * @throws { BusinessError } 2100003 - System internal error.
458   * @syscap SystemCapability.Communication.NetManager.Core
459   * @since 11
460   */
461  function getSockfdRxBytes(sockfd: number): Promise<number>;
462
463  /**
464   * Queries the data traffic (including all TCP and UDP data packets) sent through a specified sockfd.
465   * @param { number } sockfd - Indicates the file descriptor of the given socket.
466   * @param { AsyncCallback<number> } callback - Returns the data traffic bytes sent by the specified sockfd.
467   * @throws { BusinessError } 401 - Parameter error.
468   * @throws { BusinessError } 2100001 - Invalid parameter value
469   * @throws { BusinessError } 2100002 - Failed to connect to the service.
470   * @throws { BusinessError } 2100003 - System internal error.
471   * @syscap SystemCapability.Communication.NetManager.Core
472   * @since 11
473   */
474  function getSockfdTxBytes(sockfd: number, callback: AsyncCallback<number>): void;
475
476  /**
477   * Queries the data traffic (including all TCP and UDP data packets) sent through a specified sockfd.
478   * @param { number } sockfd - Indicates the file descriptor of the given socket.
479   * @returns { Promise<number> } Returns the data traffic bytes sent by the specified sockfd.
480   * @throws { BusinessError } 401 - Parameter error.
481   * @throws { BusinessError } 2100001 - Invalid parameter value
482   * @throws { BusinessError } 2100002 - Failed to connect to the service.
483   * @throws { BusinessError } 2100003 - System internal error.
484   * @syscap SystemCapability.Communication.NetManager.Core
485   * @since 11
486   */
487  function getSockfdTxBytes(sockfd: number): Promise<number>;
488
489  /**
490   * Parameters for obtaining detailed information on network interface traffic usage.
491   * @interface IfaceInfo
492   * @syscap SystemCapability.Communication.NetManager.Core
493   * @systemapi Hide this for inner system use.
494   * @since 10
495   */
496  export interface IfaceInfo {
497    /**
498     * Network interface for querying traffic.
499     * @type {string}
500     * @syscap SystemCapability.Communication.NetManager.Core
501     * @systemapi Hide this for inner system use.
502     * @since 10
503     */
504    iface: string;
505
506    /**
507     * Start time for querying traffic.
508     * @type {number}
509     * @syscap SystemCapability.Communication.NetManager.Core
510     * @systemapi Hide this for inner system use.
511     * @since 10
512     */
513    startTime: number;
514
515    /**
516     * End time for querying traffic.
517     * @type {number}
518     * @syscap SystemCapability.Communication.NetManager.Core
519     * @systemapi Hide this for inner system use.
520     * @since 10
521     */
522    endTime: number;
523  }
524
525  /**
526   * Parameters for obtaining detailed information on application traffic usage.
527   * @interface UidInfo
528   * @syscap SystemCapability.Communication.NetManager.Core
529   * @systemapi Hide this for inner system use.
530   * @since 10
531   */
532  export interface UidInfo {
533    /**
534     * See {@link IfaceInfo}
535     * @type {IfaceInfo}
536     * @syscap SystemCapability.Communication.NetManager.Core
537     * @systemapi Hide this for inner system use.
538     * @since 10
539     */
540    ifaceInfo: IfaceInfo;
541
542    /**
543     * Uid of app for querying traffic.
544     * @type {number}
545     * @syscap SystemCapability.Communication.NetManager.Core
546     * @systemapi Hide this for inner system use.
547     * @since 10
548     */
549    uid: number;
550  }
551
552  /**
553   * Detailed information of statistics.
554   * @interface NetStatsInfo
555   * @syscap SystemCapability.Communication.NetManager.Core
556   * @systemapi Hide this for inner system use.
557   * @since 10
558   */
559  export interface NetStatsInfo {
560    /**
561     * Bytes of received.
562     * @type {number}
563     * @syscap SystemCapability.Communication.NetManager.Core
564     * @systemapi Hide this for inner system use.
565     * @since 10
566     */
567    rxBytes: number;
568
569    /**
570     * Bytes of send.
571     * @type {number}
572     * @syscap SystemCapability.Communication.NetManager.Core
573     * @systemapi Hide this for inner system use.
574     * @since 10
575     */
576    txBytes: number;
577
578    /**
579     * Packets of received.
580     * @type {number}
581     * @syscap SystemCapability.Communication.NetManager.Core
582     * @systemapi Hide this for inner system use.
583     * @since 10
584     */
585    rxPackets: number;
586
587    /**
588     * Packets of send.
589     * @type {number}
590     * @syscap SystemCapability.Communication.NetManager.Core
591     * @systemapi Hide this for inner system use.
592     * @since 10
593     */
594    txPackets: number;
595  }
596
597  /**
598   * Used to monitor and manage the status and usage of network interfaces.
599   * @interface NetStatsChangeInfo
600   * @syscap SystemCapability.Communication.NetManager.Core
601   * @systemapi Hide this for inner system use.
602   * @since 11
603   */
604  export interface NetStatsChangeInfo {
605    /**
606     * Network interface for querying traffic.
607     * @type { string }
608     * @syscap SystemCapability.Communication.NetManager.Core
609     * @systemapi Hide this for inner system use.
610     * @since 11
611     */
612    iface: string;
613    /**
614     * Network interface for querying traffic.
615     * @type { ?number }
616     * @syscap SystemCapability.Communication.NetManager.Core
617     * @systemapi Hide this for inner system use.
618     * @since 11
619     */
620    uid?: number;
621  }
622
623  /**
624   * An {@link NetStatsInfo} array with start time and end time.
625   * @syscap SystemCapability.Communication.NetManager.Core
626   * @systemapi Hide this for inner system use.
627   * @since 12
628   */
629  export type NetStatsInfoSequence = {
630    /**
631     * Start time for querying traffic.
632     * @type { number }
633     * @syscap SystemCapability.Communication.NetManager.Core
634     * @systemapi Hide this for inner system use.
635     * @since 12
636     */
637    startTime: number;
638    /**
639     * End time for querying traffic.
640     * @type { number }
641     * @syscap SystemCapability.Communication.NetManager.Core
642     * @systemapi Hide this for inner system use.
643     * @since 12
644     */
645    endTime: number;
646    /**
647     * Detailed information of statistics.
648     * @type { NetStatsInfo }
649     * @syscap SystemCapability.Communication.NetManager.Core
650     * @systemapi Hide this for inner system use.
651     * @since 12
652     */
653    info: NetStatsInfo;
654  }[];
655
656  /**
657   * {@link NetStatsInfo} for every UID. Key is UID.
658   * @syscap SystemCapability.Communication.NetManager.Core
659   * @systemapi Hide this for inner system use.
660   * @since 12
661   */
662  export type UidNetStatsInfo = {
663    [uid: number]: NetStatsInfo;
664  };
665
666  /**
667   * Parameters for obtaining detailed information on specified network traffic usage.
668   * @interface NetworkInfo
669   * @syscap SystemCapability.Communication.NetManager.Core
670   * @systemapi Hide this for inner system use.
671   * @since 12
672   */
673  export interface NetworkInfo {
674    /**
675     * Network type for querying traffic.
676     * @type { NetBearType }
677     * @syscap SystemCapability.Communication.NetManager.Core
678     * @systemapi Hide this for inner system use.
679     * @since 12
680     */
681    type: NetBearType;
682    /**
683     * Start time for querying traffic.
684     * @type { number }
685     * @syscap SystemCapability.Communication.NetManager.Core
686     * @systemapi Hide this for inner system use.
687     * @since 12
688     */
689    startTime: number;
690    /**
691     * End time for querying traffic.
692     * @type { number }
693     * @syscap SystemCapability.Communication.NetManager.Core
694     * @systemapi Hide this for inner system use.
695     * @since 12
696     */
697    endTime: number;
698    /**
699     * SIM card id for querying traffic.
700     * @type { ?number }
701     * @syscap SystemCapability.Communication.NetManager.Core
702     * @systemapi Hide this for inner system use.
703     * @since 12
704     */
705    simId?: number;
706  }
707
708  /**
709   * Get the traffic usage details of the specified network of all applications in the specified time period.
710   * @permission ohos.permission.GET_NETWORK_STATS
711   * @param { NetworkInfo } networkInfo - Information about the network to be queried.
712   * @returns { Promise<UidNetStatsInfo> } The statistics of the sim card.
713   * @throws { BusinessError } 201 - Permission denied.
714   * @throws { BusinessError } 202 - Non-system applications use system APIs.
715   * @throws { BusinessError } 401 - Parameter error.
716   * @throws { BusinessError } 2100001 - Invalid parameter value.
717   * @throws { BusinessError } 2100002 - Failed to connect to the service.
718   * @throws { BusinessError } 2100003 - System internal error.
719   * @throws { BusinessError } 2103017 - Failed to read the database.
720   * @syscap SystemCapability.Communication.NetManager.Core
721   * @systemapi Hide this for inner system use.
722   * @since 12
723   */
724  function getTrafficStatsByNetwork(networkInfo: NetworkInfo): Promise<UidNetStatsInfo>;
725  /**
726   * Get the traffic usage sequence of the specified network of the application in the specified time period.
727   * @permission ohos.permission.GET_NETWORK_STATS
728   * @param { number } uid - UID with this parameter, get stats info of this UID.
729   * @param { NetworkInfo } networkInfo - Information about the network to be queried.
730   * @returns { Promise<NetStatsInfoSequence> } The statistics history of the sim card.
731   * @throws { BusinessError } 201 - Permission denied.
732   * @throws { BusinessError } 202 - Non-system applications use system APIs.
733   * @throws { BusinessError } 401 - Parameter error.
734   * @throws { BusinessError } 2100001 - Invalid parameter value.
735   * @throws { BusinessError } 2100002 - Failed to connect to the service.
736   * @throws { BusinessError } 2100003 - System internal error.
737   * @throws { BusinessError } 2103017 - Failed to read the database.
738   * @syscap SystemCapability.Communication.NetManager.Core
739   * @systemapi Hide this for inner system use.
740   * @since 12
741   */
742  function getTrafficStatsByUidNetwork(uid: number, networkInfo: NetworkInfo): Promise<NetStatsInfoSequence>;
743}
744
745export default statistics;