161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (C) 2022-2023 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit NetworkKit 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ciimport type { AsyncCallback, Callback } from './@ohos.base'; 2261847f8eSopenharmony_ciimport type http from './@ohos.net.http'; 2361847f8eSopenharmony_ciimport type socket from './@ohos.net.socket'; 2461847f8eSopenharmony_ci 2561847f8eSopenharmony_ci/** 2661847f8eSopenharmony_ci * Provides interfaces to manage and use data networks. 2761847f8eSopenharmony_ci * @namespace connection 2861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 2961847f8eSopenharmony_ci * @since 8 3061847f8eSopenharmony_ci */ 3161847f8eSopenharmony_ci/** 3261847f8eSopenharmony_ci * Provides interfaces to manage and use data networks. 3361847f8eSopenharmony_ci * @namespace connection 3461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 3561847f8eSopenharmony_ci * @crossplatform 3661847f8eSopenharmony_ci * @since 10 3761847f8eSopenharmony_ci */ 3861847f8eSopenharmony_ci/** 3961847f8eSopenharmony_ci * Provides interfaces to manage and use data networks. 4061847f8eSopenharmony_ci * @namespace connection 4161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 4261847f8eSopenharmony_ci * @crossplatform 4361847f8eSopenharmony_ci * @atomicservice 4461847f8eSopenharmony_ci * @since 11 4561847f8eSopenharmony_ci */ 4661847f8eSopenharmony_cideclare namespace connection { 4761847f8eSopenharmony_ci /** 4861847f8eSopenharmony_ci * Get an HTTP request task. 4961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 5061847f8eSopenharmony_ci * @since 8 5161847f8eSopenharmony_ci */ 5261847f8eSopenharmony_ci /** 5361847f8eSopenharmony_ci * Get an HTTP request task. 5461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 5561847f8eSopenharmony_ci * @crossplatform 5661847f8eSopenharmony_ci * @since 10 5761847f8eSopenharmony_ci */ 5861847f8eSopenharmony_ci /** 5961847f8eSopenharmony_ci * Get an HTTP request task. 6061847f8eSopenharmony_ci * @typedef { http.HttpRequest } 6161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 6261847f8eSopenharmony_ci * @crossplatform 6361847f8eSopenharmony_ci * @atomicservice 6461847f8eSopenharmony_ci * @since 11 6561847f8eSopenharmony_ci */ 6661847f8eSopenharmony_ci type HttpRequest = http.HttpRequest; 6761847f8eSopenharmony_ci 6861847f8eSopenharmony_ci /** 6961847f8eSopenharmony_ci * Get a TCPSocket object. 7061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 7161847f8eSopenharmony_ci * @since 8 7261847f8eSopenharmony_ci */ 7361847f8eSopenharmony_ci /** 7461847f8eSopenharmony_ci * Get a TCPSocket object. 7561847f8eSopenharmony_ci * @typedef { socket.TCPSocket } 7661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 7761847f8eSopenharmony_ci * @crossplatform 7861847f8eSopenharmony_ci * @since 10 7961847f8eSopenharmony_ci */ 8061847f8eSopenharmony_ci type TCPSocket = socket.TCPSocket; 8161847f8eSopenharmony_ci 8261847f8eSopenharmony_ci /** 8361847f8eSopenharmony_ci * Get a UDPSocket object. 8461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 8561847f8eSopenharmony_ci * @since 8 8661847f8eSopenharmony_ci */ 8761847f8eSopenharmony_ci /** 8861847f8eSopenharmony_ci * Get a UDPSocket object. 8961847f8eSopenharmony_ci * @typedef { socket.UDPSocket } 9061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 9161847f8eSopenharmony_ci * @crossplatform 9261847f8eSopenharmony_ci * @since 10 9361847f8eSopenharmony_ci */ 9461847f8eSopenharmony_ci type UDPSocket = socket.UDPSocket; 9561847f8eSopenharmony_ci 9661847f8eSopenharmony_ci /** 9761847f8eSopenharmony_ci * Create a network connection with optional netSpecifier and timeout. 9861847f8eSopenharmony_ci * @param { NetSpecifier } [netSpecifier] - Indicates the network specifier. See {@link NetSpecifier}. 9961847f8eSopenharmony_ci * @param { number } [timeout] - The time in milliseconds to attempt looking for a suitable network before 10061847f8eSopenharmony_ci * {@link NetConnection#netUnavailable} is called. 10161847f8eSopenharmony_ci * @returns { NetConnection } the NetConnection of the NetSpecifier. 10261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 10361847f8eSopenharmony_ci * @since 8 10461847f8eSopenharmony_ci */ 10561847f8eSopenharmony_ci /** 10661847f8eSopenharmony_ci * Create a network connection with optional netSpecifier and timeout. 10761847f8eSopenharmony_ci * @param { NetSpecifier } [netSpecifier] - Indicates the network specifier. See {@link NetSpecifier}. 10861847f8eSopenharmony_ci * @param { number } [timeout] - The time in milliseconds to attempt looking for a suitable network before 10961847f8eSopenharmony_ci * {@link NetConnection#netUnavailable} is called. 11061847f8eSopenharmony_ci * @returns { NetConnection } the NetConnection of the NetSpecifier. 11161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 11261847f8eSopenharmony_ci * @crossplatform 11361847f8eSopenharmony_ci * @since 10 11461847f8eSopenharmony_ci */ 11561847f8eSopenharmony_ci /** 11661847f8eSopenharmony_ci * Create a network connection with optional netSpecifier and timeout. 11761847f8eSopenharmony_ci * @param { NetSpecifier } [netSpecifier] - Indicates the network specifier. See {@link NetSpecifier}. 11861847f8eSopenharmony_ci * @param { number } [timeout] - The time in milliseconds to attempt looking for a suitable network before 11961847f8eSopenharmony_ci * {@link NetConnection#netUnavailable} is called. 12061847f8eSopenharmony_ci * @returns { NetConnection } the NetConnection of the NetSpecifier. 12161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 12261847f8eSopenharmony_ci * @crossplatform 12361847f8eSopenharmony_ci * @atomicservice 12461847f8eSopenharmony_ci * @since 11 12561847f8eSopenharmony_ci */ 12661847f8eSopenharmony_ci function createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection; 12761847f8eSopenharmony_ci 12861847f8eSopenharmony_ci /** 12961847f8eSopenharmony_ci * Obtains the data network that is activated by default. 13061847f8eSopenharmony_ci * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. 13161847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 13261847f8eSopenharmony_ci * @param { AsyncCallback<NetHandle> } callback - the callback of getDefaultNet. 13361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 13461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 13561847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 13661847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 13761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 13861847f8eSopenharmony_ci * @since 8 13961847f8eSopenharmony_ci */ 14061847f8eSopenharmony_ci /** 14161847f8eSopenharmony_ci * Obtains the data network that is activated by default. 14261847f8eSopenharmony_ci * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. 14361847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 14461847f8eSopenharmony_ci * @param { AsyncCallback<NetHandle> } callback - the callback of getDefaultNet. 14561847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 14661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 14761847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 14861847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 14961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 15061847f8eSopenharmony_ci * @atomicservice 15161847f8eSopenharmony_ci * @since 11 15261847f8eSopenharmony_ci */ 15361847f8eSopenharmony_ci function getDefaultNet(callback: AsyncCallback<NetHandle>): void; 15461847f8eSopenharmony_ci 15561847f8eSopenharmony_ci /** 15661847f8eSopenharmony_ci * Obtains the data network that is activated by default. 15761847f8eSopenharmony_ci * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. 15861847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 15961847f8eSopenharmony_ci * @returns { Promise<NetHandle> } The promise returned by the function. 16061847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 16161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 16261847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 16361847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 16461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 16561847f8eSopenharmony_ci * @since 8 16661847f8eSopenharmony_ci */ 16761847f8eSopenharmony_ci /** 16861847f8eSopenharmony_ci * Obtains the data network that is activated by default. 16961847f8eSopenharmony_ci * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. 17061847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 17161847f8eSopenharmony_ci * @returns { Promise<NetHandle> } The promise returned by the function. 17261847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 17361847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 17461847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 17561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 17661847f8eSopenharmony_ci * @atomicservice 17761847f8eSopenharmony_ci * @since 11 17861847f8eSopenharmony_ci */ 17961847f8eSopenharmony_ci function getDefaultNet(): Promise<NetHandle>; 18061847f8eSopenharmony_ci 18161847f8eSopenharmony_ci /** 18261847f8eSopenharmony_ci * Obtains the data network that is activated by default. 18361847f8eSopenharmony_ci * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. 18461847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 18561847f8eSopenharmony_ci * @returns { NetHandle } if the default network is not activated. 18661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 18761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 18861847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 18961847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 19061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 19161847f8eSopenharmony_ci * @since 9 19261847f8eSopenharmony_ci */ 19361847f8eSopenharmony_ci /** 19461847f8eSopenharmony_ci * Obtains the data network that is activated by default. 19561847f8eSopenharmony_ci * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. 19661847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 19761847f8eSopenharmony_ci * @returns { NetHandle } if the default network is not activated. 19861847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 19961847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 20061847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 20161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 20261847f8eSopenharmony_ci * @atomicservice 20361847f8eSopenharmony_ci * @since 11 20461847f8eSopenharmony_ci */ 20561847f8eSopenharmony_ci function getDefaultNetSync(): NetHandle; 20661847f8eSopenharmony_ci 20761847f8eSopenharmony_ci /** 20861847f8eSopenharmony_ci * Obtains the list of data networks that are activated. 20961847f8eSopenharmony_ci * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. 21061847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 21161847f8eSopenharmony_ci * @param { AsyncCallback<Array<NetHandle>> } callback - the callback of getAllNets. 21261847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 21361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 21461847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 21561847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 21661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 21761847f8eSopenharmony_ci * @since 8 21861847f8eSopenharmony_ci */ 21961847f8eSopenharmony_ci function getAllNets(callback: AsyncCallback<Array<NetHandle>>): void; 22061847f8eSopenharmony_ci 22161847f8eSopenharmony_ci /** 22261847f8eSopenharmony_ci * Obtains the list of data networks that are activated. 22361847f8eSopenharmony_ci * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. 22461847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 22561847f8eSopenharmony_ci * @returns { Promise<Array<NetHandle>> } The promise returned by the function. 22661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 22761847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 22861847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 22961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 23061847f8eSopenharmony_ci * @since 8 23161847f8eSopenharmony_ci */ 23261847f8eSopenharmony_ci function getAllNets(): Promise<Array<NetHandle>>; 23361847f8eSopenharmony_ci 23461847f8eSopenharmony_ci /** 23561847f8eSopenharmony_ci * Obtains the list of data networks that are activated. 23661847f8eSopenharmony_ci * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. 23761847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 23861847f8eSopenharmony_ci * @returns { Array<NetHandle> } Returns data networks that are activated. 23961847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 24061847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 24161847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 24261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 24361847f8eSopenharmony_ci * @since 10 24461847f8eSopenharmony_ci */ 24561847f8eSopenharmony_ci function getAllNetsSync(): Array<NetHandle>; 24661847f8eSopenharmony_ci 24761847f8eSopenharmony_ci /** 24861847f8eSopenharmony_ci * Queries the connection properties of a network. 24961847f8eSopenharmony_ci * This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission. 25061847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 25161847f8eSopenharmony_ci * @param { NetHandle } netHandle - Indicates the network to be queried. 25261847f8eSopenharmony_ci * @param { AsyncCallback<ConnectionProperties> } callback - the callback of getConnectionProperties.{@link ConnectionProperties}. 25361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 25461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 25561847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 25661847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 25761847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 25861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 25961847f8eSopenharmony_ci * @since 8 26061847f8eSopenharmony_ci */ 26161847f8eSopenharmony_ci function getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback<ConnectionProperties>): void; 26261847f8eSopenharmony_ci 26361847f8eSopenharmony_ci /** 26461847f8eSopenharmony_ci * Queries the connection properties of a network. 26561847f8eSopenharmony_ci * This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission. 26661847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 26761847f8eSopenharmony_ci * @param { NetHandle } netHandle - Indicates the network to be queried. 26861847f8eSopenharmony_ci * @returns { Promise<ConnectionProperties> } The promise returned by the function. 26961847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 27061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 27161847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 27261847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 27361847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 27461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 27561847f8eSopenharmony_ci * @since 8 27661847f8eSopenharmony_ci */ 27761847f8eSopenharmony_ci function getConnectionProperties(netHandle: NetHandle): Promise<ConnectionProperties>; 27861847f8eSopenharmony_ci 27961847f8eSopenharmony_ci /** 28061847f8eSopenharmony_ci * Queries the connection properties of a network. 28161847f8eSopenharmony_ci * This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission. 28261847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 28361847f8eSopenharmony_ci * @param { NetHandle } netHandle - Indicates the network to be queried. 28461847f8eSopenharmony_ci * @returns { ConnectionProperties } Returns the connection properties of a network. 28561847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 28661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 28761847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 28861847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 28961847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 29061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 29161847f8eSopenharmony_ci * @since 10 29261847f8eSopenharmony_ci */ 29361847f8eSopenharmony_ci function getConnectionPropertiesSync(netHandle: NetHandle): ConnectionProperties; 29461847f8eSopenharmony_ci 29561847f8eSopenharmony_ci /** 29661847f8eSopenharmony_ci * Obtains {@link NetCapabilities} of a {@link NetHandle} object. 29761847f8eSopenharmony_ci * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. 29861847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 29961847f8eSopenharmony_ci * @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}. 30061847f8eSopenharmony_ci * @param { AsyncCallback<NetCapabilities> } callback - the callback of getNetCapabilities.{@link NetCapabilities}. 30161847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 30261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 30361847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 30461847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 30561847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 30661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 30761847f8eSopenharmony_ci * @since 8 30861847f8eSopenharmony_ci */ 30961847f8eSopenharmony_ci /** 31061847f8eSopenharmony_ci * Obtains {@link NetCapabilities} of a {@link NetHandle} object. 31161847f8eSopenharmony_ci * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. 31261847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 31361847f8eSopenharmony_ci * @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}. 31461847f8eSopenharmony_ci * @param { AsyncCallback<NetCapabilities> } callback - the callback of getNetCapabilities.{@link NetCapabilities}. 31561847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 31661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 31761847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 31861847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 31961847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 32061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 32161847f8eSopenharmony_ci * @atomicservice 32261847f8eSopenharmony_ci * @since 11 32361847f8eSopenharmony_ci */ 32461847f8eSopenharmony_ci function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback<NetCapabilities>): void; 32561847f8eSopenharmony_ci 32661847f8eSopenharmony_ci /** 32761847f8eSopenharmony_ci * Obtains {@link NetCapabilities} of a {@link NetHandle} object. 32861847f8eSopenharmony_ci * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. 32961847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 33061847f8eSopenharmony_ci * @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}. 33161847f8eSopenharmony_ci * @returns { Promise<NetCapabilities> } The promise returned by the function. 33261847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 33361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 33461847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 33561847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 33661847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 33761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 33861847f8eSopenharmony_ci * @since 8 33961847f8eSopenharmony_ci */ 34061847f8eSopenharmony_ci /** 34161847f8eSopenharmony_ci * Obtains {@link NetCapabilities} of a {@link NetHandle} object. 34261847f8eSopenharmony_ci * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. 34361847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 34461847f8eSopenharmony_ci * @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}. 34561847f8eSopenharmony_ci * @returns { Promise<NetCapabilities> } The promise returned by the function. 34661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 34761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 34861847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 34961847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 35061847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 35161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 35261847f8eSopenharmony_ci * @atomicservice 35361847f8eSopenharmony_ci * @since 11 35461847f8eSopenharmony_ci */ 35561847f8eSopenharmony_ci function getNetCapabilities(netHandle: NetHandle): Promise<NetCapabilities>; 35661847f8eSopenharmony_ci 35761847f8eSopenharmony_ci /** 35861847f8eSopenharmony_ci * Obtains {@link NetCapabilities} of a {@link NetHandle} object. 35961847f8eSopenharmony_ci * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. 36061847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 36161847f8eSopenharmony_ci * @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}. 36261847f8eSopenharmony_ci * @returns { NetCapabilities } Returns the connection capabilities of a network. 36361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 36461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 36561847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 36661847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 36761847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 36861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 36961847f8eSopenharmony_ci * @since 10 37061847f8eSopenharmony_ci */ 37161847f8eSopenharmony_ci /** 37261847f8eSopenharmony_ci * Obtains {@link NetCapabilities} of a {@link NetHandle} object. 37361847f8eSopenharmony_ci * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. 37461847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 37561847f8eSopenharmony_ci * @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}. 37661847f8eSopenharmony_ci * @returns { NetCapabilities } Returns the connection capabilities of a network. 37761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 37861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 37961847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 38061847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 38161847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 38261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 38361847f8eSopenharmony_ci * @atomicservice 38461847f8eSopenharmony_ci * @since 11 38561847f8eSopenharmony_ci */ 38661847f8eSopenharmony_ci function getNetCapabilitiesSync(netHandle: NetHandle): NetCapabilities; 38761847f8eSopenharmony_ci 38861847f8eSopenharmony_ci /** 38961847f8eSopenharmony_ci * Checks whether data traffic usage on the current network is metered. 39061847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 39161847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - Returns {@code true} if data traffic usage on the current network is metered; 39261847f8eSopenharmony_ci * returns {@code false} otherwise. 39361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 39461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 39561847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 39661847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 39761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 39861847f8eSopenharmony_ci * @since 9 39961847f8eSopenharmony_ci */ 40061847f8eSopenharmony_ci function isDefaultNetMetered(callback: AsyncCallback<boolean>): void; 40161847f8eSopenharmony_ci 40261847f8eSopenharmony_ci /** 40361847f8eSopenharmony_ci * Checks whether data traffic usage on the current network is metered. 40461847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 40561847f8eSopenharmony_ci * @returns { Promise<boolean> } the promise returned by the function. 40661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 40761847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 40861847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 40961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 41061847f8eSopenharmony_ci * @since 9 41161847f8eSopenharmony_ci */ 41261847f8eSopenharmony_ci function isDefaultNetMetered(): Promise<boolean>; 41361847f8eSopenharmony_ci 41461847f8eSopenharmony_ci /** 41561847f8eSopenharmony_ci * Checks whether data traffic usage on the current network is metered. 41661847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 41761847f8eSopenharmony_ci * @returns { boolean } Returns true if the current network is metered, else returns false. 41861847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 41961847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 42061847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 42161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 42261847f8eSopenharmony_ci * @since 10 42361847f8eSopenharmony_ci */ 42461847f8eSopenharmony_ci function isDefaultNetMeteredSync(): boolean; 42561847f8eSopenharmony_ci 42661847f8eSopenharmony_ci /** 42761847f8eSopenharmony_ci * Checks whether the default data network is activated. 42861847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 42961847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - Returns {@code true} if the default data network is activated; 43061847f8eSopenharmony_ci * returns {@code false} otherwise. 43161847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 43261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 43361847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 43461847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 43561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 43661847f8eSopenharmony_ci * @since 8 43761847f8eSopenharmony_ci */ 43861847f8eSopenharmony_ci /** 43961847f8eSopenharmony_ci * Checks whether the default data network is activated. 44061847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 44161847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - Returns {@code true} if the default data network is activated; 44261847f8eSopenharmony_ci * returns {@code false} otherwise. 44361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 44461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 44561847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 44661847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 44761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 44861847f8eSopenharmony_ci * @crossplatform 44961847f8eSopenharmony_ci * @since 10 45061847f8eSopenharmony_ci */ 45161847f8eSopenharmony_ci function hasDefaultNet(callback: AsyncCallback<boolean>): void; 45261847f8eSopenharmony_ci 45361847f8eSopenharmony_ci /** 45461847f8eSopenharmony_ci * Checks whether the default data network is activated. 45561847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 45661847f8eSopenharmony_ci * @returns { Promise<boolean> } The promise returned by the function. 45761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 45861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 45961847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 46061847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 46161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 46261847f8eSopenharmony_ci * @since 8 46361847f8eSopenharmony_ci */ 46461847f8eSopenharmony_ci /** 46561847f8eSopenharmony_ci * Checks whether the default data network is activated. 46661847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 46761847f8eSopenharmony_ci * @returns { Promise<boolean> } The promise returned by the function. 46861847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 46961847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 47061847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 47161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 47261847f8eSopenharmony_ci * @crossplatform 47361847f8eSopenharmony_ci * @since 10 47461847f8eSopenharmony_ci */ 47561847f8eSopenharmony_ci function hasDefaultNet(): Promise<boolean>; 47661847f8eSopenharmony_ci 47761847f8eSopenharmony_ci /** 47861847f8eSopenharmony_ci * Checks whether the default data network is activated. 47961847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 48061847f8eSopenharmony_ci * @returns { boolean } Returns true if the default data network is activated, else returns false. 48161847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 48261847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 48361847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 48461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 48561847f8eSopenharmony_ci * @since 10 48661847f8eSopenharmony_ci */ 48761847f8eSopenharmony_ci function hasDefaultNetSync(): boolean; 48861847f8eSopenharmony_ci 48961847f8eSopenharmony_ci /** 49061847f8eSopenharmony_ci * Enables the airplane mode for a device. 49161847f8eSopenharmony_ci * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission. 49261847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 49361847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback of enableAirplaneMode. 49461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 49561847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 49661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 49761847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 49861847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 49961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 50061847f8eSopenharmony_ci * @systemapi Hide this for inner system use. Only used for system app. 50161847f8eSopenharmony_ci * @since 8 50261847f8eSopenharmony_ci */ 50361847f8eSopenharmony_ci function enableAirplaneMode(callback: AsyncCallback<void>): void; 50461847f8eSopenharmony_ci 50561847f8eSopenharmony_ci /** 50661847f8eSopenharmony_ci * Enables the airplane mode for a device. 50761847f8eSopenharmony_ci * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission. 50861847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 50961847f8eSopenharmony_ci * @returns { Promise<void> } The promise returned by the function. 51061847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 51161847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 51261847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 51361847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 51461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 51561847f8eSopenharmony_ci * @systemapi Hide this for inner system use. Only used for system app. 51661847f8eSopenharmony_ci * @since 8 51761847f8eSopenharmony_ci */ 51861847f8eSopenharmony_ci function enableAirplaneMode(): Promise<void>; 51961847f8eSopenharmony_ci 52061847f8eSopenharmony_ci /** 52161847f8eSopenharmony_ci * Disables the airplane mode for a device. 52261847f8eSopenharmony_ci * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission. 52361847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 52461847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback of disableAirplaneMode. 52561847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 52661847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 52761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 52861847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 52961847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 53061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 53161847f8eSopenharmony_ci * @systemapi Hide this for inner system use. Only used for system app. 53261847f8eSopenharmony_ci * @since 8 53361847f8eSopenharmony_ci */ 53461847f8eSopenharmony_ci function disableAirplaneMode(callback: AsyncCallback<void>): void; 53561847f8eSopenharmony_ci 53661847f8eSopenharmony_ci /** 53761847f8eSopenharmony_ci * Disables the airplane mode for a device. 53861847f8eSopenharmony_ci * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission. 53961847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 54061847f8eSopenharmony_ci * @returns { Promise<void> } The promise returned by the function. 54161847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 54261847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 54361847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 54461847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 54561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 54661847f8eSopenharmony_ci * @systemapi Hide this for inner system use. Only used for system app. 54761847f8eSopenharmony_ci * @since 8 54861847f8eSopenharmony_ci */ 54961847f8eSopenharmony_ci function disableAirplaneMode(): Promise<void>; 55061847f8eSopenharmony_ci 55161847f8eSopenharmony_ci /** 55261847f8eSopenharmony_ci * Reports the network state is connected. 55361847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET 55461847f8eSopenharmony_ci * @param { NetHandle } netHandle - Indicates the network whose state is to be reported. 55561847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback of reportNetConnected. 55661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 55761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 55861847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 55961847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 56061847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 56161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 56261847f8eSopenharmony_ci * @since 8 56361847f8eSopenharmony_ci */ 56461847f8eSopenharmony_ci function reportNetConnected(netHandle: NetHandle, callback: AsyncCallback<void>): void; 56561847f8eSopenharmony_ci 56661847f8eSopenharmony_ci /** 56761847f8eSopenharmony_ci * Reports the network state is connected. 56861847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET 56961847f8eSopenharmony_ci * @param { NetHandle } netHandle - Indicates the network whose state is to be reported. 57061847f8eSopenharmony_ci * @returns { Promise<void> } The promise returned by the function. 57161847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 57261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 57361847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 57461847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 57561847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 57661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 57761847f8eSopenharmony_ci * @since 8 57861847f8eSopenharmony_ci */ 57961847f8eSopenharmony_ci function reportNetConnected(netHandle: NetHandle): Promise<void>; 58061847f8eSopenharmony_ci 58161847f8eSopenharmony_ci /** 58261847f8eSopenharmony_ci * Reports the network state is disconnected. 58361847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET 58461847f8eSopenharmony_ci * @param { NetHandle } netHandle - Indicates the network whose state is to be reported. 58561847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback of reportNetDisconnected. 58661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 58761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 58861847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 58961847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 59061847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 59161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 59261847f8eSopenharmony_ci * @since 8 59361847f8eSopenharmony_ci */ 59461847f8eSopenharmony_ci function reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback<void>): void; 59561847f8eSopenharmony_ci 59661847f8eSopenharmony_ci /** 59761847f8eSopenharmony_ci * Reports the network state is disconnected. 59861847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET 59961847f8eSopenharmony_ci * @param { NetHandle } netHandle - Indicates the network whose state is to be reported. 60061847f8eSopenharmony_ci * @returns { Promise<void> } The promise returned by the function. 60161847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 60261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 60361847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 60461847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 60561847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 60661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 60761847f8eSopenharmony_ci * @since 8 60861847f8eSopenharmony_ci */ 60961847f8eSopenharmony_ci function reportNetDisconnected(netHandle: NetHandle): Promise<void>; 61061847f8eSopenharmony_ci 61161847f8eSopenharmony_ci /** 61261847f8eSopenharmony_ci * Resolves the host name to obtain all IP addresses based on the default data network. 61361847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 61461847f8eSopenharmony_ci * @param { string } host - Indicates the host name or the domain. 61561847f8eSopenharmony_ci * @param { AsyncCallback<Array<NetAddress>> } callback - Returns the NetAddress list. 61661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 61761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 61861847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 61961847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 62061847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 62161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 62261847f8eSopenharmony_ci * @since 8 62361847f8eSopenharmony_ci */ 62461847f8eSopenharmony_ci function getAddressesByName(host: string, callback: AsyncCallback<Array<NetAddress>>): void; 62561847f8eSopenharmony_ci 62661847f8eSopenharmony_ci /** 62761847f8eSopenharmony_ci * Resolves the host name to obtain all IP addresses based on the default data network. 62861847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 62961847f8eSopenharmony_ci * @param { string } host - Indicates the host name or the domain. 63061847f8eSopenharmony_ci * @returns { Promise<Array<NetAddress>> } The promise returned by the function. 63161847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 63261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 63361847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 63461847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 63561847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 63661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 63761847f8eSopenharmony_ci * @since 8 63861847f8eSopenharmony_ci */ 63961847f8eSopenharmony_ci function getAddressesByName(host: string): Promise<Array<NetAddress>>; 64061847f8eSopenharmony_ci 64161847f8eSopenharmony_ci /** 64261847f8eSopenharmony_ci * Obtains the {@link NetHandle} bound to a process using {@link setAppNet}. 64361847f8eSopenharmony_ci * @param { AsyncCallback<NetHandle> } callback - Returns the {@link NetHandle} bound to the process; 64461847f8eSopenharmony_ci * returns {@code null} if no {@link NetHandle} is bound to the process.For details, see {@link NetHandle}. 64561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 64661847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 64761847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 64861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 64961847f8eSopenharmony_ci * @since 9 65061847f8eSopenharmony_ci */ 65161847f8eSopenharmony_ci function getAppNet(callback: AsyncCallback<NetHandle>): void; 65261847f8eSopenharmony_ci 65361847f8eSopenharmony_ci /** 65461847f8eSopenharmony_ci * Obtains the {@link NetHandle} bound to a process using {@link setAppNet}. 65561847f8eSopenharmony_ci * @returns { Promise<NetHandle> } the promise returned by the function. 65661847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 65761847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 65861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 65961847f8eSopenharmony_ci * @since 9 66061847f8eSopenharmony_ci */ 66161847f8eSopenharmony_ci function getAppNet(): Promise<NetHandle>; 66261847f8eSopenharmony_ci 66361847f8eSopenharmony_ci /** 66461847f8eSopenharmony_ci * Obtains the {@link NetHandle} bound to a process using {@link setAppNet}. 66561847f8eSopenharmony_ci * @returns { NetHandle } Returns the {@link NetHandle} bound to a process using {@link setAppNet}. 66661847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 66761847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 66861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 66961847f8eSopenharmony_ci * @since 10 67061847f8eSopenharmony_ci */ 67161847f8eSopenharmony_ci function getAppNetSync(): NetHandle; 67261847f8eSopenharmony_ci 67361847f8eSopenharmony_ci /** 67461847f8eSopenharmony_ci * Binds a process to {@code NetHandle}. 67561847f8eSopenharmony_ci * <p>All the sockets created from the process will be bound to the {@code NetHandle}, 67661847f8eSopenharmony_ci * and the resolution of all host names will be managed by the {@code NetHandle}.</p> 67761847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 67861847f8eSopenharmony_ci * @param { NetHandle } netHandle - Indicates the handle. For details, see {@link NetHandle}. 67961847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback of setAppNet. 68061847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 68161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 68261847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 68361847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 68461847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 68561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 68661847f8eSopenharmony_ci * @since 9 68761847f8eSopenharmony_ci */ 68861847f8eSopenharmony_ci function setAppNet(netHandle: NetHandle, callback: AsyncCallback<void>): void; 68961847f8eSopenharmony_ci 69061847f8eSopenharmony_ci /** 69161847f8eSopenharmony_ci * Binds a process to {@code NetHandle}. 69261847f8eSopenharmony_ci * <p>All the sockets created from the process will be bound to the {@code NetHandle}, 69361847f8eSopenharmony_ci * and the resolution of all host names will be managed by the {@code NetHandle}.</p> 69461847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 69561847f8eSopenharmony_ci * @param { NetHandle } netHandle - Indicates the handle. For details, see {@link NetHandle}. 69661847f8eSopenharmony_ci * @returns { Promise<void> } the promise returned by the function. 69761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 69861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 69961847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 70061847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 70161847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 70261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 70361847f8eSopenharmony_ci * @since 9 70461847f8eSopenharmony_ci */ 70561847f8eSopenharmony_ci function setAppNet(netHandle: NetHandle): Promise<void>; 70661847f8eSopenharmony_ci 70761847f8eSopenharmony_ci /** 70861847f8eSopenharmony_ci * Obtains the default {@link HttpProxy} proxy settings. 70961847f8eSopenharmony_ci * 71061847f8eSopenharmony_ci * If an application level proxy is set, the application level proxy parameters are returned. 71161847f8eSopenharmony_ci * If a global proxy is set, the global proxy parameters are returned. 71261847f8eSopenharmony_ci * If the process is bound to a {@link NetHandle} using {@link setAppNet}, the {@link NetHandle} proxy settings are returned. 71361847f8eSopenharmony_ci * In other cases, the proxy settings of default network are returned. 71461847f8eSopenharmony_ci * 71561847f8eSopenharmony_ci * @param { AsyncCallback<HttpProxy> } callback - Returns the default {@link HttpProxy} settings. 71661847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 71761847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 71861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 71961847f8eSopenharmony_ci * @since 10 72061847f8eSopenharmony_ci */ 72161847f8eSopenharmony_ci function getDefaultHttpProxy(callback: AsyncCallback<HttpProxy>): void; 72261847f8eSopenharmony_ci 72361847f8eSopenharmony_ci /** 72461847f8eSopenharmony_ci * Obtains the default {@link HttpProxy} proxy settings. 72561847f8eSopenharmony_ci * 72661847f8eSopenharmony_ci * If an application level proxy is set, the application level proxy parameters are returned. 72761847f8eSopenharmony_ci * If a global proxy is set, the global proxy parameters are returned. 72861847f8eSopenharmony_ci * If the process is bound to a {@link NetHandle} using {@link setAppNet}, the {@link NetHandle} proxy settings are returned. 72961847f8eSopenharmony_ci * In other cases, the proxy settings of default network are returned. 73061847f8eSopenharmony_ci * 73161847f8eSopenharmony_ci * @returns { Promise<HttpProxy> } the promise returned by the function. 73261847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 73361847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 73461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 73561847f8eSopenharmony_ci * @since 10 73661847f8eSopenharmony_ci */ 73761847f8eSopenharmony_ci function getDefaultHttpProxy(): Promise<HttpProxy>; 73861847f8eSopenharmony_ci 73961847f8eSopenharmony_ci /** 74061847f8eSopenharmony_ci * Obtains the network independent global {@link HttpProxy} proxy settings. 74161847f8eSopenharmony_ci * @param { AsyncCallback<HttpProxy> } callback - Returns the proxy settings. For details, see {@link HttpProxy}. 74261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 74361847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 74461847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 74561847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 74661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 74761847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 74861847f8eSopenharmony_ci * @since 10 74961847f8eSopenharmony_ci */ 75061847f8eSopenharmony_ci function getGlobalHttpProxy(callback: AsyncCallback<HttpProxy>): void; 75161847f8eSopenharmony_ci 75261847f8eSopenharmony_ci /** 75361847f8eSopenharmony_ci * Obtains the network independent global {@link HttpProxy} proxy settings. 75461847f8eSopenharmony_ci * @returns { Promise<HttpProxy> } the promise returned by the function. 75561847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 75661847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 75761847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 75861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 75961847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 76061847f8eSopenharmony_ci * @since 10 76161847f8eSopenharmony_ci */ 76261847f8eSopenharmony_ci function getGlobalHttpProxy(): Promise<HttpProxy>; 76361847f8eSopenharmony_ci 76461847f8eSopenharmony_ci /** 76561847f8eSopenharmony_ci * Set application level http proxy {@link HttpProxy}. 76661847f8eSopenharmony_ci * @param { HttpProxy } httpProxy - Indicates the application level proxy settings. For details, see {@link HttpProxy}. 76761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 76861847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid http proxy. 76961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 77061847f8eSopenharmony_ci * @since 11 77161847f8eSopenharmony_ci */ 77261847f8eSopenharmony_ci function setAppHttpProxy(httpProxy: HttpProxy): void; 77361847f8eSopenharmony_ci 77461847f8eSopenharmony_ci /** 77561847f8eSopenharmony_ci * Set a network independent global {@link HttpProxy} proxy settings. 77661847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 77761847f8eSopenharmony_ci * @param { HttpProxy } httpProxy - Indicates the global proxy settings. For details, see {@link HttpProxy}. 77861847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback of setGlobalHttpProxy. 77961847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 78061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 78161847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 78261847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 78361847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 78461847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 78561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 78661847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 78761847f8eSopenharmony_ci * @since 10 78861847f8eSopenharmony_ci */ 78961847f8eSopenharmony_ci function setGlobalHttpProxy(httpProxy: HttpProxy, callback: AsyncCallback<void>): void; 79061847f8eSopenharmony_ci 79161847f8eSopenharmony_ci /** 79261847f8eSopenharmony_ci * Set a network independent global {@link HttpProxy} proxy settings. 79361847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 79461847f8eSopenharmony_ci * @param { HttpProxy } httpProxy - Indicates the global proxy settings. For details, see {@link HttpProxy}. 79561847f8eSopenharmony_ci * @returns { Promise<void> } the promise returned by the function. 79661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 79761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 79861847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 79961847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 80061847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 80161847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 80261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 80361847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 80461847f8eSopenharmony_ci * @since 10 80561847f8eSopenharmony_ci */ 80661847f8eSopenharmony_ci function setGlobalHttpProxy(httpProxy: HttpProxy): Promise<void>; 80761847f8eSopenharmony_ci 80861847f8eSopenharmony_ci /** 80961847f8eSopenharmony_ci * Add a custom {@link host} and corresponding {@link ip} mapping for current application. 81061847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 81161847f8eSopenharmony_ci * @param { string } host - Indicates the host name or the domain. 81261847f8eSopenharmony_ci * @param { Array<string> } ip - List of IP addresses mapped to the host name. 81361847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - Returns the callback of addCustomDnsRule. 81461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 81561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 81661847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 81761847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 81861847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 81961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 82061847f8eSopenharmony_ci * @since 11 82161847f8eSopenharmony_ci */ 82261847f8eSopenharmony_ci function addCustomDnsRule(host: string, ip: Array<string>, callback: AsyncCallback<void>): void; 82361847f8eSopenharmony_ci 82461847f8eSopenharmony_ci /** 82561847f8eSopenharmony_ci * Add a custom {@link host} and corresponding {@link ip} mapping for current application. 82661847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 82761847f8eSopenharmony_ci * @param { string } host - Indicates the host name or the domain. 82861847f8eSopenharmony_ci * @param { Array<string> } ip - List of IP addresses mapped to the host name. 82961847f8eSopenharmony_ci * @returns { Promise<void> } the promise returned by the function. 83061847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 83161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 83261847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 83361847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 83461847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 83561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 83661847f8eSopenharmony_ci * @since 11 83761847f8eSopenharmony_ci */ 83861847f8eSopenharmony_ci function addCustomDnsRule(host: string, ip: Array<string>): Promise<void>; 83961847f8eSopenharmony_ci 84061847f8eSopenharmony_ci /** 84161847f8eSopenharmony_ci * Remove the custom DNS rule of the {@link host} for current application. 84261847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 84361847f8eSopenharmony_ci * @param { string } host - Indicates the host name or the domain. 84461847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - Returns the callback of removeCustomDnsRule. 84561847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 84661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 84761847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 84861847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 84961847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 85061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 85161847f8eSopenharmony_ci * @since 11 85261847f8eSopenharmony_ci */ 85361847f8eSopenharmony_ci function removeCustomDnsRule(host: string, callback: AsyncCallback<void>): void; 85461847f8eSopenharmony_ci 85561847f8eSopenharmony_ci /** 85661847f8eSopenharmony_ci * Remove the custom DNS rule of the {@link host} for current application. 85761847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 85861847f8eSopenharmony_ci * @param { string } host - Indicates the host name or the domain. 85961847f8eSopenharmony_ci * @returns { Promise<void> } the promise returned by the function. 86061847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 86161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 86261847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 86361847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 86461847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 86561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 86661847f8eSopenharmony_ci * @since 11 86761847f8eSopenharmony_ci */ 86861847f8eSopenharmony_ci function removeCustomDnsRule(host: string): Promise<void>; 86961847f8eSopenharmony_ci 87061847f8eSopenharmony_ci /** 87161847f8eSopenharmony_ci * Clear all custom DNS rules for current application. 87261847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 87361847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - Returns the callback of clearCustomDnsRules. 87461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 87561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 87661847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 87761847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 87861847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 87961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 88061847f8eSopenharmony_ci * @since 11 88161847f8eSopenharmony_ci */ 88261847f8eSopenharmony_ci function clearCustomDnsRules(callback: AsyncCallback<void>): void; 88361847f8eSopenharmony_ci 88461847f8eSopenharmony_ci /** 88561847f8eSopenharmony_ci * Clear all custom DNS rules for current application. 88661847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 88761847f8eSopenharmony_ci * @returns { Promise<void> } the promise returned by the function. 88861847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 88961847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 89061847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 89161847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 89261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 89361847f8eSopenharmony_ci * @since 11 89461847f8eSopenharmony_ci */ 89561847f8eSopenharmony_ci function clearCustomDnsRules(): Promise<void>; 89661847f8eSopenharmony_ci 89761847f8eSopenharmony_ci /** 89861847f8eSopenharmony_ci * factory reset network settings 89961847f8eSopenharmony_ci * 90061847f8eSopenharmony_ci * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission. 90161847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 90261847f8eSopenharmony_ci * @returns { Promise<void> } the promise returned by the function. 90361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 90461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 90561847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 90661847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 90761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 90861847f8eSopenharmony_ci * @systemapi Hide this for inner system use. Only used for system app. 90961847f8eSopenharmony_ci * @since 11 91061847f8eSopenharmony_ci */ 91161847f8eSopenharmony_ci function factoryReset(): Promise<void>; 91261847f8eSopenharmony_ci 91361847f8eSopenharmony_ci /** 91461847f8eSopenharmony_ci * Represents the network connection handle. 91561847f8eSopenharmony_ci * @interface NetConnection 91661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 91761847f8eSopenharmony_ci * @since 8 91861847f8eSopenharmony_ci */ 91961847f8eSopenharmony_ci /** 92061847f8eSopenharmony_ci * Represents the network connection handle. 92161847f8eSopenharmony_ci * @interface NetConnection 92261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 92361847f8eSopenharmony_ci * @crossplatform 92461847f8eSopenharmony_ci * @since 10 92561847f8eSopenharmony_ci */ 92661847f8eSopenharmony_ci /** 92761847f8eSopenharmony_ci * Represents the network connection handle. 92861847f8eSopenharmony_ci * @interface NetConnection 92961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 93061847f8eSopenharmony_ci * @crossplatform 93161847f8eSopenharmony_ci * @atomicservice 93261847f8eSopenharmony_ci * @since 11 93361847f8eSopenharmony_ci */ 93461847f8eSopenharmony_ci export interface NetConnection { 93561847f8eSopenharmony_ci /** 93661847f8eSopenharmony_ci * Registers a listener for netAvailable events. 93761847f8eSopenharmony_ci * @param { 'netAvailable' } type - Indicates Event name. 93861847f8eSopenharmony_ci * @param { Callback<NetHandle> } callback - the callback used to return the result. 93961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 94061847f8eSopenharmony_ci * @since 8 94161847f8eSopenharmony_ci */ 94261847f8eSopenharmony_ci /** 94361847f8eSopenharmony_ci * Registers a listener for netAvailable events. 94461847f8eSopenharmony_ci * @param { 'netAvailable' } type - Indicates Event name. 94561847f8eSopenharmony_ci * @param { Callback<NetHandle> } callback - the callback used to return the result. 94661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 94761847f8eSopenharmony_ci * @crossplatform 94861847f8eSopenharmony_ci * @since 10 94961847f8eSopenharmony_ci */ 95061847f8eSopenharmony_ci /** 95161847f8eSopenharmony_ci * Registers a listener for netAvailable events. 95261847f8eSopenharmony_ci * @param { 'netAvailable' } type - Indicates Event name. 95361847f8eSopenharmony_ci * @param { Callback<NetHandle> } callback - the callback used to return the result. 95461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 95561847f8eSopenharmony_ci * @crossplatform 95661847f8eSopenharmony_ci * @atomicservice 95761847f8eSopenharmony_ci * @since 11 95861847f8eSopenharmony_ci */ 95961847f8eSopenharmony_ci on(type: 'netAvailable', callback: Callback<NetHandle>): void; 96061847f8eSopenharmony_ci 96161847f8eSopenharmony_ci /** 96261847f8eSopenharmony_ci * Registers a listener for netBlockStatusChange events. 96361847f8eSopenharmony_ci * @param { 'netBlockStatusChange' } type - Indicates Event name. 96461847f8eSopenharmony_ci * @param { Callback<{ netHandle: NetHandle, blocked: boolean }> } callback - the callback used to return the result. 96561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 96661847f8eSopenharmony_ci * @since 8 96761847f8eSopenharmony_ci */ 96861847f8eSopenharmony_ci /** 96961847f8eSopenharmony_ci * Registers a listener for netBlockStatusChange events. 97061847f8eSopenharmony_ci * @param { 'netBlockStatusChange' } type - Indicates Event name. 97161847f8eSopenharmony_ci * @param { Callback<NetBlockStatusInfo> } callback - the callback used to return the result. 97261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 97361847f8eSopenharmony_ci * @since 11 97461847f8eSopenharmony_ci */ 97561847f8eSopenharmony_ci on(type: 'netBlockStatusChange', callback: Callback<NetBlockStatusInfo>): void; 97661847f8eSopenharmony_ci 97761847f8eSopenharmony_ci /** 97861847f8eSopenharmony_ci * Registers a listener for **netCapabilitiesChange** events. 97961847f8eSopenharmony_ci * @param { 'netCapabilitiesChange' } type - Indicates Event name. 98061847f8eSopenharmony_ci * @param { Callback<NetCapabilityInfo> } callback - the callback used to return the result. 98161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 98261847f8eSopenharmony_ci * @since 8 98361847f8eSopenharmony_ci */ 98461847f8eSopenharmony_ci /** 98561847f8eSopenharmony_ci * Registers a listener for **netCapabilitiesChange** events. 98661847f8eSopenharmony_ci * @param { 'netCapabilitiesChange' } type - Indicates Event name. 98761847f8eSopenharmony_ci * @param { Callback<NetCapabilityInfo> } callback - the callback used to return the result. 98861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 98961847f8eSopenharmony_ci * @crossplatform 99061847f8eSopenharmony_ci * @since 10 99161847f8eSopenharmony_ci */ 99261847f8eSopenharmony_ci /** 99361847f8eSopenharmony_ci * Registers a listener for **netCapabilitiesChange** events. 99461847f8eSopenharmony_ci * @param { 'netCapabilitiesChange' } type - Indicates Event name. 99561847f8eSopenharmony_ci * @param { Callback<NetCapabilityInfo> } callback - the callback used to return the result. 99661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 99761847f8eSopenharmony_ci * @crossplatform 99861847f8eSopenharmony_ci * @atomicservice 99961847f8eSopenharmony_ci * @since 11 100061847f8eSopenharmony_ci */ 100161847f8eSopenharmony_ci on(type: 'netCapabilitiesChange', callback: Callback<NetCapabilityInfo>): void; 100261847f8eSopenharmony_ci 100361847f8eSopenharmony_ci /** 100461847f8eSopenharmony_ci * Registers a listener for netConnectionPropertiesChange events. 100561847f8eSopenharmony_ci * @param { 'netConnectionPropertiesChange' } type - Indicates Event name. 100661847f8eSopenharmony_ci * @param { Callback<{ netHandle: NetHandle, connectionProperties: ConnectionProperties }> } callback - the callback used to return the result. 100761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 100861847f8eSopenharmony_ci * @since 8 100961847f8eSopenharmony_ci */ 101061847f8eSopenharmony_ci /** 101161847f8eSopenharmony_ci * Registers a listener for netConnectionPropertiesChange events. 101261847f8eSopenharmony_ci * @param { 'netConnectionPropertiesChange' } type - Indicates Event name. 101361847f8eSopenharmony_ci * @param { Callback<NetConnectionPropertyInfo> } callback - the callback used to return the result. 101461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 101561847f8eSopenharmony_ci * @since 11 101661847f8eSopenharmony_ci */ 101761847f8eSopenharmony_ci on(type: 'netConnectionPropertiesChange', callback: Callback<NetConnectionPropertyInfo>): void; 101861847f8eSopenharmony_ci 101961847f8eSopenharmony_ci /** 102061847f8eSopenharmony_ci * Registers a listener for **netLost** events. 102161847f8eSopenharmony_ci * @param { 'netLost' } type - Indicates Event name. 102261847f8eSopenharmony_ci * @param { Callback<NetHandle> } callback - the callback used to return the result. 102361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 102461847f8eSopenharmony_ci * @since 8 102561847f8eSopenharmony_ci */ 102661847f8eSopenharmony_ci /** 102761847f8eSopenharmony_ci * Registers a listener for **netLost** events. 102861847f8eSopenharmony_ci * @param { 'netLost' } type - Indicates Event name. 102961847f8eSopenharmony_ci * @param { Callback<NetHandle> } callback - the callback used to return the result. 103061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 103161847f8eSopenharmony_ci * @crossplatform 103261847f8eSopenharmony_ci * @since 10 103361847f8eSopenharmony_ci */ 103461847f8eSopenharmony_ci /** 103561847f8eSopenharmony_ci * Registers a listener for **netLost** events. 103661847f8eSopenharmony_ci * @param { 'netLost' } type - Indicates Event name. 103761847f8eSopenharmony_ci * @param { Callback<NetHandle> } callback - the callback used to return the result. 103861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 103961847f8eSopenharmony_ci * @crossplatform 104061847f8eSopenharmony_ci * @atomicservice 104161847f8eSopenharmony_ci * @since 11 104261847f8eSopenharmony_ci */ 104361847f8eSopenharmony_ci on(type: 'netLost', callback: Callback<NetHandle>): void; 104461847f8eSopenharmony_ci 104561847f8eSopenharmony_ci /** 104661847f8eSopenharmony_ci * Registers a listener for netUnavailable events. 104761847f8eSopenharmony_ci * @param { 'netUnavailable' } type - Indicates Event name. 104861847f8eSopenharmony_ci * @param { Callback<void> } callback - the callback used to return the result. 104961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 105061847f8eSopenharmony_ci * @since 8 105161847f8eSopenharmony_ci */ 105261847f8eSopenharmony_ci /** 105361847f8eSopenharmony_ci * Registers a listener for netUnavailable events. 105461847f8eSopenharmony_ci * @param { 'netUnavailable' } type - Indicates Event name. 105561847f8eSopenharmony_ci * @param { Callback<void> } callback - the callback used to return the result. 105661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 105761847f8eSopenharmony_ci * @crossplatform 105861847f8eSopenharmony_ci * @since 10 105961847f8eSopenharmony_ci */ 106061847f8eSopenharmony_ci /** 106161847f8eSopenharmony_ci * Registers a listener for netUnavailable events. 106261847f8eSopenharmony_ci * @param { 'netUnavailable' } type - Indicates Event name. 106361847f8eSopenharmony_ci * @param { Callback<void> } callback - the callback used to return the result. 106461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 106561847f8eSopenharmony_ci * @crossplatform 106661847f8eSopenharmony_ci * @atomicservice 106761847f8eSopenharmony_ci * @since 11 106861847f8eSopenharmony_ci */ 106961847f8eSopenharmony_ci on(type: 'netUnavailable', callback: Callback<void>): void; 107061847f8eSopenharmony_ci 107161847f8eSopenharmony_ci /** 107261847f8eSopenharmony_ci * Receives status change notifications of a specified network. 107361847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 107461847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback of register. 107561847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 107661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 107761847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 107861847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 107961847f8eSopenharmony_ci * @throws { BusinessError } 2101008 - The callback already exists. 108061847f8eSopenharmony_ci * @throws { BusinessError } 2101022 - The number of requests exceeded the maximum allowed. 108161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 108261847f8eSopenharmony_ci * @since 8 108361847f8eSopenharmony_ci */ 108461847f8eSopenharmony_ci /** 108561847f8eSopenharmony_ci * Receives status change notifications of a specified network. 108661847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 108761847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback of register. 108861847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 108961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 109061847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 109161847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 109261847f8eSopenharmony_ci * @throws { BusinessError } 2101008 - The callback already exists. 109361847f8eSopenharmony_ci * @throws { BusinessError } 2101022 - The number of requests exceeded the maximum allowed. 109461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 109561847f8eSopenharmony_ci * @crossplatform 109661847f8eSopenharmony_ci * @since 10 109761847f8eSopenharmony_ci */ 109861847f8eSopenharmony_ci /** 109961847f8eSopenharmony_ci * Receives status change notifications of a specified network. 110061847f8eSopenharmony_ci * @permission ohos.permission.GET_NETWORK_INFO 110161847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback of register. 110261847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 110361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 110461847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 110561847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 110661847f8eSopenharmony_ci * @throws { BusinessError } 2101008 - The callback already exists. 110761847f8eSopenharmony_ci * @throws { BusinessError } 2101022 - The number of requests exceeded the maximum allowed. 110861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 110961847f8eSopenharmony_ci * @crossplatform 111061847f8eSopenharmony_ci * @atomicservice 111161847f8eSopenharmony_ci * @since 11 111261847f8eSopenharmony_ci */ 111361847f8eSopenharmony_ci register(callback: AsyncCallback<void>): void; 111461847f8eSopenharmony_ci 111561847f8eSopenharmony_ci /** 111661847f8eSopenharmony_ci * Cancels listening for network status changes. 111761847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback of unregister. 111861847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 111961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 112061847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 112161847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 112261847f8eSopenharmony_ci * @throws { BusinessError } 2101007 - The callback does not exist. 112361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 112461847f8eSopenharmony_ci * @since 8 112561847f8eSopenharmony_ci */ 112661847f8eSopenharmony_ci /** 112761847f8eSopenharmony_ci * Cancels listening for network status changes. 112861847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback of unregister. 112961847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 113061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 113161847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 113261847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 113361847f8eSopenharmony_ci * @throws { BusinessError } 2101007 - The callback does not exist. 113461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 113561847f8eSopenharmony_ci * @crossplatform 113661847f8eSopenharmony_ci * @since 10 113761847f8eSopenharmony_ci */ 113861847f8eSopenharmony_ci /** 113961847f8eSopenharmony_ci * Cancels listening for network status changes. 114061847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback of unregister. 114161847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 114261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 114361847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 114461847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 114561847f8eSopenharmony_ci * @throws { BusinessError } 2101007 - The callback does not exist. 114661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 114761847f8eSopenharmony_ci * @crossplatform 114861847f8eSopenharmony_ci * @atomicservice 114961847f8eSopenharmony_ci * @since 11 115061847f8eSopenharmony_ci */ 115161847f8eSopenharmony_ci /** 115261847f8eSopenharmony_ci * Cancels listening for network status changes. 115361847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback of unregister. 115461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 115561847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 115661847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 115761847f8eSopenharmony_ci * @throws { BusinessError } 2101007 - The callback does not exist. 115861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 115961847f8eSopenharmony_ci * @crossplatform 116061847f8eSopenharmony_ci * @atomicservice 116161847f8eSopenharmony_ci * @since 12 116261847f8eSopenharmony_ci */ 116361847f8eSopenharmony_ci unregister(callback: AsyncCallback<void>): void; 116461847f8eSopenharmony_ci } 116561847f8eSopenharmony_ci 116661847f8eSopenharmony_ci /** 116761847f8eSopenharmony_ci * Provides an instance that bear data network capabilities. 116861847f8eSopenharmony_ci * @interface NetSpecifier 116961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 117061847f8eSopenharmony_ci * @since 8 117161847f8eSopenharmony_ci */ 117261847f8eSopenharmony_ci /** 117361847f8eSopenharmony_ci * Provides an instance that bear data network capabilities. 117461847f8eSopenharmony_ci * @interface NetSpecifier 117561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 117661847f8eSopenharmony_ci * @atomicservice 117761847f8eSopenharmony_ci * @since 11 117861847f8eSopenharmony_ci */ 117961847f8eSopenharmony_ci export interface NetSpecifier { 118061847f8eSopenharmony_ci /** 118161847f8eSopenharmony_ci * The transmission capacity and support of the network's global proxy storage data network. 118261847f8eSopenharmony_ci * @type {NetCapabilities} 118361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 118461847f8eSopenharmony_ci * @since 8 118561847f8eSopenharmony_ci */ 118661847f8eSopenharmony_ci /** 118761847f8eSopenharmony_ci * The transmission capacity and support of the network's global proxy storage data network. 118861847f8eSopenharmony_ci * @type {NetCapabilities} 118961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 119061847f8eSopenharmony_ci * @atomicservice 119161847f8eSopenharmony_ci * @since 11 119261847f8eSopenharmony_ci */ 119361847f8eSopenharmony_ci netCapabilities: NetCapabilities; 119461847f8eSopenharmony_ci 119561847f8eSopenharmony_ci /** 119661847f8eSopenharmony_ci * Network identifier, the identifier for Wi Fi networks is "wifi", and the identifier for cellular networks is "simId1" (corresponding to SIM card 1). 119761847f8eSopenharmony_ci * @type {?string} 119861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 119961847f8eSopenharmony_ci * @since 8 120061847f8eSopenharmony_ci */ 120161847f8eSopenharmony_ci /** 120261847f8eSopenharmony_ci * Network identifier, the identifier for Wi Fi networks is "wifi", and the identifier for cellular networks is "simId1" (corresponding to SIM card 1). 120361847f8eSopenharmony_ci * @type {?string} 120461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 120561847f8eSopenharmony_ci * @atomicservice 120661847f8eSopenharmony_ci * @since 11 120761847f8eSopenharmony_ci */ 120861847f8eSopenharmony_ci bearerPrivateIdentifier?: string; 120961847f8eSopenharmony_ci } 121061847f8eSopenharmony_ci 121161847f8eSopenharmony_ci /** 121261847f8eSopenharmony_ci * Receive information about changes in network capabilities. 121361847f8eSopenharmony_ci * @interface NetCapabilityInfo 121461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 121561847f8eSopenharmony_ci * @crossplatform 121661847f8eSopenharmony_ci * @since 10 121761847f8eSopenharmony_ci */ 121861847f8eSopenharmony_ci /** 121961847f8eSopenharmony_ci * Receive information about changes in network capabilities. 122061847f8eSopenharmony_ci * @interface NetCapabilityInfo 122161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 122261847f8eSopenharmony_ci * @crossplatform 122361847f8eSopenharmony_ci * @atomicservice 122461847f8eSopenharmony_ci * @since 11 122561847f8eSopenharmony_ci */ 122661847f8eSopenharmony_ci export interface NetCapabilityInfo { 122761847f8eSopenharmony_ci /** 122861847f8eSopenharmony_ci * Defines the handle of the data network. 122961847f8eSopenharmony_ci * @type { NetHandle } 123061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 123161847f8eSopenharmony_ci * @crossplatform 123261847f8eSopenharmony_ci * @since 10 123361847f8eSopenharmony_ci */ 123461847f8eSopenharmony_ci /** 123561847f8eSopenharmony_ci * Defines the handle of the data network. 123661847f8eSopenharmony_ci * @type { NetHandle } 123761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 123861847f8eSopenharmony_ci * @crossplatform 123961847f8eSopenharmony_ci * @atomicservice 124061847f8eSopenharmony_ci * @since 11 124161847f8eSopenharmony_ci */ 124261847f8eSopenharmony_ci netHandle: NetHandle; 124361847f8eSopenharmony_ci 124461847f8eSopenharmony_ci /** 124561847f8eSopenharmony_ci * Defines the network capability set. 124661847f8eSopenharmony_ci * @type { NetCapabilities } 124761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 124861847f8eSopenharmony_ci * @crossplatform 124961847f8eSopenharmony_ci * @since 10 125061847f8eSopenharmony_ci */ 125161847f8eSopenharmony_ci /** 125261847f8eSopenharmony_ci * Defines the network capability set. 125361847f8eSopenharmony_ci * @type { NetCapabilities } 125461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 125561847f8eSopenharmony_ci * @crossplatform 125661847f8eSopenharmony_ci * @atomicservice 125761847f8eSopenharmony_ci * @since 11 125861847f8eSopenharmony_ci */ 125961847f8eSopenharmony_ci netCap: NetCapabilities; 126061847f8eSopenharmony_ci } 126161847f8eSopenharmony_ci 126261847f8eSopenharmony_ci /** 126361847f8eSopenharmony_ci * Defines the handle of the data network. 126461847f8eSopenharmony_ci * @interface NetHandle 126561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 126661847f8eSopenharmony_ci * @since 8 126761847f8eSopenharmony_ci */ 126861847f8eSopenharmony_ci /** 126961847f8eSopenharmony_ci * Defines the handle of the data network. 127061847f8eSopenharmony_ci * @interface NetHandle 127161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 127261847f8eSopenharmony_ci * @crossplatform 127361847f8eSopenharmony_ci * @since 10 127461847f8eSopenharmony_ci */ 127561847f8eSopenharmony_ci /** 127661847f8eSopenharmony_ci * Defines the handle of the data network. 127761847f8eSopenharmony_ci * @interface NetHandle 127861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 127961847f8eSopenharmony_ci * @crossplatform 128061847f8eSopenharmony_ci * @atomicservice 128161847f8eSopenharmony_ci * @since 11 128261847f8eSopenharmony_ci */ 128361847f8eSopenharmony_ci export interface NetHandle { 128461847f8eSopenharmony_ci /** 128561847f8eSopenharmony_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. 128661847f8eSopenharmony_ci * @type {number} 128761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 128861847f8eSopenharmony_ci * @since 8 128961847f8eSopenharmony_ci */ 129061847f8eSopenharmony_ci /** 129161847f8eSopenharmony_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. 129261847f8eSopenharmony_ci * @type {number} 129361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 129461847f8eSopenharmony_ci * @crossplatform 129561847f8eSopenharmony_ci * @since 10 129661847f8eSopenharmony_ci */ 129761847f8eSopenharmony_ci /** 129861847f8eSopenharmony_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. 129961847f8eSopenharmony_ci * @type {number} 130061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 130161847f8eSopenharmony_ci * @crossplatform 130261847f8eSopenharmony_ci * @atomicservice 130361847f8eSopenharmony_ci * @since 11 130461847f8eSopenharmony_ci */ 130561847f8eSopenharmony_ci netId: number; 130661847f8eSopenharmony_ci 130761847f8eSopenharmony_ci /** 130861847f8eSopenharmony_ci * <p>Binds a TCPSocket or UDPSocket to the current network. All data flows from 130961847f8eSopenharmony_ci * the socket will use this network, without being subject to {@link setAppNet}.</p> 131061847f8eSopenharmony_ci * Before using this method, ensure that the socket is disconnected. 131161847f8eSopenharmony_ci * @param { TCPSocket | UDPSocket } socketParam - Indicates the TCPSocket or UDPSocket object. 131261847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback of bindSocket. 131361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 131461847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 131561847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 131661847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 131761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 131861847f8eSopenharmony_ci * @since 9 131961847f8eSopenharmony_ci */ 132061847f8eSopenharmony_ci bindSocket(socketParam: TCPSocket | UDPSocket, callback: AsyncCallback<void>): void; 132161847f8eSopenharmony_ci 132261847f8eSopenharmony_ci /** 132361847f8eSopenharmony_ci * <p>Binds a TCPSocket or UDPSocket to the current network. All data flows from 132461847f8eSopenharmony_ci * the socket will use this network, without being subject to {@link setAppNet}.</p> 132561847f8eSopenharmony_ci * Before using this method, ensure that the socket is disconnected. 132661847f8eSopenharmony_ci * @param { TCPSocket | UDPSocket } socketParam - Indicates the TCPSocket or UDPSocket object. 132761847f8eSopenharmony_ci * @returns { Promise<void> } the promise returned by the function. 132861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 132961847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 133061847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 133161847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 133261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 133361847f8eSopenharmony_ci * @since 9 133461847f8eSopenharmony_ci */ 133561847f8eSopenharmony_ci bindSocket(socketParam: TCPSocket | UDPSocket): Promise<void>; 133661847f8eSopenharmony_ci 133761847f8eSopenharmony_ci /** 133861847f8eSopenharmony_ci * Resolves a host name to obtain all IP addresses based on the specified NetHandle. 133961847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 134061847f8eSopenharmony_ci * @param { string } host - Indicates the host name or the domain. 134161847f8eSopenharmony_ci * @param { AsyncCallback<Array<NetAddress>> } callback - the callback of getAddressesByName. 134261847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 134361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 134461847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 134561847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 134661847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 134761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 134861847f8eSopenharmony_ci * @since 8 134961847f8eSopenharmony_ci */ 135061847f8eSopenharmony_ci getAddressesByName(host: string, callback: AsyncCallback<Array<NetAddress>>): void; 135161847f8eSopenharmony_ci 135261847f8eSopenharmony_ci /** 135361847f8eSopenharmony_ci * Resolves a host name to obtain all IP addresses based on the specified NetHandle. 135461847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 135561847f8eSopenharmony_ci * @param { string } host - Indicates the host name or the domain. 135661847f8eSopenharmony_ci * @returns { Promise<Array<NetAddress>> } The promise returned by the function. 135761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 135861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 135961847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 136061847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 136161847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 136261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 136361847f8eSopenharmony_ci * @since 8 136461847f8eSopenharmony_ci */ 136561847f8eSopenharmony_ci getAddressesByName(host: string): Promise<Array<NetAddress>>; 136661847f8eSopenharmony_ci 136761847f8eSopenharmony_ci /** 136861847f8eSopenharmony_ci * Resolves a host name to obtain the first IP address based on the specified NetHandle. 136961847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 137061847f8eSopenharmony_ci * @param { string } host - Indicates the host name or the domain. 137161847f8eSopenharmony_ci * @param { AsyncCallback<NetAddress> } callback - the callback of getAddressByName. 137261847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 137361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 137461847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 137561847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 137661847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 137761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 137861847f8eSopenharmony_ci * @since 8 137961847f8eSopenharmony_ci */ 138061847f8eSopenharmony_ci getAddressByName(host: string, callback: AsyncCallback<NetAddress>): void; 138161847f8eSopenharmony_ci 138261847f8eSopenharmony_ci /** 138361847f8eSopenharmony_ci * Resolves a host name to obtain the first IP address based on the specified NetHandle. 138461847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 138561847f8eSopenharmony_ci * @param { string } host - Indicates the host name or the domain. 138661847f8eSopenharmony_ci * @returns { Promise<NetAddress> } The promise returned by the function. 138761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 138861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 138961847f8eSopenharmony_ci * @throws { BusinessError } 2100001 - Invalid parameter value. 139061847f8eSopenharmony_ci * @throws { BusinessError } 2100002 - Failed to connect to the service. 139161847f8eSopenharmony_ci * @throws { BusinessError } 2100003 - System internal error. 139261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 139361847f8eSopenharmony_ci * @since 8 139461847f8eSopenharmony_ci */ 139561847f8eSopenharmony_ci getAddressByName(host: string): Promise<NetAddress>; 139661847f8eSopenharmony_ci } 139761847f8eSopenharmony_ci 139861847f8eSopenharmony_ci /** 139961847f8eSopenharmony_ci * Defines the network capability set. 140061847f8eSopenharmony_ci * @interface NetCapabilities 140161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 140261847f8eSopenharmony_ci * @since 8 140361847f8eSopenharmony_ci */ 140461847f8eSopenharmony_ci /** 140561847f8eSopenharmony_ci * Defines the network capability set. 140661847f8eSopenharmony_ci * @interface NetCapabilities 140761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 140861847f8eSopenharmony_ci * @crossplatform 140961847f8eSopenharmony_ci * @since 10 141061847f8eSopenharmony_ci */ 141161847f8eSopenharmony_ci /** 141261847f8eSopenharmony_ci * Defines the network capability set. 141361847f8eSopenharmony_ci * @interface NetCapabilities 141461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 141561847f8eSopenharmony_ci * @crossplatform 141661847f8eSopenharmony_ci * @atomicservice 141761847f8eSopenharmony_ci * @since 11 141861847f8eSopenharmony_ci */ 141961847f8eSopenharmony_ci export interface NetCapabilities { 142061847f8eSopenharmony_ci /** 142161847f8eSopenharmony_ci * Uplink (device-to-network) bandwidth. 142261847f8eSopenharmony_ci * @type {?number} 142361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 142461847f8eSopenharmony_ci * @since 8 142561847f8eSopenharmony_ci */ 142661847f8eSopenharmony_ci linkUpBandwidthKbps?: number; 142761847f8eSopenharmony_ci 142861847f8eSopenharmony_ci /** 142961847f8eSopenharmony_ci * Downstream (network-to-device) bandwidth. 143061847f8eSopenharmony_ci * @type {?number} 143161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 143261847f8eSopenharmony_ci * @since 8 143361847f8eSopenharmony_ci */ 143461847f8eSopenharmony_ci linkDownBandwidthKbps?: number; 143561847f8eSopenharmony_ci 143661847f8eSopenharmony_ci /** 143761847f8eSopenharmony_ci * Network-specific capabilities. 143861847f8eSopenharmony_ci * @type {?Array<NetCap>} 143961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 144061847f8eSopenharmony_ci * @since 8 144161847f8eSopenharmony_ci */ 144261847f8eSopenharmony_ci /** 144361847f8eSopenharmony_ci * Network-specific capabilities. 144461847f8eSopenharmony_ci * @type {?Array<NetCap>} 144561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 144661847f8eSopenharmony_ci * @atomicservice 144761847f8eSopenharmony_ci * @since 11 144861847f8eSopenharmony_ci */ 144961847f8eSopenharmony_ci networkCap?: Array<NetCap>; 145061847f8eSopenharmony_ci 145161847f8eSopenharmony_ci /** 145261847f8eSopenharmony_ci * Network type. 145361847f8eSopenharmony_ci * @type {Array<NetBearType>} 145461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 145561847f8eSopenharmony_ci * @since 8 145661847f8eSopenharmony_ci */ 145761847f8eSopenharmony_ci /** 145861847f8eSopenharmony_ci * Network type. 145961847f8eSopenharmony_ci * @type {Array<NetBearType>} 146061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 146161847f8eSopenharmony_ci * @crossplatform 146261847f8eSopenharmony_ci * @since 10 146361847f8eSopenharmony_ci */ 146461847f8eSopenharmony_ci /** 146561847f8eSopenharmony_ci * Network type. 146661847f8eSopenharmony_ci * @type {Array<NetBearType>} 146761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 146861847f8eSopenharmony_ci * @crossplatform 146961847f8eSopenharmony_ci * @atomicservice 147061847f8eSopenharmony_ci * @since 11 147161847f8eSopenharmony_ci */ 147261847f8eSopenharmony_ci bearerTypes: Array<NetBearType>; 147361847f8eSopenharmony_ci } 147461847f8eSopenharmony_ci 147561847f8eSopenharmony_ci /** 147661847f8eSopenharmony_ci * Get information about network connections. 147761847f8eSopenharmony_ci * @interface NetConnectionPropertyInfo 147861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 147961847f8eSopenharmony_ci * @since 11 148061847f8eSopenharmony_ci */ 148161847f8eSopenharmony_ci export interface NetConnectionPropertyInfo { 148261847f8eSopenharmony_ci /** 148361847f8eSopenharmony_ci * Defines the handle of the data network. 148461847f8eSopenharmony_ci * @type { NetHandle } 148561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 148661847f8eSopenharmony_ci * @since 11 148761847f8eSopenharmony_ci */ 148861847f8eSopenharmony_ci netHandle: NetHandle; 148961847f8eSopenharmony_ci /** 149061847f8eSopenharmony_ci * Defines the network connection properties. 149161847f8eSopenharmony_ci * @type { ConnectionProperties } 149261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 149361847f8eSopenharmony_ci * @since 11 149461847f8eSopenharmony_ci */ 149561847f8eSopenharmony_ci connectionProperties: ConnectionProperties; 149661847f8eSopenharmony_ci } 149761847f8eSopenharmony_ci 149861847f8eSopenharmony_ci /** 149961847f8eSopenharmony_ci * Get network status information. 150061847f8eSopenharmony_ci * @interface NetBlockStatusInfo 150161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 150261847f8eSopenharmony_ci * @since 11 150361847f8eSopenharmony_ci */ 150461847f8eSopenharmony_ci export interface NetBlockStatusInfo { 150561847f8eSopenharmony_ci /** 150661847f8eSopenharmony_ci * Defines the handle of the data network. 150761847f8eSopenharmony_ci * @type { NetHandle } 150861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 150961847f8eSopenharmony_ci * @since 11 151061847f8eSopenharmony_ci */ 151161847f8eSopenharmony_ci netHandle: NetHandle; 151261847f8eSopenharmony_ci /** 151361847f8eSopenharmony_ci * Check whether the current state is blocked. 151461847f8eSopenharmony_ci * @type { boolean } 151561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 151661847f8eSopenharmony_ci * @since 11 151761847f8eSopenharmony_ci */ 151861847f8eSopenharmony_ci blocked: boolean; 151961847f8eSopenharmony_ci } 152061847f8eSopenharmony_ci 152161847f8eSopenharmony_ci /** 152261847f8eSopenharmony_ci * Defines the network capability. 152361847f8eSopenharmony_ci * @enum {number} 152461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 152561847f8eSopenharmony_ci * @since 8 152661847f8eSopenharmony_ci */ 152761847f8eSopenharmony_ci /** 152861847f8eSopenharmony_ci * Defines the network capability. 152961847f8eSopenharmony_ci * @enum {number} 153061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 153161847f8eSopenharmony_ci * @atomicservice 153261847f8eSopenharmony_ci * @since 11 153361847f8eSopenharmony_ci */ 153461847f8eSopenharmony_ci export enum NetCap { 153561847f8eSopenharmony_ci /** 153661847f8eSopenharmony_ci * Indicates that the network can access the carrier's MMSC to send and receive multimedia messages. 153761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 153861847f8eSopenharmony_ci * @since 8 153961847f8eSopenharmony_ci */ 154061847f8eSopenharmony_ci /** 154161847f8eSopenharmony_ci * Indicates that the network can access the carrier's MMSC to send and receive multimedia messages. 154261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 154361847f8eSopenharmony_ci * @atomicservice 154461847f8eSopenharmony_ci * @since 11 154561847f8eSopenharmony_ci */ 154661847f8eSopenharmony_ci NET_CAPABILITY_MMS = 0, 154761847f8eSopenharmony_ci 154861847f8eSopenharmony_ci /** 154961847f8eSopenharmony_ci * Indicates that the network traffic is not metered. 155061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 155161847f8eSopenharmony_ci * @since 8 155261847f8eSopenharmony_ci */ 155361847f8eSopenharmony_ci /** 155461847f8eSopenharmony_ci * Indicates that the network traffic is not metered. 155561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 155661847f8eSopenharmony_ci * @atomicservice 155761847f8eSopenharmony_ci * @since 11 155861847f8eSopenharmony_ci */ 155961847f8eSopenharmony_ci NET_CAPABILITY_NOT_METERED = 11, 156061847f8eSopenharmony_ci 156161847f8eSopenharmony_ci /** 156261847f8eSopenharmony_ci * Indicates that the network can access the Internet. 156361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 156461847f8eSopenharmony_ci * @since 8 156561847f8eSopenharmony_ci */ 156661847f8eSopenharmony_ci /** 156761847f8eSopenharmony_ci * Indicates that the network can access the Internet. 156861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 156961847f8eSopenharmony_ci * @atomicservice 157061847f8eSopenharmony_ci * @since 11 157161847f8eSopenharmony_ci */ 157261847f8eSopenharmony_ci NET_CAPABILITY_INTERNET = 12, 157361847f8eSopenharmony_ci 157461847f8eSopenharmony_ci /** 157561847f8eSopenharmony_ci * Indicates that the network does not use a VPN. 157661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 157761847f8eSopenharmony_ci * @since 8 157861847f8eSopenharmony_ci */ 157961847f8eSopenharmony_ci /** 158061847f8eSopenharmony_ci * Indicates that the network does not use a VPN. 158161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 158261847f8eSopenharmony_ci * @atomicservice 158361847f8eSopenharmony_ci * @since 11 158461847f8eSopenharmony_ci */ 158561847f8eSopenharmony_ci NET_CAPABILITY_NOT_VPN = 15, 158661847f8eSopenharmony_ci 158761847f8eSopenharmony_ci /** 158861847f8eSopenharmony_ci * Indicates that the network is available. 158961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 159061847f8eSopenharmony_ci * @since 8 159161847f8eSopenharmony_ci */ 159261847f8eSopenharmony_ci /** 159361847f8eSopenharmony_ci * Indicates that the network is available. 159461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 159561847f8eSopenharmony_ci * @atomicservice 159661847f8eSopenharmony_ci * @since 11 159761847f8eSopenharmony_ci */ 159861847f8eSopenharmony_ci NET_CAPABILITY_VALIDATED = 16, 159961847f8eSopenharmony_ci /** 160061847f8eSopenharmony_ci * Indicates that the network is portal. 160161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 160261847f8eSopenharmony_ci * @atomicservice 160361847f8eSopenharmony_ci * @since 12 160461847f8eSopenharmony_ci */ 160561847f8eSopenharmony_ci NET_CAPABILITY_PORTAL = 17, 160661847f8eSopenharmony_ci 160761847f8eSopenharmony_ci /** 160861847f8eSopenharmony_ci * Indicates that the network is checking connectivity. 160961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 161061847f8eSopenharmony_ci * @atomicservice 161161847f8eSopenharmony_ci * @since 12 161261847f8eSopenharmony_ci */ 161361847f8eSopenharmony_ci NET_CAPABILITY_CHECKING_CONNECTIVITY = 31 161461847f8eSopenharmony_ci } 161561847f8eSopenharmony_ci 161661847f8eSopenharmony_ci /** 161761847f8eSopenharmony_ci * Enumerates network types. 161861847f8eSopenharmony_ci * @enum {number} 161961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 162061847f8eSopenharmony_ci * @since 8 162161847f8eSopenharmony_ci */ 162261847f8eSopenharmony_ci /** 162361847f8eSopenharmony_ci * Enumerates network types. 162461847f8eSopenharmony_ci * @enum {number} 162561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 162661847f8eSopenharmony_ci * @crossplatform 162761847f8eSopenharmony_ci * @since 10 162861847f8eSopenharmony_ci */ 162961847f8eSopenharmony_ci /** 163061847f8eSopenharmony_ci * Enumerates network types. 163161847f8eSopenharmony_ci * @enum {number} 163261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 163361847f8eSopenharmony_ci * @crossplatform 163461847f8eSopenharmony_ci * @atomicservice 163561847f8eSopenharmony_ci * @since 11 163661847f8eSopenharmony_ci */ 163761847f8eSopenharmony_ci export enum NetBearType { 163861847f8eSopenharmony_ci /** 163961847f8eSopenharmony_ci * Indicates that the network is based on a cellular network. 164061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 164161847f8eSopenharmony_ci * @since 8 164261847f8eSopenharmony_ci */ 164361847f8eSopenharmony_ci /** 164461847f8eSopenharmony_ci * Indicates that the network is based on a cellular network. 164561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 164661847f8eSopenharmony_ci * @crossplatform 164761847f8eSopenharmony_ci * @since 10 164861847f8eSopenharmony_ci */ 164961847f8eSopenharmony_ci /** 165061847f8eSopenharmony_ci * Indicates that the network is based on a cellular network. 165161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 165261847f8eSopenharmony_ci * @crossplatform 165361847f8eSopenharmony_ci * @atomicservice 165461847f8eSopenharmony_ci * @since 11 165561847f8eSopenharmony_ci */ 165661847f8eSopenharmony_ci BEARER_CELLULAR = 0, 165761847f8eSopenharmony_ci 165861847f8eSopenharmony_ci /** 165961847f8eSopenharmony_ci * Indicates that the network is based on a Wi-Fi network. 166061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 166161847f8eSopenharmony_ci * @since 8 166261847f8eSopenharmony_ci */ 166361847f8eSopenharmony_ci /** 166461847f8eSopenharmony_ci * Indicates that the network is based on a Wi-Fi network. 166561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 166661847f8eSopenharmony_ci * @crossplatform 166761847f8eSopenharmony_ci * @since 10 166861847f8eSopenharmony_ci */ 166961847f8eSopenharmony_ci /** 167061847f8eSopenharmony_ci * Indicates that the network is based on a Wi-Fi network. 167161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 167261847f8eSopenharmony_ci * @crossplatform 167361847f8eSopenharmony_ci * @atomicservice 167461847f8eSopenharmony_ci * @since 11 167561847f8eSopenharmony_ci */ 167661847f8eSopenharmony_ci BEARER_WIFI = 1, 167761847f8eSopenharmony_ci 167861847f8eSopenharmony_ci /** 167961847f8eSopenharmony_ci * Indicates that the network is based on a bluetooth network. 168061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 168161847f8eSopenharmony_ci * @crossplatform 168261847f8eSopenharmony_ci * @since 12 168361847f8eSopenharmony_ci */ 168461847f8eSopenharmony_ci BEARER_BLUETOOTH = 2, 168561847f8eSopenharmony_ci 168661847f8eSopenharmony_ci /** 168761847f8eSopenharmony_ci * Indicates that the network is an Ethernet network. 168861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 168961847f8eSopenharmony_ci * @since 8 169061847f8eSopenharmony_ci */ 169161847f8eSopenharmony_ci /** 169261847f8eSopenharmony_ci * Indicates that the network is an Ethernet network. 169361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 169461847f8eSopenharmony_ci * @atomicservice 169561847f8eSopenharmony_ci * @since 11 169661847f8eSopenharmony_ci */ 169761847f8eSopenharmony_ci BEARER_ETHERNET = 3, 169861847f8eSopenharmony_ci 169961847f8eSopenharmony_ci /** 170061847f8eSopenharmony_ci * Indicates that the network is based on a VPN network. 170161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 170261847f8eSopenharmony_ci * @since 12 170361847f8eSopenharmony_ci */ 170461847f8eSopenharmony_ci BEARER_VPN = 4, 170561847f8eSopenharmony_ci } 170661847f8eSopenharmony_ci 170761847f8eSopenharmony_ci /** 170861847f8eSopenharmony_ci * Defines the network connection properties. 170961847f8eSopenharmony_ci * @interface ConnectionProperties 171061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 171161847f8eSopenharmony_ci * @since 8 171261847f8eSopenharmony_ci */ 171361847f8eSopenharmony_ci export interface ConnectionProperties { 171461847f8eSopenharmony_ci /** 171561847f8eSopenharmony_ci * Network card name. 171661847f8eSopenharmony_ci * @type {string} 171761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 171861847f8eSopenharmony_ci * @since 8 171961847f8eSopenharmony_ci */ 172061847f8eSopenharmony_ci interfaceName: string; 172161847f8eSopenharmony_ci /** 172261847f8eSopenharmony_ci * Domain. The default value is "". 172361847f8eSopenharmony_ci * @type {string} 172461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 172561847f8eSopenharmony_ci * @since 8 172661847f8eSopenharmony_ci */ 172761847f8eSopenharmony_ci domains: string; 172861847f8eSopenharmony_ci /** 172961847f8eSopenharmony_ci * Link information. 173061847f8eSopenharmony_ci * @type {Array<LinkAddress>} 173161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 173261847f8eSopenharmony_ci * @since 8 173361847f8eSopenharmony_ci */ 173461847f8eSopenharmony_ci linkAddresses: Array<LinkAddress>; 173561847f8eSopenharmony_ci 173661847f8eSopenharmony_ci /** 173761847f8eSopenharmony_ci * Network address, refer to [NetAddress]. 173861847f8eSopenharmony_ci * @type {Array<NetAddress>} 173961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 174061847f8eSopenharmony_ci * @since 8 174161847f8eSopenharmony_ci */ 174261847f8eSopenharmony_ci dnses: Array<NetAddress>; 174361847f8eSopenharmony_ci 174461847f8eSopenharmony_ci /** 174561847f8eSopenharmony_ci * Routing information. 174661847f8eSopenharmony_ci * @type {Array<RouteInfo>} 174761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 174861847f8eSopenharmony_ci * @since 8 174961847f8eSopenharmony_ci */ 175061847f8eSopenharmony_ci routes: Array<RouteInfo>; 175161847f8eSopenharmony_ci 175261847f8eSopenharmony_ci /** 175361847f8eSopenharmony_ci * Maximum transmission unit. 175461847f8eSopenharmony_ci * @type {number} 175561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 175661847f8eSopenharmony_ci * @since 8 175761847f8eSopenharmony_ci */ 175861847f8eSopenharmony_ci mtu: number; 175961847f8eSopenharmony_ci } 176061847f8eSopenharmony_ci 176161847f8eSopenharmony_ci /** 176261847f8eSopenharmony_ci * Defines network route information. 176361847f8eSopenharmony_ci * @interface RouteInfo 176461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 176561847f8eSopenharmony_ci * @since 8 176661847f8eSopenharmony_ci */ 176761847f8eSopenharmony_ci export interface RouteInfo { 176861847f8eSopenharmony_ci /** 176961847f8eSopenharmony_ci * Network card name. 177061847f8eSopenharmony_ci * @type {string} 177161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 177261847f8eSopenharmony_ci * @since 8 177361847f8eSopenharmony_ci */ 177461847f8eSopenharmony_ci interface: string; 177561847f8eSopenharmony_ci 177661847f8eSopenharmony_ci /** 177761847f8eSopenharmony_ci * Destination Address 177861847f8eSopenharmony_ci * @type {LinkAddress} 177961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 178061847f8eSopenharmony_ci * @since 8 178161847f8eSopenharmony_ci */ 178261847f8eSopenharmony_ci destination: LinkAddress; 178361847f8eSopenharmony_ci 178461847f8eSopenharmony_ci /** 178561847f8eSopenharmony_ci * Gateway address. 178661847f8eSopenharmony_ci * @type {NetAddress} 178761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 178861847f8eSopenharmony_ci * @since 8 178961847f8eSopenharmony_ci */ 179061847f8eSopenharmony_ci gateway: NetAddress; 179161847f8eSopenharmony_ci 179261847f8eSopenharmony_ci /** 179361847f8eSopenharmony_ci * Whether a gateway is present. 179461847f8eSopenharmony_ci * @type {boolean} 179561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 179661847f8eSopenharmony_ci * @since 8 179761847f8eSopenharmony_ci */ 179861847f8eSopenharmony_ci hasGateway: boolean; 179961847f8eSopenharmony_ci 180061847f8eSopenharmony_ci /** 180161847f8eSopenharmony_ci * Whether the route is the default route. 180261847f8eSopenharmony_ci * @type {boolean} 180361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 180461847f8eSopenharmony_ci * @since 8 180561847f8eSopenharmony_ci */ 180661847f8eSopenharmony_ci isDefaultRoute: boolean; 180761847f8eSopenharmony_ci } 180861847f8eSopenharmony_ci 180961847f8eSopenharmony_ci /** 181061847f8eSopenharmony_ci * Defines network link information. 181161847f8eSopenharmony_ci * @interface LinkAddress 181261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 181361847f8eSopenharmony_ci * @since 8 181461847f8eSopenharmony_ci */ 181561847f8eSopenharmony_ci export interface LinkAddress { 181661847f8eSopenharmony_ci /** 181761847f8eSopenharmony_ci * Link address. 181861847f8eSopenharmony_ci * @type {NetAddress} 181961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 182061847f8eSopenharmony_ci * @since 8 182161847f8eSopenharmony_ci */ 182261847f8eSopenharmony_ci address: NetAddress; 182361847f8eSopenharmony_ci /** 182461847f8eSopenharmony_ci * The length of the link address prefix. 182561847f8eSopenharmony_ci * @type {number} 182661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 182761847f8eSopenharmony_ci * @since 8 182861847f8eSopenharmony_ci */ 182961847f8eSopenharmony_ci prefixLength: number; 183061847f8eSopenharmony_ci } 183161847f8eSopenharmony_ci 183261847f8eSopenharmony_ci /** 183361847f8eSopenharmony_ci * Defines a network address. 183461847f8eSopenharmony_ci * @interface NetAddress 183561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 183661847f8eSopenharmony_ci * @since 8 183761847f8eSopenharmony_ci */ 183861847f8eSopenharmony_ci /** 183961847f8eSopenharmony_ci * Defines a network address. 184061847f8eSopenharmony_ci * @interface NetAddress 184161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 184261847f8eSopenharmony_ci * @atomicservice 184361847f8eSopenharmony_ci * @since 12 184461847f8eSopenharmony_ci */ 184561847f8eSopenharmony_ci export interface NetAddress { 184661847f8eSopenharmony_ci /** 184761847f8eSopenharmony_ci * Network address. 184861847f8eSopenharmony_ci * @type {string} 184961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 185061847f8eSopenharmony_ci * @since 8 185161847f8eSopenharmony_ci */ 185261847f8eSopenharmony_ci /** 185361847f8eSopenharmony_ci * Network address. 185461847f8eSopenharmony_ci * @type {string} 185561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 185661847f8eSopenharmony_ci * @atomicservice 185761847f8eSopenharmony_ci * @since 12 185861847f8eSopenharmony_ci */ 185961847f8eSopenharmony_ci address: string; 186061847f8eSopenharmony_ci 186161847f8eSopenharmony_ci /** 186261847f8eSopenharmony_ci * Address family identifier. The value is 1 for IPv4 and 2 for IPv6. The default value is 1. 186361847f8eSopenharmony_ci * @type {?number} 186461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 186561847f8eSopenharmony_ci * @since 8 186661847f8eSopenharmony_ci */ 186761847f8eSopenharmony_ci /** 186861847f8eSopenharmony_ci * Address family identifier. The value is 1 for IPv4 and 2 for IPv6. The default value is 1. 186961847f8eSopenharmony_ci * @type {?number} 187061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 187161847f8eSopenharmony_ci * @atomicservice 187261847f8eSopenharmony_ci * @since 12 187361847f8eSopenharmony_ci */ 187461847f8eSopenharmony_ci family?: number; 187561847f8eSopenharmony_ci 187661847f8eSopenharmony_ci /** 187761847f8eSopenharmony_ci * Port number. The value ranges from 0 to 65535. 187861847f8eSopenharmony_ci * @type {?number} 187961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 188061847f8eSopenharmony_ci * @since 8 188161847f8eSopenharmony_ci */ 188261847f8eSopenharmony_ci /** 188361847f8eSopenharmony_ci * Port number. The value ranges from 0 to 65535. 188461847f8eSopenharmony_ci * @type {?number} 188561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 188661847f8eSopenharmony_ci * @atomicservice 188761847f8eSopenharmony_ci * @since 12 188861847f8eSopenharmony_ci */ 188961847f8eSopenharmony_ci port?: number; 189061847f8eSopenharmony_ci } 189161847f8eSopenharmony_ci 189261847f8eSopenharmony_ci /** 189361847f8eSopenharmony_ci * Network Global Proxy Configuration Information. 189461847f8eSopenharmony_ci * @interface HttpProxy 189561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 189661847f8eSopenharmony_ci * @since 10 189761847f8eSopenharmony_ci */ 189861847f8eSopenharmony_ci /** 189961847f8eSopenharmony_ci * Network Global Proxy Configuration Information. 190061847f8eSopenharmony_ci * @interface HttpProxy 190161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 190261847f8eSopenharmony_ci * @atomicservice 190361847f8eSopenharmony_ci * @since 11 190461847f8eSopenharmony_ci */ 190561847f8eSopenharmony_ci export interface HttpProxy { 190661847f8eSopenharmony_ci /** 190761847f8eSopenharmony_ci * Proxy server host name. 190861847f8eSopenharmony_ci * @type {string} 190961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 191061847f8eSopenharmony_ci * @since 10 191161847f8eSopenharmony_ci */ 191261847f8eSopenharmony_ci /** 191361847f8eSopenharmony_ci * Proxy server host name. 191461847f8eSopenharmony_ci * @type {string} 191561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 191661847f8eSopenharmony_ci * @atomicservice 191761847f8eSopenharmony_ci * @since 11 191861847f8eSopenharmony_ci */ 191961847f8eSopenharmony_ci host: string; 192061847f8eSopenharmony_ci 192161847f8eSopenharmony_ci /** 192261847f8eSopenharmony_ci * Host port. 192361847f8eSopenharmony_ci * @type {number} 192461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 192561847f8eSopenharmony_ci * @since 10 192661847f8eSopenharmony_ci */ 192761847f8eSopenharmony_ci /** 192861847f8eSopenharmony_ci * Host port. 192961847f8eSopenharmony_ci * @type {number} 193061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 193161847f8eSopenharmony_ci * @atomicservice 193261847f8eSopenharmony_ci * @since 11 193361847f8eSopenharmony_ci */ 193461847f8eSopenharmony_ci port: number; 193561847f8eSopenharmony_ci 193661847f8eSopenharmony_ci /** 193761847f8eSopenharmony_ci * Http proxy username. 193861847f8eSopenharmony_ci * @type {?string} 193961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 194061847f8eSopenharmony_ci * @since 12 194161847f8eSopenharmony_ci */ 194261847f8eSopenharmony_ci username?: string; 194361847f8eSopenharmony_ci 194461847f8eSopenharmony_ci /** 194561847f8eSopenharmony_ci * Http proxy password. 194661847f8eSopenharmony_ci * @type {?string} 194761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 194861847f8eSopenharmony_ci * @since 12 194961847f8eSopenharmony_ci */ 195061847f8eSopenharmony_ci password?: string; 195161847f8eSopenharmony_ci 195261847f8eSopenharmony_ci /** 195361847f8eSopenharmony_ci * Do not use a blocking list for proxy servers. 195461847f8eSopenharmony_ci * @type {Array<string>} 195561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 195661847f8eSopenharmony_ci * @since 10 195761847f8eSopenharmony_ci */ 195861847f8eSopenharmony_ci /** 195961847f8eSopenharmony_ci * Do not use a blocking list for proxy servers. 196061847f8eSopenharmony_ci * @type {Array<string>} 196161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 196261847f8eSopenharmony_ci * @atomicservice 196361847f8eSopenharmony_ci * @since 11 196461847f8eSopenharmony_ci */ 196561847f8eSopenharmony_ci exclusionList: Array<string>; 196661847f8eSopenharmony_ci } 196761847f8eSopenharmony_ci} 196861847f8eSopenharmony_ci 196961847f8eSopenharmony_ciexport default connection; 1970