• 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   * Add a custom {@link host} and corresponding {@link ip} mapping for current application.
810   * @permission ohos.permission.INTERNET
811   * @param { string } host - Indicates the host name or the domain.
812   * @param { Array<string> } ip - List of IP addresses mapped to the host name.
813   * @param { AsyncCallback<void> } callback - Returns the callback of addCustomDnsRule.
814   * @throws { BusinessError } 201 - Permission denied.
815   * @throws { BusinessError } 401 - Parameter error.
816   * @throws { BusinessError } 2100001 - Invalid parameter value.
817   * @throws { BusinessError } 2100002 - Failed to connect to the service.
818   * @throws { BusinessError } 2100003 - System internal error.
819   * @syscap SystemCapability.Communication.NetManager.Core
820   * @since 11
821   */
822  function addCustomDnsRule(host: string, ip: Array<string>, callback: AsyncCallback<void>): void;
823
824  /**
825   * Add a custom {@link host} and corresponding {@link ip} mapping for current application.
826   * @permission ohos.permission.INTERNET
827   * @param { string } host - Indicates the host name or the domain.
828   * @param { Array<string> } ip - List of IP addresses mapped to the host name.
829   * @returns { Promise<void> } the promise returned by the function.
830   * @throws { BusinessError } 201 - Permission denied.
831   * @throws { BusinessError } 401 - Parameter error.
832   * @throws { BusinessError } 2100001 - Invalid parameter value.
833   * @throws { BusinessError } 2100002 - Failed to connect to the service.
834   * @throws { BusinessError } 2100003 - System internal error.
835   * @syscap SystemCapability.Communication.NetManager.Core
836   * @since 11
837   */
838  function addCustomDnsRule(host: string, ip: Array<string>): Promise<void>;
839
840  /**
841   * Remove the custom DNS rule of the {@link host} for current application.
842   * @permission ohos.permission.INTERNET
843   * @param { string } host - Indicates the host name or the domain.
844   * @param { AsyncCallback<void> } callback - Returns the callback of removeCustomDnsRule.
845   * @throws { BusinessError } 201 - Permission denied.
846   * @throws { BusinessError } 401 - Parameter error.
847   * @throws { BusinessError } 2100001 - Invalid parameter value.
848   * @throws { BusinessError } 2100002 - Failed to connect to the service.
849   * @throws { BusinessError } 2100003 - System internal error.
850   * @syscap SystemCapability.Communication.NetManager.Core
851   * @since 11
852   */
853  function removeCustomDnsRule(host: string, callback: AsyncCallback<void>): void;
854
855  /**
856   * Remove the custom DNS rule of the {@link host} for current application.
857   * @permission ohos.permission.INTERNET
858   * @param { string } host - Indicates the host name or the domain.
859   * @returns { Promise<void> } the promise returned by the function.
860   * @throws { BusinessError } 201 - Permission denied.
861   * @throws { BusinessError } 401 - Parameter error.
862   * @throws { BusinessError } 2100001 - Invalid parameter value.
863   * @throws { BusinessError } 2100002 - Failed to connect to the service.
864   * @throws { BusinessError } 2100003 - System internal error.
865   * @syscap SystemCapability.Communication.NetManager.Core
866   * @since 11
867   */
868  function removeCustomDnsRule(host: string): Promise<void>;
869
870  /**
871   * Clear all custom DNS rules for current application.
872   * @permission ohos.permission.INTERNET
873   * @param { AsyncCallback<void> } callback - Returns the callback of clearCustomDnsRules.
874   * @throws { BusinessError } 201 - Permission denied.
875   * @throws { BusinessError } 401 - Parameter error.
876   * @throws { BusinessError } 2100001 - Invalid parameter value.
877   * @throws { BusinessError } 2100002 - Failed to connect to the service.
878   * @throws { BusinessError } 2100003 - System internal error.
879   * @syscap SystemCapability.Communication.NetManager.Core
880   * @since 11
881   */
882  function clearCustomDnsRules(callback: AsyncCallback<void>): void;
883
884  /**
885   * Clear all custom DNS rules for current application.
886   * @permission ohos.permission.INTERNET
887   * @returns { Promise<void> } the promise returned by the function.
888   * @throws { BusinessError } 201 - Permission denied.
889   * @throws { BusinessError } 2100001 - Invalid parameter value.
890   * @throws { BusinessError } 2100002 - Failed to connect to the service.
891   * @throws { BusinessError } 2100003 - System internal error.
892   * @syscap SystemCapability.Communication.NetManager.Core
893   * @since 11
894   */
895  function clearCustomDnsRules(): Promise<void>;
896
897  /**
898   * factory reset network settings
899   *
900   * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
901   * @permission ohos.permission.CONNECTIVITY_INTERNAL
902   * @returns { Promise<void> } the promise returned by the function.
903   * @throws { BusinessError } 201 - Permission denied.
904   * @throws { BusinessError } 202 - Non-system applications use system APIs.
905   * @throws { BusinessError } 2100002 - Failed to connect to the service.
906   * @throws { BusinessError } 2100003 - System internal error.
907   * @syscap SystemCapability.Communication.NetManager.Core
908   * @systemapi Hide this for inner system use. Only used for system app.
909   * @since 11
910   */
911  function factoryReset(): Promise<void>;
912
913  /**
914   * Represents the network connection handle.
915   * @interface NetConnection
916   * @syscap SystemCapability.Communication.NetManager.Core
917   * @since 8
918   */
919  /**
920   * Represents the network connection handle.
921   * @interface NetConnection
922   * @syscap SystemCapability.Communication.NetManager.Core
923   * @crossplatform
924   * @since 10
925   */
926  /**
927   * Represents the network connection handle.
928   * @interface NetConnection
929   * @syscap SystemCapability.Communication.NetManager.Core
930   * @crossplatform
931   * @atomicservice
932   * @since 11
933   */
934  export interface NetConnection {
935    /**
936     * Registers a listener for netAvailable events.
937     * @param { 'netAvailable' } type - Indicates Event name.
938     * @param { Callback<NetHandle> } callback - the callback used to return the result.
939     * @syscap SystemCapability.Communication.NetManager.Core
940     * @since 8
941     */
942    /**
943     * Registers a listener for netAvailable events.
944     * @param { 'netAvailable' } type - Indicates Event name.
945     * @param { Callback<NetHandle> } callback - the callback used to return the result.
946     * @syscap SystemCapability.Communication.NetManager.Core
947     * @crossplatform
948     * @since 10
949     */
950    /**
951     * Registers a listener for netAvailable events.
952     * @param { 'netAvailable' } type - Indicates Event name.
953     * @param { Callback<NetHandle> } callback - the callback used to return the result.
954     * @syscap SystemCapability.Communication.NetManager.Core
955     * @crossplatform
956     * @atomicservice
957     * @since 11
958     */
959    on(type: 'netAvailable', callback: Callback<NetHandle>): void;
960
961    /**
962     * Registers a listener for netBlockStatusChange events.
963     * @param { 'netBlockStatusChange' } type - Indicates Event name.
964     * @param { Callback<{ netHandle: NetHandle, blocked: boolean }> } callback - the callback used to return the result.
965     * @syscap SystemCapability.Communication.NetManager.Core
966     * @since 8
967     */
968    /**
969     * Registers a listener for netBlockStatusChange events.
970     * @param { 'netBlockStatusChange' } type - Indicates Event name.
971     * @param { Callback<NetBlockStatusInfo> } callback - the callback used to return the result.
972     * @syscap SystemCapability.Communication.NetManager.Core
973     * @since 11
974     */
975    on(type: 'netBlockStatusChange', callback: Callback<NetBlockStatusInfo>): void;
976
977    /**
978     * Registers a listener for **netCapabilitiesChange** events.
979     * @param { 'netCapabilitiesChange' } type - Indicates Event name.
980     * @param { Callback<NetCapabilityInfo> } callback - the callback used to return the result.
981     * @syscap SystemCapability.Communication.NetManager.Core
982     * @since 8
983     */
984    /**
985     * Registers a listener for **netCapabilitiesChange** events.
986     * @param { 'netCapabilitiesChange' } type - Indicates Event name.
987     * @param { Callback<NetCapabilityInfo> } callback - the callback used to return the result.
988     * @syscap SystemCapability.Communication.NetManager.Core
989     * @crossplatform
990     * @since 10
991     */
992    /**
993     * Registers a listener for **netCapabilitiesChange** events.
994     * @param { 'netCapabilitiesChange' } type - Indicates Event name.
995     * @param { Callback<NetCapabilityInfo> } callback - the callback used to return the result.
996     * @syscap SystemCapability.Communication.NetManager.Core
997     * @crossplatform
998     * @atomicservice
999     * @since 11
1000     */
1001    on(type: 'netCapabilitiesChange', callback: Callback<NetCapabilityInfo>): void;
1002
1003    /**
1004     * Registers a listener for netConnectionPropertiesChange events.
1005     * @param { 'netConnectionPropertiesChange' } type - Indicates Event name.
1006     * @param { Callback<{ netHandle: NetHandle, connectionProperties: ConnectionProperties }> } callback - the callback used to return the result.
1007     * @syscap SystemCapability.Communication.NetManager.Core
1008     * @since 8
1009     */
1010    /**
1011     * Registers a listener for netConnectionPropertiesChange events.
1012     * @param { 'netConnectionPropertiesChange' } type - Indicates Event name.
1013     * @param { Callback<NetConnectionPropertyInfo> } callback - the callback used to return the result.
1014     * @syscap SystemCapability.Communication.NetManager.Core
1015     * @since 11
1016     */
1017    on(type: 'netConnectionPropertiesChange', callback: Callback<NetConnectionPropertyInfo>): void;
1018
1019    /**
1020     * Registers a listener for **netLost** events.
1021     * @param { 'netLost' } type - Indicates Event name.
1022     * @param { Callback<NetHandle> } callback - the callback used to return the result.
1023     * @syscap SystemCapability.Communication.NetManager.Core
1024     * @since 8
1025     */
1026    /**
1027     * Registers a listener for **netLost** events.
1028     * @param { 'netLost' } type - Indicates Event name.
1029     * @param { Callback<NetHandle> } callback - the callback used to return the result.
1030     * @syscap SystemCapability.Communication.NetManager.Core
1031     * @crossplatform
1032     * @since 10
1033     */
1034    /**
1035     * Registers a listener for **netLost** events.
1036     * @param { 'netLost' } type - Indicates Event name.
1037     * @param { Callback<NetHandle> } callback - the callback used to return the result.
1038     * @syscap SystemCapability.Communication.NetManager.Core
1039     * @crossplatform
1040     * @atomicservice
1041     * @since 11
1042     */
1043    on(type: 'netLost', callback: Callback<NetHandle>): void;
1044
1045    /**
1046     * Registers a listener for netUnavailable events.
1047     * @param { 'netUnavailable' } type - Indicates Event name.
1048     * @param { Callback<void> } callback - the callback used to return the result.
1049     * @syscap SystemCapability.Communication.NetManager.Core
1050     * @since 8
1051     */
1052    /**
1053     * Registers a listener for netUnavailable events.
1054     * @param { 'netUnavailable' } type - Indicates Event name.
1055     * @param { Callback<void> } callback - the callback used to return the result.
1056     * @syscap SystemCapability.Communication.NetManager.Core
1057     * @crossplatform
1058     * @since 10
1059     */
1060    /**
1061     * Registers a listener for netUnavailable events.
1062     * @param { 'netUnavailable' } type - Indicates Event name.
1063     * @param { Callback<void> } callback - the callback used to return the result.
1064     * @syscap SystemCapability.Communication.NetManager.Core
1065     * @crossplatform
1066     * @atomicservice
1067     * @since 11
1068     */
1069    on(type: 'netUnavailable', callback: Callback<void>): void;
1070
1071    /**
1072     * Receives status change notifications of a specified network.
1073     * @permission ohos.permission.GET_NETWORK_INFO
1074     * @param { AsyncCallback<void> } callback - the callback of register.
1075     * @throws { BusinessError } 201 - Permission denied.
1076     * @throws { BusinessError } 401 - Parameter error.
1077     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1078     * @throws { BusinessError } 2100003 - System internal error.
1079     * @throws { BusinessError } 2101008 - The callback already exists.
1080     * @throws { BusinessError } 2101022 - The number of requests exceeded the maximum allowed.
1081     * @syscap SystemCapability.Communication.NetManager.Core
1082     * @since 8
1083     */
1084    /**
1085     * Receives status change notifications of a specified network.
1086     * @permission ohos.permission.GET_NETWORK_INFO
1087     * @param { AsyncCallback<void> } callback - the callback of register.
1088     * @throws { BusinessError } 201 - Permission denied.
1089     * @throws { BusinessError } 401 - Parameter error.
1090     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1091     * @throws { BusinessError } 2100003 - System internal error.
1092     * @throws { BusinessError } 2101008 - The callback already exists.
1093     * @throws { BusinessError } 2101022 - The number of requests exceeded the maximum allowed.
1094     * @syscap SystemCapability.Communication.NetManager.Core
1095     * @crossplatform
1096     * @since 10
1097     */
1098    /**
1099     * Receives status change notifications of a specified network.
1100     * @permission ohos.permission.GET_NETWORK_INFO
1101     * @param { AsyncCallback<void> } callback - the callback of register.
1102     * @throws { BusinessError } 201 - Permission denied.
1103     * @throws { BusinessError } 401 - Parameter error.
1104     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1105     * @throws { BusinessError } 2100003 - System internal error.
1106     * @throws { BusinessError } 2101008 - The callback already exists.
1107     * @throws { BusinessError } 2101022 - The number of requests exceeded the maximum allowed.
1108     * @syscap SystemCapability.Communication.NetManager.Core
1109     * @crossplatform
1110     * @atomicservice
1111     * @since 11
1112     */
1113    register(callback: AsyncCallback<void>): void;
1114
1115    /**
1116     * Cancels listening for network status changes.
1117     * @param { AsyncCallback<void> } callback - the callback of unregister.
1118     * @throws { BusinessError } 201 - Permission denied.
1119     * @throws { BusinessError } 401 - Parameter error.
1120     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1121     * @throws { BusinessError } 2100003 - System internal error.
1122     * @throws { BusinessError } 2101007 - The callback does not exist.
1123     * @syscap SystemCapability.Communication.NetManager.Core
1124     * @since 8
1125     */
1126    /**
1127     * Cancels listening for network status changes.
1128     * @param { AsyncCallback<void> } callback - the callback of unregister.
1129     * @throws { BusinessError } 201 - Permission denied.
1130     * @throws { BusinessError } 401 - Parameter error.
1131     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1132     * @throws { BusinessError } 2100003 - System internal error.
1133     * @throws { BusinessError } 2101007 - The callback does not exist.
1134     * @syscap SystemCapability.Communication.NetManager.Core
1135     * @crossplatform
1136     * @since 10
1137     */
1138    /**
1139     * Cancels listening for network status changes.
1140     * @param { AsyncCallback<void> } callback - the callback of unregister.
1141     * @throws { BusinessError } 201 - Permission denied.
1142     * @throws { BusinessError } 401 - Parameter error.
1143     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1144     * @throws { BusinessError } 2100003 - System internal error.
1145     * @throws { BusinessError } 2101007 - The callback does not exist.
1146     * @syscap SystemCapability.Communication.NetManager.Core
1147     * @crossplatform
1148     * @atomicservice
1149     * @since 11
1150     */
1151    /**
1152     * Cancels listening for network status changes.
1153     * @param { AsyncCallback<void> } callback - the callback of unregister.
1154     * @throws { BusinessError } 401 - Parameter error.
1155     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1156     * @throws { BusinessError } 2100003 - System internal error.
1157     * @throws { BusinessError } 2101007 - The callback does not exist.
1158     * @syscap SystemCapability.Communication.NetManager.Core
1159     * @crossplatform
1160     * @atomicservice
1161     * @since 12
1162     */
1163    unregister(callback: AsyncCallback<void>): void;
1164  }
1165
1166  /**
1167   * Provides an instance that bear data network capabilities.
1168   * @interface NetSpecifier
1169   * @syscap SystemCapability.Communication.NetManager.Core
1170   * @since 8
1171   */
1172  /**
1173   * Provides an instance that bear data network capabilities.
1174   * @interface NetSpecifier
1175   * @syscap SystemCapability.Communication.NetManager.Core
1176   * @atomicservice
1177   * @since 11
1178   */
1179  export interface NetSpecifier {
1180    /**
1181     * The transmission capacity and support of the network's global proxy storage data network.
1182     * @type {NetCapabilities}
1183     * @syscap SystemCapability.Communication.NetManager.Core
1184     * @since 8
1185     */
1186    /**
1187     * The transmission capacity and support of the network's global proxy storage data network.
1188     * @type {NetCapabilities}
1189     * @syscap SystemCapability.Communication.NetManager.Core
1190     * @atomicservice
1191     * @since 11
1192     */
1193    netCapabilities: NetCapabilities;
1194
1195    /**
1196     * Network identifier, the identifier for Wi Fi networks is "wifi", and the identifier for cellular networks is "simId1" (corresponding to SIM card 1).
1197     * @type {?string}
1198     * @syscap SystemCapability.Communication.NetManager.Core
1199     * @since 8
1200     */
1201    /**
1202     * Network identifier, the identifier for Wi Fi networks is "wifi", and the identifier for cellular networks is "simId1" (corresponding to SIM card 1).
1203     * @type {?string}
1204     * @syscap SystemCapability.Communication.NetManager.Core
1205     * @atomicservice
1206     * @since 11
1207     */
1208    bearerPrivateIdentifier?: string;
1209  }
1210
1211  /**
1212   * Receive information about changes in network capabilities.
1213   * @interface NetCapabilityInfo
1214   * @syscap SystemCapability.Communication.NetManager.Core
1215   * @crossplatform
1216   * @since 10
1217   */
1218  /**
1219   * Receive information about changes in network capabilities.
1220   * @interface NetCapabilityInfo
1221   * @syscap SystemCapability.Communication.NetManager.Core
1222   * @crossplatform
1223   * @atomicservice
1224   * @since 11
1225   */
1226  export interface NetCapabilityInfo {
1227    /**
1228     * Defines the handle of the data network.
1229     * @type { NetHandle }
1230     * @syscap SystemCapability.Communication.NetManager.Core
1231     * @crossplatform
1232     * @since 10
1233     */
1234    /**
1235     * Defines the handle of the data network.
1236     * @type { NetHandle }
1237     * @syscap SystemCapability.Communication.NetManager.Core
1238     * @crossplatform
1239     * @atomicservice
1240     * @since 11
1241     */
1242    netHandle: NetHandle;
1243
1244    /**
1245     * Defines the network capability set.
1246     * @type { NetCapabilities }
1247     * @syscap SystemCapability.Communication.NetManager.Core
1248     * @crossplatform
1249     * @since 10
1250     */
1251    /**
1252     * Defines the network capability set.
1253     * @type { NetCapabilities }
1254     * @syscap SystemCapability.Communication.NetManager.Core
1255     * @crossplatform
1256     * @atomicservice
1257     * @since 11
1258     */
1259    netCap: NetCapabilities;
1260  }
1261
1262  /**
1263   * Defines the handle of the data network.
1264   * @interface NetHandle
1265   * @syscap SystemCapability.Communication.NetManager.Core
1266   * @since 8
1267   */
1268  /**
1269   * Defines the handle of the data network.
1270   * @interface NetHandle
1271   * @syscap SystemCapability.Communication.NetManager.Core
1272   * @crossplatform
1273   * @since 10
1274   */
1275  /**
1276   * Defines the handle of the data network.
1277   * @interface NetHandle
1278   * @syscap SystemCapability.Communication.NetManager.Core
1279   * @crossplatform
1280   * @atomicservice
1281   * @since 11
1282   */
1283  export interface NetHandle {
1284    /**
1285     * 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.
1286     * @type {number}
1287     * @syscap SystemCapability.Communication.NetManager.Core
1288     * @since 8
1289     */
1290    /**
1291     * 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.
1292     * @type {number}
1293     * @syscap SystemCapability.Communication.NetManager.Core
1294     * @crossplatform
1295     * @since 10
1296     */
1297    /**
1298     * 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.
1299     * @type {number}
1300     * @syscap SystemCapability.Communication.NetManager.Core
1301     * @crossplatform
1302     * @atomicservice
1303     * @since 11
1304     */
1305    netId: number;
1306
1307    /**
1308     * <p>Binds a TCPSocket or UDPSocket to the current network. All data flows from
1309     * the socket will use this network, without being subject to {@link setAppNet}.</p>
1310     * Before using this method, ensure that the socket is disconnected.
1311     * @param { TCPSocket | UDPSocket } socketParam - Indicates the TCPSocket or UDPSocket object.
1312     * @param { AsyncCallback<void> } callback - the callback of bindSocket.
1313     * @throws { BusinessError } 401 - Parameter error.
1314     * @throws { BusinessError } 2100001 - Invalid parameter value.
1315     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1316     * @throws { BusinessError } 2100003 - System internal error.
1317     * @syscap SystemCapability.Communication.NetManager.Core
1318     * @since 9
1319     */
1320    bindSocket(socketParam: TCPSocket | UDPSocket, callback: AsyncCallback<void>): void;
1321
1322    /**
1323     * <p>Binds a TCPSocket or UDPSocket to the current network. All data flows from
1324     * the socket will use this network, without being subject to {@link setAppNet}.</p>
1325     * Before using this method, ensure that the socket is disconnected.
1326     * @param { TCPSocket | UDPSocket } socketParam - Indicates the TCPSocket or UDPSocket object.
1327     * @returns { Promise<void> } the promise returned by the function.
1328     * @throws { BusinessError } 401 - Parameter error.
1329     * @throws { BusinessError } 2100001 - Invalid parameter value.
1330     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1331     * @throws { BusinessError } 2100003 - System internal error.
1332     * @syscap SystemCapability.Communication.NetManager.Core
1333     * @since 9
1334     */
1335    bindSocket(socketParam: TCPSocket | UDPSocket): Promise<void>;
1336
1337    /**
1338     * Resolves a host name to obtain all IP addresses based on the specified NetHandle.
1339     * @permission ohos.permission.INTERNET
1340     * @param { string } host - Indicates the host name or the domain.
1341     * @param { AsyncCallback<Array<NetAddress>> } callback - the callback of getAddressesByName.
1342     * @throws { BusinessError } 201 - Permission denied.
1343     * @throws { BusinessError } 401 - Parameter error.
1344     * @throws { BusinessError } 2100001 - Invalid parameter value.
1345     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1346     * @throws { BusinessError } 2100003 - System internal error.
1347     * @syscap SystemCapability.Communication.NetManager.Core
1348     * @since 8
1349     */
1350    getAddressesByName(host: string, callback: AsyncCallback<Array<NetAddress>>): void;
1351
1352    /**
1353     * Resolves a host name to obtain all IP addresses based on the specified NetHandle.
1354     * @permission ohos.permission.INTERNET
1355     * @param { string } host - Indicates the host name or the domain.
1356     * @returns { Promise<Array<NetAddress>> } The promise returned by the function.
1357     * @throws { BusinessError } 201 - Permission denied.
1358     * @throws { BusinessError } 401 - Parameter error.
1359     * @throws { BusinessError } 2100001 - Invalid parameter value.
1360     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1361     * @throws { BusinessError } 2100003 - System internal error.
1362     * @syscap SystemCapability.Communication.NetManager.Core
1363     * @since 8
1364     */
1365    getAddressesByName(host: string): Promise<Array<NetAddress>>;
1366
1367    /**
1368     * Resolves a host name to obtain the first IP address based on the specified NetHandle.
1369     * @permission ohos.permission.INTERNET
1370     * @param { string } host - Indicates the host name or the domain.
1371     * @param { AsyncCallback<NetAddress> } callback - the callback of getAddressByName.
1372     * @throws { BusinessError } 201 - Permission denied.
1373     * @throws { BusinessError } 401 - Parameter error.
1374     * @throws { BusinessError } 2100001 - Invalid parameter value.
1375     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1376     * @throws { BusinessError } 2100003 - System internal error.
1377     * @syscap SystemCapability.Communication.NetManager.Core
1378     * @since 8
1379     */
1380    getAddressByName(host: string, callback: AsyncCallback<NetAddress>): void;
1381
1382    /**
1383     * Resolves a host name to obtain the first IP address based on the specified NetHandle.
1384     * @permission ohos.permission.INTERNET
1385     * @param { string } host - Indicates the host name or the domain.
1386     * @returns { Promise<NetAddress> } The promise returned by the function.
1387     * @throws { BusinessError } 201 - Permission denied.
1388     * @throws { BusinessError } 401 - Parameter error.
1389     * @throws { BusinessError } 2100001 - Invalid parameter value.
1390     * @throws { BusinessError } 2100002 - Failed to connect to the service.
1391     * @throws { BusinessError } 2100003 - System internal error.
1392     * @syscap SystemCapability.Communication.NetManager.Core
1393     * @since 8
1394     */
1395    getAddressByName(host: string): Promise<NetAddress>;
1396  }
1397
1398  /**
1399   * Defines the network capability set.
1400   * @interface NetCapabilities
1401   * @syscap SystemCapability.Communication.NetManager.Core
1402   * @since 8
1403   */
1404  /**
1405   * Defines the network capability set.
1406   * @interface NetCapabilities
1407   * @syscap SystemCapability.Communication.NetManager.Core
1408   * @crossplatform
1409   * @since 10
1410   */
1411  /**
1412   * Defines the network capability set.
1413   * @interface NetCapabilities
1414   * @syscap SystemCapability.Communication.NetManager.Core
1415   * @crossplatform
1416   * @atomicservice
1417   * @since 11
1418   */
1419  export interface NetCapabilities {
1420    /**
1421     * Uplink (device-to-network) bandwidth.
1422     * @type {?number}
1423     * @syscap SystemCapability.Communication.NetManager.Core
1424     * @since 8
1425     */
1426    linkUpBandwidthKbps?: number;
1427
1428    /**
1429     * Downstream (network-to-device) bandwidth.
1430     * @type {?number}
1431     * @syscap SystemCapability.Communication.NetManager.Core
1432     * @since 8
1433     */
1434    linkDownBandwidthKbps?: number;
1435
1436    /**
1437     * Network-specific capabilities.
1438     * @type {?Array<NetCap>}
1439     * @syscap SystemCapability.Communication.NetManager.Core
1440     * @since 8
1441     */
1442    /**
1443     * Network-specific capabilities.
1444     * @type {?Array<NetCap>}
1445     * @syscap SystemCapability.Communication.NetManager.Core
1446     * @atomicservice
1447     * @since 11
1448     */
1449    networkCap?: Array<NetCap>;
1450
1451    /**
1452     * Network type.
1453     * @type {Array<NetBearType>}
1454     * @syscap SystemCapability.Communication.NetManager.Core
1455     * @since 8
1456     */
1457    /**
1458     * Network type.
1459     * @type {Array<NetBearType>}
1460     * @syscap SystemCapability.Communication.NetManager.Core
1461     * @crossplatform
1462     * @since 10
1463     */
1464    /**
1465     * Network type.
1466     * @type {Array<NetBearType>}
1467     * @syscap SystemCapability.Communication.NetManager.Core
1468     * @crossplatform
1469     * @atomicservice
1470     * @since 11
1471     */
1472    bearerTypes: Array<NetBearType>;
1473  }
1474
1475  /**
1476   * Get information about network connections.
1477   * @interface NetConnectionPropertyInfo
1478   * @syscap SystemCapability.Communication.NetManager.Core
1479   * @since 11
1480   */
1481  export interface NetConnectionPropertyInfo {
1482    /**
1483     * Defines the handle of the data network.
1484     * @type { NetHandle }
1485     * @syscap SystemCapability.Communication.NetManager.Core
1486     * @since 11
1487     */
1488    netHandle: NetHandle;
1489    /**
1490     * Defines the network connection properties.
1491     * @type { ConnectionProperties }
1492     * @syscap SystemCapability.Communication.NetManager.Core
1493     * @since 11
1494     */
1495    connectionProperties: ConnectionProperties;
1496  }
1497
1498  /**
1499   * Get network status information.
1500   * @interface NetBlockStatusInfo
1501   * @syscap SystemCapability.Communication.NetManager.Core
1502   * @since 11
1503   */
1504  export interface NetBlockStatusInfo {
1505    /**
1506     * Defines the handle of the data network.
1507     * @type { NetHandle }
1508     * @syscap SystemCapability.Communication.NetManager.Core
1509     * @since 11
1510     */
1511    netHandle: NetHandle;
1512    /**
1513     * Check whether the current state is blocked.
1514     * @type { boolean }
1515     * @syscap SystemCapability.Communication.NetManager.Core
1516     * @since 11
1517     */
1518    blocked: boolean;
1519  }
1520
1521  /**
1522   * Defines the network capability.
1523   * @enum {number}
1524   * @syscap SystemCapability.Communication.NetManager.Core
1525   * @since 8
1526   */
1527  /**
1528   * Defines the network capability.
1529   * @enum {number}
1530   * @syscap SystemCapability.Communication.NetManager.Core
1531   * @atomicservice
1532   * @since 11
1533   */
1534  export enum NetCap {
1535    /**
1536     * Indicates that the network can access the carrier's MMSC to send and receive multimedia messages.
1537     * @syscap SystemCapability.Communication.NetManager.Core
1538     * @since 8
1539     */
1540    /**
1541     * Indicates that the network can access the carrier's MMSC to send and receive multimedia messages.
1542     * @syscap SystemCapability.Communication.NetManager.Core
1543     * @atomicservice
1544     * @since 11
1545     */
1546    NET_CAPABILITY_MMS = 0,
1547
1548    /**
1549     * Indicates that the network traffic is not metered.
1550     * @syscap SystemCapability.Communication.NetManager.Core
1551     * @since 8
1552     */
1553    /**
1554     * Indicates that the network traffic is not metered.
1555     * @syscap SystemCapability.Communication.NetManager.Core
1556     * @atomicservice
1557     * @since 11
1558     */
1559    NET_CAPABILITY_NOT_METERED = 11,
1560
1561    /**
1562     * Indicates that the network can access the Internet.
1563     * @syscap SystemCapability.Communication.NetManager.Core
1564     * @since 8
1565     */
1566    /**
1567     * Indicates that the network can access the Internet.
1568     * @syscap SystemCapability.Communication.NetManager.Core
1569     * @atomicservice
1570     * @since 11
1571     */
1572    NET_CAPABILITY_INTERNET = 12,
1573
1574    /**
1575     * Indicates that the network does not use a VPN.
1576     * @syscap SystemCapability.Communication.NetManager.Core
1577     * @since 8
1578     */
1579    /**
1580     * Indicates that the network does not use a VPN.
1581     * @syscap SystemCapability.Communication.NetManager.Core
1582     * @atomicservice
1583     * @since 11
1584     */
1585    NET_CAPABILITY_NOT_VPN = 15,
1586
1587    /**
1588     * Indicates that the network is available.
1589     * @syscap SystemCapability.Communication.NetManager.Core
1590     * @since 8
1591     */
1592    /**
1593     * Indicates that the network is available.
1594     * @syscap SystemCapability.Communication.NetManager.Core
1595     * @atomicservice
1596     * @since 11
1597     */
1598    NET_CAPABILITY_VALIDATED = 16,
1599    /**
1600     * Indicates that the network is portal.
1601     * @syscap SystemCapability.Communication.NetManager.Core
1602     * @atomicservice
1603     * @since 12
1604     */
1605    NET_CAPABILITY_PORTAL = 17,
1606
1607    /**
1608     * Indicates that the network is checking connectivity.
1609     * @syscap SystemCapability.Communication.NetManager.Core
1610     * @atomicservice
1611     * @since 12
1612     */
1613    NET_CAPABILITY_CHECKING_CONNECTIVITY = 31
1614  }
1615
1616  /**
1617   * Enumerates network types.
1618   * @enum {number}
1619   * @syscap SystemCapability.Communication.NetManager.Core
1620   * @since 8
1621   */
1622  /**
1623   * Enumerates network types.
1624   * @enum {number}
1625   * @syscap SystemCapability.Communication.NetManager.Core
1626   * @crossplatform
1627   * @since 10
1628   */
1629  /**
1630   * Enumerates network types.
1631   * @enum {number}
1632   * @syscap SystemCapability.Communication.NetManager.Core
1633   * @crossplatform
1634   * @atomicservice
1635   * @since 11
1636   */
1637  export enum NetBearType {
1638    /**
1639     * Indicates that the network is based on a cellular network.
1640     * @syscap SystemCapability.Communication.NetManager.Core
1641     * @since 8
1642     */
1643    /**
1644     * Indicates that the network is based on a cellular network.
1645     * @syscap SystemCapability.Communication.NetManager.Core
1646     * @crossplatform
1647     * @since 10
1648     */
1649    /**
1650     * Indicates that the network is based on a cellular network.
1651     * @syscap SystemCapability.Communication.NetManager.Core
1652     * @crossplatform
1653     * @atomicservice
1654     * @since 11
1655     */
1656    BEARER_CELLULAR = 0,
1657
1658    /**
1659     * Indicates that the network is based on a Wi-Fi network.
1660     * @syscap SystemCapability.Communication.NetManager.Core
1661     * @since 8
1662     */
1663    /**
1664     * Indicates that the network is based on a Wi-Fi network.
1665     * @syscap SystemCapability.Communication.NetManager.Core
1666     * @crossplatform
1667     * @since 10
1668     */
1669    /**
1670     * Indicates that the network is based on a Wi-Fi network.
1671     * @syscap SystemCapability.Communication.NetManager.Core
1672     * @crossplatform
1673     * @atomicservice
1674     * @since 11
1675     */
1676    BEARER_WIFI = 1,
1677
1678    /**
1679     * Indicates that the network is based on a bluetooth network.
1680     * @syscap SystemCapability.Communication.NetManager.Core
1681     * @crossplatform
1682     * @since 12
1683     */
1684    BEARER_BLUETOOTH = 2,
1685
1686    /**
1687     * Indicates that the network is an Ethernet network.
1688     * @syscap SystemCapability.Communication.NetManager.Core
1689     * @since 8
1690     */
1691    /**
1692     * Indicates that the network is an Ethernet network.
1693     * @syscap SystemCapability.Communication.NetManager.Core
1694     * @atomicservice
1695     * @since 11
1696     */
1697    BEARER_ETHERNET = 3,
1698
1699    /**
1700     * Indicates that the network is based on a VPN network.
1701     * @syscap SystemCapability.Communication.NetManager.Core
1702     * @since 12
1703     */
1704    BEARER_VPN = 4,
1705  }
1706
1707  /**
1708   * Defines the network connection properties.
1709   * @interface ConnectionProperties
1710   * @syscap SystemCapability.Communication.NetManager.Core
1711   * @since 8
1712   */
1713  export interface ConnectionProperties {
1714    /**
1715     * Network card name.
1716     * @type {string}
1717     * @syscap SystemCapability.Communication.NetManager.Core
1718     * @since 8
1719     */
1720    interfaceName: string;
1721    /**
1722     * Domain. The default value is "".
1723     * @type {string}
1724     * @syscap SystemCapability.Communication.NetManager.Core
1725     * @since 8
1726     */
1727    domains: string;
1728    /**
1729     * Link information.
1730     * @type {Array<LinkAddress>}
1731     * @syscap SystemCapability.Communication.NetManager.Core
1732     * @since 8
1733     */
1734    linkAddresses: Array<LinkAddress>;
1735
1736    /**
1737     * Network address, refer to [NetAddress].
1738     * @type {Array<NetAddress>}
1739     * @syscap SystemCapability.Communication.NetManager.Core
1740     * @since 8
1741     */
1742    dnses: Array<NetAddress>;
1743
1744    /**
1745     * Routing information.
1746     * @type {Array<RouteInfo>}
1747     * @syscap SystemCapability.Communication.NetManager.Core
1748     * @since 8
1749     */
1750    routes: Array<RouteInfo>;
1751
1752    /**
1753     * Maximum transmission unit.
1754     * @type {number}
1755     * @syscap SystemCapability.Communication.NetManager.Core
1756     * @since 8
1757     */
1758    mtu: number;
1759  }
1760
1761  /**
1762   * Defines network route information.
1763   * @interface RouteInfo
1764   * @syscap SystemCapability.Communication.NetManager.Core
1765   * @since 8
1766   */
1767  export interface RouteInfo {
1768    /**
1769     * Network card name.
1770     * @type {string}
1771     * @syscap SystemCapability.Communication.NetManager.Core
1772     * @since 8
1773     */
1774    interface: string;
1775
1776    /**
1777     * Destination Address
1778     * @type {LinkAddress}
1779     * @syscap SystemCapability.Communication.NetManager.Core
1780     * @since 8
1781     */
1782    destination: LinkAddress;
1783
1784    /**
1785     * Gateway address.
1786     * @type {NetAddress}
1787     * @syscap SystemCapability.Communication.NetManager.Core
1788     * @since 8
1789     */
1790    gateway: NetAddress;
1791
1792    /**
1793     * Whether a gateway is present.
1794     * @type {boolean}
1795     * @syscap SystemCapability.Communication.NetManager.Core
1796     * @since 8
1797     */
1798    hasGateway: boolean;
1799
1800    /**
1801     * Whether the route is the default route.
1802     * @type {boolean}
1803     * @syscap SystemCapability.Communication.NetManager.Core
1804     * @since 8
1805     */
1806    isDefaultRoute: boolean;
1807  }
1808
1809  /**
1810   * Defines network link information.
1811   * @interface LinkAddress
1812   * @syscap SystemCapability.Communication.NetManager.Core
1813   * @since 8
1814   */
1815  export interface LinkAddress {
1816    /**
1817     * Link address.
1818     * @type {NetAddress}
1819     * @syscap SystemCapability.Communication.NetManager.Core
1820     * @since 8
1821     */
1822    address: NetAddress;
1823    /**
1824     * The length of the link address prefix.
1825     * @type {number}
1826     * @syscap SystemCapability.Communication.NetManager.Core
1827     * @since 8
1828     */
1829    prefixLength: number;
1830  }
1831
1832  /**
1833   * Defines a network address.
1834   * @interface NetAddress
1835   * @syscap SystemCapability.Communication.NetManager.Core
1836   * @since 8
1837   */
1838  /**
1839   * Defines a network address.
1840   * @interface NetAddress
1841   * @syscap SystemCapability.Communication.NetManager.Core
1842   * @atomicservice
1843   * @since 12
1844   */
1845  export interface NetAddress {
1846    /**
1847     * Network address.
1848     * @type {string}
1849     * @syscap SystemCapability.Communication.NetManager.Core
1850     * @since 8
1851     */
1852    /**
1853     * Network address.
1854     * @type {string}
1855     * @syscap SystemCapability.Communication.NetManager.Core
1856     * @atomicservice
1857     * @since 12
1858     */
1859    address: string;
1860
1861    /**
1862     * Address family identifier. The value is 1 for IPv4 and 2 for IPv6. The default value is 1.
1863     * @type {?number}
1864     * @syscap SystemCapability.Communication.NetManager.Core
1865     * @since 8
1866     */
1867    /**
1868     * Address family identifier. The value is 1 for IPv4 and 2 for IPv6. The default value is 1.
1869     * @type {?number}
1870     * @syscap SystemCapability.Communication.NetManager.Core
1871     * @atomicservice
1872     * @since 12
1873     */
1874    family?: number;
1875
1876    /**
1877     * Port number. The value ranges from 0 to 65535.
1878     * @type {?number}
1879     * @syscap SystemCapability.Communication.NetManager.Core
1880     * @since 8
1881     */
1882    /**
1883     * Port number. The value ranges from 0 to 65535.
1884     * @type {?number}
1885     * @syscap SystemCapability.Communication.NetManager.Core
1886     * @atomicservice
1887     * @since 12
1888     */
1889    port?: number;
1890  }
1891
1892  /**
1893   * Network Global Proxy Configuration Information.
1894   * @interface HttpProxy
1895   * @syscap SystemCapability.Communication.NetManager.Core
1896   * @since 10
1897   */
1898  /**
1899   * Network Global Proxy Configuration Information.
1900   * @interface HttpProxy
1901   * @syscap SystemCapability.Communication.NetManager.Core
1902   * @atomicservice
1903   * @since 11
1904   */
1905  export interface HttpProxy {
1906    /**
1907     * Proxy server host name.
1908     * @type {string}
1909     * @syscap SystemCapability.Communication.NetManager.Core
1910     * @since 10
1911     */
1912    /**
1913     * Proxy server host name.
1914     * @type {string}
1915     * @syscap SystemCapability.Communication.NetManager.Core
1916     * @atomicservice
1917     * @since 11
1918     */
1919    host: string;
1920
1921    /**
1922     * Host port.
1923     * @type {number}
1924     * @syscap SystemCapability.Communication.NetManager.Core
1925     * @since 10
1926     */
1927    /**
1928     * Host port.
1929     * @type {number}
1930     * @syscap SystemCapability.Communication.NetManager.Core
1931     * @atomicservice
1932     * @since 11
1933     */
1934    port: number;
1935
1936    /**
1937     * Http proxy username.
1938     * @type {?string}
1939     * @syscap SystemCapability.Communication.NetManager.Core
1940     * @since 12
1941     */
1942    username?: string;
1943
1944    /**
1945     * Http proxy password.
1946     * @type {?string}
1947     * @syscap SystemCapability.Communication.NetManager.Core
1948     * @since 12
1949     */
1950    password?: string;
1951
1952    /**
1953     * Do not use a blocking list for proxy servers.
1954     * @type {Array<string>}
1955     * @syscap SystemCapability.Communication.NetManager.Core
1956     * @since 10
1957     */
1958    /**
1959     * Do not use a blocking list for proxy servers.
1960     * @type {Array<string>}
1961     * @syscap SystemCapability.Communication.NetManager.Core
1962     * @atomicservice
1963     * @since 11
1964     */
1965    exclusionList: Array<string>;
1966  }
1967}
1968
1969export default connection;
1970