• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022-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 http from './@ohos.net.http';
23import type socket from './@ohos.net.socket';
24
25/**
26 * Provides interfaces to manage and use data networks.
27 * @namespace connection
28 * @syscap SystemCapability.Communication.NetManager.Core
29 * @since 8
30 */
31/**
32 * Provides interfaces to manage and use data networks.
33 * @namespace connection
34 * @syscap SystemCapability.Communication.NetManager.Core
35 * @crossplatform
36 * @since 10
37 */
38/**
39 * Provides interfaces to manage and use data networks.
40 * @namespace connection
41 * @syscap SystemCapability.Communication.NetManager.Core
42 * @crossplatform
43 * @atomicservice
44 * @since 11
45 */
46declare namespace connection {
47  /**
48   * Get an HTTP request task.
49   * @syscap SystemCapability.Communication.NetStack
50   * @since 8
51   */
52  /**
53   * Get an HTTP request task.
54   * @syscap SystemCapability.Communication.NetStack
55   * @crossplatform
56   * @since 10
57   */
58  /**
59   * Get an HTTP request task.
60   * @typedef { http.HttpRequest }
61   * @syscap SystemCapability.Communication.NetStack
62   * @crossplatform
63   * @atomicservice
64   * @since 11
65   */
66  type HttpRequest = http.HttpRequest;
67
68  /**
69   * Get a TCPSocket object.
70   * @syscap SystemCapability.Communication.NetStack
71   * @since 8
72   */
73  /**
74   * Get a TCPSocket object.
75   * @typedef { socket.TCPSocket }
76   * @syscap SystemCapability.Communication.NetStack
77   * @crossplatform
78   * @since 10
79   */
80  type TCPSocket = socket.TCPSocket;
81
82  /**
83   * Get a UDPSocket object.
84   * @syscap SystemCapability.Communication.NetStack
85   * @since 8
86   */
87  /**
88   * Get a UDPSocket object.
89   * @typedef { socket.UDPSocket }
90   * @syscap SystemCapability.Communication.NetStack
91   * @crossplatform
92   * @since 10
93   */
94  type UDPSocket = socket.UDPSocket;
95
96  /**
97   * Create a network connection with optional netSpecifier and timeout.
98   * @param { NetSpecifier } [netSpecifier] - Indicates the network specifier. See {@link NetSpecifier}.
99   * @param { number } [timeout] - The time in milliseconds to attempt looking for a suitable network before
100   * {@link NetConnection#netUnavailable} is called.
101   * @returns { NetConnection } the NetConnection of the NetSpecifier.
102   * @syscap SystemCapability.Communication.NetManager.Core
103   * @since 8
104   */
105  /**
106   * Create a network connection with optional netSpecifier and timeout.
107   * @param { NetSpecifier } [netSpecifier] - Indicates the network specifier. See {@link NetSpecifier}.
108   * @param { number } [timeout] - The time in milliseconds to attempt looking for a suitable network before
109   * {@link NetConnection#netUnavailable} is called.
110   * @returns { NetConnection } the NetConnection of the NetSpecifier.
111   * @syscap SystemCapability.Communication.NetManager.Core
112   * @crossplatform
113   * @since 10
114   */
115  /**
116   * Create a network connection with optional netSpecifier and timeout.
117   * @param { NetSpecifier } [netSpecifier] - Indicates the network specifier. See {@link NetSpecifier}.
118   * @param { number } [timeout] - The time in milliseconds to attempt looking for a suitable network before
119   * {@link NetConnection#netUnavailable} is called.
120   * @returns { NetConnection } the NetConnection of the NetSpecifier.
121   * @syscap SystemCapability.Communication.NetManager.Core
122   * @crossplatform
123   * @atomicservice
124   * @since 11
125   */
126  function createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection;
127
128  /**
129   * Obtains the data network that is activated by default.
130   * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
131   * @permission ohos.permission.GET_NETWORK_INFO
132   * @param { AsyncCallback<NetHandle> } callback - the callback of getDefaultNet.
133   * @throws { BusinessError } 201 - Permission denied.
134   * @throws { BusinessError } 401 - Parameter error.
135   * @throws { BusinessError } 2100002 - Failed to connect to the service.
136   * @throws { BusinessError } 2100003 - System internal error.
137   * @syscap SystemCapability.Communication.NetManager.Core
138   * @since 8
139   */
140  /**
141   * Obtains the data network that is activated by default.
142   * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
143   * @permission ohos.permission.GET_NETWORK_INFO
144   * @param { AsyncCallback<NetHandle> } callback - the callback of getDefaultNet.
145   * @throws { BusinessError } 201 - Permission denied.
146   * @throws { BusinessError } 401 - Parameter error.
147   * @throws { BusinessError } 2100002 - Failed to connect to the service.
148   * @throws { BusinessError } 2100003 - System internal error.
149   * @syscap SystemCapability.Communication.NetManager.Core
150   * @atomicservice
151   * @since 11
152   */
153  function getDefaultNet(callback: AsyncCallback<NetHandle>): void;
154
155  /**
156   * Obtains the data network that is activated by default.
157   * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
158   * @permission ohos.permission.GET_NETWORK_INFO
159   * @returns { Promise<NetHandle> } The promise returned by the function.
160   * @throws { BusinessError } 201 - Permission denied.
161   * @throws { BusinessError } 401 - Parameter error.
162   * @throws { BusinessError } 2100002 - Failed to connect to the service.
163   * @throws { BusinessError } 2100003 - System internal error.
164   * @syscap SystemCapability.Communication.NetManager.Core
165   * @since 8
166   */
167  /**
168   * Obtains the data network that is activated by default.
169   * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
170   * @permission ohos.permission.GET_NETWORK_INFO
171   * @returns { Promise<NetHandle> } The promise returned by the function.
172   * @throws { BusinessError } 201 - Permission denied.
173   * @throws { BusinessError } 2100002 - Failed to connect to the service.
174   * @throws { BusinessError } 2100003 - System internal error.
175   * @syscap SystemCapability.Communication.NetManager.Core
176   * @atomicservice
177   * @since 11
178   */
179  function getDefaultNet(): Promise<NetHandle>;
180
181  /**
182   * Obtains the data network that is activated by default.
183   * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
184   * @permission ohos.permission.GET_NETWORK_INFO
185   * @returns { NetHandle } if the default network is not activated.
186   * @throws { BusinessError } 201 - Permission denied.
187   * @throws { BusinessError } 401 - Parameter error.
188   * @throws { BusinessError } 2100002 - Failed to connect to the service.
189   * @throws { BusinessError } 2100003 - System internal error.
190   * @syscap SystemCapability.Communication.NetManager.Core
191   * @since 9
192   */
193  /**
194   * Obtains the data network that is activated by default.
195   * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
196   * @permission ohos.permission.GET_NETWORK_INFO
197   * @returns { NetHandle } if the default network is not activated.
198   * @throws { BusinessError } 201 - Permission denied.
199   * @throws { BusinessError } 2100002 - Failed to connect to the service.
200   * @throws { BusinessError } 2100003 - System internal error.
201   * @syscap SystemCapability.Communication.NetManager.Core
202   * @atomicservice
203   * @since 11
204   */
205  function getDefaultNetSync(): NetHandle;
206
207  /**
208   * Obtains the list of data networks that are activated.
209   * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
210   * @permission ohos.permission.GET_NETWORK_INFO
211   * @param { AsyncCallback<Array<NetHandle>> } callback - the callback of getAllNets.
212   * @throws { BusinessError } 201 - Permission denied.
213   * @throws { BusinessError } 401 - Parameter error.
214   * @throws { BusinessError } 2100002 - Failed to connect to the service.
215   * @throws { BusinessError } 2100003 - System internal error.
216   * @syscap SystemCapability.Communication.NetManager.Core
217   * @since 8
218   */
219  function getAllNets(callback: AsyncCallback<Array<NetHandle>>): void;
220
221  /**
222   * Obtains the list of data networks that are activated.
223   * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
224   * @permission ohos.permission.GET_NETWORK_INFO
225   * @returns { Promise<Array<NetHandle>> } The promise returned by the function.
226   * @throws { BusinessError } 201 - Permission denied.
227   * @throws { BusinessError } 2100002 - Failed to connect to the service.
228   * @throws { BusinessError } 2100003 - System internal error.
229   * @syscap SystemCapability.Communication.NetManager.Core
230   * @since 8
231   */
232  function getAllNets(): Promise<Array<NetHandle>>;
233
234  /**
235   * Obtains the list of data networks that are activated.
236   * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
237   * @permission ohos.permission.GET_NETWORK_INFO
238   * @returns { Array<NetHandle> } Returns data networks that are activated.
239   * @throws { BusinessError } 201 - Permission denied.
240   * @throws { BusinessError } 2100002 - Failed to connect to the service.
241   * @throws { BusinessError } 2100003 - System internal error.
242   * @syscap SystemCapability.Communication.NetManager.Core
243   * @since 10
244   */
245  function getAllNetsSync(): Array<NetHandle>;
246
247  /**
248   * Queries the connection properties of a network.
249   * This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission.
250   * @permission ohos.permission.GET_NETWORK_INFO
251   * @param { NetHandle } netHandle - Indicates the network to be queried.
252   * @param { AsyncCallback<ConnectionProperties> } callback - the callback of getConnectionProperties.{@link ConnectionProperties}.
253   * @throws { BusinessError } 201 - Permission denied.
254   * @throws { BusinessError } 401 - Parameter error.
255   * @throws { BusinessError } 2100001 - Invalid parameter value.
256   * @throws { BusinessError } 2100002 - Failed to connect to the service.
257   * @throws { BusinessError } 2100003 - System internal error.
258   * @syscap SystemCapability.Communication.NetManager.Core
259   * @since 8
260   */
261  function getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback<ConnectionProperties>): void;
262
263  /**
264   * Queries the connection properties of a network.
265   * This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission.
266   * @permission ohos.permission.GET_NETWORK_INFO
267   * @param { NetHandle } netHandle - Indicates the network to be queried.
268   * @returns { Promise<ConnectionProperties> } The promise returned by the function.
269   * @throws { BusinessError } 201 - Permission denied.
270   * @throws { BusinessError } 401 - Parameter error.
271   * @throws { BusinessError } 2100001 - Invalid parameter value.
272   * @throws { BusinessError } 2100002 - Failed to connect to the service.
273   * @throws { BusinessError } 2100003 - System internal error.
274   * @syscap SystemCapability.Communication.NetManager.Core
275   * @since 8
276   */
277  function getConnectionProperties(netHandle: NetHandle): Promise<ConnectionProperties>;
278
279  /**
280   * Queries the connection properties of a network.
281   * This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission.
282   * @permission ohos.permission.GET_NETWORK_INFO
283   * @param { NetHandle } netHandle - Indicates the network to be queried.
284   * @returns { ConnectionProperties } Returns the connection properties of a network.
285   * @throws { BusinessError } 201 - Permission denied.
286   * @throws { BusinessError } 401 - Parameter error.
287   * @throws { BusinessError } 2100001 - Invalid parameter value.
288   * @throws { BusinessError } 2100002 - Failed to connect to the service.
289   * @throws { BusinessError } 2100003 - System internal error.
290   * @syscap SystemCapability.Communication.NetManager.Core
291   * @since 10
292   */
293  function getConnectionPropertiesSync(netHandle: NetHandle): ConnectionProperties;
294
295  /**
296   * Obtains {@link NetCapabilities} of a {@link NetHandle} object.
297   * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
298   * @permission ohos.permission.GET_NETWORK_INFO
299   * @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}.
300   * @param { AsyncCallback<NetCapabilities> } callback - the callback of getNetCapabilities.{@link NetCapabilities}.
301   * @throws { BusinessError } 201 - Permission denied.
302   * @throws { BusinessError } 401 - Parameter error.
303   * @throws { BusinessError } 2100001 - Invalid parameter value.
304   * @throws { BusinessError } 2100002 - Failed to connect to the service.
305   * @throws { BusinessError } 2100003 - System internal error.
306   * @syscap SystemCapability.Communication.NetManager.Core
307   * @since 8
308   */
309  /**
310   * Obtains {@link NetCapabilities} of a {@link NetHandle} object.
311   * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
312   * @permission ohos.permission.GET_NETWORK_INFO
313   * @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}.
314   * @param { AsyncCallback<NetCapabilities> } callback - the callback of getNetCapabilities.{@link NetCapabilities}.
315   * @throws { BusinessError } 201 - Permission denied.
316   * @throws { BusinessError } 401 - Parameter error.
317   * @throws { BusinessError } 2100001 - Invalid parameter value.
318   * @throws { BusinessError } 2100002 - Failed to connect to the service.
319   * @throws { BusinessError } 2100003 - System internal error.
320   * @syscap SystemCapability.Communication.NetManager.Core
321   * @atomicservice
322   * @since 11
323   */
324  function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback<NetCapabilities>): void;
325
326  /**
327   * Obtains {@link NetCapabilities} of a {@link NetHandle} object.
328   * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
329   * @permission ohos.permission.GET_NETWORK_INFO
330   * @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}.
331   * @returns { Promise<NetCapabilities> } The promise returned by the function.
332   * @throws { BusinessError } 201 - Permission denied.
333   * @throws { BusinessError } 401 - Parameter error.
334   * @throws { BusinessError } 2100001 - Invalid parameter value.
335   * @throws { BusinessError } 2100002 - Failed to connect to the service.
336   * @throws { BusinessError } 2100003 - System internal error.
337   * @syscap SystemCapability.Communication.NetManager.Core
338   * @since 8
339   */
340  /**
341   * Obtains {@link NetCapabilities} of a {@link NetHandle} object.
342   * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
343   * @permission ohos.permission.GET_NETWORK_INFO
344   * @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}.
345   * @returns { Promise<NetCapabilities> } The promise returned by the function.
346   * @throws { BusinessError } 201 - Permission denied.
347   * @throws { BusinessError } 401 - Parameter error.
348   * @throws { BusinessError } 2100001 - Invalid parameter value.
349   * @throws { BusinessError } 2100002 - Failed to connect to the service.
350   * @throws { BusinessError } 2100003 - System internal error.
351   * @syscap SystemCapability.Communication.NetManager.Core
352   * @atomicservice
353   * @since 11
354   */
355  function getNetCapabilities(netHandle: NetHandle): Promise<NetCapabilities>;
356
357  /**
358   * Obtains {@link NetCapabilities} of a {@link NetHandle} object.
359   * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
360   * @permission ohos.permission.GET_NETWORK_INFO
361   * @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}.
362   * @returns { NetCapabilities } Returns the connection capabilities of a network.
363   * @throws { BusinessError } 201 - Permission denied.
364   * @throws { BusinessError } 401 - Parameter error.
365   * @throws { BusinessError } 2100001 - Invalid parameter value.
366   * @throws { BusinessError } 2100002 - Failed to connect to the service.
367   * @throws { BusinessError } 2100003 - System internal error.
368   * @syscap SystemCapability.Communication.NetManager.Core
369   * @since 10
370   */
371  /**
372   * Obtains {@link NetCapabilities} of a {@link NetHandle} object.
373   * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
374   * @permission ohos.permission.GET_NETWORK_INFO
375   * @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}.
376   * @returns { NetCapabilities } Returns the connection capabilities of a network.
377   * @throws { BusinessError } 201 - Permission denied.
378   * @throws { BusinessError } 401 - Parameter error.
379   * @throws { BusinessError } 2100001 - Invalid parameter value.
380   * @throws { BusinessError } 2100002 - Failed to connect to the service.
381   * @throws { BusinessError } 2100003 - System internal error.
382   * @syscap SystemCapability.Communication.NetManager.Core
383   * @atomicservice
384   * @since 11
385   */
386  function getNetCapabilitiesSync(netHandle: NetHandle): NetCapabilities;
387
388  /**
389   * Checks whether data traffic usage on the current network is metered.
390   * @permission ohos.permission.GET_NETWORK_INFO
391   * @param { AsyncCallback<boolean> } callback - Returns {@code true} if data traffic usage on the current network is metered;
392   * returns {@code false} otherwise.
393   * @throws { BusinessError } 201 - Permission denied.
394   * @throws { BusinessError } 401 - Parameter error.
395   * @throws { BusinessError } 2100002 - Failed to connect to the service.
396   * @throws { BusinessError } 2100003 - System internal error.
397   * @syscap SystemCapability.Communication.NetManager.Core
398   * @since 9
399   */
400  function isDefaultNetMetered(callback: AsyncCallback<boolean>): void;
401
402  /**
403   * Checks whether data traffic usage on the current network is metered.
404   * @permission ohos.permission.GET_NETWORK_INFO
405   * @returns { Promise<boolean> } the promise returned by the function.
406   * @throws { BusinessError } 201 - Permission denied.
407   * @throws { BusinessError } 2100002 - Failed to connect to the service.
408   * @throws { BusinessError } 2100003 - System internal error.
409   * @syscap SystemCapability.Communication.NetManager.Core
410   * @since 9
411   */
412  function isDefaultNetMetered(): Promise<boolean>;
413
414  /**
415   * Checks whether data traffic usage on the current network is metered.
416   * @permission ohos.permission.GET_NETWORK_INFO
417   * @returns { boolean } Returns true if the current network is metered, else returns false.
418   * @throws { BusinessError } 201 - Permission denied.
419   * @throws { BusinessError } 2100002 - Failed to connect to the service.
420   * @throws { BusinessError } 2100003 - System internal error.
421   * @syscap SystemCapability.Communication.NetManager.Core
422   * @since 10
423   */
424  function isDefaultNetMeteredSync(): boolean;
425
426  /**
427   * Checks whether the default data network is activated.
428   * @permission ohos.permission.GET_NETWORK_INFO
429   * @param { AsyncCallback<boolean> } callback - Returns {@code true} if the default data network is activated;
430   * returns {@code false} otherwise.
431   * @throws { BusinessError } 201 - Permission denied.
432   * @throws { BusinessError } 401 - Parameter error.
433   * @throws { BusinessError } 2100002 - Failed to connect to the service.
434   * @throws { BusinessError } 2100003 - System internal error.
435   * @syscap SystemCapability.Communication.NetManager.Core
436   * @since 8
437   */
438  /**
439   * Checks whether the default data network is activated.
440   * @permission ohos.permission.GET_NETWORK_INFO
441   * @param { AsyncCallback<boolean> } callback - Returns {@code true} if the default data network is activated;
442   * returns {@code false} otherwise.
443   * @throws { BusinessError } 201 - Permission denied.
444   * @throws { BusinessError } 401 - Parameter error.
445   * @throws { BusinessError } 2100002 - Failed to connect to the service.
446   * @throws { BusinessError } 2100003 - System internal error.
447   * @syscap SystemCapability.Communication.NetManager.Core
448   * @crossplatform
449   * @since 10
450   */
451  function hasDefaultNet(callback: AsyncCallback<boolean>): void;
452
453  /**
454   * Checks whether the default data network is activated.
455   * @permission ohos.permission.GET_NETWORK_INFO
456   * @returns { Promise<boolean> } The promise returned by the function.
457   * @throws { BusinessError } 201 - Permission denied.
458   * @throws { BusinessError } 401 - Parameter error.
459   * @throws { BusinessError } 2100002 - Failed to connect to the service.
460   * @throws { BusinessError } 2100003 - System internal error.
461   * @syscap SystemCapability.Communication.NetManager.Core
462   * @since 8
463   */
464  /**
465   * Checks whether the default data network is activated.
466   * @permission ohos.permission.GET_NETWORK_INFO
467   * @returns { Promise<boolean> } The promise returned by the function.
468   * @throws { BusinessError } 201 - Permission denied.
469   * @throws { BusinessError } 2100002 - Failed to connect to the service.
470   * @throws { BusinessError } 2100003 - System internal error.
471   * @syscap SystemCapability.Communication.NetManager.Core
472   * @crossplatform
473   * @since 10
474   */
475  function hasDefaultNet(): Promise<boolean>;
476
477  /**
478   * Checks whether the default data network is activated.
479   * @permission ohos.permission.GET_NETWORK_INFO
480   * @returns { boolean } Returns true if the default data network is activated, else returns false.
481   * @throws { BusinessError } 201 - Permission denied.
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 10
486   */
487  function hasDefaultNetSync(): boolean;
488
489  /**
490   * Enables the airplane mode for a device.
491   * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
492   * @permission ohos.permission.CONNECTIVITY_INTERNAL
493   * @param { AsyncCallback<void> } callback - the callback of enableAirplaneMode.
494   * @throws { BusinessError } 201 - Permission denied.
495   * @throws { BusinessError } 202 - Non-system applications use system APIs.
496   * @throws { BusinessError } 401 - Parameter error.
497   * @throws { BusinessError } 2100002 - Failed to connect to the service.
498   * @throws { BusinessError } 2100003 - System internal error.
499   * @syscap SystemCapability.Communication.NetManager.Core
500   * @systemapi Hide this for inner system use. Only used for system app.
501   * @since 8
502   */
503  function enableAirplaneMode(callback: AsyncCallback<void>): void;
504
505  /**
506   * Enables the airplane mode for a device.
507   * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
508   * @permission ohos.permission.CONNECTIVITY_INTERNAL
509   * @returns { Promise<void> } The promise returned by the function.
510   * @throws { BusinessError } 201 - Permission denied.
511   * @throws { BusinessError } 202 - Non-system applications use system APIs.
512   * @throws { BusinessError } 2100002 - Failed to connect to the service.
513   * @throws { BusinessError } 2100003 - System internal error.
514   * @syscap SystemCapability.Communication.NetManager.Core
515   * @systemapi Hide this for inner system use. Only used for system app.
516   * @since 8
517   */
518  function enableAirplaneMode(): Promise<void>;
519
520  /**
521   * Disables the airplane mode for a device.
522   * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
523   * @permission ohos.permission.CONNECTIVITY_INTERNAL
524   * @param { AsyncCallback<void> } callback - the callback of disableAirplaneMode.
525   * @throws { BusinessError } 201 - Permission denied.
526   * @throws { BusinessError } 202 - Non-system applications use system APIs.
527   * @throws { BusinessError } 401 - Parameter error.
528   * @throws { BusinessError } 2100002 - Failed to connect to the service.
529   * @throws { BusinessError } 2100003 - System internal error.
530   * @syscap SystemCapability.Communication.NetManager.Core
531   * @systemapi Hide this for inner system use. Only used for system app.
532   * @since 8
533   */
534  function disableAirplaneMode(callback: AsyncCallback<void>): void;
535
536  /**
537   * Disables the airplane mode for a device.
538   * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
539   * @permission ohos.permission.CONNECTIVITY_INTERNAL
540   * @returns { Promise<void> } The promise returned by the function.
541   * @throws { BusinessError } 201 - Permission denied.
542   * @throws { BusinessError } 202 - Non-system applications use system APIs.
543   * @throws { BusinessError } 2100002 - Failed to connect to the service.
544   * @throws { BusinessError } 2100003 - System internal error.
545   * @syscap SystemCapability.Communication.NetManager.Core
546   * @systemapi Hide this for inner system use. Only used for system app.
547   * @since 8
548   */
549  function disableAirplaneMode(): Promise<void>;
550
551  /**
552   * Reports the network state is connected.
553   * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
554   * @param { NetHandle } netHandle - Indicates the network whose state is to be reported.
555   * @param { AsyncCallback<void> } callback - the callback of reportNetConnected.
556   * @throws { BusinessError } 201 - Permission denied.
557   * @throws { BusinessError } 401 - Parameter error.
558   * @throws { BusinessError } 2100001 - Invalid parameter value.
559   * @throws { BusinessError } 2100002 - Failed to connect to the service.
560   * @throws { BusinessError } 2100003 - System internal error.
561   * @syscap SystemCapability.Communication.NetManager.Core
562   * @since 8
563   */
564  function reportNetConnected(netHandle: NetHandle, callback: AsyncCallback<void>): void;
565
566  /**
567   * Reports the network state is connected.
568   * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
569   * @param { NetHandle } netHandle - Indicates the network whose state is to be reported.
570   * @returns { Promise<void> } The promise returned by the function.
571   * @throws { BusinessError } 201 - Permission denied.
572   * @throws { BusinessError } 401 - Parameter error.
573   * @throws { BusinessError } 2100001 - Invalid parameter value.
574   * @throws { BusinessError } 2100002 - Failed to connect to the service.
575   * @throws { BusinessError } 2100003 - System internal error.
576   * @syscap SystemCapability.Communication.NetManager.Core
577   * @since 8
578   */
579  function reportNetConnected(netHandle: NetHandle): Promise<void>;
580
581  /**
582   * Reports the network state is disconnected.
583   * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
584   * @param { NetHandle } netHandle - Indicates the network whose state is to be reported.
585   * @param { AsyncCallback<void> } callback - the callback of reportNetDisconnected.
586   * @throws { BusinessError } 201 - Permission denied.
587   * @throws { BusinessError } 401 - Parameter error.
588   * @throws { BusinessError } 2100001 - Invalid parameter value.
589   * @throws { BusinessError } 2100002 - Failed to connect to the service.
590   * @throws { BusinessError } 2100003 - System internal error.
591   * @syscap SystemCapability.Communication.NetManager.Core
592   * @since 8
593   */
594  function reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback<void>): void;
595
596  /**
597   * Reports the network state is disconnected.
598   * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
599   * @param { NetHandle } netHandle - Indicates the network whose state is to be reported.
600   * @returns { Promise<void> } The promise returned by the function.
601   * @throws { BusinessError } 201 - Permission denied.
602   * @throws { BusinessError } 401 - Parameter error.
603   * @throws { BusinessError } 2100001 - Invalid parameter value.
604   * @throws { BusinessError } 2100002 - Failed to connect to the service.
605   * @throws { BusinessError } 2100003 - System internal error.
606   * @syscap SystemCapability.Communication.NetManager.Core
607   * @since 8
608   */
609  function reportNetDisconnected(netHandle: NetHandle): Promise<void>;
610
611  /**
612   * Resolves the host name to obtain all IP addresses based on the default data network.
613   * @permission ohos.permission.INTERNET
614   * @param { string } host - Indicates the host name or the domain.
615   * @param { AsyncCallback<Array<NetAddress>> } callback - Returns the NetAddress list.
616   * @throws { BusinessError } 201 - Permission denied.
617   * @throws { BusinessError } 401 - Parameter error.
618   * @throws { BusinessError } 2100001 - Invalid parameter value.
619   * @throws { BusinessError } 2100002 - Failed to connect to the service.
620   * @throws { BusinessError } 2100003 - System internal error.
621   * @syscap SystemCapability.Communication.NetManager.Core
622   * @since 8
623   */
624  function getAddressesByName(host: string, callback: AsyncCallback<Array<NetAddress>>): void;
625
626  /**
627   * Resolves the host name to obtain all IP addresses based on the default data network.
628   * @permission ohos.permission.INTERNET
629   * @param { string } host - Indicates the host name or the domain.
630   * @returns { Promise<Array<NetAddress>> } The promise returned by the function.
631   * @throws { BusinessError } 201 - Permission denied.
632   * @throws { BusinessError } 401 - Parameter error.
633   * @throws { BusinessError } 2100001 - Invalid parameter value.
634   * @throws { BusinessError } 2100002 - Failed to connect to the service.
635   * @throws { BusinessError } 2100003 - System internal error.
636   * @syscap SystemCapability.Communication.NetManager.Core
637   * @since 8
638   */
639  function getAddressesByName(host: string): Promise<Array<NetAddress>>;
640
641  /**
642   * Obtains the {@link NetHandle} bound to a process using {@link setAppNet}.
643   * @param { AsyncCallback<NetHandle> } callback - Returns the {@link NetHandle} bound to the process;
644   * returns {@code null} if no {@link NetHandle} is bound to the process.For details, see {@link NetHandle}.
645   * @throws { BusinessError } 401 - Parameter error.
646   * @throws { BusinessError } 2100002 - Failed to connect to the service.
647   * @throws { BusinessError } 2100003 - System internal error.
648   * @syscap SystemCapability.Communication.NetManager.Core
649   * @since 9
650   */
651  function getAppNet(callback: AsyncCallback<NetHandle>): void;
652
653  /**
654   * Obtains the {@link NetHandle} bound to a process using {@link setAppNet}.
655   * @returns { Promise<NetHandle> } the promise returned by the function.
656   * @throws { BusinessError } 2100002 - Failed to connect to the service.
657   * @throws { BusinessError } 2100003 - System internal error.
658   * @syscap SystemCapability.Communication.NetManager.Core
659   * @since 9
660   */
661  function getAppNet(): Promise<NetHandle>;
662
663  /**
664   * Obtains the {@link NetHandle} bound to a process using {@link setAppNet}.
665   * @returns { NetHandle } Returns the {@link NetHandle} bound to a process using {@link setAppNet}.
666   * @throws { BusinessError } 2100002 - Failed to connect to the service.
667   * @throws { BusinessError } 2100003 - System internal error.
668   * @syscap SystemCapability.Communication.NetManager.Core
669   * @since 10
670   */
671  function getAppNetSync(): NetHandle;
672
673  /**
674   * Binds a process to {@code NetHandle}.
675   * <p>All the sockets created from the process will be bound to the {@code NetHandle},
676   * and the resolution of all host names will be managed by the {@code NetHandle}.</p>
677   * @permission ohos.permission.INTERNET
678   * @param { NetHandle } netHandle - Indicates the handle. For details, see {@link NetHandle}.
679   * @param { AsyncCallback<void> } callback - the callback of setAppNet.
680   * @throws { BusinessError } 201 - Permission denied.
681   * @throws { BusinessError } 401 - Parameter error.
682   * @throws { BusinessError } 2100001 - Invalid parameter value.
683   * @throws { BusinessError } 2100002 - Failed to connect to the service.
684   * @throws { BusinessError } 2100003 - System internal error.
685   * @syscap SystemCapability.Communication.NetManager.Core
686   * @since 9
687   */
688  function setAppNet(netHandle: NetHandle, callback: AsyncCallback<void>): void;
689
690  /**
691   * Binds a process to {@code NetHandle}.
692   * <p>All the sockets created from the process will be bound to the {@code NetHandle},
693   * and the resolution of all host names will be managed by the {@code NetHandle}.</p>
694   * @permission ohos.permission.INTERNET
695   * @param { NetHandle } netHandle - Indicates the handle. For details, see {@link NetHandle}.
696   * @returns { Promise<void> } the promise returned by the function.
697   * @throws { BusinessError } 201 - Permission denied.
698   * @throws { BusinessError } 401 - Parameter error.
699   * @throws { BusinessError } 2100001 - Invalid parameter value.
700   * @throws { BusinessError } 2100002 - Failed to connect to the service.
701   * @throws { BusinessError } 2100003 - System internal error.
702   * @syscap SystemCapability.Communication.NetManager.Core
703   * @since 9
704   */
705  function setAppNet(netHandle: NetHandle): Promise<void>;
706
707  /**
708   * Obtains the default {@link HttpProxy} proxy settings.
709   *
710   * If an application level proxy is set, the application level proxy parameters are returned.
711   * If a global proxy is set, the global proxy parameters are returned.
712   * If the process is bound to a {@link NetHandle} using {@link setAppNet}, the {@link NetHandle} proxy settings are returned.
713   * In other cases, the proxy settings of default network are returned.
714   *
715   * @param { AsyncCallback<HttpProxy> } callback - Returns the default {@link HttpProxy} settings.
716   * @throws { BusinessError } 2100002 - Failed to connect to the service.
717   * @throws { BusinessError } 2100003 - System internal error.
718   * @syscap SystemCapability.Communication.NetManager.Core
719   * @since 10
720   */
721  function getDefaultHttpProxy(callback: AsyncCallback<HttpProxy>): void;
722
723  /**
724   * Obtains the default {@link HttpProxy} proxy settings.
725   *
726   * If an application level proxy is set, the application level proxy parameters are returned.
727   * If a global proxy is set, the global proxy parameters are returned.
728   * If the process is bound to a {@link NetHandle} using {@link setAppNet}, the {@link NetHandle} proxy settings are returned.
729   * In other cases, the proxy settings of default network are returned.
730   *
731   * @returns { Promise<HttpProxy> } the promise returned by the function.
732   * @throws { BusinessError } 2100002 - Failed to connect to the service.
733   * @throws { BusinessError } 2100003 - System internal error.
734   * @syscap SystemCapability.Communication.NetManager.Core
735   * @since 10
736   */
737  function getDefaultHttpProxy(): Promise<HttpProxy>;
738
739  /**
740   * Obtains the network independent global {@link HttpProxy} proxy settings.
741   * @param { AsyncCallback<HttpProxy> } callback - Returns the proxy settings. For details, see {@link HttpProxy}.
742   * @throws { BusinessError } 401 - Parameter error.
743   * @throws { BusinessError } 202 - Non-system applications use system APIs.
744   * @throws { BusinessError } 2100002 - Failed to connect to the service.
745   * @throws { BusinessError } 2100003 - System internal error.
746   * @syscap SystemCapability.Communication.NetManager.Core
747   * @systemapi Hide this for inner system use.
748   * @since 10
749   */
750  function getGlobalHttpProxy(callback: AsyncCallback<HttpProxy>): void;
751
752  /**
753   * Obtains the network independent global {@link HttpProxy} proxy settings.
754   * @returns { Promise<HttpProxy> } the promise returned by the function.
755   * @throws { BusinessError } 202 - Non-system applications use system APIs.
756   * @throws { BusinessError } 2100002 - Failed to connect to the service.
757   * @throws { BusinessError } 2100003 - System internal error.
758   * @syscap SystemCapability.Communication.NetManager.Core
759   * @systemapi Hide this for inner system use.
760   * @since 10
761   */
762  function getGlobalHttpProxy(): Promise<HttpProxy>;
763
764  /**
765   * Set application level http proxy {@link HttpProxy}.
766   * @param { HttpProxy } httpProxy - Indicates the application level proxy settings. For details, see {@link HttpProxy}.
767   * @throws { BusinessError } 401 - Parameter error.
768   * @throws { BusinessError } 2100001 - Invalid http proxy.
769   * @syscap SystemCapability.Communication.NetManager.Core
770   * @since 11
771   */
772  function setAppHttpProxy(httpProxy: HttpProxy): void;
773
774  /**
775   * Set a network independent global {@link HttpProxy} proxy settings.
776   * @permission ohos.permission.CONNECTIVITY_INTERNAL
777   * @param { HttpProxy } httpProxy - Indicates the global proxy settings. For details, see {@link HttpProxy}.
778   * @param { AsyncCallback<void> } callback - the callback of setGlobalHttpProxy.
779   * @throws { BusinessError } 201 - Permission denied.
780   * @throws { BusinessError } 401 - Parameter error.
781   * @throws { BusinessError } 202 - Non-system applications use system APIs.
782   * @throws { BusinessError } 2100001 - Invalid parameter value.
783   * @throws { BusinessError } 2100002 - Failed to connect to the service.
784   * @throws { BusinessError } 2100003 - System internal error.
785   * @syscap SystemCapability.Communication.NetManager.Core
786   * @systemapi Hide this for inner system use.
787   * @since 10
788   */
789  function setGlobalHttpProxy(httpProxy: HttpProxy, callback: AsyncCallback<void>): void;
790
791  /**
792   * Set a network independent global {@link HttpProxy} proxy settings.
793   * @permission ohos.permission.CONNECTIVITY_INTERNAL
794   * @param { HttpProxy } httpProxy - Indicates the global proxy settings. For details, see {@link HttpProxy}.
795   * @returns { Promise<void> } the promise returned by the function.
796   * @throws { BusinessError } 201 - Permission denied.
797   * @throws { BusinessError } 401 - Parameter error.
798   * @throws { BusinessError } 202 - Non-system applications use system APIs.
799   * @throws { BusinessError } 2100001 - Invalid parameter value.
800   * @throws { BusinessError } 2100002 - Failed to connect to the service.
801   * @throws { BusinessError } 2100003 - System internal error.
802   * @syscap SystemCapability.Communication.NetManager.Core
803   * @systemapi Hide this for inner system use.
804   * @since 10
805   */
806  function setGlobalHttpProxy(httpProxy: HttpProxy): Promise<void>;
807
808  /**
809   * Set the URL {@link pacUrl} of the current PAC script.
810   * To invoke this method, you must have the {@code ohos.permission.SET_PAC_URL} permission.
811   * @permission ohos.permission.SET_PAC_URL
812   * @param { string } pacUrl - Indicates the URL of the current PAC script.
813   * @throws { BusinessError } 201 - Permission denied.
814   * @throws { BusinessError } 401 - Parameter error.
815   * @throws { BusinessError } 2100002 - Failed to connect to the service.
816   * @throws { BusinessError } 2100003 - System internal error.
817   * @syscap SystemCapability.Communication.NetManager.Core
818   * @since 15
819   */
820  function setPacUrl(pacUrl: string): void;
821
822  /**
823   * Obtain the URL {@link pacUrl} of the current PAC script.
824   * @returns { string } Returns the URL of the current PAC script or empty string if there is no PAC script.
825   * @throws { BusinessError } 2100002 - Failed to connect to the service.
826   * @throws { BusinessError } 2100003 - System internal error.
827   * @syscap SystemCapability.Communication.NetManager.Core
828   * @since 15
829   */
830  function getPacUrl(): string;
831
832  /**
833   * Add a custom {@link host} and corresponding {@link ip} mapping for current application.
834   * @permission ohos.permission.INTERNET
835   * @param { string } host - Indicates the host name or the domain.
836   * @param { Array<string> } ip - List of IP addresses mapped to the host name.
837   * @param { AsyncCallback<void> } callback - Returns the callback of addCustomDnsRule.
838   * @throws { BusinessError } 201 - Permission denied.
839   * @throws { BusinessError } 401 - Parameter error.
840   * @throws { BusinessError } 2100001 - Invalid parameter value.
841   * @throws { BusinessError } 2100002 - Failed to connect to the service.
842   * @throws { BusinessError } 2100003 - System internal error.
843   * @syscap SystemCapability.Communication.NetManager.Core
844   * @since 11
845   */
846  /**
847   * Add a custom {@link host} and corresponding {@link ip} mapping for current application.
848   * @permission ohos.permission.INTERNET
849   * @param { string } host - Indicates the host name or the domain.
850   * @param { Array<string> } ip - List of IP addresses mapped to the host name.
851   * @param { AsyncCallback<void> } callback - Returns the callback of addCustomDnsRule.
852   * @throws { BusinessError } 201 - Permission denied.
853   * @throws { BusinessError } 401 - Parameter error.
854   * @throws { BusinessError } 2100001 - Invalid parameter value.
855   * @throws { BusinessError } 2100002 - Failed to connect to the service.
856   * @throws { BusinessError } 2100003 - System internal error.
857   * @syscap SystemCapability.Communication.NetManager.Core
858   * @atomicservice
859   * @since 15
860   */
861  function addCustomDnsRule(host: string, ip: Array<string>, callback: AsyncCallback<void>): void;
862
863  /**
864   * Add a custom {@link host} and corresponding {@link ip} mapping for current application.
865   * @permission ohos.permission.INTERNET
866   * @param { string } host - Indicates the host name or the domain.
867   * @param { Array<string> } ip - List of IP addresses mapped to the host name.
868   * @returns { Promise<void> } the promise returned by the function.
869   * @throws { BusinessError } 201 - Permission denied.
870   * @throws { BusinessError } 401 - Parameter error.
871   * @throws { BusinessError } 2100001 - Invalid parameter value.
872   * @throws { BusinessError } 2100002 - Failed to connect to the service.
873   * @throws { BusinessError } 2100003 - System internal error.
874   * @syscap SystemCapability.Communication.NetManager.Core
875   * @since 11
876   */
877  /**
878   * Add a custom {@link host} and corresponding {@link ip} mapping for current application.
879   * @permission ohos.permission.INTERNET
880   * @param { string } host - Indicates the host name or the domain.
881   * @param { Array<string> } ip - List of IP addresses mapped to the host name.
882   * @returns { Promise<void> } the promise returned by the function.
883   * @throws { BusinessError } 201 - Permission denied.
884   * @throws { BusinessError } 401 - Parameter error.
885   * @throws { BusinessError } 2100001 - Invalid parameter value.
886   * @throws { BusinessError } 2100002 - Failed to connect to the service.
887   * @throws { BusinessError } 2100003 - System internal error.
888   * @syscap SystemCapability.Communication.NetManager.Core
889   * @atomicservice
890   * @since 15
891   */
892  function addCustomDnsRule(host: string, ip: Array<string>): Promise<void>;
893
894  /**
895   * Remove the custom DNS rule of the {@link host} for current application.
896   * @permission ohos.permission.INTERNET
897   * @param { string } host - Indicates the host name or the domain.
898   * @param { AsyncCallback<void> } callback - Returns the callback of removeCustomDnsRule.
899   * @throws { BusinessError } 201 - Permission denied.
900   * @throws { BusinessError } 401 - Parameter error.
901   * @throws { BusinessError } 2100001 - Invalid parameter value.
902   * @throws { BusinessError } 2100002 - Failed to connect to the service.
903   * @throws { BusinessError } 2100003 - System internal error.
904   * @syscap SystemCapability.Communication.NetManager.Core
905   * @since 11
906   */
907  /**
908   * Remove the custom DNS rule of the {@link host} for current application.
909   * @permission ohos.permission.INTERNET
910   * @param { string } host - Indicates the host name or the domain.
911   * @param { AsyncCallback<void> } callback - Returns the callback of removeCustomDnsRule.
912   * @throws { BusinessError } 201 - Permission denied.
913   * @throws { BusinessError } 401 - Parameter error.
914   * @throws { BusinessError } 2100001 - Invalid parameter value.
915   * @throws { BusinessError } 2100002 - Failed to connect to the service.
916   * @throws { BusinessError } 2100003 - System internal error.
917   * @syscap SystemCapability.Communication.NetManager.Core
918   * @atomicservice
919   * @since 15
920   */
921  function removeCustomDnsRule(host: string, callback: AsyncCallback<void>): void;
922
923  /**
924   * Remove the custom DNS rule of the {@link host} for current application.
925   * @permission ohos.permission.INTERNET
926   * @param { string } host - Indicates the host name or the domain.
927   * @returns { Promise<void> } the promise returned by the function.
928   * @throws { BusinessError } 201 - Permission denied.
929   * @throws { BusinessError } 401 - Parameter error.
930   * @throws { BusinessError } 2100001 - Invalid parameter value.
931   * @throws { BusinessError } 2100002 - Failed to connect to the service.
932   * @throws { BusinessError } 2100003 - System internal error.
933   * @syscap SystemCapability.Communication.NetManager.Core
934   * @since 11
935   */
936  /**
937   * Remove the custom DNS rule of the {@link host} for current application.
938   * @permission ohos.permission.INTERNET
939   * @param { string } host - Indicates the host name or the domain.
940   * @returns { Promise<void> } the promise returned by the function.
941   * @throws { BusinessError } 201 - Permission denied.
942   * @throws { BusinessError } 401 - Parameter error.
943   * @throws { BusinessError } 2100001 - Invalid parameter value.
944   * @throws { BusinessError } 2100002 - Failed to connect to the service.
945   * @throws { BusinessError } 2100003 - System internal error.
946   * @syscap SystemCapability.Communication.NetManager.Core
947   * @atomicservice
948   * @since 15
949   */
950  function removeCustomDnsRule(host: string): Promise<void>;
951
952  /**
953   * Clear all custom DNS rules for current application.
954   * @permission ohos.permission.INTERNET
955   * @param { AsyncCallback<void> } callback - Returns the callback of clearCustomDnsRules.
956   * @throws { BusinessError } 201 - Permission denied.
957   * @throws { BusinessError } 401 - Parameter error.
958   * @throws { BusinessError } 2100001 - Invalid parameter value.
959   * @throws { BusinessError } 2100002 - Failed to connect to the service.
960   * @throws { BusinessError } 2100003 - System internal error.
961   * @syscap SystemCapability.Communication.NetManager.Core
962   * @since 11
963   */
964  function clearCustomDnsRules(callback: AsyncCallback<void>): void;
965
966  /**
967   * Clear all custom DNS rules for current application.
968   * @permission ohos.permission.INTERNET
969   * @returns { Promise<void> } the promise returned by the function.
970   * @throws { BusinessError } 201 - Permission denied.
971   * @throws { BusinessError } 2100001 - Invalid parameter value.
972   * @throws { BusinessError } 2100002 - Failed to connect to the service.
973   * @throws { BusinessError } 2100003 - System internal error.
974   * @syscap SystemCapability.Communication.NetManager.Core
975   * @since 11
976   */
977  function clearCustomDnsRules(): Promise<void>;
978
979  /**
980   * factory reset network settings
981   *
982   * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
983   * @permission ohos.permission.CONNECTIVITY_INTERNAL
984   * @returns { Promise<void> } the promise returned by the function.
985   * @throws { BusinessError } 201 - Permission denied.
986   * @throws { BusinessError } 202 - Non-system applications use system APIs.
987   * @throws { BusinessError } 2100002 - Failed to connect to the service.
988   * @throws { BusinessError } 2100003 - System internal error.
989   * @syscap SystemCapability.Communication.NetManager.Core
990   * @systemapi Hide this for inner system use. Only used for system app.
991   * @since 11
992   */
993  function factoryReset(): Promise<void>;
994
995  /**
996   * Represents the network connection handle.
997   * @interface NetConnection
998   * @syscap SystemCapability.Communication.NetManager.Core
999   * @since 8
1000   */
1001  /**
1002   * Represents the network connection handle.
1003   * @interface NetConnection
1004   * @syscap SystemCapability.Communication.NetManager.Core
1005   * @crossplatform
1006   * @since 10
1007   */
1008  /**
1009   * Represents the network connection handle.
1010   * @interface NetConnection
1011   * @syscap SystemCapability.Communication.NetManager.Core
1012   * @crossplatform
1013   * @atomicservice
1014   * @since 11
1015   */
1016  export interface NetConnection {
1017    /**
1018     * Registers a listener for netAvailable events.
1019     * @param { 'netAvailable' } type - Indicates Event name.
1020     * @param { Callback<NetHandle> } callback - the callback used to return the result.
1021     * @syscap SystemCapability.Communication.NetManager.Core
1022     * @since 8
1023     */
1024    /**
1025     * Registers a listener for netAvailable events.
1026     * @param { 'netAvailable' } type - Indicates Event name.
1027     * @param { Callback<NetHandle> } callback - the callback used to return the result.
1028     * @syscap SystemCapability.Communication.NetManager.Core
1029     * @crossplatform
1030     * @since 10
1031     */
1032    /**
1033     * Registers a listener for netAvailable events.
1034     * @param { 'netAvailable' } type - Indicates Event name.
1035     * @param { Callback<NetHandle> } callback - the callback used to return the result.
1036     * @syscap SystemCapability.Communication.NetManager.Core
1037     * @crossplatform
1038     * @atomicservice
1039     * @since 11
1040     */
1041    on(type: 'netAvailable', callback: Callback<NetHandle>): void;
1042
1043    /**
1044     * Registers a listener for netBlockStatusChange events.
1045     * @param { 'netBlockStatusChange' } type - Indicates Event name.
1046     * @param { Callback<{ netHandle: NetHandle, blocked: boolean }> } callback - the callback used to return the result.
1047     * @syscap SystemCapability.Communication.NetManager.Core
1048     * @since 8
1049     */
1050    /**
1051     * Registers a listener for netBlockStatusChange events.
1052     * @param { 'netBlockStatusChange' } type - Indicates Event name.
1053     * @param { Callback<NetBlockStatusInfo> } callback - the callback used to return the result.
1054     * @syscap SystemCapability.Communication.NetManager.Core
1055     * @since 11
1056     */
1057    on(type: 'netBlockStatusChange', callback: Callback<NetBlockStatusInfo>): void;
1058
1059    /**
1060     * Registers a listener for **netCapabilitiesChange** events.
1061     * @param { 'netCapabilitiesChange' } type - Indicates Event name.
1062     * @param { Callback<NetCapabilityInfo> } callback - the callback used to return the result.
1063     * @syscap SystemCapability.Communication.NetManager.Core
1064     * @since 8
1065     */
1066    /**
1067     * Registers a listener for **netCapabilitiesChange** events.
1068     * @param { 'netCapabilitiesChange' } type - Indicates Event name.
1069     * @param { Callback<NetCapabilityInfo> } callback - the callback used to return the result.
1070     * @syscap SystemCapability.Communication.NetManager.Core
1071     * @crossplatform
1072     * @since 10
1073     */
1074    /**
1075     * Registers a listener for **netCapabilitiesChange** events.
1076     * @param { 'netCapabilitiesChange' } type - Indicates Event name.
1077     * @param { Callback<NetCapabilityInfo> } callback - the callback used to return the result.
1078     * @syscap SystemCapability.Communication.NetManager.Core
1079     * @crossplatform
1080     * @atomicservice
1081     * @since 11
1082     */
1083    on(type: 'netCapabilitiesChange', callback: Callback<NetCapabilityInfo>): void;
1084
1085    /**
1086     * Registers a listener for netConnectionPropertiesChange events.
1087     * @param { 'netConnectionPropertiesChange' } type - Indicates Event name.
1088     * @param { Callback<{ netHandle: NetHandle, connectionProperties: ConnectionProperties }> } callback - the callback used to return the result.
1089     * @syscap SystemCapability.Communication.NetManager.Core
1090     * @since 8
1091     */
1092    /**
1093     * Registers a listener for netConnectionPropertiesChange events.
1094     * @param { 'netConnectionPropertiesChange' } type - Indicates Event name.
1095     * @param { Callback<NetConnectionPropertyInfo> } callback - the callback used to return the result.
1096     * @syscap SystemCapability.Communication.NetManager.Core
1097     * @since 11
1098     */
1099    on(type: 'netConnectionPropertiesChange', callback: Callback<NetConnectionPropertyInfo>): void;
1100
1101    /**
1102     * Registers a listener for **netLost** events.
1103     * @param { 'netLost' } type - Indicates Event name.
1104     * @param { Callback<NetHandle> } callback - the callback used to return the result.
1105     * @syscap SystemCapability.Communication.NetManager.Core
1106     * @since 8
1107     */
1108    /**
1109     * Registers a listener for **netLost** events.
1110     * @param { 'netLost' } type - Indicates Event name.
1111     * @param { Callback<NetHandle> } callback - the callback used to return the result.
1112     * @syscap SystemCapability.Communication.NetManager.Core
1113     * @crossplatform
1114     * @since 10
1115     */
1116    /**
1117     * Registers a listener for **netLost** events.
1118     * @param { 'netLost' } type - Indicates Event name.
1119     * @param { Callback<NetHandle> } callback - the callback used to return the result.
1120     * @syscap SystemCapability.Communication.NetManager.Core
1121     * @crossplatform
1122     * @atomicservice
1123     * @since 11
1124     */
1125    on(type: 'netLost', callback: Callback<NetHandle>): void;
1126
1127    /**
1128     * Registers a listener for netUnavailable events.
1129     * @param { 'netUnavailable' } type - Indicates Event name.
1130     * @param { Callback<void> } callback - the callback used to return the result.
1131     * @syscap SystemCapability.Communication.NetManager.Core
1132     * @since 8
1133     */
1134    /**
1135     * Registers a listener for netUnavailable events.
1136     * @param { 'netUnavailable' } type - Indicates Event name.
1137     * @param { Callback<void> } callback - the callback used to return the result.
1138     * @syscap SystemCapability.Communication.NetManager.Core
1139     * @crossplatform
1140     * @since 10
1141     */
1142    /**
1143     * Registers a listener for netUnavailable events.
1144     * @param { 'netUnavailable' } type - Indicates Event name.
1145     * @param { Callback<void> } callback - the callback used to return the result.
1146     * @syscap SystemCapability.Communication.NetManager.Core
1147     * @crossplatform
1148     * @atomicservice
1149     * @since 11
1150     */
1151    on(type: 'netUnavailable', callback: Callback<void>): void;
1152
1153    /**
1154     * Receives status change notifications of a specified network.
1155     * @permission ohos.permission.GET_NETWORK_INFO
1156     * @param { AsyncCallback<void> } callback - the callback of register.
1157     * @throws { BusinessError } 201 - Permission denied.
1158     * @throws { BusinessError } 401 - Parameter error.
1159     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1160     * @throws { BusinessError } 2100003 - System internal error.
1161     * @throws { BusinessError } 2101008 - The callback already exists.
1162     * @throws { BusinessError } 2101022 - The number of requests exceeded the maximum allowed.
1163     * @syscap SystemCapability.Communication.NetManager.Core
1164     * @since 8
1165     */
1166    /**
1167     * Receives status change notifications of a specified network.
1168     * @permission ohos.permission.GET_NETWORK_INFO
1169     * @param { AsyncCallback<void> } callback - the callback of register.
1170     * @throws { BusinessError } 201 - Permission denied.
1171     * @throws { BusinessError } 401 - Parameter error.
1172     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1173     * @throws { BusinessError } 2100003 - System internal error.
1174     * @throws { BusinessError } 2101008 - The callback already exists.
1175     * @throws { BusinessError } 2101022 - The number of requests exceeded the maximum allowed.
1176     * @syscap SystemCapability.Communication.NetManager.Core
1177     * @crossplatform
1178     * @since 10
1179     */
1180    /**
1181     * Receives status change notifications of a specified network.
1182     * @permission ohos.permission.GET_NETWORK_INFO
1183     * @param { AsyncCallback<void> } callback - the callback of register.
1184     * @throws { BusinessError } 201 - Permission denied.
1185     * @throws { BusinessError } 401 - Parameter error.
1186     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1187     * @throws { BusinessError } 2100003 - System internal error.
1188     * @throws { BusinessError } 2101008 - The callback already exists.
1189     * @throws { BusinessError } 2101022 - The number of requests exceeded the maximum allowed.
1190     * @syscap SystemCapability.Communication.NetManager.Core
1191     * @crossplatform
1192     * @atomicservice
1193     * @since 11
1194     */
1195    register(callback: AsyncCallback<void>): void;
1196
1197    /**
1198     * Cancels listening for network status changes.
1199     * @param { AsyncCallback<void> } callback - the callback of unregister.
1200     * @throws { BusinessError } 201 - Permission denied.
1201     * @throws { BusinessError } 401 - Parameter error.
1202     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1203     * @throws { BusinessError } 2100003 - System internal error.
1204     * @throws { BusinessError } 2101007 - The callback does not exist.
1205     * @syscap SystemCapability.Communication.NetManager.Core
1206     * @since 8
1207     */
1208    /**
1209     * Cancels listening for network status changes.
1210     * @param { AsyncCallback<void> } callback - the callback of unregister.
1211     * @throws { BusinessError } 201 - Permission denied.
1212     * @throws { BusinessError } 401 - Parameter error.
1213     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1214     * @throws { BusinessError } 2100003 - System internal error.
1215     * @throws { BusinessError } 2101007 - The callback does not exist.
1216     * @syscap SystemCapability.Communication.NetManager.Core
1217     * @crossplatform
1218     * @since 10
1219     */
1220    /**
1221     * Cancels listening for network status changes.
1222     * @param { AsyncCallback<void> } callback - the callback of unregister.
1223     * @throws { BusinessError } 201 - Permission denied.
1224     * @throws { BusinessError } 401 - Parameter error.
1225     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1226     * @throws { BusinessError } 2100003 - System internal error.
1227     * @throws { BusinessError } 2101007 - The callback does not exist.
1228     * @syscap SystemCapability.Communication.NetManager.Core
1229     * @crossplatform
1230     * @atomicservice
1231     * @since 11
1232     */
1233    /**
1234     * Cancels listening for network status changes.
1235     * @param { AsyncCallback<void> } callback - the callback of unregister.
1236     * @throws { BusinessError } 401 - Parameter error.
1237     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1238     * @throws { BusinessError } 2100003 - System internal error.
1239     * @throws { BusinessError } 2101007 - The callback does not exist.
1240     * @syscap SystemCapability.Communication.NetManager.Core
1241     * @crossplatform
1242     * @atomicservice
1243     * @since 12
1244     */
1245    unregister(callback: AsyncCallback<void>): void;
1246  }
1247
1248  /**
1249   * Provides an instance that bear data network capabilities.
1250   * @interface NetSpecifier
1251   * @syscap SystemCapability.Communication.NetManager.Core
1252   * @since 8
1253   */
1254  /**
1255   * Provides an instance that bear data network capabilities.
1256   * @interface NetSpecifier
1257   * @syscap SystemCapability.Communication.NetManager.Core
1258   * @atomicservice
1259   * @since 11
1260   */
1261  export interface NetSpecifier {
1262    /**
1263     * The transmission capacity and support of the network's global proxy storage data network.
1264     * @type {NetCapabilities}
1265     * @syscap SystemCapability.Communication.NetManager.Core
1266     * @since 8
1267     */
1268    /**
1269     * The transmission capacity and support of the network's global proxy storage data network.
1270     * @type {NetCapabilities}
1271     * @syscap SystemCapability.Communication.NetManager.Core
1272     * @atomicservice
1273     * @since 11
1274     */
1275    netCapabilities: NetCapabilities;
1276
1277    /**
1278     * Network identifier, the identifier for Wi Fi networks is "wifi", and the identifier for cellular networks is "simId1" (corresponding to SIM card 1).
1279     * @type {?string}
1280     * @syscap SystemCapability.Communication.NetManager.Core
1281     * @since 8
1282     */
1283    /**
1284     * Network identifier, the identifier for Wi Fi networks is "wifi", and the identifier for cellular networks is "simId1" (corresponding to SIM card 1).
1285     * @type {?string}
1286     * @syscap SystemCapability.Communication.NetManager.Core
1287     * @atomicservice
1288     * @since 11
1289     */
1290    bearerPrivateIdentifier?: string;
1291  }
1292
1293  /**
1294   * Receive information about changes in network capabilities.
1295   * @interface NetCapabilityInfo
1296   * @syscap SystemCapability.Communication.NetManager.Core
1297   * @crossplatform
1298   * @since 10
1299   */
1300  /**
1301   * Receive information about changes in network capabilities.
1302   * @interface NetCapabilityInfo
1303   * @syscap SystemCapability.Communication.NetManager.Core
1304   * @crossplatform
1305   * @atomicservice
1306   * @since 11
1307   */
1308  export interface NetCapabilityInfo {
1309    /**
1310     * Defines the handle of the data network.
1311     * @type { NetHandle }
1312     * @syscap SystemCapability.Communication.NetManager.Core
1313     * @crossplatform
1314     * @since 10
1315     */
1316    /**
1317     * Defines the handle of the data network.
1318     * @type { NetHandle }
1319     * @syscap SystemCapability.Communication.NetManager.Core
1320     * @crossplatform
1321     * @atomicservice
1322     * @since 11
1323     */
1324    netHandle: NetHandle;
1325
1326    /**
1327     * Defines the network capability set.
1328     * @type { NetCapabilities }
1329     * @syscap SystemCapability.Communication.NetManager.Core
1330     * @crossplatform
1331     * @since 10
1332     */
1333    /**
1334     * Defines the network capability set.
1335     * @type { NetCapabilities }
1336     * @syscap SystemCapability.Communication.NetManager.Core
1337     * @crossplatform
1338     * @atomicservice
1339     * @since 11
1340     */
1341    netCap: NetCapabilities;
1342  }
1343
1344  /**
1345   * Defines the handle of the data network.
1346   * @interface NetHandle
1347   * @syscap SystemCapability.Communication.NetManager.Core
1348   * @since 8
1349   */
1350  /**
1351   * Defines the handle of the data network.
1352   * @interface NetHandle
1353   * @syscap SystemCapability.Communication.NetManager.Core
1354   * @crossplatform
1355   * @since 10
1356   */
1357  /**
1358   * Defines the handle of the data network.
1359   * @interface NetHandle
1360   * @syscap SystemCapability.Communication.NetManager.Core
1361   * @crossplatform
1362   * @atomicservice
1363   * @since 11
1364   */
1365  export interface NetHandle {
1366    /**
1367     * Network ID, a value of 0 means that there is no default network, and the other values must be greater than or equal to 100.
1368     * @type {number}
1369     * @syscap SystemCapability.Communication.NetManager.Core
1370     * @since 8
1371     */
1372    /**
1373     * Network ID, a value of 0 means that there is no default network, and the other values must be greater than or equal to 100.
1374     * @type {number}
1375     * @syscap SystemCapability.Communication.NetManager.Core
1376     * @crossplatform
1377     * @since 10
1378     */
1379    /**
1380     * Network ID, a value of 0 means that there is no default network, and the other values must be greater than or equal to 100.
1381     * @type {number}
1382     * @syscap SystemCapability.Communication.NetManager.Core
1383     * @crossplatform
1384     * @atomicservice
1385     * @since 11
1386     */
1387    netId: number;
1388
1389    /**
1390     * <p>Binds a TCPSocket or UDPSocket to the current network. All data flows from
1391     * the socket will use this network, without being subject to {@link setAppNet}.</p>
1392     * Before using this method, ensure that the socket is disconnected.
1393     * @param { TCPSocket | UDPSocket } socketParam - Indicates the TCPSocket or UDPSocket object.
1394     * @param { AsyncCallback<void> } callback - the callback of bindSocket.
1395     * @throws { BusinessError } 401 - Parameter error.
1396     * @throws { BusinessError } 2100001 - Invalid parameter value.
1397     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1398     * @throws { BusinessError } 2100003 - System internal error.
1399     * @syscap SystemCapability.Communication.NetManager.Core
1400     * @since 9
1401     */
1402    bindSocket(socketParam: TCPSocket | UDPSocket, callback: AsyncCallback<void>): void;
1403
1404    /**
1405     * <p>Binds a TCPSocket or UDPSocket to the current network. All data flows from
1406     * the socket will use this network, without being subject to {@link setAppNet}.</p>
1407     * Before using this method, ensure that the socket is disconnected.
1408     * @param { TCPSocket | UDPSocket } socketParam - Indicates the TCPSocket or UDPSocket object.
1409     * @returns { Promise<void> } the promise returned by the function.
1410     * @throws { BusinessError } 401 - Parameter error.
1411     * @throws { BusinessError } 2100001 - Invalid parameter value.
1412     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1413     * @throws { BusinessError } 2100003 - System internal error.
1414     * @syscap SystemCapability.Communication.NetManager.Core
1415     * @since 9
1416     */
1417    bindSocket(socketParam: TCPSocket | UDPSocket): Promise<void>;
1418
1419    /**
1420     * Resolves a host name to obtain all IP addresses based on the specified NetHandle.
1421     * @permission ohos.permission.INTERNET
1422     * @param { string } host - Indicates the host name or the domain.
1423     * @param { AsyncCallback<Array<NetAddress>> } callback - the callback of getAddressesByName.
1424     * @throws { BusinessError } 201 - Permission denied.
1425     * @throws { BusinessError } 401 - Parameter error.
1426     * @throws { BusinessError } 2100001 - Invalid parameter value.
1427     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1428     * @throws { BusinessError } 2100003 - System internal error.
1429     * @syscap SystemCapability.Communication.NetManager.Core
1430     * @since 8
1431     */
1432    /**
1433     * Resolves a host name to obtain all IP addresses based on the specified NetHandle.
1434     * @permission ohos.permission.INTERNET
1435     * @param { string } host - Indicates the host name or the domain.
1436     * @param { AsyncCallback<Array<NetAddress>> } callback - the callback of getAddressesByName.
1437     * @throws { BusinessError } 201 - Permission denied.
1438     * @throws { BusinessError } 401 - Parameter error.
1439     * @throws { BusinessError } 2100001 - Invalid parameter value.
1440     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1441     * @throws { BusinessError } 2100003 - System internal error.
1442     * @syscap SystemCapability.Communication.NetManager.Core
1443     * @atomicservice
1444     * @since 15
1445     */
1446    getAddressesByName(host: string, callback: AsyncCallback<Array<NetAddress>>): void;
1447
1448    /**
1449     * Resolves a host name to obtain all IP addresses based on the specified NetHandle.
1450     * @permission ohos.permission.INTERNET
1451     * @param { string } host - Indicates the host name or the domain.
1452     * @returns { Promise<Array<NetAddress>> } The promise returned by the function.
1453     * @throws { BusinessError } 201 - Permission denied.
1454     * @throws { BusinessError } 401 - Parameter error.
1455     * @throws { BusinessError } 2100001 - Invalid parameter value.
1456     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1457     * @throws { BusinessError } 2100003 - System internal error.
1458     * @syscap SystemCapability.Communication.NetManager.Core
1459     * @since 8
1460     */
1461    /**
1462     * Resolves a host name to obtain all IP addresses based on the specified NetHandle.
1463     * @permission ohos.permission.INTERNET
1464     * @param { string } host - Indicates the host name or the domain.
1465     * @returns { Promise<Array<NetAddress>> } The promise returned by the function.
1466     * @throws { BusinessError } 201 - Permission denied.
1467     * @throws { BusinessError } 401 - Parameter error.
1468     * @throws { BusinessError } 2100001 - Invalid parameter value.
1469     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1470     * @throws { BusinessError } 2100003 - System internal error.
1471     * @syscap SystemCapability.Communication.NetManager.Core
1472     * @atomicservice
1473     * @since 15
1474     */
1475    getAddressesByName(host: string): Promise<Array<NetAddress>>;
1476
1477    /**
1478     * Resolves a host name to obtain the first IP address based on the specified NetHandle.
1479     * @permission ohos.permission.INTERNET
1480     * @param { string } host - Indicates the host name or the domain.
1481     * @param { AsyncCallback<NetAddress> } callback - the callback of getAddressByName.
1482     * @throws { BusinessError } 201 - Permission denied.
1483     * @throws { BusinessError } 401 - Parameter error.
1484     * @throws { BusinessError } 2100001 - Invalid parameter value.
1485     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1486     * @throws { BusinessError } 2100003 - System internal error.
1487     * @syscap SystemCapability.Communication.NetManager.Core
1488     * @since 8
1489     */
1490    getAddressByName(host: string, callback: AsyncCallback<NetAddress>): void;
1491
1492    /**
1493     * Resolves a host name to obtain the first IP address based on the specified NetHandle.
1494     * @permission ohos.permission.INTERNET
1495     * @param { string } host - Indicates the host name or the domain.
1496     * @returns { Promise<NetAddress> } The promise returned by the function.
1497     * @throws { BusinessError } 201 - Permission denied.
1498     * @throws { BusinessError } 401 - Parameter error.
1499     * @throws { BusinessError } 2100001 - Invalid parameter value.
1500     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1501     * @throws { BusinessError } 2100003 - System internal error.
1502     * @syscap SystemCapability.Communication.NetManager.Core
1503     * @since 8
1504     */
1505    getAddressByName(host: string): Promise<NetAddress>;
1506  }
1507
1508  /**
1509   * Defines the network capability set.
1510   * @interface NetCapabilities
1511   * @syscap SystemCapability.Communication.NetManager.Core
1512   * @since 8
1513   */
1514  /**
1515   * Defines the network capability set.
1516   * @interface NetCapabilities
1517   * @syscap SystemCapability.Communication.NetManager.Core
1518   * @crossplatform
1519   * @since 10
1520   */
1521  /**
1522   * Defines the network capability set.
1523   * @interface NetCapabilities
1524   * @syscap SystemCapability.Communication.NetManager.Core
1525   * @crossplatform
1526   * @atomicservice
1527   * @since 11
1528   */
1529  export interface NetCapabilities {
1530    /**
1531     * Uplink (device-to-network) bandwidth.
1532     * @type {?number}
1533     * @syscap SystemCapability.Communication.NetManager.Core
1534     * @since 8
1535     */
1536    linkUpBandwidthKbps?: number;
1537
1538    /**
1539     * Downstream (network-to-device) bandwidth.
1540     * @type {?number}
1541     * @syscap SystemCapability.Communication.NetManager.Core
1542     * @since 8
1543     */
1544    linkDownBandwidthKbps?: number;
1545
1546    /**
1547     * Network-specific capabilities.
1548     * @type {?Array<NetCap>}
1549     * @syscap SystemCapability.Communication.NetManager.Core
1550     * @since 8
1551     */
1552    /**
1553     * Network-specific capabilities.
1554     * @type {?Array<NetCap>}
1555     * @syscap SystemCapability.Communication.NetManager.Core
1556     * @atomicservice
1557     * @since 11
1558     */
1559    networkCap?: Array<NetCap>;
1560
1561    /**
1562     * Network type.
1563     * @type {Array<NetBearType>}
1564     * @syscap SystemCapability.Communication.NetManager.Core
1565     * @since 8
1566     */
1567    /**
1568     * Network type.
1569     * @type {Array<NetBearType>}
1570     * @syscap SystemCapability.Communication.NetManager.Core
1571     * @crossplatform
1572     * @since 10
1573     */
1574    /**
1575     * Network type.
1576     * @type {Array<NetBearType>}
1577     * @syscap SystemCapability.Communication.NetManager.Core
1578     * @crossplatform
1579     * @atomicservice
1580     * @since 11
1581     */
1582    bearerTypes: Array<NetBearType>;
1583  }
1584
1585  /**
1586   * Get information about network connections.
1587   * @interface NetConnectionPropertyInfo
1588   * @syscap SystemCapability.Communication.NetManager.Core
1589   * @since 11
1590   */
1591  export interface NetConnectionPropertyInfo {
1592    /**
1593     * Defines the handle of the data network.
1594     * @type { NetHandle }
1595     * @syscap SystemCapability.Communication.NetManager.Core
1596     * @since 11
1597     */
1598    netHandle: NetHandle;
1599    /**
1600     * Defines the network connection properties.
1601     * @type { ConnectionProperties }
1602     * @syscap SystemCapability.Communication.NetManager.Core
1603     * @since 11
1604     */
1605    connectionProperties: ConnectionProperties;
1606  }
1607
1608  /**
1609   * Get network status information.
1610   * @interface NetBlockStatusInfo
1611   * @syscap SystemCapability.Communication.NetManager.Core
1612   * @since 11
1613   */
1614  export interface NetBlockStatusInfo {
1615    /**
1616     * Defines the handle of the data network.
1617     * @type { NetHandle }
1618     * @syscap SystemCapability.Communication.NetManager.Core
1619     * @since 11
1620     */
1621    netHandle: NetHandle;
1622    /**
1623     * Check whether the current state is blocked.
1624     * @type { boolean }
1625     * @syscap SystemCapability.Communication.NetManager.Core
1626     * @since 11
1627     */
1628    blocked: boolean;
1629  }
1630
1631  /**
1632   * Defines the network capability.
1633   * @enum {number}
1634   * @syscap SystemCapability.Communication.NetManager.Core
1635   * @since 8
1636   */
1637  /**
1638   * Defines the network capability.
1639   * @enum {number}
1640   * @syscap SystemCapability.Communication.NetManager.Core
1641   * @atomicservice
1642   * @since 11
1643   */
1644  export enum NetCap {
1645    /**
1646     * Indicates that the network can access the carrier's MMSC to send and receive multimedia messages.
1647     * @syscap SystemCapability.Communication.NetManager.Core
1648     * @since 8
1649     */
1650    /**
1651     * Indicates that the network can access the carrier's MMSC to send and receive multimedia messages.
1652     * @syscap SystemCapability.Communication.NetManager.Core
1653     * @atomicservice
1654     * @since 11
1655     */
1656    NET_CAPABILITY_MMS = 0,
1657
1658    /**
1659     * Indicates that the network traffic is not metered.
1660     * @syscap SystemCapability.Communication.NetManager.Core
1661     * @since 8
1662     */
1663    /**
1664     * Indicates that the network traffic is not metered.
1665     * @syscap SystemCapability.Communication.NetManager.Core
1666     * @atomicservice
1667     * @since 11
1668     */
1669    NET_CAPABILITY_NOT_METERED = 11,
1670
1671    /**
1672     * Indicates that the network can access the Internet.
1673     * @syscap SystemCapability.Communication.NetManager.Core
1674     * @since 8
1675     */
1676    /**
1677     * Indicates that the network can access the Internet.
1678     * @syscap SystemCapability.Communication.NetManager.Core
1679     * @atomicservice
1680     * @since 11
1681     */
1682    NET_CAPABILITY_INTERNET = 12,
1683
1684    /**
1685     * Indicates that the network does not use a VPN.
1686     * @syscap SystemCapability.Communication.NetManager.Core
1687     * @since 8
1688     */
1689    /**
1690     * Indicates that the network does not use a VPN.
1691     * @syscap SystemCapability.Communication.NetManager.Core
1692     * @atomicservice
1693     * @since 11
1694     */
1695    NET_CAPABILITY_NOT_VPN = 15,
1696
1697    /**
1698     * Indicates that the network is available.
1699     * @syscap SystemCapability.Communication.NetManager.Core
1700     * @since 8
1701     */
1702    /**
1703     * Indicates that the network is available.
1704     * @syscap SystemCapability.Communication.NetManager.Core
1705     * @atomicservice
1706     * @since 11
1707     */
1708    NET_CAPABILITY_VALIDATED = 16,
1709    /**
1710     * Indicates that the network is portal.
1711     * @syscap SystemCapability.Communication.NetManager.Core
1712     * @atomicservice
1713     * @since 12
1714     */
1715    NET_CAPABILITY_PORTAL = 17,
1716
1717    /**
1718     * Indicates that the network is checking connectivity.
1719     * @syscap SystemCapability.Communication.NetManager.Core
1720     * @atomicservice
1721     * @since 12
1722     */
1723    NET_CAPABILITY_CHECKING_CONNECTIVITY = 31
1724  }
1725
1726  /**
1727   * Enumerates network types.
1728   * @enum {number}
1729   * @syscap SystemCapability.Communication.NetManager.Core
1730   * @since 8
1731   */
1732  /**
1733   * Enumerates network types.
1734   * @enum {number}
1735   * @syscap SystemCapability.Communication.NetManager.Core
1736   * @crossplatform
1737   * @since 10
1738   */
1739  /**
1740   * Enumerates network types.
1741   * @enum {number}
1742   * @syscap SystemCapability.Communication.NetManager.Core
1743   * @crossplatform
1744   * @atomicservice
1745   * @since 11
1746   */
1747  export enum NetBearType {
1748    /**
1749     * Indicates that the network is based on a cellular network.
1750     * @syscap SystemCapability.Communication.NetManager.Core
1751     * @since 8
1752     */
1753    /**
1754     * Indicates that the network is based on a cellular network.
1755     * @syscap SystemCapability.Communication.NetManager.Core
1756     * @crossplatform
1757     * @since 10
1758     */
1759    /**
1760     * Indicates that the network is based on a cellular network.
1761     * @syscap SystemCapability.Communication.NetManager.Core
1762     * @crossplatform
1763     * @atomicservice
1764     * @since 11
1765     */
1766    BEARER_CELLULAR = 0,
1767
1768    /**
1769     * Indicates that the network is based on a Wi-Fi network.
1770     * @syscap SystemCapability.Communication.NetManager.Core
1771     * @since 8
1772     */
1773    /**
1774     * Indicates that the network is based on a Wi-Fi network.
1775     * @syscap SystemCapability.Communication.NetManager.Core
1776     * @crossplatform
1777     * @since 10
1778     */
1779    /**
1780     * Indicates that the network is based on a Wi-Fi network.
1781     * @syscap SystemCapability.Communication.NetManager.Core
1782     * @crossplatform
1783     * @atomicservice
1784     * @since 11
1785     */
1786    BEARER_WIFI = 1,
1787
1788    /**
1789     * Indicates that the network is based on a bluetooth network.
1790     * @syscap SystemCapability.Communication.NetManager.Core
1791     * @crossplatform
1792     * @since 12
1793     */
1794    BEARER_BLUETOOTH = 2,
1795
1796    /**
1797     * Indicates that the network is an Ethernet network.
1798     * @syscap SystemCapability.Communication.NetManager.Core
1799     * @since 8
1800     */
1801    /**
1802     * Indicates that the network is an Ethernet network.
1803     * @syscap SystemCapability.Communication.NetManager.Core
1804     * @atomicservice
1805     * @since 11
1806     */
1807    BEARER_ETHERNET = 3,
1808
1809    /**
1810     * Indicates that the network is based on a VPN network.
1811     * @syscap SystemCapability.Communication.NetManager.Core
1812     * @since 12
1813     */
1814    BEARER_VPN = 4,
1815  }
1816
1817  /**
1818   * Defines the network connection properties.
1819   * @interface ConnectionProperties
1820   * @syscap SystemCapability.Communication.NetManager.Core
1821   * @since 8
1822   */
1823  export interface ConnectionProperties {
1824    /**
1825     * Network card name.
1826     * @type {string}
1827     * @syscap SystemCapability.Communication.NetManager.Core
1828     * @since 8
1829     */
1830    interfaceName: string;
1831    /**
1832     * Domain. The default value is "".
1833     * @type {string}
1834     * @syscap SystemCapability.Communication.NetManager.Core
1835     * @since 8
1836     */
1837    domains: string;
1838    /**
1839     * Link information.
1840     * @type {Array<LinkAddress>}
1841     * @syscap SystemCapability.Communication.NetManager.Core
1842     * @since 8
1843     */
1844    linkAddresses: Array<LinkAddress>;
1845
1846    /**
1847     * Network address, refer to [NetAddress].
1848     * @type {Array<NetAddress>}
1849     * @syscap SystemCapability.Communication.NetManager.Core
1850     * @since 8
1851     */
1852    dnses: Array<NetAddress>;
1853
1854    /**
1855     * Routing information.
1856     * @type {Array<RouteInfo>}
1857     * @syscap SystemCapability.Communication.NetManager.Core
1858     * @since 8
1859     */
1860    routes: Array<RouteInfo>;
1861
1862    /**
1863     * Maximum transmission unit.
1864     * @type {number}
1865     * @syscap SystemCapability.Communication.NetManager.Core
1866     * @since 8
1867     */
1868    mtu: number;
1869  }
1870
1871  /**
1872   * Defines network route information.
1873   * @interface RouteInfo
1874   * @syscap SystemCapability.Communication.NetManager.Core
1875   * @since 8
1876   */
1877  export interface RouteInfo {
1878    /**
1879     * Network card name.
1880     * @type {string}
1881     * @syscap SystemCapability.Communication.NetManager.Core
1882     * @since 8
1883     */
1884    interface: string;
1885
1886    /**
1887     * Destination Address
1888     * @type {LinkAddress}
1889     * @syscap SystemCapability.Communication.NetManager.Core
1890     * @since 8
1891     */
1892    destination: LinkAddress;
1893
1894    /**
1895     * Gateway address.
1896     * @type {NetAddress}
1897     * @syscap SystemCapability.Communication.NetManager.Core
1898     * @since 8
1899     */
1900    gateway: NetAddress;
1901
1902    /**
1903     * Whether a gateway is present.
1904     * @type {boolean}
1905     * @syscap SystemCapability.Communication.NetManager.Core
1906     * @since 8
1907     */
1908    hasGateway: boolean;
1909
1910    /**
1911     * Whether the route is the default route.
1912     * @type {boolean}
1913     * @syscap SystemCapability.Communication.NetManager.Core
1914     * @since 8
1915     */
1916    isDefaultRoute: boolean;
1917  }
1918
1919  /**
1920   * Defines network link information.
1921   * @interface LinkAddress
1922   * @syscap SystemCapability.Communication.NetManager.Core
1923   * @since 8
1924   */
1925  export interface LinkAddress {
1926    /**
1927     * Link address.
1928     * @type {NetAddress}
1929     * @syscap SystemCapability.Communication.NetManager.Core
1930     * @since 8
1931     */
1932    address: NetAddress;
1933    /**
1934     * The length of the link address prefix.
1935     * @type {number}
1936     * @syscap SystemCapability.Communication.NetManager.Core
1937     * @since 8
1938     */
1939    prefixLength: number;
1940  }
1941
1942  /**
1943   * Defines a network address.
1944   * @interface NetAddress
1945   * @syscap SystemCapability.Communication.NetManager.Core
1946   * @since 8
1947   */
1948  /**
1949   * Defines a network address.
1950   * @interface NetAddress
1951   * @syscap SystemCapability.Communication.NetManager.Core
1952   * @atomicservice
1953   * @since 12
1954   */
1955  export interface NetAddress {
1956    /**
1957     * Network address.
1958     * @type {string}
1959     * @syscap SystemCapability.Communication.NetManager.Core
1960     * @since 8
1961     */
1962    /**
1963     * Network address.
1964     * @type {string}
1965     * @syscap SystemCapability.Communication.NetManager.Core
1966     * @atomicservice
1967     * @since 12
1968     */
1969    address: string;
1970
1971    /**
1972     * Address family identifier. The value is 1 for IPv4 and 2 for IPv6. The default value is 1.
1973     * @type {?number}
1974     * @syscap SystemCapability.Communication.NetManager.Core
1975     * @since 8
1976     */
1977    /**
1978     * Address family identifier. The value is 1 for IPv4 and 2 for IPv6. The default value is 1.
1979     * @type {?number}
1980     * @syscap SystemCapability.Communication.NetManager.Core
1981     * @atomicservice
1982     * @since 12
1983     */
1984    family?: number;
1985
1986    /**
1987     * Port number. The value ranges from 0 to 65535.
1988     * @type {?number}
1989     * @syscap SystemCapability.Communication.NetManager.Core
1990     * @since 8
1991     */
1992    /**
1993     * Port number. The value ranges from 0 to 65535.
1994     * @type {?number}
1995     * @syscap SystemCapability.Communication.NetManager.Core
1996     * @atomicservice
1997     * @since 12
1998     */
1999    port?: number;
2000  }
2001
2002  /**
2003   * Network Global Proxy Configuration Information.
2004   * @interface HttpProxy
2005   * @syscap SystemCapability.Communication.NetManager.Core
2006   * @since 10
2007   */
2008  /**
2009   * Network Global Proxy Configuration Information.
2010   * @interface HttpProxy
2011   * @syscap SystemCapability.Communication.NetManager.Core
2012   * @atomicservice
2013   * @since 11
2014   */
2015  export interface HttpProxy {
2016    /**
2017     * Proxy server host name.
2018     * @type {string}
2019     * @syscap SystemCapability.Communication.NetManager.Core
2020     * @since 10
2021     */
2022    /**
2023     * Proxy server host name.
2024     * @type {string}
2025     * @syscap SystemCapability.Communication.NetManager.Core
2026     * @atomicservice
2027     * @since 11
2028     */
2029    host: string;
2030
2031    /**
2032     * Host port.
2033     * @type {number}
2034     * @syscap SystemCapability.Communication.NetManager.Core
2035     * @since 10
2036     */
2037    /**
2038     * Host port.
2039     * @type {number}
2040     * @syscap SystemCapability.Communication.NetManager.Core
2041     * @atomicservice
2042     * @since 11
2043     */
2044    port: number;
2045
2046    /**
2047     * Http proxy username.
2048     * @type {?string}
2049     * @syscap SystemCapability.Communication.NetManager.Core
2050     * @since 12
2051     */
2052    username?: string;
2053
2054    /**
2055     * Http proxy password.
2056     * @type {?string}
2057     * @syscap SystemCapability.Communication.NetManager.Core
2058     * @since 12
2059     */
2060    password?: string;
2061
2062    /**
2063     * Do not use a blocking list for proxy servers.
2064     * @type {Array<string>}
2065     * @syscap SystemCapability.Communication.NetManager.Core
2066     * @since 10
2067     */
2068    /**
2069     * Do not use a blocking list for proxy servers.
2070     * @type {Array<string>}
2071     * @syscap SystemCapability.Communication.NetManager.Core
2072     * @atomicservice
2073     * @since 11
2074     */
2075    exclusionList: Array<string>;
2076  }
2077}
2078
2079export default connection;
2080