提交 93abc745 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 7192afcc
...@@ -70,6 +70,8 @@ httpRequest.request( ...@@ -70,6 +70,8 @@ httpRequest.request(
// data.header carries the HTTP response header. Parse the content based on service requirements. // data.header carries the HTTP response header. Parse the content based on service requirements.
console.info('header:' + JSON.stringify(data.header)); console.info('header:' + JSON.stringify(data.header));
console.info('cookies:' + JSON.stringify(data.cookies)); // 8+ console.info('cookies:' + JSON.stringify(data.cookies)); // 8+
// Call the destroy() method to release resources after the HttpRequest is complete.
httpRequest.destroy();
} else { } else {
console.info('error:' + JSON.stringify(err)); console.info('error:' + JSON.stringify(err));
// Unsubscribe from HTTP Response Header events. // Unsubscribe from HTTP Response Header events.
......
...@@ -21,7 +21,7 @@ Due to the asynchronous I/O feature of JS, the hiTraceMeter module provides only ...@@ -21,7 +21,7 @@ Due to the asynchronous I/O feature of JS, the hiTraceMeter module provides only
## Available APIs ## Available APIs
The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference]( ../reference/apis/js-apis-hitracemeter.md). The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference](../reference/apis/js-apis-hitracemeter.md).
**APIs for performance tracing** **APIs for performance tracing**
......
...@@ -111,7 +111,7 @@ The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capa ...@@ -111,7 +111,7 @@ The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capa
let dateTimeFormat = new Intl.DateTimeFormat(); let dateTimeFormat = new Intl.DateTimeFormat();
``` ```
Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md#datetimeoptions9). Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md#datetimeoptions6).
```js ```js
let options = {dateStyle: "full", timeStyle: "full"}; let options = {dateStyle: "full", timeStyle: "full"};
...@@ -181,7 +181,7 @@ The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capa ...@@ -181,7 +181,7 @@ The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capa
let numberFormat = new Intl.NumberFormat(); let numberFormat = new Intl.NumberFormat();
``` ```
Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md#numberoptions9). Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md#numberoptions6).
```js ```js
let options = {compactDisplay: "short", notation: "compact"}; let options = {compactDisplay: "short", notation: "compact"};
...@@ -240,7 +240,7 @@ Users in different regions have different requirements for string sorting. [Coll ...@@ -240,7 +240,7 @@ Users in different regions have different requirements for string sorting. [Coll
let collator = new Intl.Collator(); let collator = new Intl.Collator();
``` ```
Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md#collatoroptions9). Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md#collatoroptions8).
The **sensitivity** parameter is used to specify the levels of differences that will be used for string comparison. The value **base** indicates that only characters are compared, but not the accent and capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **accent** indicates that the accent is considered, but not the capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **case** indicates that the capitalization is considered, but the accent. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **variant** indicates that the accent and capitalization are considered. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The **sensitivity** parameter is used to specify the levels of differences that will be used for string comparison. The value **base** indicates that only characters are compared, but not the accent and capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **accent** indicates that the accent is considered, but not the capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **case** indicates that the capitalization is considered, but the accent. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **variant** indicates that the accent and capitalization are considered. For example, 'a' != 'b', 'a' == '', 'a'=='A'.
```js ```js
...@@ -301,7 +301,7 @@ According to grammars in certain languages, the singular or plural form of a nou ...@@ -301,7 +301,7 @@ According to grammars in certain languages, the singular or plural form of a nou
let pluralRules = new Intl.PluralRules(); let pluralRules = new Intl.PluralRules();
``` ```
Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md#pluralrulesoptions9). Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md#pluralrulesoptions8).
```js ```js
let pluralRules = new Intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"}); let pluralRules = new Intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"});
...@@ -349,7 +349,7 @@ According to grammars in certain languages, the singular or plural form of a nou ...@@ -349,7 +349,7 @@ According to grammars in certain languages, the singular or plural form of a nou
let relativeTimeFormat = new Intl.RelativeTimeFormat(); let relativeTimeFormat = new Intl.RelativeTimeFormat();
``` ```
Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md#relativetimeformatinputoptions9). Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [ RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md#relativetimeformatinputoptions8).
```js ```js
let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}); let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"});
...@@ -384,4 +384,4 @@ According to grammars in certain languages, the singular or plural form of a nou ...@@ -384,4 +384,4 @@ According to grammars in certain languages, the singular or plural form of a nou
```js ```js
let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}); let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"});
let options = relativeTimeFormat.resolvedOptions(); // options = {"locale": "zh-CN", "style": "long", "numeric": "always", "numberingSystem": "latn"} let options = relativeTimeFormat.resolvedOptions(); // options = {"locale": "zh-CN", "style": "long", "numeric": "always", "numberingSystem": "latn"}
``` ```
\ No newline at end of file
...@@ -301,7 +301,7 @@ ...@@ -301,7 +301,7 @@
- [@ohos.systemTimer (System Timer)](js-apis-system-timer.md) - [@ohos.systemTimer (System Timer)](js-apis-system-timer.md)
- [@ohos.wallpaper (Wallpaper)](js-apis-wallpaper.md) - [@ohos.wallpaper (Wallpaper)](js-apis-wallpaper.md)
- [@ohos.web.webview (Webview)](js-apis-webview.md) - [@ohos.web.webview (Webview)](js-apis-webview.md)
- [console (Log)](js-apis-logs.md) - [Console](js-apis-logs.md)
- [Timer](js-apis-timer.md) - [Timer](js-apis-timer.md)
- application - application
- [AccessibilityExtensionContext (Accessibility Extension Context)](js-apis-inner-application-accessibilityExtensionContext.md) - [AccessibilityExtensionContext (Accessibility Extension Context)](js-apis-inner-application-accessibilityExtensionContext.md)
......
...@@ -53,11 +53,13 @@ httpRequest.request( ...@@ -53,11 +53,13 @@ httpRequest.request(
// data.header carries the HTTP response header. Parse the content based on service requirements. // data.header carries the HTTP response header. Parse the content based on service requirements.
console.info('header:' + JSON.stringify(data.header)); console.info('header:' + JSON.stringify(data.header));
console.info('cookies:' + JSON.stringify(data.cookies)); // 8+ console.info('cookies:' + JSON.stringify(data.cookies)); // 8+
// Call the destroy() method to release resources after the HttpRequest is complete.
httpRequest.destroy();
} else { } else {
console.info('error:' + JSON.stringify(err)); console.info('error:' + JSON.stringify(err));
// Unsubscribe from HTTP Response Header events. // Unsubscribe from HTTP Response Header events.
httpRequest.off('headersReceive'); httpRequest.off('headersReceive');
// Call the destroy() method to release resources after HttpRequest is complete. // Call the destroy() method to release resources after the HttpRequest is complete.
httpRequest.destroy(); httpRequest.destroy();
} }
} }
...@@ -73,6 +75,9 @@ createHttp(): HttpRequest ...@@ -73,6 +75,9 @@ createHttp(): HttpRequest
Creates an HTTP request. You can use this API to initiate or destroy an HTTP request, or enable or disable listening for HTTP Response Header events. An **HttpRequest** object corresponds to an HTTP request. To initiate multiple HTTP requests, you must create an **HttpRequest** object for each HTTP request. Creates an HTTP request. You can use this API to initiate or destroy an HTTP request, or enable or disable listening for HTTP Response Header events. An **HttpRequest** object corresponds to an HTTP request. To initiate multiple HTTP requests, you must create an **HttpRequest** object for each HTTP request.
> **NOTE**
> Call the **destroy()** method to release resources after the HttpRequest is complete.
**System capability**: SystemCapability.Communication.NetStack **System capability**: SystemCapability.Communication.NetStack
**Return value** **Return value**
...@@ -115,7 +120,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback ...@@ -115,7 +120,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback
**Error codes** **Error codes**
| Code | Error Message | | ID | Error Message |
|---------|-------------------------------------------------------| |---------|-------------------------------------------------------|
| 401 | Parameter error. | | 401 | Parameter error. |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -167,7 +172,7 @@ Initiates an HTTP request containing specified options to a given URL. This API ...@@ -167,7 +172,7 @@ Initiates an HTTP request containing specified options to a given URL. This API
**Error codes** **Error codes**
| Code | Error Message | | ID | Error Message |
|---------|-------------------------------------------------------| |---------|-------------------------------------------------------|
| 401 | Parameter error. | | 401 | Parameter error. |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -258,7 +263,7 @@ Initiates an HTTP request containing specified options to a given URL. This API ...@@ -258,7 +263,7 @@ Initiates an HTTP request containing specified options to a given URL. This API
**Error codes** **Error codes**
| Code | Error Message | | ID | Error Message |
|---------|-------------------------------------------------------| |---------|-------------------------------------------------------|
| 401 | Parameter error. | | 401 | Parameter error. |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -465,7 +470,7 @@ Specifies the type and value range of the optional parameters in the HTTP reques ...@@ -465,7 +470,7 @@ Specifies the type and value range of the optional parameters in the HTTP reques
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | | -------------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
| method | [RequestMethod](#requestmethod) | No | Request method. The default value is **GET**. | | method | [RequestMethod](#requestmethod) | No | Request method. The default value is **GET**. |
| extraData | string<sup>6+</sup> \| Object<sup>6+</sup> \| ArrayBuffer<sup>8+</sup> | No | Additional data for sending a request. This parameter is not used by default.<br>- If the HTTP request uses a POST or PUT method, this parameter serves as the content of the HTTP request and is encoded in UTF-8 format. If **'Content-Type'** is **'application/x-www-form-urlencoded'**, the data in the request body must be encoded in the format of **key1=value1&key2=value2&key3=value3** after URL transcoding.<sup>6+</sup><br>- If the HTTP request uses the GET, OPTIONS, DELETE, TRACE, or CONNECT method, this parameter serves as a supplement to HTTP request parameters. Parameters of the string type need to be encoded before being passed to the HTTP request. Parameters of the object type do not need to be precoded and will be directly concatenated to the URL. Parameters of the ArrayBuffer type will not be concatenated to the URL.<sup>6+</sup> | | extraData | string<sup>6+</sup> \| Object<sup>6+</sup> \| ArrayBuffer<sup>8+</sup> | No | Additional data for sending a request. This parameter is not used by default.<br>- If the HTTP request uses a POST or PUT method, this parameter serves as the content of the HTTP request and is encoded in UTF-8 format. If **'Content-Type'** is **'application/x-www-form-urlencoded'**, the data in the request body must be encoded in the format of **key1=value1&key2=value2&key3=value3** after URL transcoding.<br>- If the HTTP request uses the GET, OPTIONS, DELETE, TRACE, or CONNECT method, this parameter serves as a supplement to HTTP request parameters. Parameters of the string type need to be encoded before being passed to the HTTP request. Parameters of the object type do not need to be precoded and will be directly concatenated to the URL. Parameters of the ArrayBuffer type will not be concatenated to the URL.|
| expectDataType<sup>9+</sup> | [HttpDataType](#httpdatatype9) | No | Type of the returned data. This parameter is not used by default. If this parameter is set, the system returns the specified type of data preferentially.| | expectDataType<sup>9+</sup> | [HttpDataType](#httpdatatype9) | No | Type of the returned data. This parameter is not used by default. If this parameter is set, the system returns the specified type of data preferentially.|
| usingCache<sup>9+</sup> | boolean | No | Whether to use the cache. The default value is **true**. | | usingCache<sup>9+</sup> | boolean | No | Whether to use the cache. The default value is **true**. |
| priority<sup>9+</sup> | number | No | Priority. The value range is [1,1000]. The default value is **1**. | | priority<sup>9+</sup> | number | No | Priority. The value range is [1,1000]. The default value is **1**. |
......
# console (Log) # Console
> **NOTE**<br> > **NOTE**<br>
> The APIs of this module are no longer maintained since API version 7. You are advised to use ['@ohos.hilog](js-apis-hilog.md)' instead. > The APIs of this module are no longer maintained since API version 7. You are advised to use ['@ohos.hilog](js-apis-hilog.md)' instead.
......
...@@ -53,8 +53,7 @@ ethernet.setIfaceConfig("eth0", { ...@@ -53,8 +53,7 @@ ethernet.setIfaceConfig("eth0", {
route: "192.168.xx.xxx", route: "192.168.xx.xxx",
gateway: "192.168.xx.xxx", gateway: "192.168.xx.xxx",
netMask: "255.255.255.0", netMask: "255.255.255.0",
dnsServers: "1.1.1.1", dnsServers: "1.1.1.1"
domain: "2.2.2.2"
}, (error) => { }, (error) => {
if (error) { if (error) {
console.log("setIfaceConfig callback error = " + JSON.stringify(error)); console.log("setIfaceConfig callback error = " + JSON.stringify(error));
...@@ -111,8 +110,7 @@ ethernet.setIfaceConfig("eth0", { ...@@ -111,8 +110,7 @@ ethernet.setIfaceConfig("eth0", {
route: "192.168.xx.xxx", route: "192.168.xx.xxx",
gateway: "192.168.xx.xxx", gateway: "192.168.xx.xxx",
netMask: "255.255.255.0", netMask: "255.255.255.0",
dnsServers: "1.1.1.1", dnsServers: "1.1.1.1"
domain: "2.2.2.2"
}).then(() => { }).then(() => {
console.log("setIfaceConfig promise ok "); console.log("setIfaceConfig promise ok ");
}).catch(error => { }).catch(error => {
...@@ -163,7 +161,6 @@ ethernet.getIfaceConfig("eth0", (error, value) => { ...@@ -163,7 +161,6 @@ ethernet.getIfaceConfig("eth0", (error, value) => {
console.log("getIfaceConfig callback gateway = " + JSON.stringify(value.gateway)); console.log("getIfaceConfig callback gateway = " + JSON.stringify(value.gateway));
console.log("getIfaceConfig callback netMask = " + JSON.stringify(value.netMask)); console.log("getIfaceConfig callback netMask = " + JSON.stringify(value.netMask));
console.log("getIfaceConfig callback dnsServers = " + JSON.stringify(value.dnsServers)); console.log("getIfaceConfig callback dnsServers = " + JSON.stringify(value.dnsServers));
console.log("getIfaceConfig callback domain = " + JSON.stringify(value.domain));
} }
}); });
``` ```
...@@ -213,7 +210,6 @@ ethernet.getIfaceConfig("eth0").then((data) => { ...@@ -213,7 +210,6 @@ ethernet.getIfaceConfig("eth0").then((data) => {
console.log("getIfaceConfig promise gateway = " + JSON.stringify(data.gateway)); console.log("getIfaceConfig promise gateway = " + JSON.stringify(data.gateway));
console.log("getIfaceConfig promise netMask = " + JSON.stringify(data.netMask)); console.log("getIfaceConfig promise netMask = " + JSON.stringify(data.netMask));
console.log("getIfaceConfig promise dnsServers = " + JSON.stringify(data.dnsServers)); console.log("getIfaceConfig promise dnsServers = " + JSON.stringify(data.dnsServers));
console.log("getIfaceConfig promise domain = " + JSON.stringify(data.domain));
}).catch(error => { }).catch(error => {
console.log("getIfaceConfig promise error = " + JSON.stringify(error)); console.log("getIfaceConfig promise error = " + JSON.stringify(error));
}); });
...@@ -386,74 +382,6 @@ ethernet.getAllActiveIfaces().then((data) => { ...@@ -386,74 +382,6 @@ ethernet.getAllActiveIfaces().then((data) => {
}); });
``` ```
## ethernet.on('interfaceStateChange')<sup>10+</sup>
on(type: 'interfaceStateChange', callback: Callback\<{ iface: string, active: boolean }\>): void
Registers an observer for NIC hot swap events. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Ethernet
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ---------- |
| type | string | Yes | Event type. The value is **interfaceStateChange**.|
| callback | AsyncCallback\<{ iface: string, active: boolean }\> | Yes | Callback used to return the result.<br>**iface**: NIC name.<br>**active**: whether the NIC is active. The value **true** indicates that the NIC is active, and the value **false** indicates the opposite.|
**Error codes**
| ID| Error Message |
| ------- | -------------------------------------------- |
| 201 | Permission denied. |
| 202 | Applicable only to system applications. |
| 401 | Parameter error. |
**Example**
```js
ethernet.on('interfaceStateChange', (data) => {
console.log('on interfaceSharingStateChange: ' + JSON.stringify(data));
});
```
## ethernet.off('interfaceStateChange')<sup>10+</sup>
off(type: 'interfaceStateChange', callback?: Callback\<{ iface: string, active: boolean }\>): void
Unregisters the observer for NIC hot swap events. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Ethernet
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ---------- |
| type | string | Yes | Event type. The value is **interfaceStateChange**.|
| callback | AsyncCallback\<{ iface: string, active: boolean }> | No | Callback used to return the result.<br>**iface**: NIC name.<br>**active**: whether the NIC is active. The value **true** indicates that the NIC is active, and the value **false** indicates the opposite.|
**Error codes**
| ID| Error Message |
| ------- | -------------------------------------------- |
| 201 | Permission denied. |
| 202 | Applicable only to system applications. |
| 401 | Parameter error. |
**Example**
```js
ethernet.off('interfaceStateChange');
```
## InterfaceConfiguration ## InterfaceConfiguration
Defines the network configuration for the Ethernet connection. Defines the network configuration for the Ethernet connection.
......
...@@ -6821,8 +6821,8 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6821,8 +6821,8 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
let deathRecipient = new MyDeathRecipient(); let deathRecipient = new MyDeathRecipient();
try { try {
proxy.registerDeathRecippient(deathRecipient, 0); proxy.registerDeathRecipient(deathRecipient, 0);
proxy.unregisterDeathRecippient(deathRecipient, 0); proxy.unregisterDeathRecipient(deathRecipient, 0);
} catch(error) { } catch(error) {
console.info("proxy register deathRecipient fail, errorCode " + error.code); console.info("proxy register deathRecipient fail, errorCode " + error.code);
console.info("proxy register deathRecipient fail, errorMessage " + error.message); console.info("proxy register deathRecipient fail, errorMessage " + error.message);
...@@ -6893,7 +6893,7 @@ Removes the callback used to receive death notifications of the remote object. ...@@ -6893,7 +6893,7 @@ Removes the callback used to receive death notifications of the remote object.
} }
} }
let deathRecipient = new MyDeathRecipient(); let deathRecipient = new MyDeathRecipient();
proxy.addDeathRecippient(deathRecipient, 0); proxy.addDeathRecipient(deathRecipient, 0);
proxy.removeDeathRecipient(deathRecipient, 0); proxy.removeDeathRecipient(deathRecipient, 0);
``` ```
......
...@@ -32,11 +32,11 @@ Creates a **UDPSocket** object. ...@@ -32,11 +32,11 @@ Creates a **UDPSocket** object.
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
``` ```
## UDPSocket ## UDPSocket<sup>7+</sup>
Defines a **UDPSocket** connection. Before invoking UDPSocket APIs, you need to call [socket.constructUDPSocketInstance](#socketconstructudpsocketinstance) to create a **UDPSocket** object. Defines a **UDPSocket** connection. Before invoking UDPSocket APIs, you need to call [socket.constructUDPSocketInstance](#socketconstructudpsocketinstance) to create a **UDPSocket** object.
### bind ### bind<sup>7+</sup>
bind(address: NetAddress, callback: AsyncCallback\<void\>): void bind(address: NetAddress, callback: AsyncCallback\<void\>): void
...@@ -76,7 +76,7 @@ udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { ...@@ -76,7 +76,7 @@ udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
}) })
``` ```
### bind ### bind<sup>7+</sup>
bind(address: NetAddress): Promise\<void\> bind(address: NetAddress): Promise\<void\>
...@@ -120,7 +120,7 @@ promise.then(() => { ...@@ -120,7 +120,7 @@ promise.then(() => {
}); });
``` ```
### send ### send<sup>7+</sup>
send(options: UDPSendOptions, callback: AsyncCallback\<void\>): void send(options: UDPSendOptions, callback: AsyncCallback\<void\>): void
...@@ -166,7 +166,7 @@ udp.send({ ...@@ -166,7 +166,7 @@ udp.send({
}) })
``` ```
### send ### send<sup>7+</sup>
send(options: UDPSendOptions): Promise\<void\> send(options: UDPSendOptions): Promise\<void\>
...@@ -216,7 +216,7 @@ promise.then(() => { ...@@ -216,7 +216,7 @@ promise.then(() => {
}); });
``` ```
### close ### close<sup>7+</sup>
close(callback: AsyncCallback\<void\>): void close(callback: AsyncCallback\<void\>): void
...@@ -245,7 +245,7 @@ udp.close(err => { ...@@ -245,7 +245,7 @@ udp.close(err => {
}) })
``` ```
### close ### close<sup>7+</sup>
close(): Promise\<void\> close(): Promise\<void\>
...@@ -273,7 +273,7 @@ promise.then(() => { ...@@ -273,7 +273,7 @@ promise.then(() => {
}); });
``` ```
### getState ### getState<sup>7+</sup>
getState(callback: AsyncCallback\<SocketStateBase\>): void getState(callback: AsyncCallback\<SocketStateBase\>): void
...@@ -318,7 +318,7 @@ udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { ...@@ -318,7 +318,7 @@ udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
}) })
``` ```
### getState ### getState<sup>7+</sup>
getState(): Promise\<SocketStateBase\> getState(): Promise\<SocketStateBase\>
...@@ -357,7 +357,7 @@ promise.then(err => { ...@@ -357,7 +357,7 @@ promise.then(err => {
}); });
``` ```
### setExtraOptions ### setExtraOptions<sup>7+</sup>
setExtraOptions(options: UDPExtraOptions, callback: AsyncCallback\<void\>): void setExtraOptions(options: UDPExtraOptions, callback: AsyncCallback\<void\>): void
...@@ -410,7 +410,7 @@ udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { ...@@ -410,7 +410,7 @@ udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
}) })
``` ```
### setExtraOptions ### setExtraOptions<sup>7+</sup>
setExtraOptions(options: UDPExtraOptions): Promise\<void\> setExtraOptions(options: UDPExtraOptions): Promise\<void\>
...@@ -466,7 +466,7 @@ promise.then(() => { ...@@ -466,7 +466,7 @@ promise.then(() => {
}); });
``` ```
### on('message') ### on('message')<sup>7+</sup>
on(type: 'message', callback: Callback\<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void on(type: 'message', callback: Callback\<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void
...@@ -490,7 +490,7 @@ udp.on('message', value => { ...@@ -490,7 +490,7 @@ udp.on('message', value => {
}); });
``` ```
### off('message') ### off('message')<sup>7+</sup>
off(type: 'message', callback?: Callback\<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void off(type: 'message', callback?: Callback\<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void
...@@ -521,7 +521,7 @@ udp.off('message', callback); ...@@ -521,7 +521,7 @@ udp.off('message', callback);
udp.off('message'); udp.off('message');
``` ```
### on('listening' | 'close') ### on('listening' | 'close')<sup>7+</sup>
on(type: 'listening' | 'close', callback: Callback\<void\>): void on(type: 'listening' | 'close', callback: Callback\<void\>): void
...@@ -548,7 +548,7 @@ udp.on('close', () => { ...@@ -548,7 +548,7 @@ udp.on('close', () => {
}); });
``` ```
### off('listening' | 'close') ### off('listening' | 'close')<sup>7+</sup>
off(type: 'listening' | 'close', callback?: Callback\<void\>): void off(type: 'listening' | 'close', callback?: Callback\<void\>): void
...@@ -586,7 +586,7 @@ udp.off('close', callback2); ...@@ -586,7 +586,7 @@ udp.off('close', callback2);
udp.off('close'); udp.off('close');
``` ```
### on('error') ### on('error')<sup>7+</sup>
on(type: 'error', callback: ErrorCallback): void on(type: 'error', callback: ErrorCallback): void
...@@ -610,7 +610,7 @@ udp.on('error', err => { ...@@ -610,7 +610,7 @@ udp.on('error', err => {
}); });
``` ```
### off('error') ### off('error')<sup>7+</sup>
off(type: 'error', callback?: ErrorCallback): void off(type: 'error', callback?: ErrorCallback): void
...@@ -641,7 +641,7 @@ udp.off('error', callback); ...@@ -641,7 +641,7 @@ udp.off('error', callback);
udp.off('error'); udp.off('error');
``` ```
## NetAddress ## NetAddress<sup>7+</sup>
Defines the destination address. Defines the destination address.
...@@ -653,7 +653,7 @@ Defines the destination address. ...@@ -653,7 +653,7 @@ Defines the destination address.
| port | number | No | Port number. The value ranges from **0** to **65535**. If this parameter is not specified, the system randomly allocates a port. | | port | number | No | Port number. The value ranges from **0** to **65535**. If this parameter is not specified, the system randomly allocates a port. |
| family | number | No | Network protocol type.<br>- **1**: IPv4<br>- **2**: IPv6<br>The default value is **1**.| | family | number | No | Network protocol type.<br>- **1**: IPv4<br>- **2**: IPv6<br>The default value is **1**.|
## UDPSendOptions ## UDPSendOptions<sup>7+</sup>
Defines the parameters for sending data over the UDPSocket connection. Defines the parameters for sending data over the UDPSocket connection.
...@@ -664,7 +664,7 @@ Defines the parameters for sending data over the UDPSocket connection. ...@@ -664,7 +664,7 @@ Defines the parameters for sending data over the UDPSocket connection.
| data | string \| ArrayBuffer<sup>7+</sup> | Yes | Data to send. | | data | string \| ArrayBuffer<sup>7+</sup> | Yes | Data to send. |
| address | [NetAddress](#netaddress) | Yes | Destination address.| | address | [NetAddress](#netaddress) | Yes | Destination address.|
## UDPExtraOptions ## UDPExtraOptions<sup>7+</sup>
Defines other properties of the UDPSocket connection. Defines other properties of the UDPSocket connection.
...@@ -673,12 +673,12 @@ Defines other properties of the UDPSocket connection. ...@@ -673,12 +673,12 @@ Defines other properties of the UDPSocket connection.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------------- | ------- | ---- | -------------------------------- | | ----------------- | ------- | ---- | -------------------------------- |
| broadcast | boolean | No | Whether to send broadcast messages. The default value is **false**. | | broadcast | boolean | No | Whether to send broadcast messages. The default value is **false**. |
| receiveBufferSize | number | No | Size of the receive buffer, in bytes. | | receiveBufferSize | number | No | Size of the receive buffer, in bytes. The default value is **0**. |
| sendBufferSize | number | No | Size of the send buffer, in bytes. | | sendBufferSize | number | No | Size of the send buffer, in bytes. The default value is **0**. |
| reuseAddress | boolean | No | Whether to reuse addresses. The default value is **false**. | | reuseAddress | boolean | No | Whether to reuse addresses. The default value is **false**. |
| socketTimeout | number | No | Timeout duration of the UDPSocket connection, in ms.| | socketTimeout | number | No | Timeout duration of the UDPSocket connection, in ms. The default value is **0**.|
## SocketStateBase ## SocketStateBase<sup>7+</sup>
Defines the status of the socket connection. Defines the status of the socket connection.
...@@ -690,7 +690,7 @@ Defines the status of the socket connection. ...@@ -690,7 +690,7 @@ Defines the status of the socket connection.
| isClose | boolean | Yes | Whether the connection is in the closed state.| | isClose | boolean | Yes | Whether the connection is in the closed state.|
| isConnected | boolean | Yes | Whether the connection is in the connected state.| | isConnected | boolean | Yes | Whether the connection is in the connected state.|
## SocketRemoteInfo ## SocketRemoteInfo<sup>7+</sup>
Defines information about the socket connection. Defines information about the socket connection.
...@@ -709,7 +709,7 @@ The UDP error code mapping is in the format of 2301000 + Linux kernel error code ...@@ -709,7 +709,7 @@ The UDP error code mapping is in the format of 2301000 + Linux kernel error code
For details about error codes, see [Socket Error Codes](../errorcodes/errorcode-net-socket.md). For details about error codes, see [Socket Error Codes](../errorcodes/errorcode-net-socket.md).
## socket.constructTCPSocketInstance ## socket.constructTCPSocketInstance<sup>7+</sup>
constructTCPSocketInstance(): TCPSocket constructTCPSocketInstance(): TCPSocket
...@@ -729,11 +729,11 @@ Creates a **TCPSocket** object. ...@@ -729,11 +729,11 @@ Creates a **TCPSocket** object.
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
``` ```
## TCPSocket ## TCPSocket<sup>7+</sup>
Defines a TCPSocket connection. Before invoking TCPSocket APIs, you need to call [socket.constructTCPSocketInstance](#socketconstructtcpsocketinstance) to create a **TCPSocket** object. Defines a TCPSocket connection. Before invoking TCPSocket APIs, you need to call [socket.constructTCPSocketInstance](#socketconstructtcpsocketinstance) to create a **TCPSocket** object.
### bind ### bind<sup>7+</sup>
bind(address: NetAddress, callback: AsyncCallback\<void\>): void bind(address: NetAddress, callback: AsyncCallback\<void\>): void
...@@ -773,7 +773,7 @@ tcp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { ...@@ -773,7 +773,7 @@ tcp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
}) })
``` ```
### bind ### bind<sup>7+</sup>
bind(address: NetAddress): Promise\<void\> bind(address: NetAddress): Promise\<void\>
...@@ -817,7 +817,7 @@ promise.then(() => { ...@@ -817,7 +817,7 @@ promise.then(() => {
}); });
``` ```
### connect ### connect<sup>7+</sup>
connect(options: TCPConnectOptions, callback: AsyncCallback\<void\>): void connect(options: TCPConnectOptions, callback: AsyncCallback\<void\>): void
...@@ -857,7 +857,7 @@ tcp.connect({address: {address: '192.168.xx.xxx', port: xxxx, family: 1}, timeou ...@@ -857,7 +857,7 @@ tcp.connect({address: {address: '192.168.xx.xxx', port: xxxx, family: 1}, timeou
}) })
``` ```
### connect ### connect<sup>7+</sup>
connect(options: TCPConnectOptions): Promise\<void\> connect(options: TCPConnectOptions): Promise\<void\>
...@@ -898,7 +898,7 @@ promise.then(() => { ...@@ -898,7 +898,7 @@ promise.then(() => {
}); });
``` ```
### send ### send<sup>7+</sup>
send(options: TCPSendOptions, callback: AsyncCallback\<void\>): void send(options: TCPSendOptions, callback: AsyncCallback\<void\>): void
...@@ -944,7 +944,7 @@ tcp.connect({address: {address: '192.168.xx.xxx', port: xxxx, family: 1}, timeou ...@@ -944,7 +944,7 @@ tcp.connect({address: {address: '192.168.xx.xxx', port: xxxx, family: 1}, timeou
}) })
``` ```
### send ### send<sup>7+</sup>
send(options: TCPSendOptions): Promise\<void\> send(options: TCPSendOptions): Promise\<void\>
...@@ -996,7 +996,7 @@ promise1.then(() => { ...@@ -996,7 +996,7 @@ promise1.then(() => {
}); });
``` ```
### close ### close<sup>7+</sup>
close(callback: AsyncCallback\<void\>): void close(callback: AsyncCallback\<void\>): void
...@@ -1031,7 +1031,7 @@ tcp.close(err => { ...@@ -1031,7 +1031,7 @@ tcp.close(err => {
}) })
``` ```
### close ### close<sup>7+</sup>
close(): Promise\<void\> close(): Promise\<void\>
...@@ -1065,7 +1065,7 @@ promise.then(() => { ...@@ -1065,7 +1065,7 @@ promise.then(() => {
}); });
``` ```
### getRemoteAddress ### getRemoteAddress<sup>7+</sup>
getRemoteAddress(callback: AsyncCallback\<NetAddress\>): void getRemoteAddress(callback: AsyncCallback\<NetAddress\>): void
...@@ -1106,7 +1106,7 @@ tcp.connect({address: {address: '192.168.xx.xxx', port: xxxx, family: 1}, timeou ...@@ -1106,7 +1106,7 @@ tcp.connect({address: {address: '192.168.xx.xxx', port: xxxx, family: 1}, timeou
}); });
``` ```
### getRemoteAddress ### getRemoteAddress<sup>7+</sup>
getRemoteAddress(): Promise\<NetAddress\> getRemoteAddress(): Promise\<NetAddress\>
...@@ -1149,7 +1149,7 @@ promise1.then(() => { ...@@ -1149,7 +1149,7 @@ promise1.then(() => {
}); });
``` ```
### getState ### getState<sup>7+</sup>
getState(callback: AsyncCallback\<SocketStateBase\>): void getState(callback: AsyncCallback\<SocketStateBase\>): void
...@@ -1190,7 +1190,7 @@ let promise = tcp.connect({address: {address: '192.168.xx.xxx', port: xxxx, fami ...@@ -1190,7 +1190,7 @@ let promise = tcp.connect({address: {address: '192.168.xx.xxx', port: xxxx, fami
}); });
``` ```
### getState ### getState<sup>7+</sup>
getState(): Promise\<SocketStateBase\> getState(): Promise\<SocketStateBase\>
...@@ -1233,7 +1233,7 @@ promise.then(() => { ...@@ -1233,7 +1233,7 @@ promise.then(() => {
}); });
``` ```
### setExtraOptions ### setExtraOptions<sup>7+</sup>
setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback\<void\>): void setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback\<void\>): void
...@@ -1285,7 +1285,7 @@ let promise = tcp.connect({address: {address: '192.168.xx.xxx', port: xxxx, fami ...@@ -1285,7 +1285,7 @@ let promise = tcp.connect({address: {address: '192.168.xx.xxx', port: xxxx, fami
}); });
``` ```
### setExtraOptions ### setExtraOptions<sup>7+</sup>
setExtraOptions(options: TCPExtraOptions): Promise\<void\> setExtraOptions(options: TCPExtraOptions): Promise\<void\>
...@@ -1344,7 +1344,7 @@ promise.then(() => { ...@@ -1344,7 +1344,7 @@ promise.then(() => {
}); });
``` ```
### on('message') ### on('message')<sup>7+</sup>
on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void
...@@ -1368,7 +1368,7 @@ tcp.on('message', value => { ...@@ -1368,7 +1368,7 @@ tcp.on('message', value => {
}); });
``` ```
### off('message') ### off('message')<sup>7+</sup>
off(type: 'message', callback?: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void off(type: 'message', callback?: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void
...@@ -1399,7 +1399,7 @@ tcp.off('message', callback); ...@@ -1399,7 +1399,7 @@ tcp.off('message', callback);
tcp.off('message'); tcp.off('message');
``` ```
### on('connect' | 'close') ### on('connect' | 'close')<sup>7+</sup>
on(type: 'connect' | 'close', callback: Callback\<void\>): void on(type: 'connect' | 'close', callback: Callback\<void\>): void
...@@ -1426,7 +1426,7 @@ tcp.on('close', data => { ...@@ -1426,7 +1426,7 @@ tcp.on('close', data => {
}); });
``` ```
### off('connect' | 'close') ### off('connect' | 'close')<sup>7+</sup>
off(type: 'connect' | 'close', callback?: Callback\<void\>): void off(type: 'connect' | 'close', callback?: Callback\<void\>): void
...@@ -1464,7 +1464,7 @@ tcp.off('close', callback2); ...@@ -1464,7 +1464,7 @@ tcp.off('close', callback2);
tcp.off('close'); tcp.off('close');
``` ```
### on('error') ### on('error')<sup>7+</sup>
on(type: 'error', callback: ErrorCallback): void on(type: 'error', callback: ErrorCallback): void
...@@ -1488,7 +1488,7 @@ tcp.on('error', err => { ...@@ -1488,7 +1488,7 @@ tcp.on('error', err => {
}); });
``` ```
### off('error') ### off('error')<sup>7+</sup>
off(type: 'error', callback?: ErrorCallback): void off(type: 'error', callback?: ErrorCallback): void
...@@ -1519,7 +1519,7 @@ tcp.off('error', callback); ...@@ -1519,7 +1519,7 @@ tcp.off('error', callback);
tcp.off('error'); tcp.off('error');
``` ```
## TCPConnectOptions ## TCPConnectOptions<sup>7+</sup>
Defines TCPSocket connection parameters. Defines TCPSocket connection parameters.
...@@ -1530,7 +1530,7 @@ Defines TCPSocket connection parameters. ...@@ -1530,7 +1530,7 @@ Defines TCPSocket connection parameters.
| address | [NetAddress](#netaddress) | Yes | Bound IP address and port number. | | address | [NetAddress](#netaddress) | Yes | Bound IP address and port number. |
| timeout | number | No | Timeout duration of the TCPSocket connection, in ms.| | timeout | number | No | Timeout duration of the TCPSocket connection, in ms.|
## TCPSendOptions ## TCPSendOptions<sup>7+</sup>
Defines the parameters for sending data over the TCPSocket connection. Defines the parameters for sending data over the TCPSocket connection.
...@@ -1541,7 +1541,7 @@ Defines the parameters for sending data over the TCPSocket connection. ...@@ -1541,7 +1541,7 @@ Defines the parameters for sending data over the TCPSocket connection.
| data | string\| ArrayBuffer<sup>7+</sup> | Yes | Data to send. | | data | string\| ArrayBuffer<sup>7+</sup> | Yes | Data to send. |
| encoding | string | No | Character encoding format. The options are as follows: **UTF-8**, **UTF-16BE**, **UTF-16LE**, **UTF-16**, **US-AECII**, and **ISO-8859-1**. The default value is **UTF-8**.| | encoding | string | No | Character encoding format. The options are as follows: **UTF-8**, **UTF-16BE**, **UTF-16LE**, **UTF-16**, **US-AECII**, and **ISO-8859-1**. The default value is **UTF-8**.|
## TCPExtraOptions ## TCPExtraOptions<sup>7+</sup>
Defines other properties of the TCPSocket connection. Defines other properties of the TCPSocket connection.
...@@ -1553,10 +1553,10 @@ Defines other properties of the TCPSocket connection. ...@@ -1553,10 +1553,10 @@ Defines other properties of the TCPSocket connection.
| OOBInline | boolean | No | Whether to enable OOBInline. The default value is **false**. | | OOBInline | boolean | No | Whether to enable OOBInline. The default value is **false**. |
| TCPNoDelay | boolean | No | Whether to enable no-delay on the TCPSocket connection. The default value is **false**. | | TCPNoDelay | boolean | No | Whether to enable no-delay on the TCPSocket connection. The default value is **false**. |
| socketLinger | Object | Yes | Socket linger.<br>- **on**: whether to enable socket linger. The value true means to enable socket linger and false means the opposite.<br>- **linger**: linger time, in ms. The value ranges from **0** to **65535**.<br>Specify this parameter only when **on** is set to **true**.| | socketLinger | Object | Yes | Socket linger.<br>- **on**: whether to enable socket linger. The value true means to enable socket linger and false means the opposite.<br>- **linger**: linger time, in ms. The value ranges from **0** to **65535**.<br>Specify this parameter only when **on** is set to **true**.|
| receiveBufferSize | number | No | Size of the receive buffer, in bytes. | | receiveBufferSize | number | No | Size of the receive buffer, in bytes. The default value is **0**. |
| sendBufferSize | number | No | Size of the send buffer, in bytes. | | sendBufferSize | number | No | Size of the send buffer, in bytes. The default value is **0**. |
| reuseAddress | boolean | No | Whether to reuse addresses. The default value is **false**. | | reuseAddress | boolean | No | Whether to reuse addresses. The default value is **false**. |
| socketTimeout | number | No | Timeout duration of the UDPSocket connection, in ms. | | socketTimeout | number | No | Timeout duration of the TCPSocket connection, in ms. The default value is **0**. |
## Description of TCP Error Codes ## Description of TCP Error Codes
...@@ -1853,7 +1853,7 @@ promise.then(() => { ...@@ -1853,7 +1853,7 @@ promise.then(() => {
}); });
``` ```
### on('message') ### on('message')<sup>9+</sup>
on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void;
...@@ -1884,7 +1884,7 @@ tls.on('message', value => { ...@@ -1884,7 +1884,7 @@ tls.on('message', value => {
}); });
``` ```
### off('message') ### off('message')<sup>9+</sup>
off(type: 'message', callback?: Callback\<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void off(type: 'message', callback?: Callback\<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void
...@@ -1920,7 +1920,7 @@ tls.on('message', callback); ...@@ -1920,7 +1920,7 @@ tls.on('message', callback);
// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. // You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks.
tls.off('message', callback); tls.off('message', callback);
``` ```
### on('connect' | 'close') ### on('connect' | 'close')<sup>9+</sup>
on(type: 'connect' | 'close', callback: Callback\<void\>): void on(type: 'connect' | 'close', callback: Callback\<void\>): void
...@@ -1947,7 +1947,7 @@ tls.on('close', () => { ...@@ -1947,7 +1947,7 @@ tls.on('close', () => {
}); });
``` ```
### off('connect' | 'close') ### off('connect' | 'close')<sup>9+</sup>
off(type: 'connect' | 'close', callback?: Callback\<void\>): void off(type: 'connect' | 'close', callback?: Callback\<void\>): void
...@@ -1984,7 +1984,7 @@ tls.on('close', callback2); ...@@ -1984,7 +1984,7 @@ tls.on('close', callback2);
tls.off('close', callback2); tls.off('close', callback2);
``` ```
### on('error') ### on('error')<sup>9+</sup>
on(type: 'error', callback: ErrorCallback): void on(type: 'error', callback: ErrorCallback): void
...@@ -2008,7 +2008,7 @@ tls.on('error', err => { ...@@ -2008,7 +2008,7 @@ tls.on('error', err => {
}); });
``` ```
### off('error') ### off('error')<sup>9+</sup>
off(type: 'error', callback?: ErrorCallback): void off(type: 'error', callback?: ErrorCallback): void
...@@ -2783,7 +2783,7 @@ Defines TLS connection options. ...@@ -2783,7 +2783,7 @@ Defines TLS connection options.
| -------------- | ------------------------------------- | --- |-------------- | | -------------- | ------------------------------------- | --- |-------------- |
| address | [NetAddress](#netaddress) | Yes | Gateway address. | | address | [NetAddress](#netaddress) | Yes | Gateway address. |
| secureOptions | [TLSSecureOptions](#tlssecureoptions9) | Yes| TLS security options.| | secureOptions | [TLSSecureOptions](#tlssecureoptions9) | Yes| TLS security options.|
| ALPNProtocols | Array\<string\> | No| Application Layer Protocol Negotiation (ALPN) protocols. | | ALPNProtocols | Array\<string\> | No| ALPN protocol. The value range is ["spdy/1", "http/1.1"]. The default value is **[]**. |
## TLSSecureOptions<sup>9+</sup> ## TLSSecureOptions<sup>9+</sup>
...@@ -2797,10 +2797,10 @@ Defines TLS security options. The CA certificate is mandatory, and other paramet ...@@ -2797,10 +2797,10 @@ Defines TLS security options. The CA certificate is mandatory, and other paramet
| cert | string | No| Digital certificate of the local client. | | cert | string | No| Digital certificate of the local client. |
| key | string | No| Private key of the local digital certificate. | | key | string | No| Private key of the local digital certificate. |
| password | string | No| Password for reading the private key. | | password | string | No| Password for reading the private key. |
| protocols | [Protocol](#protocol9) \|Array\<[Protocol](#protocol9)\> | No| TLS protocol version. | | protocols | [Protocol](#protocol9) \|Array\<[Protocol](#protocol9)\> | No| TLS protocol version. The default value is **TLSv1.2**. |
| useRemoteCipherPrefer | boolean | No| Whether to use the remote cipher suite preferentially. | | useRemoteCipherPrefer | boolean | No| Whether to use the remote cipher suite preferentially. |
| signatureAlgorithms | string | No| Signing algorithm used during communication. | | signatureAlgorithms | string | No| Signing algorithm used during communication. The default value is **""**. |
| cipherSuite | string | No| Cipher suite used during communication. | | cipherSuite | string | No| Cipher suite used during communication. The default value is **""**. |
## Protocol<sup>9+</sup> ## Protocol<sup>9+</sup>
......
...@@ -27,7 +27,7 @@ Obtains the current charging state and battery level. ...@@ -27,7 +27,7 @@ Obtains the current charging state and battery level.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [GetStatusOptions](#getstatusoptions) | No| Object that contains the API calling result.| | options | [GetStatusOptions](#getstatusoptions) | No| Object that contains the API calling result. This parameter is optional and is left blank by default.|
**Example** **Example**
...@@ -44,15 +44,15 @@ battery.getStatus({ ...@@ -44,15 +44,15 @@ battery.getStatus({
## GetStatusOptions ## GetStatusOptions
Obtains the object that contains the API calling result. Object that contains the API calling result.
**System capability**: SystemCapability.PowerManager.BatteryManager.Core **System capability**: SystemCapability.PowerManager.BatteryManager.Core
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ |
| success | (data: [BatteryResponse](#batteryresponse)) => void | No | Called when API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponse) type.| | success | (data: [BatteryResponse](#batteryresponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponse) type.|
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | | fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when API call is complete. | | complete | () => void | No | Called when an API call is complete. |
## BatteryResponse ## BatteryResponse
...@@ -60,7 +60,7 @@ Defines a response that returns the charging status and remaining power of the d ...@@ -60,7 +60,7 @@ Defines a response that returns the charging status and remaining power of the d
**System capability**: SystemCapability.PowerManager.BatteryManager.Core **System capability**: SystemCapability.PowerManager.BatteryManager.Core
| Name| Type| Readable | Writable | Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| charging | boolean | Yes | No | Whether the battery is being charged.| | charging | boolean | Yes| No| Whether the battery is being charged.|
| level | number | Yes | No | Current battery level, which ranges from **0.00** to **1.00**.| | level | number | Yes| No| Current battery level, which ranges from **0.00** to **1.00**.|
...@@ -28,7 +28,7 @@ Obtains the current screen brightness. ...@@ -28,7 +28,7 @@ Obtains the current screen brightness.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [GetBrightnessOptions](#getbrightnessoptions) | No | Options for obtaining the screen brightness.| | options | [GetBrightnessOptions](#getbrightnessoptions) | No | Options for obtaining the screen brightness. This parameter is optional and is left blank by default.|
**Example** **Example**
...@@ -56,7 +56,7 @@ Sets the screen brightness. ...@@ -56,7 +56,7 @@ Sets the screen brightness.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [SetBrightnessOptions](#setbrightnessoptions) | No | Options for setting the screen brightness.| | options | [SetBrightnessOptions](#setbrightnessoptions) | No | Options for setting the screen brightness. This parameter is optional and is left blank by default.|
**Example** **Example**
...@@ -85,7 +85,7 @@ Obtains the screen brightness adjustment mode. ...@@ -85,7 +85,7 @@ Obtains the screen brightness adjustment mode.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [GetBrightnessModeOptions](#getbrightnessmodeoptions) | No| Options for obtaining the screen brightness mode.| | options | [GetBrightnessModeOptions](#getbrightnessmodeoptions) | No| Options for obtaining the screen brightness mode. This parameter is optional and is left blank by default.|
**Example** **Example**
...@@ -112,7 +112,7 @@ Sets the screen brightness adjustment mode. ...@@ -112,7 +112,7 @@ Sets the screen brightness adjustment mode.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [SetBrightnessModeOptions](#setbrightnessmodeoptions) | No | Options for setting the screen brightness mode.| | options | [SetBrightnessModeOptions](#setbrightnessmodeoptions) | No | Options for setting the screen brightness mode. This parameter is optional and is left blank by default.|
**Example** **Example**
...@@ -143,7 +143,7 @@ Sets whether to always keep the screen on. Call this API in **onShow()**. ...@@ -143,7 +143,7 @@ Sets whether to always keep the screen on. Call this API in **onShow()**.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [SetKeepScreenOnOptions](#setkeepscreenonoptions) | No| Options for setting the screen to be steady on.| | options | [SetKeepScreenOnOptions](#setkeepscreenonoptions) | No| Options for setting the screen to be steady on. This parameter is optional and is left blank by default.|
**Example** **Example**
...@@ -166,9 +166,9 @@ Defines the options for obtaining the screen brightness. ...@@ -166,9 +166,9 @@ Defines the options for obtaining the screen brightness.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| success | (data: [BrightnessResponse](#brightnessresponse)) => void | No | Called when API call is successful. **data** is a return value of the [BrightnessResponse](#brightnessresponse) type.| | success | (data: [BrightnessResponse](#brightnessresponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BrightnessResponse](#brightnessresponse) type.|
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | | fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when the API call is complete. | | complete | () => void | No | Called when an API call is complete. |
## SetBrightnessOptions ## SetBrightnessOptions
...@@ -178,10 +178,10 @@ Defines the options for setting the screen brightness. ...@@ -178,10 +178,10 @@ Defines the options for setting the screen brightness.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
| value | number | Yes | Screen brightness. The value is an integer ranging from **1** to **255**.<br>-&nbsp;If the value is less than or equal to **0**, value **1** will be used.<br>-&nbsp;If the value is greater than **255**, value **255** will be used.<br>-&nbsp;If the value contains decimals, the integral part of the value will be used. For example, if value **8.1** is set, value **8** will be used.| | value | number | Yes | Screen brightness. The value is an integer ranging from **1** to **255**.<br>- If the value is less than or equal to **0**, value **1** will be used.<br>- If the value is greater than **255**, value **255** will be used.<br>- If the value contains decimals, the integral part of the value will be used. For example, if value **8.1** is set, value **8** will be used.|
| success | () => void | No | Callback upon a successful API call. | | success | () => void | No | Called when an API call is successful. |
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | | fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when the API call is complete. | | complete | () => void | No | Called when an API call is complete. |
## BrightnessResponse ## BrightnessResponse
...@@ -201,9 +201,9 @@ Defines the options for obtaining the screen brightness mode. ...@@ -201,9 +201,9 @@ Defines the options for obtaining the screen brightness mode.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| success | (data: [BrightnessModeResponse](#brightnessmoderesponse)) => void | No | Called when API call is successful. **data** is a return value of the [BrightnessModeResponse](#brightnessmoderesponse) type.| | success | (data: [BrightnessModeResponse](#brightnessmoderesponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BrightnessModeResponse](#brightnessmoderesponse) type.|
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | | fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when the API call is complete. | | complete | () => void | No | Called when an API call is complete. |
## SetBrightnessModeOptions ## SetBrightnessModeOptions
...@@ -214,9 +214,9 @@ Defines the options for setting the screen brightness mode. ...@@ -214,9 +214,9 @@ Defines the options for setting the screen brightness mode.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------ | | -------- | ------------------------------------ | ---- | ------------------------------------------------------ |
| mode | number | Yes | The value **0** indicates the manual adjustment mode, and the value **1** indicates the automatic adjustment mode.| | mode | number | Yes | The value **0** indicates the manual adjustment mode, and the value **1** indicates the automatic adjustment mode.|
| success | () => void | No | Callback upon a successful API call. | | success | () => void | No | Called when an API call is successful. |
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.| | fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code.|
| complete | () => void | No | Called when the API call is complete. | | complete | () => void | No | Called when an API call is complete. |
## BrightnessModeResponse ## BrightnessModeResponse
...@@ -237,6 +237,6 @@ Defines the options for setting the screen to be steady on. ...@@ -237,6 +237,6 @@ Defines the options for setting the screen to be steady on.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------ | ------------------------------------ | ---- | ------------------------------------------------------ | | ------------ | ------------------------------------ | ---- | ------------------------------------------------------ |
| keepScreenOn | boolean | Yes | The value **true** means to keep the screen steady on, and the value **false** indicates the opposite. | | keepScreenOn | boolean | Yes | The value **true** means to keep the screen steady on, and the value **false** indicates the opposite. |
| success | () => void | No | Callback upon a successful API call. | | success | () => void | No | Called when an API call is successful. |
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.| | fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code.|
| complete | () => void | No | Called when the API call is complete. | | complete | () => void | No | Called when an API call is complete. |
...@@ -1211,7 +1211,7 @@ ...@@ -1211,7 +1211,7 @@
- [@ohos.systemTimer (System Timer)](reference/apis/js-apis-system-timer.md) - [@ohos.systemTimer (System Timer)](reference/apis/js-apis-system-timer.md)
- [@ohos.wallpaper (Wallpaper)](reference/apis/js-apis-wallpaper.md) - [@ohos.wallpaper (Wallpaper)](reference/apis/js-apis-wallpaper.md)
- [@ohos.web.webview (Webview)](reference/apis/js-apis-webview.md) - [@ohos.web.webview (Webview)](reference/apis/js-apis-webview.md)
- [console (Log)](reference/apis/js-apis-logs.md) - [Console](reference/apis/js-apis-logs.md)
- [Timer](reference/apis/js-apis-timer.md) - [Timer](reference/apis/js-apis-timer.md)
- application - application
- [AccessibilityExtensionContext](reference/apis/js-apis-inner-application-accessibilityExtensionContext.md) - [AccessibilityExtensionContext](reference/apis/js-apis-inner-application-accessibilityExtensionContext.md)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册