1 Star 0 Fork 4K

Feng Lin/interface_sdk-js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
@ohos.net.connection.d.ts 76.39 KB
一键复制 编辑 原始数据 按行查看 历史
NoCodeNoBB 提交于 2024-08-15 17:29 +08:00 . 网络管理新增枚举
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969
/*
* Copyright (C) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @kit NetworkKit
*/
import type { AsyncCallback, Callback } from './@ohos.base';
import type http from './@ohos.net.http';
import type socket from './@ohos.net.socket';
/**
* Provides interfaces to manage and use data networks.
* @namespace connection
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Provides interfaces to manage and use data networks.
* @namespace connection
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Provides interfaces to manage and use data networks.
* @namespace connection
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
declare namespace connection {
/**
* Get an HTTP request task.
* @syscap SystemCapability.Communication.NetStack
* @since 8
*/
/**
* Get an HTTP request task.
* @syscap SystemCapability.Communication.NetStack
* @crossplatform
* @since 10
*/
/**
* Get an HTTP request task.
* @typedef { http.HttpRequest }
* @syscap SystemCapability.Communication.NetStack
* @crossplatform
* @atomicservice
* @since 11
*/
type HttpRequest = http.HttpRequest;
/**
* Get a TCPSocket object.
* @syscap SystemCapability.Communication.NetStack
* @since 8
*/
/**
* Get a TCPSocket object.
* @typedef { socket.TCPSocket }
* @syscap SystemCapability.Communication.NetStack
* @crossplatform
* @since 10
*/
type TCPSocket = socket.TCPSocket;
/**
* Get a UDPSocket object.
* @syscap SystemCapability.Communication.NetStack
* @since 8
*/
/**
* Get a UDPSocket object.
* @typedef { socket.UDPSocket }
* @syscap SystemCapability.Communication.NetStack
* @crossplatform
* @since 10
*/
type UDPSocket = socket.UDPSocket;
/**
* Create a network connection with optional netSpecifier and timeout.
* @param { NetSpecifier } [netSpecifier] - Indicates the network specifier. See {@link NetSpecifier}.
* @param { number } [timeout] - The time in milliseconds to attempt looking for a suitable network before
* {@link NetConnection#netUnavailable} is called.
* @returns { NetConnection } the NetConnection of the NetSpecifier.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Create a network connection with optional netSpecifier and timeout.
* @param { NetSpecifier } [netSpecifier] - Indicates the network specifier. See {@link NetSpecifier}.
* @param { number } [timeout] - The time in milliseconds to attempt looking for a suitable network before
* {@link NetConnection#netUnavailable} is called.
* @returns { NetConnection } the NetConnection of the NetSpecifier.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Create a network connection with optional netSpecifier and timeout.
* @param { NetSpecifier } [netSpecifier] - Indicates the network specifier. See {@link NetSpecifier}.
* @param { number } [timeout] - The time in milliseconds to attempt looking for a suitable network before
* {@link NetConnection#netUnavailable} is called.
* @returns { NetConnection } the NetConnection of the NetSpecifier.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
function createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection;
/**
* Obtains the data network that is activated by default.
* To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { AsyncCallback<NetHandle> } callback - the callback of getDefaultNet.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Obtains the data network that is activated by default.
* To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { AsyncCallback<NetHandle> } callback - the callback of getDefaultNet.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
function getDefaultNet(callback: AsyncCallback<NetHandle>): void;
/**
* Obtains the data network that is activated by default.
* To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @returns { Promise<NetHandle> } The promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Obtains the data network that is activated by default.
* To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @returns { Promise<NetHandle> } The promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
function getDefaultNet(): Promise<NetHandle>;
/**
* Obtains the data network that is activated by default.
* To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @returns { NetHandle } if the default network is not activated.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 9
*/
/**
* Obtains the data network that is activated by default.
* To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @returns { NetHandle } if the default network is not activated.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
function getDefaultNetSync(): NetHandle;
/**
* Obtains the list of data networks that are activated.
* To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { AsyncCallback<Array<NetHandle>> } callback - the callback of getAllNets.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
function getAllNets(callback: AsyncCallback<Array<NetHandle>>): void;
/**
* Obtains the list of data networks that are activated.
* To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @returns { Promise<Array<NetHandle>> } The promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
function getAllNets(): Promise<Array<NetHandle>>;
/**
* Obtains the list of data networks that are activated.
* To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @returns { Array<NetHandle> } Returns data networks that are activated.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 10
*/
function getAllNetsSync(): Array<NetHandle>;
/**
* Queries the connection properties of a network.
* This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { NetHandle } netHandle - Indicates the network to be queried.
* @param { AsyncCallback<ConnectionProperties> } callback - the callback of getConnectionProperties.{@link ConnectionProperties}.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
function getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback<ConnectionProperties>): void;
/**
* Queries the connection properties of a network.
* This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { NetHandle } netHandle - Indicates the network to be queried.
* @returns { Promise<ConnectionProperties> } The promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
function getConnectionProperties(netHandle: NetHandle): Promise<ConnectionProperties>;
/**
* Queries the connection properties of a network.
* This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { NetHandle } netHandle - Indicates the network to be queried.
* @returns { ConnectionProperties } Returns the connection properties of a network.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 10
*/
function getConnectionPropertiesSync(netHandle: NetHandle): ConnectionProperties;
/**
* Obtains {@link NetCapabilities} of a {@link NetHandle} object.
* To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}.
* @param { AsyncCallback<NetCapabilities> } callback - the callback of getNetCapabilities.{@link NetCapabilities}.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Obtains {@link NetCapabilities} of a {@link NetHandle} object.
* To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}.
* @param { AsyncCallback<NetCapabilities> } callback - the callback of getNetCapabilities.{@link NetCapabilities}.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback<NetCapabilities>): void;
/**
* Obtains {@link NetCapabilities} of a {@link NetHandle} object.
* To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}.
* @returns { Promise<NetCapabilities> } The promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Obtains {@link NetCapabilities} of a {@link NetHandle} object.
* To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}.
* @returns { Promise<NetCapabilities> } The promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
function getNetCapabilities(netHandle: NetHandle): Promise<NetCapabilities>;
/**
* Obtains {@link NetCapabilities} of a {@link NetHandle} object.
* To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}.
* @returns { NetCapabilities } Returns the connection capabilities of a network.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 10
*/
/**
* Obtains {@link NetCapabilities} of a {@link NetHandle} object.
* To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}.
* @returns { NetCapabilities } Returns the connection capabilities of a network.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
function getNetCapabilitiesSync(netHandle: NetHandle): NetCapabilities;
/**
* Checks whether data traffic usage on the current network is metered.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { AsyncCallback<boolean> } callback - Returns {@code true} if data traffic usage on the current network is metered;
* returns {@code false} otherwise.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 9
*/
function isDefaultNetMetered(callback: AsyncCallback<boolean>): void;
/**
* Checks whether data traffic usage on the current network is metered.
* @permission ohos.permission.GET_NETWORK_INFO
* @returns { Promise<boolean> } the promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 9
*/
function isDefaultNetMetered(): Promise<boolean>;
/**
* Checks whether data traffic usage on the current network is metered.
* @permission ohos.permission.GET_NETWORK_INFO
* @returns { boolean } Returns true if the current network is metered, else returns false.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 10
*/
function isDefaultNetMeteredSync(): boolean;
/**
* Checks whether the default data network is activated.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { AsyncCallback<boolean> } callback - Returns {@code true} if the default data network is activated;
* returns {@code false} otherwise.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Checks whether the default data network is activated.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { AsyncCallback<boolean> } callback - Returns {@code true} if the default data network is activated;
* returns {@code false} otherwise.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
function hasDefaultNet(callback: AsyncCallback<boolean>): void;
/**
* Checks whether the default data network is activated.
* @permission ohos.permission.GET_NETWORK_INFO
* @returns { Promise<boolean> } The promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Checks whether the default data network is activated.
* @permission ohos.permission.GET_NETWORK_INFO
* @returns { Promise<boolean> } The promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
function hasDefaultNet(): Promise<boolean>;
/**
* Checks whether the default data network is activated.
* @permission ohos.permission.GET_NETWORK_INFO
* @returns { boolean } Returns true if the default data network is activated, else returns false.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 10
*/
function hasDefaultNetSync(): boolean;
/**
* Enables the airplane mode for a device.
* To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
* @permission ohos.permission.CONNECTIVITY_INTERNAL
* @param { AsyncCallback<void> } callback - the callback of enableAirplaneMode.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @systemapi Hide this for inner system use. Only used for system app.
* @since 8
*/
function enableAirplaneMode(callback: AsyncCallback<void>): void;
/**
* Enables the airplane mode for a device.
* To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
* @permission ohos.permission.CONNECTIVITY_INTERNAL
* @returns { Promise<void> } The promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @systemapi Hide this for inner system use. Only used for system app.
* @since 8
*/
function enableAirplaneMode(): Promise<void>;
/**
* Disables the airplane mode for a device.
* To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
* @permission ohos.permission.CONNECTIVITY_INTERNAL
* @param { AsyncCallback<void> } callback - the callback of disableAirplaneMode.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @systemapi Hide this for inner system use. Only used for system app.
* @since 8
*/
function disableAirplaneMode(callback: AsyncCallback<void>): void;
/**
* Disables the airplane mode for a device.
* To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
* @permission ohos.permission.CONNECTIVITY_INTERNAL
* @returns { Promise<void> } The promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @systemapi Hide this for inner system use. Only used for system app.
* @since 8
*/
function disableAirplaneMode(): Promise<void>;
/**
* Reports the network state is connected.
* @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
* @param { NetHandle } netHandle - Indicates the network whose state is to be reported.
* @param { AsyncCallback<void> } callback - the callback of reportNetConnected.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
function reportNetConnected(netHandle: NetHandle, callback: AsyncCallback<void>): void;
/**
* Reports the network state is connected.
* @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
* @param { NetHandle } netHandle - Indicates the network whose state is to be reported.
* @returns { Promise<void> } The promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
function reportNetConnected(netHandle: NetHandle): Promise<void>;
/**
* Reports the network state is disconnected.
* @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
* @param { NetHandle } netHandle - Indicates the network whose state is to be reported.
* @param { AsyncCallback<void> } callback - the callback of reportNetDisconnected.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
function reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback<void>): void;
/**
* Reports the network state is disconnected.
* @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
* @param { NetHandle } netHandle - Indicates the network whose state is to be reported.
* @returns { Promise<void> } The promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
function reportNetDisconnected(netHandle: NetHandle): Promise<void>;
/**
* Resolves the host name to obtain all IP addresses based on the default data network.
* @permission ohos.permission.INTERNET
* @param { string } host - Indicates the host name or the domain.
* @param { AsyncCallback<Array<NetAddress>> } callback - Returns the NetAddress list.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
function getAddressesByName(host: string, callback: AsyncCallback<Array<NetAddress>>): void;
/**
* Resolves the host name to obtain all IP addresses based on the default data network.
* @permission ohos.permission.INTERNET
* @param { string } host - Indicates the host name or the domain.
* @returns { Promise<Array<NetAddress>> } The promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
function getAddressesByName(host: string): Promise<Array<NetAddress>>;
/**
* Obtains the {@link NetHandle} bound to a process using {@link setAppNet}.
* @param { AsyncCallback<NetHandle> } callback - Returns the {@link NetHandle} bound to the process;
* returns {@code null} if no {@link NetHandle} is bound to the process.For details, see {@link NetHandle}.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 9
*/
function getAppNet(callback: AsyncCallback<NetHandle>): void;
/**
* Obtains the {@link NetHandle} bound to a process using {@link setAppNet}.
* @returns { Promise<NetHandle> } the promise returned by the function.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 9
*/
function getAppNet(): Promise<NetHandle>;
/**
* Obtains the {@link NetHandle} bound to a process using {@link setAppNet}.
* @returns { NetHandle } Returns the {@link NetHandle} bound to a process using {@link setAppNet}.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 10
*/
function getAppNetSync(): NetHandle;
/**
* Binds a process to {@code NetHandle}.
* <p>All the sockets created from the process will be bound to the {@code NetHandle},
* and the resolution of all host names will be managed by the {@code NetHandle}.</p>
* @permission ohos.permission.INTERNET
* @param { NetHandle } netHandle - Indicates the handle. For details, see {@link NetHandle}.
* @param { AsyncCallback<void> } callback - the callback of setAppNet.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 9
*/
function setAppNet(netHandle: NetHandle, callback: AsyncCallback<void>): void;
/**
* Binds a process to {@code NetHandle}.
* <p>All the sockets created from the process will be bound to the {@code NetHandle},
* and the resolution of all host names will be managed by the {@code NetHandle}.</p>
* @permission ohos.permission.INTERNET
* @param { NetHandle } netHandle - Indicates the handle. For details, see {@link NetHandle}.
* @returns { Promise<void> } the promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 9
*/
function setAppNet(netHandle: NetHandle): Promise<void>;
/**
* Obtains the default {@link HttpProxy} proxy settings.
*
* If an application level proxy is set, the application level proxy parameters are returned.
* If a global proxy is set, the global proxy parameters are returned.
* If the process is bound to a {@link NetHandle} using {@link setAppNet}, the {@link NetHandle} proxy settings are returned.
* In other cases, the proxy settings of default network are returned.
*
* @param { AsyncCallback<HttpProxy> } callback - Returns the default {@link HttpProxy} settings.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 10
*/
function getDefaultHttpProxy(callback: AsyncCallback<HttpProxy>): void;
/**
* Obtains the default {@link HttpProxy} proxy settings.
*
* If an application level proxy is set, the application level proxy parameters are returned.
* If a global proxy is set, the global proxy parameters are returned.
* If the process is bound to a {@link NetHandle} using {@link setAppNet}, the {@link NetHandle} proxy settings are returned.
* In other cases, the proxy settings of default network are returned.
*
* @returns { Promise<HttpProxy> } the promise returned by the function.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 10
*/
function getDefaultHttpProxy(): Promise<HttpProxy>;
/**
* Obtains the network independent global {@link HttpProxy} proxy settings.
* @param { AsyncCallback<HttpProxy> } callback - Returns the proxy settings. For details, see {@link HttpProxy}.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @systemapi Hide this for inner system use.
* @since 10
*/
function getGlobalHttpProxy(callback: AsyncCallback<HttpProxy>): void;
/**
* Obtains the network independent global {@link HttpProxy} proxy settings.
* @returns { Promise<HttpProxy> } the promise returned by the function.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @systemapi Hide this for inner system use.
* @since 10
*/
function getGlobalHttpProxy(): Promise<HttpProxy>;
/**
* Set application level http proxy {@link HttpProxy}.
* @param { HttpProxy } httpProxy - Indicates the application level proxy settings. For details, see {@link HttpProxy}.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid http proxy.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 11
*/
function setAppHttpProxy(httpProxy: HttpProxy): void;
/**
* Set a network independent global {@link HttpProxy} proxy settings.
* @permission ohos.permission.CONNECTIVITY_INTERNAL
* @param { HttpProxy } httpProxy - Indicates the global proxy settings. For details, see {@link HttpProxy}.
* @param { AsyncCallback<void> } callback - the callback of setGlobalHttpProxy.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @systemapi Hide this for inner system use.
* @since 10
*/
function setGlobalHttpProxy(httpProxy: HttpProxy, callback: AsyncCallback<void>): void;
/**
* Set a network independent global {@link HttpProxy} proxy settings.
* @permission ohos.permission.CONNECTIVITY_INTERNAL
* @param { HttpProxy } httpProxy - Indicates the global proxy settings. For details, see {@link HttpProxy}.
* @returns { Promise<void> } the promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @systemapi Hide this for inner system use.
* @since 10
*/
function setGlobalHttpProxy(httpProxy: HttpProxy): Promise<void>;
/**
* Add a custom {@link host} and corresponding {@link ip} mapping for current application.
* @permission ohos.permission.INTERNET
* @param { string } host - Indicates the host name or the domain.
* @param { Array<string> } ip - List of IP addresses mapped to the host name.
* @param { AsyncCallback<void> } callback - Returns the callback of addCustomDnsRule.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 11
*/
function addCustomDnsRule(host: string, ip: Array<string>, callback: AsyncCallback<void>): void;
/**
* Add a custom {@link host} and corresponding {@link ip} mapping for current application.
* @permission ohos.permission.INTERNET
* @param { string } host - Indicates the host name or the domain.
* @param { Array<string> } ip - List of IP addresses mapped to the host name.
* @returns { Promise<void> } the promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 11
*/
function addCustomDnsRule(host: string, ip: Array<string>): Promise<void>;
/**
* Remove the custom DNS rule of the {@link host} for current application.
* @permission ohos.permission.INTERNET
* @param { string } host - Indicates the host name or the domain.
* @param { AsyncCallback<void> } callback - Returns the callback of removeCustomDnsRule.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 11
*/
function removeCustomDnsRule(host: string, callback: AsyncCallback<void>): void;
/**
* Remove the custom DNS rule of the {@link host} for current application.
* @permission ohos.permission.INTERNET
* @param { string } host - Indicates the host name or the domain.
* @returns { Promise<void> } the promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 11
*/
function removeCustomDnsRule(host: string): Promise<void>;
/**
* Clear all custom DNS rules for current application.
* @permission ohos.permission.INTERNET
* @param { AsyncCallback<void> } callback - Returns the callback of clearCustomDnsRules.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 11
*/
function clearCustomDnsRules(callback: AsyncCallback<void>): void;
/**
* Clear all custom DNS rules for current application.
* @permission ohos.permission.INTERNET
* @returns { Promise<void> } the promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 11
*/
function clearCustomDnsRules(): Promise<void>;
/**
* factory reset network settings
*
* To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission.
* @permission ohos.permission.CONNECTIVITY_INTERNAL
* @returns { Promise<void> } the promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @systemapi Hide this for inner system use. Only used for system app.
* @since 11
*/
function factoryReset(): Promise<void>;
/**
* Represents the network connection handle.
* @interface NetConnection
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Represents the network connection handle.
* @interface NetConnection
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Represents the network connection handle.
* @interface NetConnection
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
export interface NetConnection {
/**
* Registers a listener for netAvailable events.
* @param { 'netAvailable' } type - Indicates Event name.
* @param { Callback<NetHandle> } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Registers a listener for netAvailable events.
* @param { 'netAvailable' } type - Indicates Event name.
* @param { Callback<NetHandle> } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Registers a listener for netAvailable events.
* @param { 'netAvailable' } type - Indicates Event name.
* @param { Callback<NetHandle> } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
on(type: 'netAvailable', callback: Callback<NetHandle>): void;
/**
* Registers a listener for netBlockStatusChange events.
* @param { 'netBlockStatusChange' } type - Indicates Event name.
* @param { Callback<{ netHandle: NetHandle, blocked: boolean }> } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Registers a listener for netBlockStatusChange events.
* @param { 'netBlockStatusChange' } type - Indicates Event name.
* @param { Callback<NetBlockStatusInfo> } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 11
*/
on(type: 'netBlockStatusChange', callback: Callback<NetBlockStatusInfo>): void;
/**
* Registers a listener for **netCapabilitiesChange** events.
* @param { 'netCapabilitiesChange' } type - Indicates Event name.
* @param { Callback<NetCapabilityInfo> } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Registers a listener for **netCapabilitiesChange** events.
* @param { 'netCapabilitiesChange' } type - Indicates Event name.
* @param { Callback<NetCapabilityInfo> } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Registers a listener for **netCapabilitiesChange** events.
* @param { 'netCapabilitiesChange' } type - Indicates Event name.
* @param { Callback<NetCapabilityInfo> } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
on(type: 'netCapabilitiesChange', callback: Callback<NetCapabilityInfo>): void;
/**
* Registers a listener for netConnectionPropertiesChange events.
* @param { 'netConnectionPropertiesChange' } type - Indicates Event name.
* @param { Callback<{ netHandle: NetHandle, connectionProperties: ConnectionProperties }> } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Registers a listener for netConnectionPropertiesChange events.
* @param { 'netConnectionPropertiesChange' } type - Indicates Event name.
* @param { Callback<NetConnectionPropertyInfo> } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 11
*/
on(type: 'netConnectionPropertiesChange', callback: Callback<NetConnectionPropertyInfo>): void;
/**
* Registers a listener for **netLost** events.
* @param { 'netLost' } type - Indicates Event name.
* @param { Callback<NetHandle> } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Registers a listener for **netLost** events.
* @param { 'netLost' } type - Indicates Event name.
* @param { Callback<NetHandle> } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Registers a listener for **netLost** events.
* @param { 'netLost' } type - Indicates Event name.
* @param { Callback<NetHandle> } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
on(type: 'netLost', callback: Callback<NetHandle>): void;
/**
* Registers a listener for netUnavailable events.
* @param { 'netUnavailable' } type - Indicates Event name.
* @param { Callback<void> } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Registers a listener for netUnavailable events.
* @param { 'netUnavailable' } type - Indicates Event name.
* @param { Callback<void> } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Registers a listener for netUnavailable events.
* @param { 'netUnavailable' } type - Indicates Event name.
* @param { Callback<void> } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
on(type: 'netUnavailable', callback: Callback<void>): void;
/**
* Receives status change notifications of a specified network.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { AsyncCallback<void> } callback - the callback of register.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @throws { BusinessError } 2101008 - The callback already exists.
* @throws { BusinessError } 2101022 - The number of requests exceeded the maximum allowed.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Receives status change notifications of a specified network.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { AsyncCallback<void> } callback - the callback of register.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @throws { BusinessError } 2101008 - The callback already exists.
* @throws { BusinessError } 2101022 - The number of requests exceeded the maximum allowed.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Receives status change notifications of a specified network.
* @permission ohos.permission.GET_NETWORK_INFO
* @param { AsyncCallback<void> } callback - the callback of register.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @throws { BusinessError } 2101008 - The callback already exists.
* @throws { BusinessError } 2101022 - The number of requests exceeded the maximum allowed.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
register(callback: AsyncCallback<void>): void;
/**
* Cancels listening for network status changes.
* @param { AsyncCallback<void> } callback - the callback of unregister.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @throws { BusinessError } 2101007 - The callback does not exist.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Cancels listening for network status changes.
* @param { AsyncCallback<void> } callback - the callback of unregister.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @throws { BusinessError } 2101007 - The callback does not exist.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Cancels listening for network status changes.
* @param { AsyncCallback<void> } callback - the callback of unregister.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @throws { BusinessError } 2101007 - The callback does not exist.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
/**
* Cancels listening for network status changes.
* @param { AsyncCallback<void> } callback - the callback of unregister.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @throws { BusinessError } 2101007 - The callback does not exist.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 12
*/
unregister(callback: AsyncCallback<void>): void;
}
/**
* Provides an instance that bear data network capabilities.
* @interface NetSpecifier
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Provides an instance that bear data network capabilities.
* @interface NetSpecifier
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
export interface NetSpecifier {
/**
* The transmission capacity and support of the network's global proxy storage data network.
* @type {NetCapabilities}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* The transmission capacity and support of the network's global proxy storage data network.
* @type {NetCapabilities}
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
netCapabilities: NetCapabilities;
/**
* Network identifier, the identifier for Wi Fi networks is "wifi", and the identifier for cellular networks is "simId1" (corresponding to SIM card 1).
* @type {?string}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Network identifier, the identifier for Wi Fi networks is "wifi", and the identifier for cellular networks is "simId1" (corresponding to SIM card 1).
* @type {?string}
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
bearerPrivateIdentifier?: string;
}
/**
* Receive information about changes in network capabilities.
* @interface NetCapabilityInfo
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Receive information about changes in network capabilities.
* @interface NetCapabilityInfo
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
export interface NetCapabilityInfo {
/**
* Defines the handle of the data network.
* @type { NetHandle }
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Defines the handle of the data network.
* @type { NetHandle }
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
netHandle: NetHandle;
/**
* Defines the network capability set.
* @type { NetCapabilities }
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Defines the network capability set.
* @type { NetCapabilities }
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
netCap: NetCapabilities;
}
/**
* Defines the handle of the data network.
* @interface NetHandle
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Defines the handle of the data network.
* @interface NetHandle
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Defines the handle of the data network.
* @interface NetHandle
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
export interface NetHandle {
/**
* 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.
* @type {number}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* 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.
* @type {number}
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* 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.
* @type {number}
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
netId: number;
/**
* <p>Binds a TCPSocket or UDPSocket to the current network. All data flows from
* the socket will use this network, without being subject to {@link setAppNet}.</p>
* Before using this method, ensure that the socket is disconnected.
* @param { TCPSocket | UDPSocket } socketParam - Indicates the TCPSocket or UDPSocket object.
* @param { AsyncCallback<void> } callback - the callback of bindSocket.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 9
*/
bindSocket(socketParam: TCPSocket | UDPSocket, callback: AsyncCallback<void>): void;
/**
* <p>Binds a TCPSocket or UDPSocket to the current network. All data flows from
* the socket will use this network, without being subject to {@link setAppNet}.</p>
* Before using this method, ensure that the socket is disconnected.
* @param { TCPSocket | UDPSocket } socketParam - Indicates the TCPSocket or UDPSocket object.
* @returns { Promise<void> } the promise returned by the function.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 9
*/
bindSocket(socketParam: TCPSocket | UDPSocket): Promise<void>;
/**
* Resolves a host name to obtain all IP addresses based on the specified NetHandle.
* @permission ohos.permission.INTERNET
* @param { string } host - Indicates the host name or the domain.
* @param { AsyncCallback<Array<NetAddress>> } callback - the callback of getAddressesByName.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
getAddressesByName(host: string, callback: AsyncCallback<Array<NetAddress>>): void;
/**
* Resolves a host name to obtain all IP addresses based on the specified NetHandle.
* @permission ohos.permission.INTERNET
* @param { string } host - Indicates the host name or the domain.
* @returns { Promise<Array<NetAddress>> } The promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
getAddressesByName(host: string): Promise<Array<NetAddress>>;
/**
* Resolves a host name to obtain the first IP address based on the specified NetHandle.
* @permission ohos.permission.INTERNET
* @param { string } host - Indicates the host name or the domain.
* @param { AsyncCallback<NetAddress> } callback - the callback of getAddressByName.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
getAddressByName(host: string, callback: AsyncCallback<NetAddress>): void;
/**
* Resolves a host name to obtain the first IP address based on the specified NetHandle.
* @permission ohos.permission.INTERNET
* @param { string } host - Indicates the host name or the domain.
* @returns { Promise<NetAddress> } The promise returned by the function.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 2100001 - Invalid parameter value.
* @throws { BusinessError } 2100002 - Failed to connect to the service.
* @throws { BusinessError } 2100003 - System internal error.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
getAddressByName(host: string): Promise<NetAddress>;
}
/**
* Defines the network capability set.
* @interface NetCapabilities
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Defines the network capability set.
* @interface NetCapabilities
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Defines the network capability set.
* @interface NetCapabilities
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
export interface NetCapabilities {
/**
* Uplink (device-to-network) bandwidth.
* @type {?number}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
linkUpBandwidthKbps?: number;
/**
* Downstream (network-to-device) bandwidth.
* @type {?number}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
linkDownBandwidthKbps?: number;
/**
* Network-specific capabilities.
* @type {?Array<NetCap>}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Network-specific capabilities.
* @type {?Array<NetCap>}
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
networkCap?: Array<NetCap>;
/**
* Network type.
* @type {Array<NetBearType>}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Network type.
* @type {Array<NetBearType>}
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Network type.
* @type {Array<NetBearType>}
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
bearerTypes: Array<NetBearType>;
}
/**
* Get information about network connections.
* @interface NetConnectionPropertyInfo
* @syscap SystemCapability.Communication.NetManager.Core
* @since 11
*/
export interface NetConnectionPropertyInfo {
/**
* Defines the handle of the data network.
* @type { NetHandle }
* @syscap SystemCapability.Communication.NetManager.Core
* @since 11
*/
netHandle: NetHandle;
/**
* Defines the network connection properties.
* @type { ConnectionProperties }
* @syscap SystemCapability.Communication.NetManager.Core
* @since 11
*/
connectionProperties: ConnectionProperties;
}
/**
* Get network status information.
* @interface NetBlockStatusInfo
* @syscap SystemCapability.Communication.NetManager.Core
* @since 11
*/
export interface NetBlockStatusInfo {
/**
* Defines the handle of the data network.
* @type { NetHandle }
* @syscap SystemCapability.Communication.NetManager.Core
* @since 11
*/
netHandle: NetHandle;
/**
* Check whether the current state is blocked.
* @type { boolean }
* @syscap SystemCapability.Communication.NetManager.Core
* @since 11
*/
blocked: boolean;
}
/**
* Defines the network capability.
* @enum {number}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Defines the network capability.
* @enum {number}
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
export enum NetCap {
/**
* Indicates that the network can access the carrier's MMSC to send and receive multimedia messages.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Indicates that the network can access the carrier's MMSC to send and receive multimedia messages.
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
NET_CAPABILITY_MMS = 0,
/**
* Indicates that the network traffic is not metered.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Indicates that the network traffic is not metered.
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
NET_CAPABILITY_NOT_METERED = 11,
/**
* Indicates that the network can access the Internet.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Indicates that the network can access the Internet.
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
NET_CAPABILITY_INTERNET = 12,
/**
* Indicates that the network does not use a VPN.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Indicates that the network does not use a VPN.
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
NET_CAPABILITY_NOT_VPN = 15,
/**
* Indicates that the network is available.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Indicates that the network is available.
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
NET_CAPABILITY_VALIDATED = 16,
/**
* Indicates that the network is portal.
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 12
*/
NET_CAPABILITY_PORTAL = 17,
/**
* Indicates that the network is checking connectivity.
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 12
*/
NET_CAPABILITY_CHECKING_CONNECTIVITY = 31
}
/**
* Enumerates network types.
* @enum {number}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Enumerates network types.
* @enum {number}
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Enumerates network types.
* @enum {number}
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
export enum NetBearType {
/**
* Indicates that the network is based on a cellular network.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Indicates that the network is based on a cellular network.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Indicates that the network is based on a cellular network.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
BEARER_CELLULAR = 0,
/**
* Indicates that the network is based on a Wi-Fi network.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Indicates that the network is based on a Wi-Fi network.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 10
*/
/**
* Indicates that the network is based on a Wi-Fi network.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @atomicservice
* @since 11
*/
BEARER_WIFI = 1,
/**
* Indicates that the network is based on a bluetooth network.
* @syscap SystemCapability.Communication.NetManager.Core
* @crossplatform
* @since 12
*/
BEARER_BLUETOOTH = 2,
/**
* Indicates that the network is an Ethernet network.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Indicates that the network is an Ethernet network.
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
BEARER_ETHERNET = 3,
/**
* Indicates that the network is based on a VPN network.
* @syscap SystemCapability.Communication.NetManager.Core
* @since 12
*/
BEARER_VPN = 4,
}
/**
* Defines the network connection properties.
* @interface ConnectionProperties
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
export interface ConnectionProperties {
/**
* Network card name.
* @type {string}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
interfaceName: string;
/**
* Domain. The default value is "".
* @type {string}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
domains: string;
/**
* Link information.
* @type {Array<LinkAddress>}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
linkAddresses: Array<LinkAddress>;
/**
* Network address, refer to [NetAddress].
* @type {Array<NetAddress>}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
dnses: Array<NetAddress>;
/**
* Routing information.
* @type {Array<RouteInfo>}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
routes: Array<RouteInfo>;
/**
* Maximum transmission unit.
* @type {number}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
mtu: number;
}
/**
* Defines network route information.
* @interface RouteInfo
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
export interface RouteInfo {
/**
* Network card name.
* @type {string}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
interface: string;
/**
* Destination Address
* @type {LinkAddress}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
destination: LinkAddress;
/**
* Gateway address.
* @type {NetAddress}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
gateway: NetAddress;
/**
* Whether a gateway is present.
* @type {boolean}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
hasGateway: boolean;
/**
* Whether the route is the default route.
* @type {boolean}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
isDefaultRoute: boolean;
}
/**
* Defines network link information.
* @interface LinkAddress
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
export interface LinkAddress {
/**
* Link address.
* @type {NetAddress}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
address: NetAddress;
/**
* The length of the link address prefix.
* @type {number}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
prefixLength: number;
}
/**
* Defines a network address.
* @interface NetAddress
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Defines a network address.
* @interface NetAddress
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 12
*/
export interface NetAddress {
/**
* Network address.
* @type {string}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Network address.
* @type {string}
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 12
*/
address: string;
/**
* Address family identifier. The value is 1 for IPv4 and 2 for IPv6. The default value is 1.
* @type {?number}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Address family identifier. The value is 1 for IPv4 and 2 for IPv6. The default value is 1.
* @type {?number}
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 12
*/
family?: number;
/**
* Port number. The value ranges from 0 to 65535.
* @type {?number}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 8
*/
/**
* Port number. The value ranges from 0 to 65535.
* @type {?number}
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 12
*/
port?: number;
}
/**
* Network Global Proxy Configuration Information.
* @interface HttpProxy
* @syscap SystemCapability.Communication.NetManager.Core
* @since 10
*/
/**
* Network Global Proxy Configuration Information.
* @interface HttpProxy
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
export interface HttpProxy {
/**
* Proxy server host name.
* @type {string}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 10
*/
/**
* Proxy server host name.
* @type {string}
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
host: string;
/**
* Host port.
* @type {number}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 10
*/
/**
* Host port.
* @type {number}
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
port: number;
/**
* Http proxy username.
* @type {?string}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 12
*/
username?: string;
/**
* Http proxy password.
* @type {?string}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 12
*/
password?: string;
/**
* Do not use a blocking list for proxy servers.
* @type {Array<string>}
* @syscap SystemCapability.Communication.NetManager.Core
* @since 10
*/
/**
* Do not use a blocking list for proxy servers.
* @type {Array<string>}
* @syscap SystemCapability.Communication.NetManager.Core
* @atomicservice
* @since 11
*/
exclusionList: Array<string>;
}
}
export default connection;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lffl8796/interface_sdk-js.git
git@gitee.com:lffl8796/interface_sdk-js.git
lffl8796
interface_sdk-js
interface_sdk-js
master

搜索帮助