• 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
16import type { AsyncCallback, Callback } from './@ohos.base';
17import type http from './@ohos.net.http';
18import type socket from './@ohos.net.socket';
19
20/**
21 * Provides interfaces to manage and use data networks.
22 * @namespace connection
23 * @syscap SystemCapability.Communication.NetManager.Core
24 * @since 8
25 */
26/**
27 * Provides interfaces to manage and use data networks.
28 * @namespace connection
29 * @syscap SystemCapability.Communication.NetManager.Core
30 * @crossplatform
31 * @since 10
32 */
33declare namespace connection {
34  type HttpRequest = http.HttpRequest;
35  type TCPSocket = socket.TCPSocket;
36  type UDPSocket = socket.UDPSocket;
37
38  /**
39   * Create a network connection with optional netSpecifier and timeout.
40   * @param { NetSpecifier } netSpecifier - Indicates the network specifier. See {@link NetSpecifier}.
41   * @param { number } timeout - The time in milliseconds to attempt looking for a suitable network before
42   * {@link NetConnection#netUnavailable} is called.
43   * @returns { NetConnection } the NetConnection of the NetSpecifier.
44   * @syscap SystemCapability.Communication.NetManager.Core
45   * @since 8
46   */
47  /**
48   * Create a network connection with optional netSpecifier and timeout.
49   * @param { NetSpecifier } netSpecifier - Indicates the network specifier. See {@link NetSpecifier}.
50   * @param { number } timeout - The time in milliseconds to attempt looking for a suitable network before
51   * {@link NetConnection#netUnavailable} is called.
52   * @returns { NetConnection } the NetConnection of the NetSpecifier.
53   * @syscap SystemCapability.Communication.NetManager.Core
54   * @crossplatform
55   * @since 10
56   */
57  function createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection;
58
59  /**
60   * Obtains the data network that is activated by default.
61   * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
62   * @permission ohos.permission.GET_NETWORK_INFO
63   * @param { AsyncCallback<NetHandle> } callback - the callback of getDefaultNet.
64   * @throws { BusinessError } 201 - Permission denied.
65   * @throws { BusinessError } 401 - Parameter error.
66   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
67   * @throws { BusinessError } 2100003 - System internal error.
68   * @syscap SystemCapability.Communication.NetManager.Core
69   * @since 8
70   */
71  function getDefaultNet(callback: AsyncCallback<NetHandle>): void;
72
73  /**
74   * Obtains the data network that is activated by default.
75   * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
76   * @permission ohos.permission.GET_NETWORK_INFO
77   * @returns { Promise<NetHandle> } The promise returned by the function.
78   * @throws { BusinessError } 201 - Permission denied.
79   * @throws { BusinessError } 401 - Parameter error.
80   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
81   * @throws { BusinessError } 2100003 - System internal error.
82   * @syscap SystemCapability.Communication.NetManager.Core
83   * @since 8
84   */
85  function getDefaultNet(): Promise<NetHandle>;
86
87  /**
88   * Obtains the data network that is activated by default.
89   * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
90   * @permission ohos.permission.GET_NETWORK_INFO
91   * @returns { NetHandle } if the default network is not activated.
92   * @throws { BusinessError } 201 - Permission denied.
93   * @throws { BusinessError } 401 - Parameter error.
94   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
95   * @throws { BusinessError } 2100003 - System internal error.
96   * @syscap SystemCapability.Communication.NetManager.Core
97   * @since 9
98   */
99  function getDefaultNetSync(): NetHandle;
100
101  /**
102   * Obtains the list of data networks that are activated.
103   * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
104   * @permission ohos.permission.GET_NETWORK_INFO
105   * @param { AsyncCallback<Array<NetHandle>> } callback - the callback of getAllNets.
106   * @throws { BusinessError } 201 - Permission denied.
107   * @throws { BusinessError } 401 - Parameter error.
108   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
109   * @throws { BusinessError } 2100003 - System internal error.
110   * @syscap SystemCapability.Communication.NetManager.Core
111   * @since 8
112   */
113  function getAllNets(callback: AsyncCallback<Array<NetHandle>>): void;
114
115  /**
116   * Obtains the list of data networks that are activated.
117   * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
118   * @permission ohos.permission.GET_NETWORK_INFO
119   * @returns { Promise<Array<NetHandle>> } The promise returned by the function.
120   * @throws { BusinessError } 201 - Permission denied.
121   * @throws { BusinessError } 401 - Parameter error.
122   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
123   * @throws { BusinessError } 2100003 - System internal error.
124   * @syscap SystemCapability.Communication.NetManager.Core
125   * @since 8
126   */
127  function getAllNets(): Promise<Array<NetHandle>>;
128
129  /**
130   * Obtains the list of data networks that are activated.
131   * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
132   * @permission ohos.permission.GET_NETWORK_INFO
133   * @returns { Array<NetHandle> } Returns data networks that are activated.
134   * @throws { BusinessError } 201 - Permission denied.
135   * @throws { BusinessError } 401 - Parameter error.
136   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
137   * @throws { BusinessError } 2100003 - System internal error.
138   * @syscap SystemCapability.Communication.NetManager.Core
139   * @since 10
140   */
141  function getAllNetsSync(): Array<NetHandle>;
142
143  /**
144   * Queries the connection properties of a network.
145   * This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission.
146   * @permission ohos.permission.GET_NETWORK_INFO
147   * @param { NetHandle } netHandle - Indicates the network to be queried.
148   * @param { AsyncCallback<ConnectionProperties> } callback - the callback of getConnectionProperties.{@link ConnectionProperties}.
149   * @throws { BusinessError } 201 - Permission denied.
150   * @throws { BusinessError } 401 - Parameter error.
151   * @throws { BusinessError } 2100001 - Invalid parameter value.
152   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
153   * @throws { BusinessError } 2100003 - System internal error.
154   * @syscap SystemCapability.Communication.NetManager.Core
155   * @since 8
156   */
157  function getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback<ConnectionProperties>): void;
158
159  /**
160   * Queries the connection properties of a network.
161   * This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission.
162   * @permission ohos.permission.GET_NETWORK_INFO
163   * @param { NetHandle } netHandle - Indicates the network to be queried.
164   * @returns { Promise<ConnectionProperties> } The promise returned by the function.
165   * @throws { BusinessError } 201 - Permission denied.
166   * @throws { BusinessError } 401 - Parameter error.
167   * @throws { BusinessError } 2100001 - Invalid parameter value.
168   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
169   * @throws { BusinessError } 2100003 - System internal error.
170   * @syscap SystemCapability.Communication.NetManager.Core
171   * @since 8
172   */
173  function getConnectionProperties(netHandle: NetHandle): Promise<ConnectionProperties>;
174
175  /**
176   * Queries the connection properties of a network.
177   * This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission.
178   * @permission ohos.permission.GET_NETWORK_INFO
179   * @param { NetHandle } netHandle - Indicates the network to be queried.
180   * @returns { ConnectionProperties } Returns the connection properties of a network.
181   * @throws { BusinessError } 201 - Permission denied.
182   * @throws { BusinessError } 401 - Parameter error.
183   * @throws { BusinessError } 2100001 - Invalid parameter value.
184   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
185   * @throws { BusinessError } 2100003 - System internal error.
186   * @syscap SystemCapability.Communication.NetManager.Core
187   * @since 10
188   */
189  function getConnectionPropertiesSync(netHandle: NetHandle): ConnectionProperties;
190
191  /**
192   * Obtains {@link NetCapabilities} of a {@link NetHandle} object.
193   * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
194   * @permission ohos.permission.GET_NETWORK_INFO
195   * @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}.
196   * @param { AsyncCallback<NetCapabilities> } callback - the callback of getNetCapabilities.{@link NetCapabilities}.
197   * @throws { BusinessError } 201 - Permission denied.
198   * @throws { BusinessError } 401 - Parameter error.
199   * @throws { BusinessError } 2100001 - Invalid parameter value.
200   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
201   * @throws { BusinessError } 2100003 - System internal error.
202   * @syscap SystemCapability.Communication.NetManager.Core
203   * @since 8
204   */
205  function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback<NetCapabilities>): void;
206
207  /**
208   * Obtains {@link NetCapabilities} of a {@link NetHandle} object.
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 { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}.
212   * @returns { Promise<NetCapabilities> } The promise returned by the function.
213   * @throws { BusinessError } 201 - Permission denied.
214   * @throws { BusinessError } 401 - Parameter error.
215   * @throws { BusinessError } 2100001 - Invalid parameter value.
216   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
217   * @throws { BusinessError } 2100003 - System internal error.
218   * @syscap SystemCapability.Communication.NetManager.Core
219   * @since 8
220   */
221  function getNetCapabilities(netHandle: NetHandle): Promise<NetCapabilities>;
222
223  /**
224   * Obtains {@link NetCapabilities} of a {@link NetHandle} object.
225   * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
226   * @permission ohos.permission.GET_NETWORK_INFO
227   * @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}.
228   * @returns { NetCapabilities } Returns the connection capabilities of a network.
229   * @throws { BusinessError } 201 - Permission denied.
230   * @throws { BusinessError } 401 - Parameter error.
231   * @throws { BusinessError } 2100001 - Invalid parameter value.
232   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
233   * @throws { BusinessError } 2100003 - System internal error.
234   * @syscap SystemCapability.Communication.NetManager.Core
235   * @since 10
236   */
237  function getNetCapabilitiesSync(netHandle: NetHandle): NetCapabilities;
238
239  /**
240   * Checks whether data traffic usage on the current network is metered.
241   * @permission ohos.permission.GET_NETWORK_INFO
242   * @param { AsyncCallback<boolean> } callback - Returns {@code true} if data traffic usage on the current network is metered;
243   * returns {@code false} otherwise.
244   * @throws { BusinessError } 201 - Permission denied.
245   * @throws { BusinessError } 401 - Parameter error.
246   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
247   * @throws { BusinessError } 2100003 - System internal error.
248   * @syscap SystemCapability.Communication.NetManager.Core
249   * @since 9
250   */
251  function isDefaultNetMetered(callback: AsyncCallback<boolean>): void;
252
253  /**
254   * Checks whether data traffic usage on the current network is metered.
255   * @permission ohos.permission.GET_NETWORK_INFO
256   * @returns { Promise<boolean> } the promise returned by the function.
257   * @throws { BusinessError } 201 - Permission denied.
258   * @throws { BusinessError } 401 - Parameter error.
259   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
260   * @throws { BusinessError } 2100003 - System internal error.
261   * @syscap SystemCapability.Communication.NetManager.Core
262   * @since 9
263   */
264  function isDefaultNetMetered(): Promise<boolean>;
265
266  /**
267   * Checks whether data traffic usage on the current network is metered.
268   * @permission ohos.permission.GET_NETWORK_INFO
269   * @returns { boolean } Returns true if the current network is metered, else returns false.
270   * @throws { BusinessError } 201 - Permission denied.
271   * @throws { BusinessError } 401 - Parameter error.
272   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
273   * @throws { BusinessError } 2100003 - System internal error.
274   * @syscap SystemCapability.Communication.NetManager.Core
275   * @since 10
276   */
277  function isDefaultNetMeteredSync(): boolean;
278
279  /**
280   * Checks whether the default data network is activated.
281   * @permission ohos.permission.GET_NETWORK_INFO
282   * @param { AsyncCallback<boolean> } callback - Returns {@code true} if the default data network is activated;
283   * returns {@code false} otherwise.
284   * @throws { BusinessError } 201 - Permission denied.
285   * @throws { BusinessError } 401 - Parameter error.
286   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
287   * @throws { BusinessError } 2100003 - System internal error.
288   * @syscap SystemCapability.Communication.NetManager.Core
289   * @since 8
290   */
291  /**
292   * Checks whether the default data network is activated.
293   * @permission ohos.permission.GET_NETWORK_INFO
294   * @param { AsyncCallback<boolean> } callback - Returns {@code true} if the default data network is activated;
295   * returns {@code false} otherwise.
296   * @throws { BusinessError } 201 - Permission denied.
297   * @throws { BusinessError } 401 - Parameter error.
298   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
299   * @throws { BusinessError } 2100003 - System internal error.
300   * @syscap SystemCapability.Communication.NetManager.Core
301   * @crossplatform
302   * @since 10
303   */
304  function hasDefaultNet(callback: AsyncCallback<boolean>): void;
305
306  /**
307   * Checks whether the default data network is activated.
308   * @permission ohos.permission.GET_NETWORK_INFO
309   * @returns { Promise<boolean> } The promise returned by the function.
310   * @throws { BusinessError } 201 - Permission denied.
311   * @throws { BusinessError } 401 - Parameter error.
312   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
313   * @throws { BusinessError } 2100003 - System internal error.
314   * @syscap SystemCapability.Communication.NetManager.Core
315   * @since 8
316   */
317  /**
318   * Checks whether the default data network is activated.
319   * @permission ohos.permission.GET_NETWORK_INFO
320   * @returns { Promise<boolean> } The promise returned by the function.
321   * @throws { BusinessError } 201 - Permission denied.
322   * @throws { BusinessError } 401 - Parameter error.
323   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
324   * @throws { BusinessError } 2100003 - System internal error.
325   * @syscap SystemCapability.Communication.NetManager.Core
326   * @crossplatform
327   * @since 10
328   */
329  function hasDefaultNet(): Promise<boolean>;
330
331  /**
332   * Checks whether the default data network is activated.
333   * @permission ohos.permission.GET_NETWORK_INFO
334   * @returns { boolean } Returns true if the default data network is activated, else returns false.
335   * @throws { BusinessError } 201 - Permission denied.
336   * @throws { BusinessError } 401 - Parameter error.
337   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
338   * @throws { BusinessError } 2100003 - System internal error.
339   * @syscap SystemCapability.Communication.NetManager.Core
340   * @since 10
341   */
342  function hasDefaultNetSync(): boolean;
343
344  /**
345   * Enables the airplane mode for a device.
346   * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
347   * @permission ohos.permission.CONNECTIVITY_INTERNAL
348   * @param { AsyncCallback<void> } callback - the callback of enableAirplaneMode.
349   * @throws { BusinessError } 201 - Permission denied.
350   * @throws { BusinessError } 202 - Non-system applications use system APIs.
351   * @throws { BusinessError } 401 - Parameter error.
352   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
353   * @throws { BusinessError } 2100003 - System internal error.
354   * @syscap SystemCapability.Communication.NetManager.Core
355   * @systemapi Hide this for inner system use. Only used for system app.
356   * @since 8
357   */
358  function enableAirplaneMode(callback: AsyncCallback<void>): void;
359
360  /**
361   * Enables the airplane mode for a device.
362   * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
363   * @permission ohos.permission.CONNECTIVITY_INTERNAL
364   * @returns { Promise<void> } The promise returned by the function.
365   * @throws { BusinessError } 201 - Permission denied.
366   * @throws { BusinessError } 202 - Non-system applications use system APIs.
367   * @throws { BusinessError } 401 - Parameter error.
368   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
369   * @throws { BusinessError } 2100003 - System internal error.
370   * @syscap SystemCapability.Communication.NetManager.Core
371   * @systemapi Hide this for inner system use. Only used for system app.
372   * @since 8
373   */
374  function enableAirplaneMode(): Promise<void>;
375
376  /**
377   * Disables the airplane mode for a device.
378   * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
379   * @permission ohos.permission.CONNECTIVITY_INTERNAL
380   * @param { AsyncCallback<void> } callback - the callback of disableAirplaneMode.
381   * @throws { BusinessError } 201 - Permission denied.
382   * @throws { BusinessError } 202 - Non-system applications use system APIs.
383   * @throws { BusinessError } 401 - Parameter error.
384   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
385   * @throws { BusinessError } 2100003 - System internal error.
386   * @syscap SystemCapability.Communication.NetManager.Core
387   * @systemapi Hide this for inner system use. Only used for system app.
388   * @since 8
389   */
390  function disableAirplaneMode(callback: AsyncCallback<void>): void;
391
392  /**
393   * Disables the airplane mode for a device.
394   * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
395   * @permission ohos.permission.CONNECTIVITY_INTERNAL
396   * @returns { Promise<void> } The promise returned by the function.
397   * @throws { BusinessError } 201 - Permission denied.
398   * @throws { BusinessError } 202 - Non-system applications use system APIs.
399   * @throws { BusinessError } 401 - Parameter error.
400   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
401   * @throws { BusinessError } 2100003 - System internal error.
402   * @syscap SystemCapability.Communication.NetManager.Core
403   * @systemapi Hide this for inner system use. Only used for system app.
404   * @since 8
405   */
406  function disableAirplaneMode(): Promise<void>;
407
408  /**
409   * Reports the network state is connected.
410   * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
411   * @param { NetHandle } netHandle - Indicates the network whose state is to be reported.
412   * @param { AsyncCallback<void> } callback - the callback of reportNetConnected.
413   * @throws { BusinessError } 201 - Permission denied.
414   * @throws { BusinessError } 401 - Parameter error.
415   * @throws { BusinessError } 2100001 - Invalid parameter value.
416   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
417   * @throws { BusinessError } 2100003 - System internal error.
418   * @syscap SystemCapability.Communication.NetManager.Core
419   * @since 8
420   */
421  function reportNetConnected(netHandle: NetHandle, callback: AsyncCallback<void>): void;
422
423  /**
424   * Reports the network state is connected.
425   * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
426   * @param { NetHandle } netHandle - Indicates the network whose state is to be reported.
427   * @returns { Promise<void> } The promise returned by the function.
428   * @throws { BusinessError } 201 - Permission denied.
429   * @throws { BusinessError } 401 - Parameter error.
430   * @throws { BusinessError } 2100001 - Invalid parameter value.
431   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
432   * @throws { BusinessError } 2100003 - System internal error.
433   * @syscap SystemCapability.Communication.NetManager.Core
434   * @since 8
435   */
436  function reportNetConnected(netHandle: NetHandle): Promise<void>;
437
438  /**
439   * Reports the network state is disconnected.
440   * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
441   * @param { NetHandle } netHandle - Indicates the network whose state is to be reported.
442   * @param { AsyncCallback<void> } callback - the callback of reportNetDisconnected.
443   * @throws { BusinessError } 201 - Permission denied.
444   * @throws { BusinessError } 401 - Parameter error.
445   * @throws { BusinessError } 2100001 - Invalid parameter value.
446   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
447   * @throws { BusinessError } 2100003 - System internal error.
448   * @syscap SystemCapability.Communication.NetManager.Core
449   * @since 8
450   */
451  function reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback<void>): void;
452
453  /**
454   * Reports the network state is disconnected.
455   * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
456   * @param { NetHandle } netHandle - Indicates the network whose state is to be reported.
457   * @returns { Promise<void> } The promise returned by the function.
458   * @throws { BusinessError } 201 - Permission denied.
459   * @throws { BusinessError } 401 - Parameter error.
460   * @throws { BusinessError } 2100001 - Invalid parameter value.
461   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
462   * @throws { BusinessError } 2100003 - System internal error.
463   * @syscap SystemCapability.Communication.NetManager.Core
464   * @since 8
465   */
466  function reportNetDisconnected(netHandle: NetHandle): Promise<void>;
467
468  /**
469   * Resolves the host name to obtain all IP addresses based on the default data network.
470   * @permission ohos.permission.INTERNET
471   * @param { string } host - Indicates the host name or the domain.
472   * @param { AsyncCallback<Array<NetAddress>> } callback - Returns the NetAddress list.
473   * @throws { BusinessError } 201 - Permission denied.
474   * @throws { BusinessError } 401 - Parameter error.
475   * @throws { BusinessError } 2100001 - Invalid parameter value.
476   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
477   * @throws { BusinessError } 2100003 - System internal error.
478   * @syscap SystemCapability.Communication.NetManager.Core
479   * @since 8
480   */
481  function getAddressesByName(host: string, callback: AsyncCallback<Array<NetAddress>>): void;
482
483  /**
484   * Resolves the host name to obtain all IP addresses based on the default data network.
485   * @permission ohos.permission.INTERNET
486   * @param { string } host - Indicates the host name or the domain.
487   * @returns { Promise<Array<NetAddress>> } The promise returned by the function.
488   * @throws { BusinessError } 201 - Permission denied.
489   * @throws { BusinessError } 401 - Parameter error.
490   * @throws { BusinessError } 2100001 - Invalid parameter value.
491   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
492   * @throws { BusinessError } 2100003 - System internal error.
493   * @syscap SystemCapability.Communication.NetManager.Core
494   * @since 8
495   */
496  function getAddressesByName(host: string): Promise<Array<NetAddress>>;
497
498  /**
499   * Obtains the {@link NetHandle} bound to a process using {@link setAppNet}.
500   * @param { AsyncCallback<NetHandle> } callback - Returns the {@link NetHandle} bound to the process;
501   * returns {@code null} if no {@link NetHandle} is bound to the process.For details, see {@link NetHandle}.
502   * @throws { BusinessError } 401 - Parameter error.
503   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
504   * @throws { BusinessError } 2100003 - System internal error.
505   * @syscap SystemCapability.Communication.NetManager.Core
506   * @since 9
507   */
508  function getAppNet(callback: AsyncCallback<NetHandle>): void;
509
510  /**
511   * Obtains the {@link NetHandle} bound to a process using {@link setAppNet}.
512   * @returns { Promise<NetHandle> } the promise returned by the function.
513   * @throws { BusinessError } 401 - Parameter error.
514   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
515   * @throws { BusinessError } 2100003 - System internal error.
516   * @syscap SystemCapability.Communication.NetManager.Core
517   * @since 9
518   */
519  function getAppNet(): Promise<NetHandle>;
520
521  /**
522   * Obtains the {@link NetHandle} bound to a process using {@link setAppNet}.
523   * @returns { NetHandle } Returns the {@link NetHandle} bound to a process using {@link setAppNet}.
524   * @throws { BusinessError } 401 - Parameter error.
525   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
526   * @throws { BusinessError } 2100003 - System internal error.
527   * @syscap SystemCapability.Communication.NetManager.Core
528   * @since 10
529   */
530  function getAppNetSync(): NetHandle;
531
532  /**
533   * Binds a process to {@code NetHandle}.
534   * <p>All the sockets created from the process will be bound to the {@code NetHandle},
535   * and the resolution of all host names will be managed by the {@code NetHandle}.</p>
536   * @permission ohos.permission.INTERNET
537   * @param { NetHandle } netHandle - Indicates the handle. For details, see {@link NetHandle}.
538   * @param { AsyncCallback<void> } callback - the callback of setAppNet.
539   * @throws { BusinessError } 201 - Permission denied.
540   * @throws { BusinessError } 401 - Parameter error.
541   * @throws { BusinessError } 2100001 - Invalid parameter value.
542   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
543   * @throws { BusinessError } 2100003 - System internal error.
544   * @syscap SystemCapability.Communication.NetManager.Core
545   * @since 9
546   */
547  function setAppNet(netHandle: NetHandle, callback: AsyncCallback<void>): void;
548
549  /**
550   * Binds a process to {@code NetHandle}.
551   * <p>All the sockets created from the process will be bound to the {@code NetHandle},
552   * and the resolution of all host names will be managed by the {@code NetHandle}.</p>
553   * @permission ohos.permission.INTERNET
554   * @param { NetHandle } netHandle - Indicates the handle. For details, see {@link NetHandle}.
555   * @returns { Promise<void> } the promise returned by the function.
556   * @throws { BusinessError } 201 - Permission denied.
557   * @throws { BusinessError } 401 - Parameter error.
558   * @throws { BusinessError } 2100001 - Invalid parameter value.
559   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
560   * @throws { BusinessError } 2100003 - System internal error.
561   * @syscap SystemCapability.Communication.NetManager.Core
562   * @since 9
563   */
564  function setAppNet(netHandle: NetHandle): Promise<void>;
565
566  /**
567   * Obtains the default {@link HttpProxy} proxy settings.
568   *
569   * If a global proxy is set, the global proxy parameters are returned.
570   * If the process is bound to a {@link NetHandle} using {@link setAppNet}, the {@link NetHandle} proxy settings are returned.
571   * In other cases, the proxy settings of default network are returned.
572   *
573   * @param { AsyncCallback<HttpProxy> } callback - Returns the default {@link HttpProxy} settings.
574   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
575   * @throws { BusinessError } 2100003 - System internal error.
576   * @syscap SystemCapability.Communication.NetManager.Core
577   * @since 10
578   */
579  function getDefaultHttpProxy(callback: AsyncCallback<HttpProxy>): void;
580
581  /**
582   * Obtains the default {@link HttpProxy} proxy settings.
583   *
584   * If a global proxy is set, the global proxy parameters are returned.
585   * If the process is bound to a {@link NetHandle} using {@link setAppNet}, the {@link NetHandle} proxy settings are returned.
586   * In other cases, the proxy settings of default network are returned.
587   *
588   * @returns { Promise<HttpProxy> } the promise returned by the function.
589   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
590   * @throws { BusinessError } 2100003 - System internal error.
591   * @syscap SystemCapability.Communication.NetManager.Core
592   * @since 10
593   */
594  function getDefaultHttpProxy(): Promise<HttpProxy>;
595
596  /**
597   * Obtains the network independent global {@link HttpProxy} proxy settings.
598   * @param { AsyncCallback<HttpProxy> } callback - Returns the proxy settings. For details, see {@link HttpProxy}.
599   * @throws { BusinessError } 401 - Parameter error.
600   * @throws { BusinessError } 202 - Non-system applications use system APIs.
601   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
602   * @throws { BusinessError } 2100003 - System internal error.
603   * @syscap SystemCapability.Communication.NetManager.Core
604   * @systemapi Hide this for inner system use.
605   * @since 10
606   */
607  function getGlobalHttpProxy(callback: AsyncCallback<HttpProxy>): void;
608
609  /**
610   * Obtains the network independent global {@link HttpProxy} proxy settings.
611   * @returns { Promise<HttpProxy> } the promise returned by the function.
612   * @throws { BusinessError } 401 - Parameter error.
613   * @throws { BusinessError } 202 - Non-system applications use system APIs.
614   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
615   * @throws { BusinessError } 2100003 - System internal error.
616   * @syscap SystemCapability.Communication.NetManager.Core
617   * @systemapi Hide this for inner system use.
618   * @since 10
619   */
620  function getGlobalHttpProxy(): Promise<HttpProxy>;
621
622  /**
623   * Set a network independent global {@link HttpProxy} proxy settings.
624   * @permission ohos.permission.CONNECTIVITY_INTERNAL
625   * @param { HttpProxy } httpProxy - Indicates the global proxy settings. For details, see {@link HttpProxy}.
626   * @param { AsyncCallback<void> } callback - the callback of setGlobalHttpProxy.
627   * @throws { BusinessError } 201 - Permission denied.
628   * @throws { BusinessError } 401 - Parameter error.
629   * @throws { BusinessError } 202 - Non-system applications use system APIs.
630   * @throws { BusinessError } 2100001 - Invalid parameter value.
631   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
632   * @throws { BusinessError } 2100003 - System internal error.
633   * @syscap SystemCapability.Communication.NetManager.Core
634   * @systemapi Hide this for inner system use.
635   * @since 10
636   */
637  function setGlobalHttpProxy(httpProxy: HttpProxy, callback: AsyncCallback<void>): void;
638
639  /**
640   * Set a network independent global {@link HttpProxy} proxy settings.
641   * @permission ohos.permission.CONNECTIVITY_INTERNAL
642   * @param { HttpProxy } httpProxy - Indicates the global proxy settings. For details, see {@link HttpProxy}.
643   * @returns { Promise<void> } the promise returned by the function.
644   * @throws { BusinessError } 201 - Permission denied.
645   * @throws { BusinessError } 401 - Parameter error.
646   * @throws { BusinessError } 202 - Non-system applications use system APIs.
647   * @throws { BusinessError } 2100001 - Invalid parameter value.
648   * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
649   * @throws { BusinessError } 2100003 - System internal error.
650   * @syscap SystemCapability.Communication.NetManager.Core
651   * @systemapi Hide this for inner system use.
652   * @since 10
653   */
654  function setGlobalHttpProxy(httpProxy: HttpProxy): Promise<void>;
655
656  /**
657   * Represents the network connection handle.
658   * @interface NetConnection
659   * @syscap SystemCapability.Communication.NetManager.Core
660   * @since 8
661   */
662  /**
663   * Represents the network connection handle.
664   * @interface NetConnection
665   * @syscap SystemCapability.Communication.NetManager.Core
666   * @crossplatform
667   * @since 10
668   */
669  export interface NetConnection {
670    /**
671     * Registers a listener for netAvailable events.
672     * @param { 'netAvailable' } type - Indicates Event name.
673     * @param { Callback<NetHandle> } callback - the callback used to return the result.
674     * @syscap SystemCapability.Communication.NetManager.Core
675     * @since 8
676     */
677    /**
678     * Registers a listener for netAvailable events.
679     * @param { 'netAvailable' } type - Indicates Event name.
680     * @param { Callback<NetHandle> } callback - the callback used to return the result.
681     * @syscap SystemCapability.Communication.NetManager.Core
682     * @crossplatform
683     * @since 10
684     */
685    on(type: 'netAvailable', callback: Callback<NetHandle>): void;
686
687    /**
688     * Registers a listener for netBlockStatusChange events.
689     * @param { 'netBlockStatusChange' } type - Indicates Event name.
690     * @param { Callback<{ netHandle: NetHandle, blocked: boolean }> } callback - the callback used to return the result.
691     * @syscap SystemCapability.Communication.NetManager.Core
692     * @since 8
693     */
694    on(type: 'netBlockStatusChange', callback: Callback<{ netHandle: NetHandle, blocked: boolean }>): void;
695
696    /**
697     * Registers a listener for **netCapabilitiesChange** events.
698     * @param { 'netCapabilitiesChange' } type - Indicates Event name.
699     * @param { Callback<NetCapabilityInfo> } callback - the callback used to return the result.
700     * @syscap SystemCapability.Communication.NetManager.Core
701     * @since 8
702     */
703    /**
704     * Registers a listener for **netCapabilitiesChange** events.
705     * @param { 'netCapabilitiesChange' } type - Indicates Event name.
706     * @param { Callback<NetCapabilityInfo> } callback - the callback used to return the result.
707     * @syscap SystemCapability.Communication.NetManager.Core
708     * @crossplatform
709     * @since 10
710     */
711    on(type: 'netCapabilitiesChange', callback: Callback<NetCapabilityInfo>): void;
712
713    /**
714     * Registers a listener for netConnectionPropertiesChange events.
715     * @param { 'netConnectionPropertiesChange' } type - Indicates Event name.
716     * @param { Callback<{ netHandle: NetHandle, connectionProperties: ConnectionProperties }> } callback - the callback used to return the result.
717     * @syscap SystemCapability.Communication.NetManager.Core
718     * @since 8
719     */
720    on(type: 'netConnectionPropertiesChange', callback: Callback<{ netHandle: NetHandle, connectionProperties: ConnectionProperties }>): void;
721
722    /**
723     * Registers a listener for **netLost** events.
724     * @param { 'netLost' } type - Indicates Event name.
725     * @param { Callback<NetHandle> } callback - the callback used to return the result.
726     * @syscap SystemCapability.Communication.NetManager.Core
727     * @since 8
728     */
729    /**
730     * Registers a listener for **netLost** events.
731     * @param { 'netLost' } type - Indicates Event name.
732     * @param { Callback<NetHandle> } callback - the callback used to return the result.
733     * @syscap SystemCapability.Communication.NetManager.Core
734     * @crossplatform
735     * @since 10
736     */
737    on(type: 'netLost', callback: Callback<NetHandle>): void;
738
739    /**
740     * Registers a listener for netUnavailable events.
741     * @param { 'netUnavailable' } type - Indicates Event name.
742     * @param { Callback<void> } callback - the callback used to return the result.
743     * @syscap SystemCapability.Communication.NetManager.Core
744     * @since 8
745     */
746    /**
747     * Registers a listener for netUnavailable events.
748     * @param { 'netUnavailable' } type - Indicates Event name.
749     * @param { Callback<void> } callback - the callback used to return the result.
750     * @syscap SystemCapability.Communication.NetManager.Core
751     * @crossplatform
752     * @since 10
753     */
754    on(type: 'netUnavailable', callback: Callback<void>): void;
755
756    /**
757     * Receives status change notifications of a specified network.
758     * @permission ohos.permission.GET_NETWORK_INFO
759     * @param { AsyncCallback<void> } callback - the callback of register.
760     * @throws { BusinessError } 201 - Permission denied.
761     * @throws { BusinessError } 401 - Parameter error.
762     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
763     * @throws { BusinessError } 2100003 - System internal error.
764     * @throws { BusinessError } 2101008 - The same callback exists.
765     * @throws { BusinessError } 2101022 - The number of requests exceeded the maximum.
766     * @syscap SystemCapability.Communication.NetManager.Core
767     * @since 8
768     */
769    /**
770     * Receives status change notifications of a specified network.
771     * @permission ohos.permission.GET_NETWORK_INFO
772     * @param { AsyncCallback<void> } callback - the callback of register.
773     * @throws { BusinessError } 201 - Permission denied.
774     * @throws { BusinessError } 401 - Parameter error.
775     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
776     * @throws { BusinessError } 2100003 - System internal error.
777     * @throws { BusinessError } 2101008 - The same callback exists.
778     * @throws { BusinessError } 2101022 - The number of requests exceeded the maximum.
779     * @syscap SystemCapability.Communication.NetManager.Core
780     * @crossplatform
781     * @since 10
782     */
783    register(callback: AsyncCallback<void>): void;
784
785    /**
786     * Cancels listening for network status changes.
787     * @param { AsyncCallback<void> } callback - the callback of unregister.
788     * @throws { BusinessError } 201 - Permission denied.
789     * @throws { BusinessError } 401 - Parameter error.
790     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
791     * @throws { BusinessError } 2100003 - System internal error.
792     * @throws { BusinessError } 2101007 - The callback is not exists.
793     * @syscap SystemCapability.Communication.NetManager.Core
794     * @since 8
795     */
796    /**
797     * Cancels listening for network status changes.
798     * @param { AsyncCallback<void> } callback - the callback of unregister.
799     * @throws { BusinessError } 201 - Permission denied.
800     * @throws { BusinessError } 401 - Parameter error.
801     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
802     * @throws { BusinessError } 2100003 - System internal error.
803     * @throws { BusinessError } 2101007 - The callback is not exists.
804     * @syscap SystemCapability.Communication.NetManager.Core
805     * @crossplatform
806     * @since 10
807     */
808    unregister(callback: AsyncCallback<void>): void;
809  }
810
811  /**
812   * Provides an instance that bear data network capabilities.
813   * @interface NetSpecifier
814   * @syscap SystemCapability.Communication.NetManager.Core
815   * @since 8
816   */
817  export interface NetSpecifier {
818    /**
819     * The transmission capacity and support of the network's global proxy storage data network.
820     * @type {NetCapabilities}
821     * @syscap SystemCapability.Communication.NetManager.Core
822     * @since 8
823     */
824    netCapabilities: NetCapabilities;
825
826    /**
827     * Network identifier, the identifier for Wi Fi networks is "wifi", and the identifier for cellular networks is "simId1" (corresponding to SIM card 1).
828     * @type {?string}
829     * @syscap SystemCapability.Communication.NetManager.Core
830     * @since 8
831     */
832    bearerPrivateIdentifier?: string;
833  }
834
835  /**
836   * Receive information about changes in network capabilities.
837   * @interface NetCapabilityInfo
838   * @syscap SystemCapability.Communication.NetManager.Core
839   * @crossplatform
840   * @since 10
841   */
842  export interface NetCapabilityInfo {
843    /**
844     * Defines the handle of the data network.
845     * @type { NetHandle }
846     * @syscap SystemCapability.Communication.NetManager.Core
847     * @crossplatform
848     * @since 10
849     */
850    netHandle: NetHandle;
851
852    /**
853     * Defines the network capability set.
854     * @type { NetCapabilities }
855     * @syscap SystemCapability.Communication.NetManager.Core
856     * @crossplatform
857     * @since 10
858     */
859    netCap: NetCapabilities;
860  }
861
862  /**
863   * Defines the handle of the data network.
864   * @interface NetHandle
865   * @syscap SystemCapability.Communication.NetManager.Core
866   * @since 8
867   */
868  /**
869   * Defines the handle of the data network.
870   * @interface NetHandle
871   * @syscap SystemCapability.Communication.NetManager.Core
872   * @crossplatform
873   * @since 10
874   */
875  export interface NetHandle {
876    /**
877     * 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.
878     * @type {number}
879     * @syscap SystemCapability.Communication.NetManager.Core
880     * @since 8
881     */
882    /**
883     * 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.
884     * @type {number}
885     * @syscap SystemCapability.Communication.NetManager.Core
886     * @crossplatform
887     * @since 10
888     */
889    netId: number;
890
891    /**
892     * <p>Binds a TCPSocket or UDPSocket to the current network. All data flows from
893     * the socket will use this network, without being subject to {@link setAppNet}.</p>
894     * Before using this method, ensure that the socket is disconnected.
895     * @param { TCPSocket | UDPSocket } socketParam - Indicates the TCPSocket or UDPSocket object.
896     * @param { AsyncCallback<void> } callback - the callback of bindSocket.
897     * @throws { BusinessError } 401 - Parameter error.
898     * @throws { BusinessError } 2100001 - Invalid parameter value.
899     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
900     * @throws { BusinessError } 2100003 - System internal error.
901     * @syscap SystemCapability.Communication.NetManager.Core
902     * @since 9
903     */
904    bindSocket(socketParam: TCPSocket | UDPSocket, callback: AsyncCallback<void>): void;
905
906    /**
907     * <p>Binds a TCPSocket or UDPSocket to the current network. All data flows from
908     * the socket will use this network, without being subject to {@link setAppNet}.</p>
909     * Before using this method, ensure that the socket is disconnected.
910     * @param { TCPSocket | UDPSocket } socketParam - Indicates the TCPSocket or UDPSocket object.
911     * @returns { Promise<void> } the promise returned by the function.
912     * @throws { BusinessError } 401 - Parameter error.
913     * @throws { BusinessError } 2100001 - Invalid parameter value.
914     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
915     * @throws { BusinessError } 2100003 - System internal error.
916     * @syscap SystemCapability.Communication.NetManager.Core
917     * @since 9
918     */
919    bindSocket(socketParam: TCPSocket | UDPSocket): Promise<void>;
920
921    /**
922     * Resolves a host name to obtain all IP addresses based on the specified NetHandle.
923     * @permission ohos.permission.INTERNET
924     * @param { string } host - Indicates the host name or the domain.
925     * @param { AsyncCallback<Array<NetAddress>> } callback - the callback of getAddressesByName.
926     * @throws { BusinessError } 201 - Permission denied.
927     * @throws { BusinessError } 401 - Parameter error.
928     * @throws { BusinessError } 2100001 - Invalid parameter value.
929     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
930     * @throws { BusinessError } 2100003 - System internal error.
931     * @syscap SystemCapability.Communication.NetManager.Core
932     * @since 8
933     */
934    getAddressesByName(host: string, callback: AsyncCallback<Array<NetAddress>>): void;
935
936    /**
937     * Resolves a host name to obtain all IP addresses based on the specified NetHandle.
938     * @permission ohos.permission.INTERNET
939     * @param { string } host - Indicates the host name or the domain.
940     * @returns { Promise<Array<NetAddress>> } 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 - Operation failed. Cannot connect to service.
945     * @throws { BusinessError } 2100003 - System internal error.
946     * @syscap SystemCapability.Communication.NetManager.Core
947     * @since 8
948     */
949    getAddressesByName(host: string): Promise<Array<NetAddress>>;
950
951    /**
952     * Resolves a host name to obtain the first IP address based on the specified NetHandle.
953     * @permission ohos.permission.INTERNET
954     * @param { string } host - Indicates the host name or the domain.
955     * @param { AsyncCallback<NetAddress> } callback - the callback of getAddressByName.
956     * @throws { BusinessError } 201 - Permission denied.
957     * @throws { BusinessError } 401 - Parameter error.
958     * @throws { BusinessError } 2100001 - Invalid parameter value.
959     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
960     * @throws { BusinessError } 2100003 - System internal error.
961     * @syscap SystemCapability.Communication.NetManager.Core
962     * @since 8
963     */
964    getAddressByName(host: string, callback: AsyncCallback<NetAddress>): void;
965
966    /**
967     * Resolves a host name to obtain the first IP address based on the specified NetHandle.
968     * @permission ohos.permission.INTERNET
969     * @param { string } host - Indicates the host name or the domain.
970     * @returns { Promise<NetAddress> } The promise returned by the function.
971     * @throws { BusinessError } 201 - Permission denied.
972     * @throws { BusinessError } 401 - Parameter error.
973     * @throws { BusinessError } 2100001 - Invalid parameter value.
974     * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service.
975     * @throws { BusinessError } 2100003 - System internal error.
976     * @syscap SystemCapability.Communication.NetManager.Core
977     * @since 8
978     */
979    getAddressByName(host: string): Promise<NetAddress>;
980  }
981
982  /**
983   * Defines the network capability set.
984   * @interface NetCapabilities
985   * @syscap SystemCapability.Communication.NetManager.Core
986   * @since 8
987   */
988  /**
989   * Defines the network capability set.
990   * @interface NetCapabilities
991   * @syscap SystemCapability.Communication.NetManager.Core
992   * @crossplatform
993   * @since 10
994   */
995  export interface NetCapabilities {
996    /**
997     * Uplink (device-to-network) bandwidth.
998     * @type {?number}
999     * @syscap SystemCapability.Communication.NetManager.Core
1000     * @since 8
1001     */
1002    linkUpBandwidthKbps?: number;
1003
1004    /**
1005     * Downstream (network-to-device) bandwidth.
1006     * @type {?number}
1007     * @syscap SystemCapability.Communication.NetManager.Core
1008     * @since 8
1009     */
1010    linkDownBandwidthKbps?: number;
1011
1012    /**
1013     * Network-specific capabilities.
1014     * @type {?Array<NetCap>}
1015     * @syscap SystemCapability.Communication.NetManager.Core
1016     * @since 8
1017     */
1018    networkCap?: Array<NetCap>;
1019
1020    /**
1021     * Network type.
1022     * @type {Array<NetBearType>}
1023     * @syscap SystemCapability.Communication.NetManager.Core
1024     * @since 8
1025     */
1026    /**
1027     * Network type.
1028     * @type {Array<NetBearType>}
1029     * @syscap SystemCapability.Communication.NetManager.Core
1030     * @crossplatform
1031     * @since 10
1032     */
1033    bearerTypes: Array<NetBearType>;
1034  }
1035
1036  /**
1037   * Defines the network capability.
1038   * @enum {number}
1039   * @syscap SystemCapability.Communication.NetManager.Core
1040   * @since 8
1041   */
1042  export enum NetCap {
1043    /**
1044     * Indicates that the network can access the carrier's MMSC to send and receive multimedia messages.
1045     * @syscap SystemCapability.Communication.NetManager.Core
1046     * @since 8
1047     */
1048    NET_CAPABILITY_MMS = 0,
1049
1050    /**
1051     * Indicates that the network traffic is not metered.
1052     * @syscap SystemCapability.Communication.NetManager.Core
1053     * @since 8
1054     */
1055    NET_CAPABILITY_NOT_METERED = 11,
1056
1057    /**
1058     * Indicates that the network can access the Internet.
1059     * @syscap SystemCapability.Communication.NetManager.Core
1060     * @since 8
1061     */
1062    NET_CAPABILITY_INTERNET = 12,
1063
1064    /**
1065     * Indicates that the network does not use a VPN.
1066     * @syscap SystemCapability.Communication.NetManager.Core
1067     * @since 8
1068     */
1069    NET_CAPABILITY_NOT_VPN = 15,
1070
1071    /**
1072     * Indicates that the network is available.
1073     * @syscap SystemCapability.Communication.NetManager.Core
1074     * @since 8
1075     */
1076    NET_CAPABILITY_VALIDATED = 16,
1077  }
1078
1079  /**
1080   * Enumerates network types.
1081   * @enum {number}
1082   * @syscap SystemCapability.Communication.NetManager.Core
1083   * @since 8
1084   */
1085  /**
1086   * Enumerates network types.
1087   * @enum {number}
1088   * @syscap SystemCapability.Communication.NetManager.Core
1089   * @crossplatform
1090   * @since 10
1091   */
1092  export enum NetBearType {
1093    /**
1094     * Indicates that the network is based on a cellular network.
1095     * @syscap SystemCapability.Communication.NetManager.Core
1096     * @since 8
1097     */
1098    /**
1099     * Indicates that the network is based on a cellular network.
1100     * @syscap SystemCapability.Communication.NetManager.Core
1101     * @crossplatform
1102     * @since 10
1103     */
1104    BEARER_CELLULAR = 0,
1105
1106    /**
1107     * Indicates that the network is based on a Wi-Fi network.
1108     * @syscap SystemCapability.Communication.NetManager.Core
1109     * @since 8
1110     */
1111    /**
1112     * Indicates that the network is based on a Wi-Fi network.
1113     * @syscap SystemCapability.Communication.NetManager.Core
1114     * @crossplatform
1115     * @since 10
1116     */
1117    BEARER_WIFI = 1,
1118
1119    /**
1120     * Indicates that the network is an Ethernet network.
1121     * @syscap SystemCapability.Communication.NetManager.Core
1122     * @since 8
1123     */
1124    BEARER_ETHERNET = 3,
1125  }
1126
1127  /**
1128   * Defines the network connection properties.
1129   * @interface ConnectionProperties
1130   * @syscap SystemCapability.Communication.NetManager.Core
1131   * @since 8
1132   */
1133  export interface ConnectionProperties {
1134    /**
1135     * Network card name.
1136     * @type {string}
1137     * @syscap SystemCapability.Communication.NetManager.Core
1138     * @since 8
1139     */
1140    interfaceName: string;
1141    /**
1142     * Domain. The default value is "".
1143     * @type {string}
1144     * @syscap SystemCapability.Communication.NetManager.Core
1145     * @since 8
1146     */
1147    domains: string;
1148    /**
1149     * Link information.
1150     * @type {Array<LinkAddress>}
1151     * @syscap SystemCapability.Communication.NetManager.Core
1152     * @since 8
1153     */
1154    linkAddresses: Array<LinkAddress>;
1155
1156    /**
1157     * Network address, refer to [NetAddress].
1158     * @type {Array<NetAddress>}
1159     * @syscap SystemCapability.Communication.NetManager.Core
1160     * @since 8
1161     */
1162    dnses: Array<NetAddress>;
1163
1164    /**
1165     * Routing information.
1166     * @type {Array<RouteInfo>}
1167     * @syscap SystemCapability.Communication.NetManager.Core
1168     * @since 8
1169     */
1170    routes: Array<RouteInfo>;
1171
1172    /**
1173     * Maximum transmission unit.
1174     * @type {number}
1175     * @syscap SystemCapability.Communication.NetManager.Core
1176     * @since 8
1177     */
1178    mtu: number;
1179  }
1180
1181  /**
1182   * Defines network route information.
1183   * @interface RouteInfo
1184   * @syscap SystemCapability.Communication.NetManager.Core
1185   * @since 8
1186   */
1187  export interface RouteInfo {
1188    /**
1189     * Network card name.
1190     * @type {string}
1191     * @syscap SystemCapability.Communication.NetManager.Core
1192     * @since 8
1193     */
1194    interface: string;
1195
1196    /**
1197     * Destination Address
1198     * @type {LinkAddress}
1199     * @syscap SystemCapability.Communication.NetManager.Core
1200     * @since 8
1201     */
1202    destination: LinkAddress;
1203
1204    /**
1205     * Gateway address.
1206     * @type {NetAddress}
1207     * @syscap SystemCapability.Communication.NetManager.Core
1208     * @since 8
1209     */
1210    gateway: NetAddress;
1211
1212    /**
1213     * Whether a gateway is present.
1214     * @type {boolean}
1215     * @syscap SystemCapability.Communication.NetManager.Core
1216     * @since 8
1217     */
1218    hasGateway: boolean;
1219
1220    /**
1221     * Whether the route is the default route.
1222     * @type {boolean}
1223     * @syscap SystemCapability.Communication.NetManager.Core
1224     * @since 8
1225     */
1226    isDefaultRoute: boolean;
1227  }
1228
1229  /**
1230   * Defines network link information.
1231   * @interface LinkAddress
1232   * @syscap SystemCapability.Communication.NetManager.Core
1233   * @since 8
1234   */
1235  export interface LinkAddress {
1236    /**
1237     * Link address.
1238     * @type {NetAddress}
1239     * @syscap SystemCapability.Communication.NetManager.Core
1240     * @since 8
1241     */
1242    address: NetAddress;
1243    /**
1244     * The length of the link address prefix.
1245     * @type {number}
1246     * @syscap SystemCapability.Communication.NetManager.Core
1247     * @since 8
1248     */
1249    prefixLength: number;
1250  }
1251
1252  /**
1253   * Defines a network address.
1254   * @interface NetAddress
1255   * @syscap SystemCapability.Communication.NetManager.Core
1256   * @since 8
1257   */
1258  export interface NetAddress {
1259    /**
1260     * Network address.
1261     * @type {string}
1262     * @syscap SystemCapability.Communication.NetManager.Core
1263     * @since 8
1264     */
1265    address: string;
1266
1267    /**
1268     * Address family identifier. The value is 1 for IPv4 and 2 for IPv6. The default value is 1.
1269     * @type {?number}
1270     * @syscap SystemCapability.Communication.NetManager.Core
1271     * @since 8
1272     */
1273    family?: number;
1274
1275    /**
1276     * Port number. The value ranges from 0 to 65535.
1277     * @type {?number}
1278     * @syscap SystemCapability.Communication.NetManager.Core
1279     * @since 8
1280     */
1281    port?: number;
1282  }
1283
1284  /**
1285   * Network Global Proxy Configuration Information.
1286   * @interface HttpProxy
1287   * @syscap SystemCapability.Communication.NetManager.Core
1288   * @since 10
1289   */
1290  export interface HttpProxy {
1291    /**
1292     * Proxy server host name.
1293     * @type {string}
1294     * @syscap SystemCapability.Communication.NetManager.Core
1295     * @since 10
1296     */
1297    host: string;
1298
1299    /**
1300     * Host port.
1301     * @type {number}
1302     * @syscap SystemCapability.Communication.NetManager.Core
1303     * @since 10
1304     */
1305    port: number;
1306
1307    /**
1308     * Do not use a blocking list for proxy servers.
1309     * @type {Array<string>}
1310     * @syscap SystemCapability.Communication.NetManager.Core
1311     * @since 10
1312     */
1313    exclusionList: Array<string>;
1314  }
1315}
1316
1317export default connection;
1318