diff --git a/.gitignore b/.gitignore
index a82da52d73edbb03f18f944df1e77fafeeef54a6..c25ef95e663e8a06b7145f92ce84ace28bc40bc7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,4 @@
Network Trash Folder
Temporary Items
.apdisk
+.idea
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/@ohos.net.connection.d.ts b/zh-cn/application-dev/reference/apis/@ohos.net.connection.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..639a6ef4268014272617fcb25b4d13a249a641d4
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/@ohos.net.connection.d.ts
@@ -0,0 +1,509 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+import {AsyncCallback, Callback} from "./basic";
+import http from "./@ohos.net.http";
+import socket from "./@ohos.net.socket";
+
+/**
+ * Provides interfaces to manage and use data networks.
+ *
+ * @since 8
+ * @sysCap SystemCapability.Communication.NetManager.Core
+ */
+declare namespace connection {
+ type HttpRequest = http.HttpRequest;
+ type TCPSocket = socket.TCPSocket;
+ type UDPSocket = socket.UDPSocket;
+
+ /**
+ * Create a network connection with optional netSpefifier and timeout.
+ *
+ * @param netSpecifier Indicates the network specifier. See {@link NetSpecifier}.
+ * @param timeout The time in milliseconds to attempt looking for a suitable network before
+ * {@link NetConnection#netUnavailable} is called.
+ */
+ 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.
+ *
+ * @param callback Returns the {@link NetHandle} object;
+ * returns {@code null} if the default network is not activated.
+ * @permission ohos.permission.GET_NETWORK_INFO
+ */
+ function getDefaultNet(callback: AsyncCallback): void;
+ function getDefaultNet(): Promise;
+
+ /**
+ * Obtains the list of data networks that are activated.
+ *
+ * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
+ *
+ * @param callback Returns the {@link NetHandle} object; returns {@code null} if no network is activated.
+ * @permission ohos.permission.GET_NETWORK_INFO
+ */
+ function getAllNets(callback: AsyncCallback>): void;
+ function getAllNets(): Promise>;
+
+ /**
+ * Queries the connection properties of a network.
+ *
+ * This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission.
+ *
+ * @param netHandle Indicates the network to be queried.
+ * @param callback Returns the {@link ConnectionProperties} object.
+ * @permission ohos.permission.GET_NETWORK_INFO
+ */
+ function getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback): void;
+ function getConnectionProperties(netHandle: NetHandle): Promise;
+
+ /**
+ * Obtains {@link NetCapabilities} of a {@link NetHandle} object.
+ *
+ * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission.
+ *
+ * @param netHandle Indicates the handle. See {@link NetHandle}.
+ * @param callback Returns {@link NetCapabilities}; returns {@code null} if {@code handle} is invalid.
+ * @permission ohos.permission.GET_NETWORK_INFO
+ */
+ function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback): void;
+ function getNetCapabilities(netHandle: NetHandle): Promise;
+
+ /**
+ * Checks whether the default data network is activated.
+ *
+ * @param callback Returns {@code true} if the default data network is activated; returns {@code false} otherwise.
+ */
+ function hasDefaultNet(callback: AsyncCallback): void;
+ function hasDefaultNet(): Promise;
+
+ /**
+ * Enables the airplane mode for a device.
+ *
+ * @systemapi Hide this for inner system use. Only used for system app.
+ */
+ function enableAirplaneMode(callback: AsyncCallback): void;
+ function enableAirplaneMode(): Promise;
+
+ /**
+ * Disables the airplane mode for a device.
+ *
+ * @systemapi Hide this for inner system use. Only used for system app.
+ */
+ function disableAirplaneMode(callback: AsyncCallback): void;
+ function disableAirplaneMode(): Promise;
+
+ /**
+ * Reports the network state is connected.
+ *
+ * @param netHandle Indicates the network whose state is to be reported.
+ * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
+ */
+ function reportNetConnected(netHandle: NetHandle, callback: AsyncCallback): void;
+ function reportNetConnected(netHandle: NetHandle): Promise;
+
+ /**
+ * Reports the network state is disconnected.
+ *
+ * @param netHandle Indicates the network whose state is to be reported.
+ * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
+ */
+ function reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback): void;
+ function reportNetDisconnected(netHandle: NetHandle): Promise;
+
+ /**
+ * Resolves the host name to obtain all IP addresses based on the default data network.
+ *
+ * @param host Indicates the host name or the domain.
+ * @param callback Returns the NetAddress list.
+ * @permission ohos.permission.GET_NETWORK_INFO
+ */
+ function getAddressesByName(host: string, callback: AsyncCallback>): void;
+ function getAddressesByName(host: string): Promise>;
+
+ export interface NetConnection {
+ on(type: 'netAvailable', callback: Callback): void;
+
+ on(type: 'netBlockStatusChange', callback: Callback<{ netHandle: NetHandle, blocked: boolean }>): void;
+
+ on(type: 'netCapabilitiesChange', callback: Callback<{ netHandle: NetHandle, netCap: NetCapabilities }>): void;
+
+ on(type: 'netConnectionPropertiesChange', callback: Callback<{ netHandle: NetHandle, connectionProperties: ConnectionProperties }>): void;
+
+ on(type: 'netLost', callback: Callback): void;
+
+ on(type: 'netUnavailable', callback: Callback): void;
+
+ /**
+ * Receives status change notifications of a specified network.
+ *
+ * @permission ohos.permission.GET_NETWORK_INFO
+ */
+ register(callback: AsyncCallback): void;
+
+ /**
+ * Cancels listening for network status changes.
+ */
+ unregister(callback: AsyncCallback): void;
+ }
+
+ export interface NetSpecifier {
+ netCapabilities: NetCapabilities;
+ bearerPrivateIdentifier?: string;
+ }
+
+ export interface NetHandle {
+ netId: number;
+
+ /**
+ * 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}.
+ * Before using this method, ensure that the socket is disconnected.
+ *
+ * @param socketParam Indicates the TCPSocket or UDPSocket object.
+ */
+ bindSocket(socketParam: TCPSocket | UDPSocket, callback: AsyncCallback): void;
+ bindSocket(socketParam: TCPSocket | UDPSocket): Promise;
+
+ /**
+ * Accesses a specified URL.
+ *
+ * @param url Indicates a URL connection.
+ * @param callback Returns a {@code URLConnection} object matching the given {@code url}.
+ */
+ openConnection(url: string, callback: AsyncCallback): void;
+ openConnection(url: string, proxy: NetProxy, callback: AsyncCallback): void;
+ openConnection(url: string, proxy?: NetProxy): Promise;
+
+ /**
+ * Resolves a host name to obtain all IP addresses based on the specified NetHandle.
+ *
+ * @param host Indicates the host name or the domain.
+ * @param callback Returns the NetAddress list.
+ */
+ getAddressesByName(host: string, callback: AsyncCallback>): void;
+ getAddressesByName(host: string): Promise>;
+
+ /**
+ * Resolves a host name to obtain the first IP address based on the specified NetHandle.
+ *
+ * @param host Indicates the host name or the domain.
+ * @return Returns the first NetAddress.
+ */
+ getAddressByName(host: string, callback: AsyncCallback): void;
+ getAddressByName(host: string): Promise;
+ }
+
+ export interface NetCapabilities {
+ linkUpBandwidthKbps?: number;
+ linkDownBandwidthKbps?: number;
+ networkCap?: Array;
+ bearerTypes: Array;
+ }
+
+ export enum NetCap {
+ /**
+ * Indicates that the network can access the carrier's MMSC to send and receive multimedia messages.
+ */
+ NET_CAPABILITY_MMS = 0,
+
+ /**
+ * Indicates that the network can access the carrier's SUPL server.
+ */
+ NET_CAPABILITY_SUPL = 1,
+
+ /**
+ * Indicates that the network can access the carrier's DUN or Tethering gateway.
+ */
+ NET_CAPABILITY_DUN = 2,
+
+ /**
+ * Indicates that the network can access the FOTA server for remote device upgrade.
+ */
+ NET_CAPABILITY_FOTA = 3,
+
+ /**
+ * Indicates that the network can access the IMS server.
+ */
+ NET_CAPABILITY_IMS = 4,
+
+ /**
+ * Indicates that the network can access the carrier's CBS server.
+ */
+ NET_CAPABILITY_CBS = 5,
+
+ /**
+ * Indicates that the network can be used for Wi-Fi Direct.
+ */
+ NET_CAPABILITY_WIFI_P2P = 6,
+
+ /**
+ * Indicates that the network can access the carrier's Initial Attach server.
+ */
+ NET_CAPABILITY_IA = 7,
+
+ /**
+ * Indicates that the network can access the carrier's RCS server.
+ */
+ NET_CAPABILITY_RCS = 8,
+
+ /**
+ * Indicates that the network can access the carrier's XCAP server.
+ */
+ NET_CAPABILITY_XCAP = 9,
+
+ /**
+ * Indicates that the network can access the carrier's IMS emergency call server.
+ */
+ NET_CAPABILITY_EIMS = 10,
+
+ /**
+ * Indicates that the network traffic is not metered.
+ */
+ NET_CAPABILITY_NOT_METERED = 11,
+
+ /**
+ * Indicates that the network can access the Internet.
+ */
+ NET_CAPABILITY_INTERNET = 12,
+
+ /**
+ * Indicates that the network is not restricted.
+ */
+ NET_CAPABILITY_NOT_RESTRICTED = 13,
+
+ /**
+ * Indicates that the network is trusted.
+ */
+ NET_CAPABILITY_TRUSTED = 14,
+
+ /**
+ * Indicates that the network does not use a VPN.
+ */
+ NET_CAPABILITY_NOT_VPN = 15,
+
+ /**
+ * Indicates that the network is available.
+ */
+ NET_CAPABILITY_VALIDATED = 16,
+
+ /**
+ * Indicates that this network was found to have a captive portal in place last time it was
+ * probed.
+ */
+ NET_CAPABILITY_CAPTIVE_PORTAL = 17,
+
+ /**
+ * Indicates that the network is unavailable during roaming.
+ */
+ NET_CAPABILITY_NOT_ROAMING = 18,
+
+ /**
+ * Indicates that the network is available only for foreground applications.
+ */
+ NET_CAPABILITY_FOREGROUND = 19,
+
+ /**
+ * Indicates that the network is not congested.
+ */
+ NET_CAPABILITY_NOT_CONGESTED = 20,
+
+ /**
+ * Indicates that the network is not suspended.
+ */
+ NET_CAPABILITY_NOT_SUSPENDED = 21,
+
+ /**
+ * Indicates that traffic that goes through this network is paid by oem. For example,
+ * this network can be used by system apps to upload telemetry data.
+ *
+ * @systemapi Hide this for inner system use.
+ */
+ NET_CAPABILITY_OEM_PAID = 22,
+
+ /**
+ * Indicates that the network can access the Mission Critical server of the carrier.
+ */
+ NET_CAPABILITY_MCX = 23,
+
+ /**
+ * Indicates that the network was tested to only provide partial connectivity.
+ *
+ * @systemapi Hide this for inner system use.
+ */
+ NET_CAPABILITY_PARTIAL_CONNECTIVITY = 24,
+
+ /**
+ * Indicates that the network extends cap
+ *
+ * @systemapi Hide this for inner system use.
+ */
+ NET_CAPABILITY_HW_BASE = NET_CAPABILITY_PARTIAL_CONNECTIVITY,
+
+ /**
+ * Indicates that the network can access the BIP0 server.
+ *
+ * @systemapi Hide this for inner system use.
+ */
+ NET_CAPABILITY_BIP0 = NET_CAPABILITY_HW_BASE + 1,
+
+ /**
+ * Indicates that the network can access the BIP1 server.
+ *
+ * @systemapi Hide this for inner system use.
+ */
+ NET_CAPABILITY_BIP1 = NET_CAPABILITY_HW_BASE + 2,
+
+ /**
+ * Indicates that the network can access the BIP2 server.
+ *
+ * @systemapi Hide this for inner system use.
+ */
+ NET_CAPABILITY_BIP2 = NET_CAPABILITY_HW_BASE + 3,
+
+ /**
+ * Indicates that the network can access the BIP3 server.
+ *
+ * @systemapi Hide this for inner system use.
+ */
+ NET_CAPABILITY_BIP3 = NET_CAPABILITY_HW_BASE + 4,
+
+ /**
+ * Indicates that the network can access the BIP4 server.
+ *
+ * @systemapi Hide this for inner system use.
+ */
+ NET_CAPABILITY_BIP4 = NET_CAPABILITY_HW_BASE + 5,
+
+ /**
+ * Indicates that the network can access the BIP5 server.
+ *
+ * @systemapi Hide this for inner system use.
+ */
+ NET_CAPABILITY_BIP5 = NET_CAPABILITY_HW_BASE + 6,
+
+ /**
+ * Indicates that the network can access the BIP6 server.
+ *
+ * @systemapi Hide this for inner system use.
+ */
+ NET_CAPABILITY_BIP6 = NET_CAPABILITY_HW_BASE + 7,
+
+ /**
+ * Indicates that the network can access internal default servers.
+ *
+ * @systemapi Hide this for inner system use.
+ */
+ NET_CAPABILITY_INTERNAL_DEFAULT
+ }
+
+ export enum NetBearType {
+ /**
+ * Indicates that the network is based on a cellular network.
+ */
+ BEARER_CELLULAR = 0,
+
+ /**
+ * Indicates that the network is based on a Wi-Fi network.
+ */
+ BEARER_WIFI = 1,
+
+ /**
+ * Indicates that the network is based on a Bluetooth network.
+ */
+ BEARER_BLUETOOTH = 2,
+
+ /**
+ * Indicates that the network is an Ethernet network.
+ */
+ BEARER_ETHERNET = 3,
+
+ /**
+ * Indicates that the network is a VPN.
+ */
+ BEARER_VPN = 4,
+
+ /**
+ * Indicates that the network is a Wi-Fi Aware network.
+ */
+ BEARER_WIFI_AWARE = 5,
+
+ /**
+ * Indicates that the network is a LoWPAN network.
+ */
+ BEARER_LOWPAN = 6
+ }
+
+ export interface ConnectionProperties {
+ interfaceName: string;
+ isUsePrivateDns: boolean;
+ privateDnsServerName: string;
+ domains: string;
+ httpProxy: HttpProxy;
+ linkAddresses: Array;
+ dnses: Array;
+ routes: Array;
+ mtu: number;
+ }
+
+ export interface HttpProxy {
+ host: string;
+ port: number;
+ parsedExclusionList: Array;
+ }
+
+ export interface RouteInfo {
+ interface: string;
+ destination: LinkAddress;
+ gateway: NetAddress;
+ hasGateway: boolean;
+ isDefaultRoute: boolean;
+ }
+
+ export interface LinkAddress {
+ address: NetAddress;
+ prefixLength: number;
+ }
+
+ /**
+ * @since 7
+ */
+ export interface NetAddress {
+ address: string;
+ family?: number; // IPv4 = 1; IPv6 = 2, default is IPv4
+ port?: number; // [0, 65535]
+ }
+
+ export interface NetProxy {
+ type: ProxyType;
+ address: NetAddress;
+ }
+
+ export enum ProxyType {
+ /**
+ * Represents proxy for high level protocols such as HTTP or FTP.
+ */
+ HTTP,
+ /**
+ * Represents a SOCKS (V4 or V5) proxy.
+ */
+ SOCKS
+ }
+}
+
+export default connection;
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-net-connection.md b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md
index cba80c21a2f3acab9b0267ac90fa56b27300d9d6..4be6ce4741426579aee2fd913ac71343d6961c65 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-net-connection.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md
@@ -24,7 +24,7 @@ getDefaultNet(callback: AsyncCallback\): void
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----- | ---- | ----- |
-| callback | AsyncCallback\<[NetHandle](#NetHandle)> | 是 | 回调函数 |
+| callback | AsyncCallback\<[NetHandle](#nethandle)> | 是 | 回调函数 |
**示例:**
@@ -49,7 +49,7 @@ getDefaultNet(): Promise\
| 类型 | 说明 |
| ----- | ----- |
-| Promise\<[NetHandle](#NetHandle)> | 以Promise形式返回 |
+| Promise\<[NetHandle](#nethandle)> | 以Promise形式返回 |
**示例:**
@@ -122,8 +122,8 @@ getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\ | 是 | 回调函数 |
+| netHandle | [NetHandle](#nethandle) | 是 | 对应网络 |
+| callback | AsyncCallback\<[ConnectionProperties](#connectionproperties)> | 是 | 回调函数 |
**示例:**
@@ -150,13 +150,13 @@ getConnectionProperties(netHandle: NetHandle): Promise\
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----- | ---- | ----- |
-| netHandle | [NetHandle](#NetHandle) | 是 | 对应网络 |
+| netHandle | [NetHandle](#nethandle) | 是 | 对应网络 |
**返回值:**
| 类型 | 说明 |
| ----- | ----- |
-| Promise\<[ConnectionProperties](#ConnectionProperties)> | 以Promise形式返回 |
+| Promise\<[ConnectionProperties](#connectionproperties)> | 以Promise形式返回 |
**示例:**
@@ -182,8 +182,8 @@ getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback\ | 是 | 回调函数 |
+| netHandle | [NetHandle](#nethandle) | 是 | 对应网络 |
+| callback | AsyncCallback\<[NetCapabilities](#netcapabilities)> | 是 | 回调函数 |
**示例:**
@@ -210,13 +210,13 @@ getNetCapabilities(netHandle: NetHandle): Promise\
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----- | ---- | ----- |
-| netHandle | [NetHandle](#NetHandle) | 是 | 对应网络 |
+| netHandle | [NetHandle](#nethandle) | 是 | 对应网络 |
**返回值:**
| 类型 | 说明 |
| ----- | ----- |
-| Promise\<[NetCapabilities](#NetCapabilities)> | 以Promise形式返回 |
+| Promise\<[NetCapabilities](#netcapabilities)> | 以Promise形式返回 |
**示例:**
@@ -243,7 +243,7 @@ getAddressesByName(host: string, callback: AsyncCallback\>):
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----- | ---- | ----- |
| host | string | 是 | 需要解析的域名 |
-| callback | AsyncCallback\> | 是 | 回调函数 |
+| callback | AsyncCallback\> | 是 | 回调函数 |
**示例:**
@@ -276,7 +276,7 @@ getAddressesByName(netHandle: NetHandle): Promise\>
| 类型 | 说明 |
| ----- | ----- |
-| Promise\> | 以Promise形式返回 |
+| Promise\> | 以Promise形式返回 |
**示例:**
@@ -292,7 +292,7 @@ connection.getDefaultNet().then(function (netHandle) {
createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection
-获取一个netSpecifier指定的网络的句柄
+获取一个netSpecifier指定的网络的句柄。
**需要权限**:ohos.permission.GET_NETWORK_INFO
@@ -302,14 +302,14 @@ createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnectio
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----- | ---- | ----- |
-| netSpecifier | [NetSpecifier](#NetSpecifier) | 否 | 关注的网络的各项特征,不指定则关注默认网络 |
-| timeout | number | 否 | 获取netSpecifier指定的网络时的超时时间,前提是netSpecifier存在 |
+| netSpecifier | [NetSpecifier](#netspecifier) | 否 | 指定网络的各项特征,不指定则关注默认网络。 |
+| timeout | number | 否 | 获取netSpecifier指定的网络时的超时时间,仅netSpecifier存在时生效。 |
**返回值:**
| 类型 | 说明 |
| ----- | ----- |
-|[NetConnection](#NetConnection) | 所关注的网络的句柄 |
+|[NetConnection](#netconnection) | 所关注的网络的句柄 |
**示例:**
@@ -325,7 +325,7 @@ let netConnection2 = connection.createNetConnection({
})
```
-## connection.NetConnection
+## NetConnection
网络连接的句柄
@@ -333,7 +333,7 @@ let netConnection2 = connection.createNetConnection({
on(type: 'netAvailable', callback: Callback\): void
-监听网络可用事件
+监听网络可用事件。
**需要权限**:ohos.permission.GET_NETWORK_INFO
@@ -344,7 +344,7 @@ on(type: 'netAvailable', callback: Callback\): void
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----- | ---- | ----- |
| type | string | 是 | 监听的事件,固定'netAvailable' |
-| callback | Callback\<[NetHandle](#NetHandle)>> | 是 | 回调函数 |
+| callback | Callback\<[NetHandle](#nethandle)>> | 是 | 回调函数 |
**示例:**
@@ -358,7 +358,7 @@ connection.createNetConnection().on('netAvailable', function (data) {
on(type: 'netCapabilitiesChange', callback: Callback<{ netHandle: NetHandle, netCap: NetCapabilities }>): void
-监听网络能力变化事件
+监听网络能力变化事件。
**需要权限**:ohos.permission.GET_NETWORK_INFO
@@ -369,7 +369,7 @@ on(type: 'netCapabilitiesChange', callback: Callback<{ netHandle: NetHandle, net
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----- | ---- | ----- |
| type | string | 是 | 监听的事件,固定'netCapabilitiesChange' |
-| callback | Callback<{ netHandle: [NetHandle](#NetHandle), netCap: [NetCapabilities](#NetCapabilities) }> | 是 | 回调函数 |
+| callback | Callback<{ netHandle: [NetHandle](#nethandle), netCap: [NetCapabilities](#netcapabilities) }> | 是 | 回调函数 |
**示例:**
@@ -383,7 +383,7 @@ connection.createNetConnection().on('netCapabilitiesChange', function (data) {
on(type: 'netConnectionPropertiesChange', callback: Callback<{ netHandle: NetHandle, connectionProperties: ConnectionProperties }>): void
-监听网络连接信息变化事件
+监听网络连接信息变化事件。
**需要权限**:ohos.permission.GET_NETWORK_INFO
@@ -394,7 +394,7 @@ on(type: 'netConnectionPropertiesChange', callback: Callback<{ netHandle: NetHan
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----- | ---- | ----- |
| type | string | 是 | 监听的事件,固定'netConnectionPropertiesChange' |
-| callback | Callback<{ netHandle: [NetHandle](#NetHandle), connectionProperties: [ConnectionProperties](#ConnectionProperties) }> | 是 | 回调函数 |
+| callback | Callback<{ netHandle: [NetHandle](#nethandle), connectionProperties: [ConnectionProperties](#connectionproperties) }> | 是 | 回调函数 |
**示例:**
@@ -408,7 +408,7 @@ connection.createNetConnection().on('netConnectionPropertiesChange', function (d
on(type: 'netLost', callback: Callback\): void
-监听网络丢失事件
+监听网络丢失事件。
**需要权限**:ohos.permission.GET_NETWORK_INFO
@@ -419,7 +419,7 @@ on(type: 'netLost', callback: Callback\): void
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----- | ---- | ----- |
| type | string | 是 | 监听的事件,固定'netLost' |
-| callback | Callback\<[NetHandle](#NetHandle)>> | 是 | 回调函数 |
+| callback | Callback\<[NetHandle](#nethandle)>> | 是 | 回调函数 |
**示例:**
@@ -433,7 +433,7 @@ connection.createNetConnection().on('netLost', function (data) {
on(type: 'netUnavailable', callback: Callback\): void
-监听网络不可用事件
+监听网络不可用事件。
**需要权限**:ohos.permission.GET_NETWORK_INFO
@@ -458,7 +458,7 @@ connection.createNetConnection().on('netUnavailable', function (data) {
register(callback: AsyncCallback\): void
-注册网络的监听
+注册网络的监听。
**需要权限**:ohos.permission.GET_NETWORK_INFO
@@ -482,7 +482,7 @@ connection.createNetConnection().register(function (error) {
unregister(callback: AsyncCallback\): void
-注销网络的监听
+注销网络的监听。
**需要权限**:ohos.permission.GET_NETWORK_INFO
@@ -502,7 +502,7 @@ connection.createNetConnection().unregister(function (error) {
})
```
-## connection.NetHandle
+## NetHandle
网络的句柄
@@ -525,7 +525,7 @@ getAddressesByName(host: string, callback: AsyncCallback\>):
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----- | ---- | ----- |
| host | string | 是 | 需要解析的域名 |
-| callback | AsyncCallback\> | 是 | 回调函数 |
+| callback | AsyncCallback\> | 是 | 回调函数 |
**示例:**
@@ -558,7 +558,7 @@ getAddressesByName(netHandle: NetHandle): Promise\>
| 类型 | 说明 |
| ----- | ----- |
-| Promise\> | 以Promise形式返回 |
+| Promise\> | 以Promise形式返回 |
**示例:**
@@ -585,7 +585,7 @@ getAddressByName(host: string, callback: AsyncCallback\): void
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----- | ---- | ----- |
| host | string | 是 | 需要解析的域名 |
-| callback | AsyncCallback\<[NetAddress](#NetAddress)> | 是 | 回调函数 |
+| callback | AsyncCallback\<[NetAddress](#netaddress)> | 是 | 回调函数 |
**示例:**
@@ -618,7 +618,7 @@ getAddressByName(netHandle: NetHandle): Promise\
| 类型 | 说明 |
| ----- | ----- |
-| Promise\<[NetAddress](#NetAddress)> | 以Promise形式返回 |
+| Promise\<[NetAddress](#netaddress)> | 以Promise形式返回 |
**示例:**
@@ -630,80 +630,80 @@ connection.getDefaultNet().then(function (netHandle) {
})
```
-## connection.NetSpecifier
+## NetSpecifier
-网络的特征
+网络的特征。
| 变量 | 类型 | 说明 |
| ----- | ----- | ----- |
-| netCapabilities | [NetCapabilities](#NetCapabilities) | 网络的能力集 |
+| netCapabilities | [NetCapabilities](#netcapabilities) | 网络的能力集 |
| bearerPrivateIdentifier | string | 网络标识符,WIFI网络的标识符是"wifi",蜂窝网络的标识符是"slot0"(对应SIM卡1) |
-## connection.NetCapabilities
+## NetCapabilities
-网络的能力集
+网络的能力集。
| 变量 | 类型 | 说明 |
| ----- | ----- | ----- |
| linkUpBandwidthKbps | number | 带宽上限 |
| linkDownBandwidthKbps | number | 带宽下限 |
-| networkCap | Array<[NetCap](#NetCap)> | 网络具体能力 |
-| bearerTypes | Array<[NetBearType](#NetBearType)> | 网络类型 |
+| networkCap | Array<[NetCap](#netcap)> | 网络具体能力 |
+| bearerTypes | Array<[NetBearType](#netbearType)> | 网络类型 |
-## connection.NetCap
+## NetCap
-网络具体能力
+网络具体能力。
| 变量 | 值 | 说明 |
| ------ | ----- | ----- |
| NET_CAPABILITY_INTERNET | 12 | 联网能力 |
| NET_CAPABILITY_VALIDATED | 16 | 网络可用 |
-## connection.NetBearType
+## NetBearType
-网络类型
+网络类型。
| 变量 | 值 | 说明 |
| ------ | ----- | ----- |
| BEARER_CELLULAR | 0 | 蜂窝网络 |
| BEARER_WIFI | 1 | WIFI网络 |
-## connection.ConnectionProperties
+## ConnectionProperties
-网络连接信息
+网络连接信息。
| 变量 | 类型 | 说明 |
| ----- | ----- | ----- |
| interfaceName | string | 网卡名称 |
| domains | string | 所属域,默认"" |
-| linkAddresses | Array<[LinkAddress](#LinkAddress)> | 链路信息 |
-| routes | Array<[RouteInfo](#RouteInfo)> | 路由信息 |
+| linkAddresses | Array<[LinkAddress](#linkaddress)> | 链路信息 |
+| routes | Array<[RouteInfo](#routeinfo)> | 路由信息 |
| mtu | number | 最大传输单元 |
-## connection.LinkAddress
+## LinkAddress
-网络链路信息
+网络链路信息。
| 变量 | 类型 | 说明 |
| ----- | ----- | ----- |
-| address | [NetAddress](#NetAddress) | 链路地址 |
+| address | [NetAddress](#netaddress) | 链路地址 |
| prefixLength | number | 地址前缀长度 |
-## connection.RouteInfo
+## RouteInfo
-网络路由信息
+网络路由信息。
| 变量 | 类型 | 说明 |
| ----- | ----- | ----- |
| interface | string | 网卡名称 |
-| destination | [LinkAddress](#LinkAddress) | 目的地址 |
-| gateway | [NetAddress](#NetAddress) | 网关地址 |
+| destination | [LinkAddress](#linkaddress) | 目的地址 |
+| gateway | [NetAddress](#netaddress) | 网关地址 |
| hasGateway | boolean | 是否有网关 |
| isDefaultRoute | boolean | 是否为默认路由 |
-## connection.NetAddress
+## NetAddress
-地址
+地址。
| 变量 | 类型 | 说明 |
| ----- | ----- | ----- |