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