提交 98672c9f 编写于 作者: Y yuyaozhi

Merge branch 'master' of https://gitee.com/yuyaozhi/docs

......@@ -45,8 +45,13 @@
- [SMS](js-apis-sms.md)
- [SIM Management](js-apis-sim.md)
- [Radio](js-apis-radio.md)
- [observer](js-apis-observer.md)
- [Observer](js-apis-observer.md)
- [Cellular Data](js-apis-telephony-data.md)
- Network Management
- [Network Connection Management](js-apis-net-connection.md)
- [Socket Connection](js-apis-socket.md)
- [WebSocket Connection](js-apis-webSocket.md)
- [Data Request](js-apis-http.md)
- Network and Connectivity
- [WLAN](js-apis-wifi.md)
- [Bluetooth](js-apis-bluetooth.md)
......
......@@ -9,57 +9,62 @@
import hiTraceChain from '@ohos.hiTraceChain';
```
## System Capabilities
SystemCapability.HiviewDFX.HiTrace
## HiTraceFlag
Enumerates trace flag types.
**System capability**: SystemCapability.HiviewDFX.HiTrace
| Name| Default Value| Description|
| -------- | -------- | -------- |
| DEFAULT | 0 | Default flag|
| INCLUDE_ASYNC | 1 | Asynchronous call flag|
| DONOT_CREATE_SPAN | 1 << 1 | No span flag|
| TP_INFO | 1 << 2 | Trace point flag|
| NO_BE_INFO | 1 << 3 | No begin/end flag|
| DISABLE_LOG | 1 << 4 | Log association flag|
| FAILURE_TRIGGER | 1 << 5 | Failure trigger flag|
| D2D_TP_INFO | 1 << 6 | Device-to-device trace point flag|
| DEFAULT | 0 | Default flag. |
| INCLUDE_ASYNC | 1 | Asynchronous call flag. By default, only synchronous calls are traced. If this flag is set, both synchronous and asynchronous calls will be traced. |
| DONOT_CREATE_SPAN | 1 << 1 | No span flag. By default, a span is automatically created during tracing of synchronous and asynchronous calls. If this flag is set, no span will be created. |
| TP_INFO | 1 << 2 | Trace point flag. By default, no trace point is added when tracing is enabled. This flag is used for debugging. If this flag is set, trace points will be automatically added on the TX and RX sides of synchronous and asynchronous calls to output trace point and timestamp information. Trace points are classified into four types: [CS, SR, SS, and CR](#hitracetracepointtype). For a synchronous call, the output trace points are CS, SR, SS, and CR; for an asynchronous call, the output trace points are CS, SR, and SS. |
| NO_BE_INFO | 1 << 3 | No begin/end flag. By default, information about the start and end of the trace task is printed. If this flag is set, information about the start and end of the trace task will not be printed.|
| DISABLE_LOG | 1 << 4 | Log association flag. If this flag is set, information about the trace task will not be printed. |
| FAILURE_TRIGGER | 1 << 5 | Failure trigger flag. This flag is reserved for future use. |
| D2D_TP_INFO | 1 << 6 | Device-to-device trace point flag. It is a subset of **TP_INFO**. If this flag is set, trace points are added only for call chain tracing between devices.|
## HiTraceTracepointType
Enumerates trace point types.
**System capability**: SystemCapability.HiviewDFX.HiTrace
| Name| Default Value| Description|
| -------- | -------- | -------- |
| CS | 0 | Client Send|
| CR | 1 | Client Receive|
| SS | 2 | Server Send|
| SR | 3 | Server Receive|
| GENERAL | 4 | General|
| CS | 0 | Client Send (CS) trace point. |
| CR | 1 | Client Receive (CS) trace point. |
| SS | 2 | Server Send (SS) trace point. |
| SR | 3 | Server Receive (SR) trace point. |
| GENERAL | 4 | General trace points except CS, CR, SS, and SR.|
## HiTraceCommunicationMode
Enumerates communication modes.
**System capability**: SystemCapability.HiviewDFX.HiTrace
| Name| Default Value| Description|
| -------- | -------- | -------- |
| DEFAULT | 0 | Default mode|
| THREAD | 1 | Inter-thread communication|
| PROCESS | 2 | Inter-process communication|
| DEVICE | 3 | Inter-device communication|
| DEFAULT | 0 | Default communication mode. |
| THREAD | 1 | Inter-thread communication. |
| PROCESS | 2 | Inter-process communication. |
| DEVICE | 3 | Inter-device communication. |
## HiTraceId
Defines a **HiTraceId** object.
**System capability**: SystemCapability.HiviewDFX.HiTrace
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| chainId | bigint | Yes| Call chain ID.|
| spanId | number | No| Span ID.|
| parentSpanId | number | No| Parent span ID.|
| chainId | bigint | Yes| Call chain ID. |
| spanId | number | No| Span ID. |
| parentSpanId | number | No| Parent span ID. |
| flags | number | No| Trace flag combination.|
## hiTraceChain.begin
......@@ -68,6 +73,8 @@ begin(name: string, flags: number = HiTraceFlag.DEFAULT): HiTraceId
Starts call chain tracing. This API works in synchronous manner.
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -93,6 +100,8 @@ end(id: HiTraceId): void
Stops call chain tracing. This API works in synchronous manner.
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -113,6 +122,8 @@ getId(): HiTraceId
Obtains the trace ID. This API works in synchronous manner.
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Return value**
| Type| Description|
......@@ -133,6 +144,8 @@ setId(id: HiTraceId): void
Sets a trace ID. This API works in synchronous manner.
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -153,6 +166,8 @@ clearId(): void
Clears the trace ID. This API works in synchronous manner.
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Example**
```
......@@ -167,6 +182,8 @@ createSpan(): HiTraceId
Creates a trace span. This API works in synchronous manner.
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Return value**
| Type| Description|
......@@ -187,6 +204,8 @@ tracepoint(mode: HiTraceCommunicationMode, type: HiTraceTracepointType, id: HiTr
Triggers a trace point. This API works in synchronous manner.
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -210,6 +229,8 @@ isValid(id: HiTraceId): boolean
Checks whether a **HiTraceId** instance is valid. This API works in synchronous manner.
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -235,6 +256,8 @@ isFlagEnabled(id: HiTraceId, flag: HiTraceFlag): boolean
Checks whether the specified trace flag in the **HiTraceId** instance is enabled. This API works in synchronous manner.
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -262,6 +285,8 @@ enableFlag(id: HiTraceId, flag: HiTraceFlag): void
Enables the specified trace flag in the **HiTraceId** instance. This API works in synchronous manner.
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
......
......@@ -37,8 +37,8 @@ httpRequest.request(
extraData: {
"data": "data to send",
},
connectTimeout: 60000, // Optional. The default value is **60000**, in ms.
readTimeout: 60000, // Optional. The default value is **60000**, in ms.
connectTimeout: 60000, // Optional. The default value is 60000, in ms.
readTimeout: 60000, // Optional. The default value is 60000, in ms.
},(err, data) => {
if (!err) {
// data.result contains the HTTP response. It is up to you whether to parse the content.
......@@ -60,7 +60,7 @@ httpRequest.request(
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.
**System capability**: SystemCapability.Communication.NetStack
......@@ -68,7 +68,7 @@ Creates an HTTP request. You can use this API to initiate or destroy an HTTP req
| Type | Description |
| :---------- | :----------------------------------------------------------- |
| HttpRequest | An **HttpRequest **object, which contains the **request**, **destroy**, **on**, or **off** method.|
| HttpRequest | An **HttpRequest** object, which contains the **request**, **destroy**, **on**, or **off** method.|
**Example**
......@@ -137,25 +137,25 @@ Initiates an HTTP request containing specified options to a given URL. This API
```
httpRequest.request("EXAMPLE_URL",
{
method: 'GET',
header: {
'Content-Type': 'application/json'
},
readTimeout: 60000,
connectTimeout: 60000
},(err, data) => {
if (!err) {
console.info('Result:' + data.result);
console.info('code:' + data.responseCode);
console.info('header:' + data.header);
console.info('cookies:' + data.cookies); // 8+
console.info('header['Content-Type']:' + data.header['Content-Type']);
console.info('header['Status-Line']:' + data.header['Status-Line']);
console.info('header.Date:' + data.header.Date);
console.info('header.Server:' + data.header.Server);
} else {
console.info('error:' + err.data);
}
method: 'GET',
header: {
'Content-Type': 'application/json'
},
readTimeout: 60000,
connectTimeout: 60000
}, (err, data) => {
if (!err) {
console.info('Result:' + data.result);
console.info('code:' + data.responseCode);
console.info('header:' + data.header);
console.info('cookies:' + data.cookies); // 8+
console.info('header.Content-Type:' + data.header['Content-Type']);
console.info('header.Status-Line:' + data.header['Status-Line']);
console.info('header.Date:' + data.header.Date);
console.info('header.Server:' + data.header.Server);
} else {
console.info('error:' + err.data);
}
});
```
......@@ -188,24 +188,24 @@ Initiates an HTTP request to a given URL. This API uses a promise to return the
```
let promise = httpRequest.request("EXAMPLE_URL", {
method: "GET",
connectTimeout: 60000,
readTimeout: 60000,
header: {
'Content-Type': 'application/json'
}
method: "GET",
connectTimeout: 60000,
readTimeout: 60000,
header: {
'Content-Type': 'application/json'
}
});
promise.then((value) => {
console.info('Result:' + value.result);
console.info('code:' + value.responseCode);
console.info('header:' + value.header);
console.info('cookies:' + value.cookies); // 8+
console.info('header['Content-Type']:' + value.header['Content-Type']);
console.info('header['Status-Line']:' + value.header['Status-Line']);
console.info('header.Date:' + value.header.Date);
console.info('header.Server:' + value.header.Server);
console.info('Result:' + value.result);
console.info('code:' + value.responseCode);
console.info('header:' + value.header);
console.info('cookies:' + value.cookies); // 8+
console.info('header.Content-Type:' + value.header['Content-Type']);
console.info('header.Status-Line:' + value.header['Status-Line']);
console.info('header.Date:' + value.header.Date);
console.info('header.Server:' + value.header.Server);
}).catch((err) => {
console.error(`errCode:${err.code}, errMessage:${err.data}`);
console.error(`errCode:${err.code}, errMessage:${err.data}`);
});
```
......@@ -246,9 +246,9 @@ Registers an observer for HTTP Response Header events.
```
httpRequest.on('headerReceive', (err, data) => {
if (!err) {
console.info('header: ' + data.header);
console.info('header: ' + data.header);
} else {
console.info('error:' + err.data);
console.info('error:' + err.data);
}
});
```
......@@ -280,9 +280,9 @@ Unregisters the observer for HTTP Response Header events.
```
httpRequest.on('headerReceive', (err, data) => {
if (!err) {
console.info('header: ' + data.header);
console.info('header: ' + data.header);
} else {
console.info('error:' + err.data);
console.info('error:' + err.data);
}
});
httpRequest.off('headerReceive');
......
# Network Connection Management
> **NOTE**<br/>
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -17,7 +17,7 @@ getDefaultNet(callback: AsyncCallback\<NetHandle>): void
Obtains the default active data network. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -42,11 +42,11 @@ getDefaultNet(): Promise\<NetHandle>
Obtains the default active data network. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Return value**
**Return Value**
| Type | Description |
| --------------------------------- | ------------------------------------- |
......@@ -91,7 +91,7 @@ Checks whether the default data network is activated. This API uses a promise to
**System capability**: SystemCapability.Communication.NetManager.Core
**Return value**
**Return Value**
| Type | Description |
| ----------------- | ----------------------------------------------- |
......@@ -111,7 +111,7 @@ getAllNets(callback: AsyncCallback&lt;Array&lt;NetHandle&gt;&gt;): void
Obtains the list of all active data networks. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -136,11 +136,11 @@ getAllNets(): Promise&lt;Array&lt;NetHandle&gt;&gt;
Obtains the list of all active data networks. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Return value**
**Return Value**
| Type| Description|
| -------- | -------- |
| Promise&lt;Array&lt;[NetHandle](#nethandle)&gt;&gt; | Promise used to return the result.|
......@@ -157,9 +157,9 @@ connection.getAllNets().then(function (nets) {
getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\<ConnectionProperties>): void
Obtains connection properties of the network corresponding to the **netHandle**. This API uses an asynchronous callback to return the result.
Obtains connection properties of the network corresponding to given network handle. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -185,9 +185,9 @@ connection.getDefaultNet().then(function (netHandle) {
getConnectionProperties(netHandle: NetHandle): Promise\<ConnectionProperties>
Obtains connection properties of the network corresponding to the **netHandle**. This API uses a promise to return the result.
Obtains connection properties of the network corresponding to **netHandle**. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -197,7 +197,7 @@ Obtains connection properties of the network corresponding to the **netHandle**.
| --------- | ----------------------- | ---- | ---------------- |
| netHandle | [NetHandle](#nethandle) | Yes | Network handle.|
**Return value**
**Return Value**
| Type | Description |
| ------------------------------------------------------- | --------------------------------- |
......@@ -217,9 +217,9 @@ connection.getDefaultNet().then(function (netHandle) {
getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback\<NetCapabilities>): void
Obtains capability information of the network corresponding to the **netHandle**. This API uses an asynchronous callback to return the result.
Obtains capability information of the network corresponding to **netHandle**. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -245,9 +245,9 @@ connection.getDefaultNet().then(function (netHandle) {
getNetCapabilities(netHandle: NetHandle): Promise\<NetCapabilities>
Obtains capability information of the network corresponding to the **netHandle**. This API uses a promise to return the result.
Obtains capability information of the network corresponding to **netHandle**. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -257,7 +257,7 @@ Obtains capability information of the network corresponding to the **netHandle**
| --------- | ----------------------- | ---- | ---------------- |
| netHandle | [NetHandle](#nethandle) | Yes | Network handle.|
**Return value**
**Return Value**
| Type | Description |
| --------------------------------------------- | --------------------------------- |
......@@ -279,7 +279,7 @@ reportNetConnected(netHandle: NetHandle, callback: AsyncCallback&lt;void&gt;): v
Reports connection of the data network. This API uses an asynchronous callback to return the result.
**Required permissions** : ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
**Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -306,7 +306,7 @@ reportNetConnected(netHandle: NetHandle): Promise&lt;void&gt;
Reports connection of the data network. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
**Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -315,7 +315,7 @@ Reports connection of the data network. This API uses a promise to return the re
| -------- | -------- | -------- | -------- |
| netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).|
**Return value**
**Return Value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
......@@ -337,7 +337,7 @@ reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback&lt;void&gt;)
Reports disconnection of the data network. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
**Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -364,7 +364,7 @@ reportNetDisconnected(netHandle: NetHandle): Promise&lt;void&gt;
Reports disconnection of the data network. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
**Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -373,7 +373,7 @@ Reports disconnection of the data network. This API uses a promise to return the
| -------- | -------- | -------- | -------- |
| netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).|
**Return value**
**Return Value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
......@@ -394,7 +394,7 @@ getAddressesByName(host: string, callback: AsyncCallback\<Array\<NetAddress>>):
Resolves the host name by using the default network to obtain all IP addresses. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -402,7 +402,7 @@ Resolves the host name by using the default network to obtain all IP addresses.
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------- | ---- | ------------------ |
| host | string | Yes | Host name to resolve.|
| host | string | Yes | Host name to be resolved.|
| callback | AsyncCallback\<Array\<[NetAddress](#netaddress)>> | Yes | Callback used to return the result. |
**Example**
......@@ -421,7 +421,7 @@ getAddressesByName(host: string): Promise\<Array\<NetAddress>>
Resolves the host name by using the default network to obtain all IP addresses. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -429,13 +429,13 @@ Resolves the host name by using the default network to obtain all IP addresses.
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ |
| host | string | Yes | Host name to resolve.|
| host | string | Yes | Host name to be resolved.|
**Return value**
**Return Value**
| Type | Description |
| ------------------------------------------- | ----------------------------- |
| Promise\<Array\<[NetAddress](#netaddress)>> | Promise used to return the IP addresses obtained.|
| Promise\<Array\<[NetAddress](#netaddress)>> | Promise used to return the result.|
**Example**
......@@ -461,7 +461,7 @@ Obtains the handle of the network specified by **netSpecifier**.
| netSpecifier | [NetSpecifier](#netspecifier) | No | Network specifier. If this parameter is not set, the default network is used. |
| timeout | number | No | Timeout interval for obtaining the network specified by **netSpecifier**. This parameter is valid only when **netSpecifier** is set.|
**Return value**
**Return Value**
| Type | Description |
| ------------------------------- | -------------------- |
......@@ -520,7 +520,7 @@ Registers a listener for **netCapabilitiesChange** events.
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The value is fixed to **netCapabilitiesChange**.<br>**netCapabilitiesChange**: event indicating that the network capabilities have changed.|
| type | string | Yes | Event type. The value is fixed to **netCapabilitiesChange**.<br>**netCapabilitiesChange**: event indicating that he network capabilities have changed.|
| callback | Callback<{ netHandle: [NetHandle](#nethandle), netCap: [NetCapabilities](#netcapabilities) }> | Yes | Callback used to return the result. |
**Example**
......@@ -630,7 +630,7 @@ register(callback: AsyncCallback\<void>): void
Registers a listener for network status changes.
**Required permissions**: ohos.permission.GET_NETWORK_INFO
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -674,15 +674,15 @@ netConnection.unregister(function (error) {
Defines the handle of the data network.
Before invoking **NetHandle** APIs, call **getNetHandle** to obtain a **NetHandle** object.
Before invoking NetHandle APIs, call **getNetHandle** to obtain a **NetHandle** object.
**System capability**: SystemCapability.Communication.NetManager.Core
### Attributes
### Parameters
| Name| Type | Description |
| ------ | ------ | ------------------------- |
| netId | number | Network ID. The value must be greater than or equal to **100**.|
| netId | number | Network ID. The value must be greater than or equal to 100.|
### bindSocket
......@@ -731,7 +731,7 @@ Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| socketParam | TCPSocket \| UDPSocket | Yes | **TCPSocket** or **UDPSocket** object.|
**Return value**
**Return Value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
......@@ -767,7 +767,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------- | ---- | ------------------ |
| host | string | Yes | Host name to resolve.|
| host | string | Yes | Host name to be resolved.|
| callback | AsyncCallback\<Array\<[NetAddress](#netaddress)>> | Yes | Callback used to return the result. |
**Example**
......@@ -794,9 +794,9 @@ Resolves the host name by using the corresponding network to obtain all IP addre
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ |
| host | string | Yes | Host name to resolve.|
| host | string | Yes | Host name to be resolved.|
**Return value**
**Return Value**
| Type | Description |
| ------------------------------------------- | ----------------------------- |
......@@ -825,7 +825,7 @@ Resolves the host name by using the corresponding network to obtain the first IP
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | ------------------ |
| host | string | Yes | Host name to resolve.|
| host | string | Yes | Host name to be resolved.|
| callback | AsyncCallback\<[NetAddress](#netaddress)> | Yes | Callback used to return the result. |
**Example**
......@@ -852,9 +852,9 @@ Resolves the host name by using the corresponding network to obtain the first IP
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ |
| host | string | Yes | Host name to resolve.|
| host | string | Yes | Host name to be resolved.|
**Return value**
**Return Value**
| Type | Description |
| ----------------------------------- | ------------------------------- |
......@@ -901,7 +901,7 @@ Defines the network capability.
**System capability**: SystemCapability.Communication.NetManager.Core
| Name | Value α | Description |
| Name | Value | Description |
| ------------------------ | ---- | ---------------------- |
| NET_CAPABILITY_MMS | 0 | The network can connect to the carrier's Multimedia Messaging Service Center (MMSC) to send and receive multimedia messages.|
| NET_CAPABILITY_NOT_METERED | 11 | The network traffic is not metered.|
......@@ -915,7 +915,7 @@ Defines the network type.
**System capability**: SystemCapability.Communication.NetManager.Core
| Name | Value α | Description |
| Name | Value | Description |
| --------------- | ---- | ----------- |
| BEARER_CELLULAR | 0 | Cellular network |
| BEARER_WIFI | 1 | Wi-Fi network|
......@@ -938,7 +938,7 @@ Defines the network connection properties.
## LinkAddress
Defines network link information.
Network link information.
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -949,7 +949,7 @@ Defines network link information.
## RouteInfo
Defines network route information.
Network route information.
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -971,4 +971,4 @@ Defines the network address.
| ------- | ------ | ------------------------------ |
| address | string | Network address. |
| family | number | Address family identifier. The value is **1** for IPv4 and **2** for IPv6. The default value is **1**.|
| port | number | Port number. The value range is 0 to 65535. |
| port | number | Port number. The value ranges from **0** to **65535**. |
......@@ -600,13 +600,13 @@ Defines the network type.
| Name | Value | Description |
| -------------------- | ---- | ------------------------------------------------------------ |
| NETWORK_TYPE_UNKNOWN | 0 | Unknown network |
| NETWORK_TYPE_GSM | 1 | GSM network |
| NETWORK_TYPE_CDMA | 2 | CDMA network |
| NETWORK_TYPE_WCDMA | 3 | WCDMA network |
| NETWORK_TYPE_TDSCDMA | 4 | TD-SCDMA network|
| NETWORK_TYPE_LTE | 5 | LTE network |
| NETWORK_TYPE_NR | 6 | 5G NR network |
| NETWORK_TYPE_UNKNOWN | 0 | Unknown network. |
| NETWORK_TYPE_GSM | 1 | GSM network. |
| NETWORK_TYPE_CDMA | 2 | CDMA network. |
| NETWORK_TYPE_WCDMA | 3 | WCDMA network. |
| NETWORK_TYPE_TDSCDMA | 4 | TD-SCDMA network.|
| NETWORK_TYPE_LTE | 5 | LTE network. |
| NETWORK_TYPE_NR | 6 | 5G NR network. |
## NetworkState
......
......@@ -15,7 +15,7 @@ import sim from '@ohos.telephony.sim';
isSimActive\(slotId: number, callback: AsyncCallback<boolean\>\): void
Checks whether the SIM card in the specified slot is activated. This function uses an asynchronous callback to return the result.
Checks whether the SIM card in the specified slot is activated. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService
......@@ -23,7 +23,7 @@ Checks whether the SIM card in the specified slot is activated. This function us
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -39,7 +39,7 @@ sim.isSimActive(0, (err, data) => {
isSimActive\(slotId: number\): Promise<boolean\>
Checks whether the SIM card in the specified slot is activated. This function uses a promise to return the result.
Checks whether the SIM card in the specified slot is activated. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService
......@@ -47,9 +47,9 @@ Checks whether the SIM card in the specified slot is activated. This function us
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return Value**
**Return value**
| Type | Description |
| --------------------- | ---------------------------------- |
......@@ -71,7 +71,7 @@ promise.then(data => {
getDefaultVoiceSlotId\(callback: AsyncCallback<number\>\): void
Obtains the default slot ID of the SIM card that provides voice services. This function uses an asynchronous callback to return the result.
Obtains the default slot ID of the SIM card that provides voice services. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService
......@@ -94,11 +94,11 @@ sim.getDefaultVoiceSlotId((err, data) => {
getDefaultVoiceSlotId\(\): Promise<number\>
Obtains the default slot ID of the SIM card that provides voice services. This function uses a promise to return the result.
Obtains the default slot ID of the SIM card that provides voice services. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService
**Return Value**
**Return value**
| Type | Description |
| ----------------- | --------------------------------------- |
......@@ -119,7 +119,7 @@ promise.then(data => {
hasOperatorPrivileges(slotId: number, callback: AsyncCallback\<boolean\>): void
Checks whether the application (caller) has been granted the operator permission. This function uses an asynchronous callback to return the result.
Checks whether the application (caller) has been granted the operator permission. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService
......@@ -127,7 +127,7 @@ Checks whether the application (caller) has been granted the operator permission
| Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | ---------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result. |
**Example**
......@@ -140,9 +140,9 @@ sim.hasOperatorPrivileges(0, (err, data) => {
## sim.hasOperatorPrivileges<sup>7+</sup>
hasOperatorPrivileges(slotId: number): Promise<boolean>
hasOperatorPrivileges(slotId: number): Promise<boolean\>
Checks whether the application (caller) has been granted the operator permission. This function uses a promise to return the result.
Checks whether the application (caller) has been granted the operator permission. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService
......@@ -150,9 +150,9 @@ Checks whether the application (caller) has been granted the operator permission
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return Value**
**Return value**
| Type | Description |
| :----------------- | :---------------------------------------------------------- |
......@@ -173,7 +173,7 @@ promise.then(data => {
getISOCountryCodeForSim\(slotId: number, callback: AsyncCallback<string\>\): void
Obtains the ISO country code of the SIM card in the specified slot. This function uses an asynchronous callback to return the result.
Obtains the ISO country code of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService
......@@ -181,7 +181,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This functio
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2 |
| slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| callback | AsyncCallback\<string\> | Yes | Callback used to return the result, which is a country code, for example, **CN** (China).|
**Example**
......@@ -197,7 +197,7 @@ sim.getISOCountryCodeForSim(0, (err, data) => {
getISOCountryCodeForSim\(slotId: number\): Promise<string\>
Obtains the ISO country code of the SIM card in the specified slot. This function uses a promise to return the result.
Obtains the ISO country code of the SIM card in the specified slot. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService
......@@ -205,9 +205,9 @@ Obtains the ISO country code of the SIM card in the specified slot. This functio
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return Value**
**Return value**
| Type | Description |
| ----------------- | ------------------------------------------------------------ |
......@@ -229,7 +229,7 @@ promise.then(data => {
getSimOperatorNumeric\(slotId: number, callback: AsyncCallback<string\>\): void
Obtains the public land mobile network (PLMN) ID of the SIM card in the specified slot. This function uses an asynchronous callback to return the result.
Obtains the public land mobile network (PLMN) ID of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService
......@@ -237,7 +237,7 @@ Obtains the public land mobile network (PLMN) ID of the SIM card in the specifie
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<string\> | Yes | Callback used to return the result. |
**Example**
......@@ -253,7 +253,7 @@ sim.getSimOperatorNumeric(0, (err, data) => {
getSimOperatorNumeric\(slotId: number\): Promise<string\>
Obtains the PLMN ID of the SIM card in the specified slot. This function uses a promise to return the result.
Obtains the PLMN ID of the SIM card in the specified slot. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService
......@@ -261,9 +261,9 @@ Obtains the PLMN ID of the SIM card in the specified slot. This function uses a
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return Value**
**Return value**
| Type | Description |
| ----------------- | ------------------------------------------------ |
......@@ -285,7 +285,7 @@ promise.then(data => {
getSimSpn\(slotId: number, callback: AsyncCallback<string\>\): void
Obtains the service provider name (SPN) of the SIM card in the specified slot. This function uses an asynchronous callback to return the result.
Obtains the service provider name (SPN) of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService
......@@ -293,7 +293,7 @@ Obtains the service provider name (SPN) of the SIM card in the specified slot. T
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<string\> | Yes | Callback used to return the result. |
**Example**
......@@ -309,7 +309,7 @@ sim.getSimSpn(0, (err, data) => {
getSimSpn\(slotId: number\): Promise<string\>
Obtains the SPN of the SIM card in the specified slot. This function uses a promise to return the result.
Obtains the SPN of the SIM card in the specified slot. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService
......@@ -317,9 +317,9 @@ Obtains the SPN of the SIM card in the specified slot. This function uses a prom
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return Value**
**Return value**
| Type | Description |
| ----------------- | ----------------------------------------- |
......@@ -341,7 +341,7 @@ promise.then(data => {
getSimState\(slotId: number, callback: AsyncCallback<SimState\>\): void
Obtains the status of the SIM card in the specified slot. This function uses an asynchronous callback to return the result.
Obtains the status of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService
......@@ -349,7 +349,7 @@ Obtains the status of the SIM card in the specified slot. This function uses an
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<[SimState](#simState)\> | Yes | Callback used to return the result. For details, see [SimState](#simState). |
**Example**
......@@ -365,7 +365,7 @@ sim.getSimState(0, (err, data) => {
getSimState\(slotId: number\): Promise<SimState\>
Obtains the status of the SIM card in the specified slot. This function uses a promise to return the result.
Obtains the status of the SIM card in the specified slot. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService
......@@ -373,9 +373,9 @@ Obtains the status of the SIM card in the specified slot. This function uses a p
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return Value**
**Return value**
| Type | Description |
| -------------------------------- | ------------------------------------------ |
......@@ -396,7 +396,7 @@ promise.then(data => {
getCardType\(slotId: number, callback: AsyncCallback<CardType\>\): void
Obtains the type of the SIM card in the specified slot. This function uses an asynchronous callback to return the result.
Obtains the type of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService
......@@ -404,7 +404,7 @@ Obtains the type of the SIM card in the specified slot. This function uses an as
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<[CardType](#cardtype7)\> | Yes | Callback used to return the result. |
**Example**
......@@ -420,7 +420,7 @@ sim.getCardType(0, (err, data) => {
getCardType\(slotId: number\): Promise<CardType\>
Obtains the type of the SIM card in the specified slot. This function uses a promise to return the result.
Obtains the type of the SIM card in the specified slot. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService
......@@ -428,9 +428,9 @@ Obtains the type of the SIM card in the specified slot. This function uses a pro
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return Value**
**Return value**
| Type | Description |
| ----------------- | ------------------------------------------------------------ |
......@@ -452,7 +452,7 @@ promise.then(data => {
hasSimCard\(slotId: number, callback: AsyncCallback<boolean\>\): void
Checks whether the SIM card in the specified slot is installed. This function uses an asynchronous callback to return the result.
Checks whether the SIM card in the specified slot is installed. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService
......@@ -460,7 +460,7 @@ Checks whether the SIM card in the specified slot is installed. This function us
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -476,7 +476,7 @@ sim.hasSimCard(0, (err, data) => {
hasSimCard\(slotId: number\): Promise<boolean\>
Checks whether the SIM card in the specified slot is installed. This function uses a promise to return the result.
Checks whether the SIM card in the specified slot is installed. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService
......@@ -484,9 +484,9 @@ Checks whether the SIM card in the specified slot is installed. This function us
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return Value**
**Return value**
| Type | Description |
| --------------------- | ---------------------------------- |
......@@ -512,7 +512,7 @@ Obtains the number of card slots.
**System capability**: SystemCapability.Communication.CoreService
**Return Value**
**Return value**
| Type | Description |
| ----------------- | ------------------------------------------------------------ |
......@@ -557,4 +557,4 @@ Enumerates card types.
|CU_DUAL_MODE_CARD | 42 | China Unicom dual-mode card|
|DUAL_MODE_TELECOM_LTE_CARD | 43 | China Telecom dual-mode LTE card|
|DUAL_MODE_UG_CARD | 50 | Dual-mode card (UMTS+GSM)|
|SINGLE_MODE_ISIM_CARD | 60 | Single-card (ISIM)|
|SINGLE_MODE_ISIM_CARD<sup>8+</sup> | 60 | Single-card (ISIM)|
......@@ -10,11 +10,11 @@
import sms from '@ohos.telephony.sms';
```
## sms.createMessage<a name=sms.createMessage-callback></a>
## sms.createMessage
createMessage\(pdu: Array<number\>, specification: string, callback: AsyncCallback<ShortMessage\>\): void
Creates an SMS message instance based on the protocol data unit (PDU) and the specified SMS protocol. This function uses an asynchronous callback to return the result.
Creates an SMS message instance based on the protocol data unit (PDU) and the specified SMS protocol. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Telephony.SmsMms
......@@ -24,7 +24,7 @@ Creates an SMS message instance based on the protocol data unit (PDU) and the sp
| ------------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ |
| pdu | Array&lt;number&gt; | Yes | PDU, which is obtained from the received SMS message. |
| specification | string | Yes | SMS protocol type. <br>- **3gpp**: GSM/UMTS/LTE SMS<br>- **3gpp2**: CDMA SMS|
| callback | AsyncCallback&lt;[ShortMessage](#ShortMessage)&gt; | Yes | Callback used to return the result. |
| callback | AsyncCallback&lt;[ShortMessage](#shortmessage)&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -38,11 +38,11 @@ sms.createMessage(pdu, specification, (err, data) => {
```
## sms.createMessage<a name=sms.createMessage-promise></a>
## sms.createMessage
createMessage\(pdu: Array<number\>, specification: string\): Promise<ShortMessage\>
Creates an SMS message instance based on the PDU and the specified SMS protocol. This function uses a promise to return the result.
Creates an SMS message instance based on the PDU and the specified SMS protocol. This API uses a promise to return the result.
**System capability**: SystemCapability.Telephony.SmsMms
......@@ -57,7 +57,7 @@ Creates an SMS message instance based on the PDU and the specified SMS protocol.
| Type | Description |
| -------------------------------------------- | --------------------------------- |
| Promise&lt;[ShortMessage](#ShortMessage)&gt; | Promise used to return the result.|
| Promise&lt;[ShortMessage](#shortmessage)&gt; | Promise used to return the result.|
**Example**
......@@ -87,7 +87,7 @@ Sends an SMS message.
| Name | Type | Mandatory| Description |
| ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [SendMessageOptions](#SendMessageOptions) | Yes | Options (including the callback) for sending an SMS message. For details, see [SendMessageOptions](#SendMessageOptions).|
| options | [SendMessageOptions](#sendmessageoptions) | Yes | Options (including the callback) for sending an SMS message. For details, see [SendMessageOptions](#sendmessageoptions).|
**Example**
......@@ -108,11 +108,11 @@ sms.sendMessage(options);
```
## sms.getDefaultSmsSlotId<sup>7+</sup><a name=sms.getDefaultSmsSlotId-callback></a>
## sms.getDefaultSmsSlotId<sup>7+</sup>
getDefaultSmsSlotId\(callback: AsyncCallback<number\>\): void
Obtains the default slot of the SIM card used to send SMS messages. This function uses an asynchronous callback to return the result.
Obtains the default slot of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Telephony.SmsMms
......@@ -131,11 +131,11 @@ sms.getDefaultSmsSlotId((err, data) => {
```
## sms.getDefaultSmsSlotId<sup>7+</sup><a name=sms.getDefaultSmsSlotId-promise></a>
## sms.getDefaultSmsSlotId<sup>7+</sup>
getDefaultSmsSlotId\(\): Promise<number\>
Obtains the default slot of the SIM card used to send SMS messages. This function uses a promise to return the result.
Obtains the default slot of the SIM card used to send SMS messages. This API uses a promise to return the result.
**System capability**: SystemCapability.Telephony.SmsMms
......@@ -157,16 +157,18 @@ promise.then(data => {
```
## sms.setSmscAddr<sup>7+</sup><a name=sms.setSmscAddr-callback></a>
## sms.setSmscAddr<sup>7+</sup>
setSmscAddr\(slotId: number, smscAddr: string, callback: AsyncCallback<void\>\): void
Sets the short message service center (SMSC) address. This function uses an asynchronous callback to return the result.
Sets the short message service center (SMSC) address. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE (a system permission)
**System capability**: SystemCapability.Telephony.SmsMms
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
......@@ -186,16 +188,18 @@ sms.setSmscAddr(slotId, smscAddr, (err,data) => {
```
## sms.setSmscAddr<sup>7+</sup><a name=sms.setSmscAddr-promise></a>
## sms.setSmscAddr<sup>7+</sup>
setSmscAddr\(slotId: number, smscAddr: string\): Promise<void\>
Sets the SMSC address. This function uses a promise to return the result.
Sets the SMSC address. This API uses a promise to return the result.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE (a system permission)
**System capability**: SystemCapability.Telephony.SmsMms
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
......@@ -223,17 +227,17 @@ promise.then(data => {
```
## sms.getSmscAddr<sup>7+</sup><a name=sms.getSmscAddr-callback></a>
## sms.getSmscAddr<sup>7+</sup>
getSmscAddr\(slotId: number, callback: AsyncCallback<string\>\): void
Obtains the SMSC address. This function uses an asynchronous callback to return the result.
Obtains the SMSC address. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE (a system permission)
**System capability**: SystemCapability.Telephony.SmsMms
**Note:** This is a system API and it is used only for system applications.
This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -252,17 +256,17 @@ sms.getSmscAddr(slotId, (err, data) => {
```
## sms.getSmscAddr<sup>7+</sup><a name=sms.getSmscAddr-promise></a>
## sms.getSmscAddr<sup>7+</sup>
getSmscAddr\(slotId: number\): Promise<string\>
Obtains the SMSC address. This function uses a promise to return the result.
Obtains the SMSC address. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE (a system permission)
**System capability**: SystemCapability.Telephony.SmsMms
**Note:** This is a system API and it is used only for system applications.
This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -288,11 +292,11 @@ promise.then(data => {
});
```
## sms.hasSmsCapability<sup>7+</sup><a name=sms.hasSmsCapability></a>
## sms.hasSmsCapability<sup>7+</sup>
hasSmsCapability(): boolean
Checks whether the current device can send and receive SMS messages. This function works in synchronous mode.
Checks whether the current device can send and receive SMS messages. This API works in synchronous mode.
**System capability**: SystemCapability.Telephony.SmsMms
......@@ -307,18 +311,18 @@ let result = sms.hasSmsCapability();
console.log(`hasSmsCapability: ${JSON.stringify(result)}`);
```
## ShortMessage<a name=ShortMessage></a>
## ShortMessage
Defines an SMS message instance.
**System capability**: SystemCapability.Telephony.SmsMms
| Variable | Type | Description |
| Name | Type | Description |
| ------------------------ | --------------------------------------- | ------------------------------------------------------------ |
| hasReplyPath | boolean | Whether the received SMS contains **TP-Reply-Path**. The default value is **false**.<br>**TP-Reply-Path**: the path in which the mobile phone can reply to the SMS message through the originating SMSC.|
| isReplaceMessage | boolean | Whether the received SMS message is a **replace short message**. The default value is **false**.<br>For details, see section 9.2.3.9 in **3GPP TS 23.040**.|
| isSmsStatusReportMessage | boolean | Whether the received SMS message is an SMS delivery status report. The default value is **false**.<br>**SMS-Status-Report**: a message sent from the SMSC to the mobile station to show the SMS message delivery status.|
| messageClass | [ShortMessageClass](#ShortMessageClass) | SMS message type. |
| messageClass | [ShortMessageClass](#shortmessageclass) | SMS message type. |
| pdu | Array&lt;number&gt; | PDU in the SMS message. |
| protocolId | number | ID of the protocol used for sending SMS messages. |
| scAddress | string | Address of the short message service center (SMSC). |
......@@ -328,69 +332,69 @@ Defines an SMS message instance.
| visibleRawAddress | string | Sender address. |
## ShortMessageClass<a name=ShortMessageClass></a>
## ShortMessageClass
Enumerates SMS message types.
SMS message type.
| Variable | Value | Description |
| ---------------- | ---- | ------------------------------------------------------------ |
| UNKNOWN | 0 | Unknown type.<br>**System capability**: SystemCapability.Telephony.SmsMms|
| INSTANT_MESSAGE | 1 | Instant message, which is displayed immediately after being received.<br>**System capability**: SystemCapability.Telephony.SmsMms|
| OPTIONAL_MESSAGE | 2 | Message stored in the device or SIM card.<br>**System capability**: SystemCapability.Telephony.SmsMms|
| SIM_MESSAGE | 3 | Message containing SIM card information, which is to be stored in the SIM card.<br>**System capability**: SystemCapability.Telephony.SmsMms|
| FORWARD_MESSAGE | 4 | Message to be forwarded to another device.<br>**System capability**: SystemCapability.Telephony.SmsMms|
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Value | Description |
| ---------------- | ---- | ---------------------------------------- |
| UNKNOWN | 0 | Unknown type. |
| INSTANT_MESSAGE | 1 | Instant message, which is displayed immediately after being received. |
| OPTIONAL_MESSAGE | 2 | Message stored in the device or SIM card. |
| SIM_MESSAGE | 3 | Message containing SIM card information, which is to be stored in the SIM card.|
| FORWARD_MESSAGE | 4 | Message to be forwarded to another device. |
## SendMessageOptions<a name=SendMessageOptions></a>
Provides the options (including callbacks) for sending an SMS message.
## SendMessageOptions
For example, you can specify the SMS message type by the optional parameter **content**.
Provides the options (including callbacks) for sending an SMS message. For example, you can specify the SMS message type by the optional parameter **content**.
**System capability**: SystemCapability.Telephony.SmsMms
| Parameter | Type | Mandatory| Description |
| Name | Type | Mandatory| Description |
| ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | Slot ID of the SIM card used for sending SMS messages. <br>- **0**: card slot 1<br>- **1**: card slot 2 |
| destinationHost | string | Yes | Destination address of the SMS message. |
| content | string \| Array&lt;number&gt; | Yes | SMS message type. If the content is composed of character strings, the SMS message is a text message. If the content is composed of byte arrays, the SMS message is a data message.|
| serviceCenter | string | No | SMSC address. By default, the SMSC address in the SIM card is used. |
| destinationPort | number | No | Destination port of the SMS message. This field is mandatory only for a data message. Otherwise, it is optional. |
| sendCallback | AsyncCallback&lt;[ISendShortMessageCallback](#ISendShortMessageCallback)&gt; | No | Callback used to return the SMS message sending result. For details, see [ISendShortMessageCallback](#ISendShortMessageCallback).|
| deliveryCallback | AsyncCallback&lt;[IDeliveryShortMessageCallback](#IDeliveryShortMessageCallback)&gt; | No | Callback used to return the SMS message delivery report. For details, see [IDeliveryShortMessageCallback](#IDeliveryShortMessageCallback).|
| sendCallback | AsyncCallback&lt;[ISendShortMessageCallback](#isendshortmessagecallback)&gt; | No | Callback used to return the SMS message sending result. For details, see [ISendShortMessageCallback](#isendshortmessagecallback).|
| deliveryCallback | AsyncCallback&lt;[IDeliveryShortMessageCallback](#ideliveryshortmessagecallback)&gt; | No | Callback used to return the SMS message delivery report. For details, see [IDeliveryShortMessageCallback](#ideliveryshortmessagecallback).|
## ISendShortMessageCallback<a name=ISendShortMessageCallback></a>
## ISendShortMessageCallback
Provides the callback for the SMS message sending result. It consists of three parts: SMS message sending result, URI for storing the sent SMS message, and whether the SMS message is the last part of a long SMS message.
**System capability**: SystemCapability.Telephony.SmsMms
| Parameter | Type | Mandatory| Description |
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| isLastPart | boolean | No | Whether this SMS message is the last part of a long SMS message. The value **true** indicates that this SMS message is the last part of a long SMS message, and value **false** indicates the opposite. The default value is **false**.|
| result | [SendSmsResult](#SendSmsResult) | Yes | SMS message sending result. |
| result | [SendSmsResult](#sendsmsresult) | Yes | SMS message sending result. |
| url | string | Yes | URI for storing sent SMS messages. |
## IDeliveryShortMessageCallback<a name=IDeliveryShortMessageCallback></a>
## IDeliveryShortMessageCallback
Provides the callback for the SMS message sending result. Return the SMS delivery report.
**System capability**: SystemCapability.Telephony.SmsMms
| Parameter| Type | Mandatory| Description |
| Name| Type | Mandatory| Description |
| ------ | ------------------- | ---- | -------------- |
| pdu | Array&lt;number&gt; | Yes | SMS message delivery report.|
## SendSmsResult<a name=SendSmsResult></a>
## SendSmsResult
Enumerates SMS message sending results.
SMS message sending result.
**System capability**: SystemCapability.Telephony.SmsMms
| Parameter | Value | Description |
| Name | Value | Description |
| ------------------------------------ | ---- | ------------------------------------------------------ |
| SEND_SMS_SUCCESS | 0 | SMS message sent successfully. |
| SEND_SMS_FAILURE_UNKNOWN | 1 | Failed to send the SMS message due to unknown reasons. |
......
# Socket
# Socket Connection
>![](public_sys-resources/icon-note.gif) **NOTE:**
>
......
......@@ -10,11 +10,11 @@
import data from '@ohos.telephony.data';
```
## data.getDefaultCellularDataSlotId<a name=data.getDefaultCellularDataSlotId-callback></a>
## data.getDefaultCellularDataSlotId
getDefaultCellularDataSlotId(callback: AsyncCallback\<number\>): void
Obtains the default SIM card used for mobile data. This function uses an asynchronous callback to return the result.
Obtains the default SIM card used for mobile data. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
......@@ -22,9 +22,9 @@ Obtains the default SIM card used for mobile data. This function uses an asynchr
**Parameters**
| Name| Type| Mandatory| Description|
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ------------------------------------------ |
| callback | AsyncCallback\<number\> | Yes| Callback used to return the result. <br /> **0**: slot 1 <br/>**1**: slot 2|
| callback | AsyncCallback\<number\> | Yes | Callback used to return the result.<br>**0**: card slot 1<br>**1**: card slot 2|
**Example**
......@@ -34,21 +34,21 @@ data.getDefaultCellularDataSlotId((err, data) => {
});
```
## data.getDefaultCellularDataSlotId<a name=data.getDefaultCellularDataSlotId-promise></a>
## data.getDefaultCellularDataSlotId
getDefaultCellularDataSlotId(): Promise\<number\>
Obtains the default SIM card used for mobile data. This function uses a promise to return the result.
Obtains the default SIM card used for mobile data. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Telephony.CellularData
**Return value**
**Return Value**
| Type| Description|
| Type | Description |
| ----------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result, wherein: <br />**0**: slot 1 <br/>**1**: slot 2|
| Promise\<number\> | Promise used to return the result.<br>**0**: card slot 1<br>**1**: card slot 2|
**Example**
......@@ -61,19 +61,19 @@ promise.then((data) => {
});
```
## data.getCellularDataFlowType<a name=data.getCellularDataFlowType-callback></a>
## data.getCellularDataFlowType
getCellularDataFlowType(callback: AsyncCallback\<DataFlowType\>): void
Obtains the cellular data flow type, which can be uplink or downlink. This function uses an asynchronous callback to return the result.
Obtains the cellular data flow type, which can be uplink or downlink. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Telephony.CellularData
**Parameters**
| Name| Type| Mandatory| Description|
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------- | ---- | ---------- |
| callback | AsyncCallback\<[DataFlowType](#DataFlowType)\> | Yes| Callback used to return the result.|
| callback | AsyncCallback\<[DataFlowType](#dataflowtype)\> | Yes | Callback used to return the result.|
**Example**
......@@ -83,19 +83,19 @@ data.getCellularDataFlowType((err, data) => {
});
```
## data.getCellularDataFlowType<a name=data.getCellularDataFlowType-promise></a>
## data.getCellularDataFlowType
getCellularDataFlowType(): Promise\<DataFlowType\>
Obtains the cellular data flow type, which can be uplink or downlink. This function uses a promise to return the result.
Obtains the cellular data flow type, which can be uplink or downlink. This API uses a promise to return the result.
**System capability**: SystemCapability.Telephony.CellularData
**Return value**
**Return Value**
| Type| Description|
| Type | Description |
| ---------------------------------------- | ----------------------------------------------- |
| Promise\<[DataFlowType](#DataFlowType)\> | Promise used to return the result. |
| Promise\<[DataFlowType](#dataflowtype)\> | Promise used to return the result. |
**Example**
......@@ -108,19 +108,19 @@ promise.then((data) => {
});
```
## data.getCellularDataState<a name=data.getCellularDataState-callback></a>
## data.getCellularDataState
getCellularDataState(callback: AsyncCallback\<DataConnectState\>): void
Obtains the connection status of the packet switched (PS) domain. This function uses an asynchronous callback to return the result.
Obtains the connection status of the packet switched (PS) domain. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Telephony.CellularData
**Parameters**
| Name| Type| Mandatory| Description|
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------ | ---- | ---------- |
| callback | AsyncCallback\<[DataConnectState](#DataConnectState)\> | Yes| Callback used to return the result.|
| callback | AsyncCallback\<[DataConnectState](#dataconnectstate)\> | Yes | Callback used to return the result.|
**Example**
......@@ -130,19 +130,19 @@ data.getCellularDataState((err, data) => {
});
```
## data.getCellularDataState<a name=data.getCellularDataState-promise></a>
## data.getCellularDataState
getCellularDataState(): Promise\<DataConnectState\>
Obtains the connection status of the PS domain. This function uses a promise to return the result.
Obtains the connection status of the PS domain. This API uses a promise to return the result.
**System capability**: SystemCapability.Telephony.CellularData
**Return value**
**Return Value**
| Type| Description|
| Type | Description |
| ------------------------------------------------ | ------------------------------------- |
| Promise\<[DataConnectState](#DataConnectState)\> | Promise used to return the result.|
| Promise\<[DataConnectState](#dataconnectstate)\> | Promise used to return the result.|
**Example**
......@@ -155,11 +155,11 @@ promise.then((data) => {
});
```
## data.isCellularDataEnabled<a name=data.isCellularDataEnabled-callback></a>
## data.isCellularDataEnabled
isCellularDataEnabled(callback: AsyncCallback\<boolean\>): void
Checks whether the cellular data service is enabled. This function uses an asynchronous callback to return the result.
Checks whether the cellular data service is enabled. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
......@@ -167,9 +167,9 @@ Checks whether the cellular data service is enabled. This function uses an async
**Parameters**
| Name| Type| Mandatory| Description|
| Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback\<boolean\> | Yes| Callback used to return the result. <br />**true**: The cellular data service is enabled. <br />**false**: The cellular data service is disabled.|
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.<br>**true**: The cellular data service is enabled.<br>**false**: The cellular data service is disabled.|
**Example**
......@@ -179,21 +179,21 @@ data.isCellularDataEnabled((err, data) => {
});
```
## data.isCellularDataEnabled<a name=data.isCellularDataEnabled-promise></a>
## data.isCellularDataEnabled
isCellularDataEnabled(): Promise\<boolean\>
Checks whether the cellular data service is enabled. This function uses a promise to return the result.
Checks whether the cellular data service is enabled. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Telephony.CellularData
**Return value**
**Return Value**
| Type| Description|
| Type | Description |
| ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result, wherein: <br />**true**: The cellular data service is enabled. <br />**false**: The cellular data service is disabled.|
| Promise\<boolean\> | Promise used to return the result.<br>**true**: The cellular data service is enabled.<br>**false**: The cellular data service is disabled.|
**Example**
......@@ -206,11 +206,11 @@ promise.then((data) => {
});
```
## data.isCellularDataRoamingEnabled<a name=data.isCellularDataRoamingEnabled-callback></a>
## data.isCellularDataRoamingEnabled
isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback\<boolean\>): void
Checks whether roaming is enabled for the cellular data service. This function uses an asynchronous callback to return the result.
Checks whether roaming is enabled for the cellular data service. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
......@@ -218,10 +218,10 @@ Checks whether roaming is enabled for the cellular data service. This function u
**Parameters**
| Name| Type| Mandatory| Description|
| Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | ------------------------------------------------------------ |
| slotId | number | Yes| Card slot ID. The options are as follows: <br />**0**: slot 1 <br />**1**: slot 2|
| callback | AsyncCallback\<boolean\> | Yes| Callback used to return the result. <br />**true**: Roaming is enabled for the cellular data service. <br />**false**: Roaming is disabled for the cellular data service.|
| slotId | number | Yes | Card slot ID. <br>**0**: card slot 1<br>**1**: card slot 2 |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.<br>**true**: Roaming is enabled for the cellular data service.<br>**false**: Roaming is disabled for the cellular data service.|
**Example**
......@@ -231,11 +231,11 @@ data.isCellularDataRoamingEnabled(0,(err, data) => {
});
```
## data.isCellularDataRoamingEnabled<a name=data.isCellularDataRoamingEnabled-promise></a>
## data.isCellularDataRoamingEnabled
isCellularDataRoamingEnabled(slotId: number): Promise\<boolean\>
Checks whether roaming is enabled for the cellular data service. This method uses a promise to return the result.
Checks whether roaming is enabled for the cellular data service. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
......@@ -243,15 +243,15 @@ Checks whether roaming is enabled for the cellular data service. This method use
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------------------- |
| slotId | number | Yes| Card slot ID. The options are as follows: <br />**0**: slot 1 <br/>**1**: slot 2|
| slotId | number | Yes | Card slot ID. <br>**0**: card slot 1<br>**1**: card slot 2|
**Return value**
**Return Value**
| Type| Description|
| Type | Description |
| ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result, wherein: <br />**true**: Roaming is enabled for the cellular data service. <br />**false**: Roaming is disabled for the cellular data service.|
| Promise\<boolean\> | Promise used to return the result.<br>**true**: Roaming is enabled for the cellular data service.<br>**false**: Roaming is disabled for the cellular data service.|
**Example**
......@@ -264,26 +264,30 @@ promise.then((data) => {
});
```
## DataFlowType<a name=DataFlowType></a>
## DataFlowType
Defines the cellular data flow type.
Defines the cellular data flow type.
| Name| Value| Description|
| ------ | ---------------------- | ------------------------------------------------------------ |
| 0 | DATA_FLOW_TYPE_NONE | No uplink or downlink data is available. <br />**System capability**: SystemCapability.Telephony.CellularData|
| 1 | DATA_FLOW_TYPE_DOWN | Only the downlink data is available. <br />**System capability**: SystemCapability.Telephony.CellularData|
| 2 | DATA_FLOW_TYPE_UP | Only the uplink data is available. <br />**System capability**: SystemCapability.Telephony.CellularData|
| 3 | DATA_FLOW_TYPE_UP_DOWN | Both uplink data and downlink data are available. <br />**System capability**: SystemCapability.Telephony.CellularData|
| 4 | DATA_FLOW_TYPE_DORMANT | No uplink or downlink data is available because the lower-layer link is in the dormant state. <br />**System capability**: SystemCapability.Telephony.CellularData|
**System capability**: SystemCapability.Telephony.CellularData
| Name | Value | Description |
| ---------------------- | ---- | ------------------------------------------ |
| DATA_FLOW_TYPE_NONE | 0 | No uplink or downlink data is available. |
| DATA_FLOW_TYPE_DOWN | 1 | Only the downlink data is available. |
| DATA_FLOW_TYPE_UP | 2 | Only the uplink data is available. |
| DATA_FLOW_TYPE_UP_DOWN | 3 | Both uplink data and downlink data are available. |
| DATA_FLOW_TYPE_DORMANT | 4 | No uplink or downlink data is available because the lower-layer link is in the dormant state.|
## DataConnectState<a name=DataConnectState></a>
## DataConnectState
Describes the connection status of a cellular data link.
Describes the connection status of a cellular data link.
**System capability**: SystemCapability.Telephony.CellularData
| Name| Value| Description|
| ------ | ----------------------- | ------------------------------------------------------------ |
| -1 | DATA_STATE_UNKNOWN| The status of the cellular data link is unknown. <br />**System capability**: SystemCapability.Telephony.CellularData|
| 0 | DATA_STATE_DISCONNECTED | The cellular data link is disconnected. <br />**System capability**: SystemCapability.Telephony.CellularData|
| 1 | DATA_STATE_CONNECTING | The cellular data link is being connected. <br />**System capability**: SystemCapability.Telephony.CellularData|
| 2 | DATA_STATE_CONNECTED | The cellular data link is connected. <br />**System capability**: SystemCapability.Telephony.CellularData|
| 3 | DATA_STATE_SUSPENDED | The cellular data link is suspended. <br />**System capability**: SystemCapability.Telephony.CellularData|
| Name | Value | Description |
| ----------------------- | ---- | -------------------------- |
| DATA_STATE_UNKNOWN | -1 | The status of the cellular data link is unknown. |
| DATA_STATE_DISCONNECTED | 0 | The cellular data link is disconnected. |
| DATA_STATE_CONNECTING | 1 | The cellular data link is being connected.|
| DATA_STATE_CONNECTED | 2 | The cellular data link is connected. |
| DATA_STATE_SUSPENDED | 3 | The cellular data link is suspended. |
......@@ -3,7 +3,7 @@
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The Thermal Manager module provides APIs for listening to the device thermal status.
This module provides thermal level-related callback and query APIs to obtain the information required for thermal control.
## Modules to Import
......@@ -17,15 +17,17 @@ import thermal from '@ohos.thermal';
Represents the thermal level.
**System capability:** SystemCapability.PowerManager.ThermalManager
| Name | Default Value | Description |
| ---------- | ---- | ---------------------------------------- |
| COOL | 0 | The device is cool, and services are not restricted.<br>**System capability:** SystemCapability.PowerManager.ThermalManager|
| NORMAL | 1 | The device is operational but is not cool. You need to pay attention to its heating.<br>**System capability:** SystemCapability.PowerManager.ThermalManager|
| WARM | 2 | The device is warm. You need to stop or delay some imperceptible services.<br>**System capability:** SystemCapability.PowerManager.ThermalManager|
| HOT | 3 | The device is heating up. You need to stop all imperceptible services and downgrade or reduce the load of other services.<br>**System capability:** SystemCapability.PowerManager.ThermalManager|
| OVERHEATED | 4 | The device is overheated. You need to stop all imperceptible services and downgrade or reduce the load of major services.<br>**System capability:** SystemCapability.PowerManager.ThermalManager|
| WARNING | 5 | The device is overheated and is about to enter the emergency state. You need to stop all imperceptible services and downgrade major services to the maximum extent.<br>**System capability:** SystemCapability.PowerManager.ThermalManager|
| EMERGENCY | 6 | The device has entered the emergency state. You need to stop all services except those for the emergency help purposes.<br>**System capability:** SystemCapability.PowerManager.ThermalManager|
| COOL | 0 | The device is cool, and services are not restricted.|
| NORMAL | 1 | The device is operational but is not cool. You need to pay attention to its heating.|
| WARM | 2 | The device is warm. You need to stop or delay some imperceptible services.|
| HOT | 3 | The device is heating up. You need to stop all imperceptible services and downgrade or reduce the load of other services.|
| OVERHEATED | 4 | The device is overheated. You need to stop all imperceptible services and downgrade or reduce the load of major services.|
| WARNING | 5 | The device is overheated and is about to enter the emergency state. You need to stop all imperceptible services and downgrade major services to the maximum extent.|
| EMERGENCY | 6 | The device has entered the emergency state. You need to stop all services except those for the emergency help purposes.|
## thermal.subscribeThermalLevel
......
# WebSocket
# WebSocket Connection
>![](public_sys-resources/icon-note.gif) **NOTE:**
>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......
此差异已折叠。
......@@ -308,7 +308,7 @@
- [Startup](subsystems/subsys-boot.md)
- [DFX](subsystems/subsys-dfx.md)
- Featured Topics
- [HPM Bundle](bundles/Readme-EN.md)
- HPM Bundle
- [Development Specifications](bundles/bundles-standard-rules.md)
- Development Guidelines
- [Bundle Development](bundles/bundles-guide-overview.md)
......@@ -333,7 +333,7 @@
- [Samples](https://gitee.com/openharmony/app_samples/blob/master/README.md)
- [Codelabs](https://gitee.com/openharmony/codelabs/blob/master/README.md)
- References
- [FAQs](faqs/Readme-EN.md)
- FAQs
- [Overview of FAQs](faqs/faqs-overview.md)
- [Environment Setup](faqs/faqs-environment-setup.md)
- [Compilation and Building Subsystem](faqs/faqs-building.md)
......
此差异已折叠。
# Ability开发
- [Ability框架概述](ability-brief.md)
- FA模型
- FA模型
- [FA模型综述](fa-brief.md)
- [PageAbility开发指导](fa-pageability.md)
- [ServiceAbility开发指导](fa-serviceability.md)
- [DataAbility开发指导](fa-dataability.md)
- [FormAbility开发指导](fa-formability.md)
- Stage模型
- [Stage模型综述](stage-brief.md)
- [Ability开发指导](stage-ability.md)
- [ServiceExtensionAbility开发指导](stage-serviceextension.md)
- [FormExtensionAbility开发指导](stage-formextension.md)
- [应用迁移开发指导](stage-ability-continuation.md)
- [跨端迁移开发指导](stage-ability-continuation.md)
- [Call调用开发指导](stage-call.md)
- 其他
- [WantAgent使用指导](wantagent.md)
- [Ability助手使用指导](ability-assistant-guidelines.md)
\ No newline at end of file
- [Ability助手使用指导](ability-assistant-guidelines.md)
- [测试框架使用指导](ability-delegator.md)
\ No newline at end of file
# 测试框架使用指导
Delegator测试框架是OpenHarmony提供的一套开发者应用自测试框架,旨在为开发者提供针对应用的自测试环境。开发者可以通过delegator类启动对应Ability,并通过Delegator类提供的能力对Ability进行生命周期切换和监听,同时支持shellCMD输入和测试结果打印显示等功能。
## 测试框架启动
测试框架启动有两种方式,方式一:通过aa test命令启动,方式二:通过IDE启动。
### aa test启动
开发者可通过 aa test 命令启动启动测试框架,开发者可以自行指定使用的runner以及runner所在hap包的package name/module name,具体命令示例如下:
**FA模型:**
```javascript
aa test -p com.example.myapplicationfaets -s unittest OpenHarmonyTestRunner -s class ActsAbilityTest -w 20
```
**Stage模型:**
```javascript
aa test -m com.example.myapplicationfaets -s unittest OpenHarmonyTestRunner -s class ActsAbilityTest -w 20
```
| 参数 | 是否必选 | 参数说明 |
| --------------- | -------- | ------------------------------------------------------------ |
| -p | 是 | TestRunner所在hap包的package name,FA模型使用。 |
| -m | 是 | TestRunner所在hap包的module name,stage模型使用。 |
| -s unittest | 是 | 启用的TestRunner名称,TestRunner名称和文件名需要保持一致。 |
| -w | 否 | 测试用例超时时间,如果未指定,测试框架会一直等待测试代码调用finishTest才退出。 |
| -s <key><value> | 否 | 支持以key-value的方式输入任何参数,输入的参数可通过AbilityDelegatorArgs.parameters以key-value的方式获取。 |
### IDE启动
IDE文档中介绍,待IDE文档上库补充链接。
## TestRunner介绍
TestRunner是测试框架测试流程入口类,当测试流程启动时,系统会调用TestRunner内相关接口,开发者需要派生该类,并重写onPrepare、onRun方法。IDE在创建应用模板时会初始化一个默认TestRunner,并在onRun方法启动默认的TestAbility。开发者也可以修改TestAbility测试代码内容,也可以修改默认的TestRunner内onPrepare、onRun方法,自行实现测试代码。具体详细内容请参考TestRunnerAPI接口说明[TestRunner](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-testRunner.md)
## AbilityMonitor介绍
AbilityMonitor是测试框架提供用来绑定并监听Ability类,开发者可以使用AbilityMonitor绑定Ability,并将AbilityMonitor添加到监听列表。绑定后Ability的创建、生命周期变化等会触发AbilityMonitor内相关回调函数,开发者可以在对应回调函数内进行测试验证。具体详细内容请参考AbilityMonitor API接口说明[AbilityMonitor](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-application-abilityMonitor.md)
**示例**
```javascript
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function onAbilityCreateCallback() {
console.info("onAbilityCreateCallback");
}
var monitor = {
abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback
}
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.addAbilityMonitor(monitor).then((void) => {
console.info("addAbilityMonitor promise");
});
```
## AbilityDelegator介绍
AbilityDelegator是测试框架主要功能类,提供了启动Ability、获取Ability示例、调度Ability生命周期、对Ability生命周期进行监听、打印测试结果等功能。
**导入模块**
```javascript
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
```
```javascript
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
```
### 启动Ability并监听Ability状态变化
配合AbilityMonitor使用,可以实现对Ability启动、Ability实例获取、监听状态变化功能。
**示例:**
```javascript
var abilityDelegator;
var ability;
var timeout = 100;
function onAbilityCreateCallback() {
console.info("onAbilityCreateCallback");
}
var monitor = {
abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.waitAbilityMonitor(monitor, timeout, (err, data) => {
ability = data;
console.info("waitAbilityMonitor callback");
});
var want = {
bundleName: "bundleName",
abilityName: "abilityName"
};
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.startAbility(want, (err, data) => {
console.info("startAbility callback");
});
```
### 调度Ability生命周期
AbilityDelegator提供对Ability生命周期进行显示调度,支持Foreground、Background,配合AbilityMonitor中对Ability生命周期监听方法,可以完整的测试Ability生命周期变化。具体详细内容请参考AbilityDelegator API接口说明[AbilityDelegator](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegator.md#abilitydelegator)
### 执行shellCMD命令
AbilityDelegator提供执行shellCMD命令功能,开发者可以在测试代码中执行shell命令,该功能仅在测试环境中生效,非测试环境该接口调用无效果。
**示例:**
```javascript
var abilityDelegator;
var cmd = "cmd";
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.executeShellCommand(cmd, (err,data) => {
console.info("executeShellCommand callback");
});
```
\ No newline at end of file
......@@ -186,4 +186,10 @@ var promise = await featureAbility.startAbility({
},
}
);
```
\ No newline at end of file
```
## 开发实例
针对pageAbility开发,有以下示例工程可供参考:
- [DMS](https://gitee.com/openharmony/app_samples/tree/master/ability/DMS)
在本示例中完整展示了启动本地Ability、启动远程Ability的使用方法。
\ No newline at end of file
# 应用迁移开发指导
# 跨端迁移开发指导
## 场景介绍
迁移的主要工作是实现将应用当前任务,包括页面部分数据、栈信息等,迁移到远端设备。迁移成功后,本端任务将被清除;若失败则不会,可允许再次迁移。
迁移的主要工作是实现将应用当前任务,包括页面控件状态变量、分布式对象等,迁移到远端设备。页面控件状态变量用于同步页面UI数据,分布式对象用于同步内存中的数据。
## 接口说明
迁移提供的能力如下,具体的API详见接口文档
迁移提供的能力如下,具体的API详见[接口文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-application-ability.md)
**表1** 应用迁移API接口功能介绍
|接口名 | 描述|
|:------ | :------|
| onContinue(wantParams : {[key: string]: any}) | 迁移发起端在该回调中保存迁移所需要的数据,同时返回是否同意迁移:true表示同意,false表示拒绝。 |
| onContinue(wantParams : {[key: string]: any}): OnContinueResult | 迁移**发起端**在该回调中保存迁移所需要的数据,同时返回是否同意迁移:0表示同意,拒绝返回相应错误码。 |
| onCreate(want: Want,param:LaunchParam): void | 迁移**目标端**在该回调中完成数据恢复,并触发页面恢复。 |
| **enum** OnContinueResult | onContinue的返回值类型:AGREE表示同意;REJECT表示拒绝;MISMATCH表示版本不匹配 |
## 开发步骤
**图1** 迁移开发示意图
### 迁移应用
![continuation_dev](figures/continuation-info.png)
## 开发步骤
### 迁移应用
1. 配置
- 配置应用支持迁移
​ 在config.json中配置continuable字段:true表示支持迁移,false表示不支持,默认为false.
在module.json5中配置continuable字段:true表示支持迁移,false表示不支持,默认为false。配置为false的应用将被系统识别为无法迁移。
```
```javascript
"continuable": true
```
​ 配置为false的应用将无法在任务中心进行迁移。
* 配置应用启动类型
​ 迁移当前只支持多实例应用,需要在在config.json中配置launchType字段为standard
迁移当前只支持多实例应用,需要在在module.json5中配置launchType字段为standard
```
```javascript
"launchType": "standard"
```
* 申请分布式权限
支持跨端迁移的应用需要在module.json5申请分布式权限 DISTRIBUTED_DATASYNC。
```javascript
"requestPermissions": [
{
"name": "ohos.permission.DISTRIBUTED_DATASYNC"
},
```
这个权限需要在应用首次启动的时候弹窗让用户授予,可以通过在ability的onWindowStageCreate中添加如下代码实现
```javascript
requestPermissions = async () => {
let permissions: Array<string> = [
"ohos.permission.DISTRIBUTED_DATASYNC"
];
let needGrantPermission = false
let accessManger = accessControl.createAtManager()
Logger.info("app permission get bundle info")
let bundleInfo = await bundle.getApplicationInfo(BUNDLE_NAME, 0, 100)
Logger.info(`app permission query permission ${bundleInfo.accessTokenId.toString()}`)
for (const permission of permissions) {
Logger.info(`app permission query grant status ${permission}`)
try {
let grantStatus = await accessManger.verifyAccessToken(bundleInfo.accessTokenId, permission)
if (grantStatus === PERMISSION_REJECT) {
needGrantPermission = true
break;
}
} catch (err) {
Logger.error(`app permission query grant status error ${permission} ${JSON.stringify(err)}`)
needGrantPermission = true
break;
}
}
if (needGrantPermission) {
Logger.info("app permission needGrantPermission")
try {
await this.context.requestPermissionsFromUser(permissions)
} catch (err) {
Logger.error(`app permission ${JSON.stringify(err)}`)
}
} else {
Logger.info("app permission already granted")
}
}
```
2. 实现onContinue接口
2. 实现onContinue接口
导入模块
onContinue接口在**发起端**被调用,主要用于在迁移发起时,通知开发者保存控件状态变量和内存中数据,准备迁移。当应用准备完成后,需要返回OnContinueResult.AGREE(0)表示同意迁移,否则返回相应的错误码拒绝迁移。如果不实现该接口,系统将默认为拒绝迁移。
```
导入模块
```javascript
import Ability from '@ohos.application.Ability';
import AbilityConstant from '@ohos.application.AbilityConstant';
```
- 要实现迁移,此接口必须实现并返回true,否则默认为拒绝迁移。
- 要实现迁移,此接口必须实现并返回AGREE,否则默认为拒绝迁移。
- 示例
```javascript
onContinue(wantParams : {[key: string]: any}) {
console.log("MainAbility onContinue")
return true;
}
onContinue(wantParam : {[key: string]: any}) {
Logger.info("onContinue using distributedObject")
// set user input data into want params
wantParam["input"] = AppStorage.Get<string>('ContinueInput');
Logger.info(`onContinue input = ${wantParam["input"]}`);
return AbilityConstant.OnContinueResult.AGREE
}
```
3. 在onCreate接口中实现迁移逻辑
- 远端设备上,在onCreate中根据launchReason判断该次启动是否为迁移LaunchReason.CONTINUATION(3)
onCreate接口在迁移**目标端**被调用,在目标端ability被拉起时,通知开发者同步已保存的内存数据和控件状态,完成后触发页面的恢复。如果不实现该接口中迁移相关逻辑,ability将会作为普通的启动方式拉起,无法恢复页面。
- 远端设备上,在onCreate中根据launchReason判断该次启动是否为迁移LaunchReason.CONTINUATION
- 完成数据恢复后,开发者需要调用**restoreWindowStage**来触发页面恢复。
* 示例
```javascript
onCreate(want , launchParam) {
// Ability is creating, initialize resources for this ability
console.log("MainAbility onCreate", launchParam.launchReason);
if (launchParam.launchReason == LaunchReason.CONTINUATION) {
this.contentStorage = new ContenStorage();
onCreate(want, launchParam) {
Logger.info(`MainAbility onCreate ${AbilityConstant.LaunchReason.CONTINUATION}`)
globalThis.abilityWant = want;
if (launchParam.launchReason == AbilityConstant.LaunchReason.CONTINUATION) {
let input = want.parameters.input // get user data from want params
AppStorage.SetOrCreate<string>('ContinueInput', input)
Logger.info(`onCreate for continuation sessionId: ${this.sessionId}`)
this.contentStorage = new ContentStorage();
this.context.restoreWindowStage(this.contentStorage);
}
}
```
### 迁移数据
1. 使用自定义数据
1. 使用分布式对象
- wantParams中可以填写key-value形式自定义数据,key类型string,填充的数据将随want被传输到远端,用于携带一些简单、轻量的数据
分布式数据对象提供了与本地变量类似的操作,实现两个设备的数据同步,当设备1的应用A的分布式数据对象增、删、改数据后,设备2的应用A也可以获取到对应的数据变化,同时还能监听数据变更以及对端数据对象的上下线。用法详见[分布式对象指导文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/database/database-distributedobject-guidelines.md)
迁移场景中,分布式对象(distributedDataObject)主要用于将本机内存数据同步到目标设备。
```javascript
onContinue(wantParams : {[key: string]: any}) {
console.log("Continue My Data")
wantParams["myData"] = "my1234567";
return true;
}
```
- 同时在远端判断如果是迁移,可以从want.parameters中取出在发起端保存的自定义数据。
- 发起端在onContinue中,将待迁移的数据存入分布式对象中,然后设置好session id,并通过wantParams将session id传到远端设备。
```javascript
onCreate(want , launchParam) {
if (launchParam.launchReason == LaunchReason.CONTINUATION) {
console.log("onCreate LaunchReason = CONTINUATION",want.parameters["myData"]); // my1234567
...
this.context.restoreWindowStage(this.contentStorage);
}
```javascript
import Ability from '@ohos.application.Ability';
import distributedObject from '@ohos.data.distributedDataObject';
var g_object = distributedObject.createDistributedObject({name:undefined});
export default class MainAbility extends Ability {
contentStorage : ContenStorage
sessionId : string;
onContinue(wantParam : {[key: string]: any}) {
Logger.info("onContinue using distributedObject")
this.sessionId = distributedObject.genSessionId();
//set distributed data object session id
g_object.setSessionId(this.sessionId);
g_object.name = "Amy";
// set session id into want params
wantParam["session"] = this.sessionId;
return AbilityConstant.OnContinueResult.AGREE
}
```
```
- 目标设备在onCreate中,取出发起端传过来的session id,建立分布式对象并关联该session id,这样就能实现分布式对象的同步。需要注意的是,在调用restoreWindowStage之前,迁移需要的分布式对象必须全部关联完,保证能够获取到正确的数据。
2. 使用分布式对象
使用分布式对象可以传输更多的数据到远端设备,更多用法详见分布式对象接口文档。
- 发起端在onContinue中,将待迁移的数据存入分布式对象中,然后设置好session id,并通过wantParams将session id传到远端设备。
- 远端设备在onCreate中,取出发起端传过来的session id,建立分布式对象并关联该session id,这样就能实现分布式对象的同步。需要注意的是,在调用restoreWindowStage之前,迁移需要的分布式对象必须全部关联完,保证能够获取到正确的数据。
* 示例
```javascript
import Ability from '@ohos.application.Ability';
import distributedObject from '@ohos.data.distributedDataObject';
var g_object = distributedObject.createDistributedObject({name:undefined});
export default class MainAbility extends Ability {
contentStorage : ContenStorage
sessionId : string;
onCreate(want , launchParam) {
if (launchParam.launchReason == 3) {
this.sessionId = want.parameters["session"] // 取出session id
function statusCallback(sessionId, networkid, status) {
console.info("object status change sessionId: " + sessionId + " status: " + status +
"g_object.name: " + g_object.name); // 回调中可以取到同步过来的分布式对象内容 name = Amy
}
g_object.on("status", statusCallback); // 注册分布式对象同步结果的监听
g_object.setSessionId(this.sessionId); // 将本地分布式对象也关联发起端的session id
this.contentStorage = new ContenStorage();
this.context.restoreWindowStage(this.contentStorage);
}
}
onContinue(wantParams : {[key: string]: any}) {
console.log("using distributedObject")
this.sessionId = "654321";
g_object.setSessionId(this.sessionId); //1 设置分布式对象的session id
g_object.name = "Amy"; // 填入数据
wantParams["session"] = this.sessionId; // 将session id 通过want传到远端
return true;
}
import Ability from '@ohos.application.Ability';
import distributedObject from '@ohos.data.distributedDataObject';
var g_object = distributedObject.createDistributedObject({name:undefined});
export default class MainAbility extends Ability {
contentStorage : ContentStorage
sessionId : string;
statusCallback(sessionId, networkid, status) {
Logger.info(`continuation object status change, sessionId: ${sessionId}, status: ${status}, g_object.name: ${g_object.name}`)
}
onCreate(want, launchParam) {
Logger.info(`MainAbility onCreate ${AbilityConstant.LaunchReason.CONTINUATION}`)
if (launchParam.launchReason == AbilityConstant.LaunchReason.CONTINUATION) {
// get distributed data object session id from want params
this.sessionId = want.parameters.session
Logger.info(`onCreate for continuation sessionId: ${this.sessionId}`)
g_object.on("status", this.statusCallback);
// set session id, so it will sync data from remote device
g_object.setSessionId(this.sessionId);
this.contentStorage = new ContentStorage();
this.context.restoreWindowStage(this.contentStorage);
}
}
}
```
以上完整的示例见sample
# Ability开发指导
\ No newline at end of file
# Ability开发指导
## 场景介绍
Stage模型是基于API version 9的应用开发模型,对此模型的介绍详见[Stage模型综述](stage-brief.md)。基于Stage模型的Ability应用开发,主要涉及如下功能逻辑:
- 创建Page Ability应用,如视频播放、新闻资讯等,需要通过屏幕进行浏览的应用,以及支持人机交互。
- 获取Ability的配置信息,如ApplicationInfo、AbilityInfo及HapModuleInfo等。
- 启动/带参数启动/带返回结果启动/带AccountId启动其他Ability。
- 应用向用户申请授权。
- 系统环境变化通知给AbilityStage及Ability。
- 通用组件Call功能,详见[Call调用开发指导](stage-call.md)
- 连接ServiceAbility,与ServiceAbility断开连接,详见[ServiceExtensionAbility开发指导](stage-serviceextension.md)
- 应用迁移,详见[应用迁移开发指导](stage-ability-continuation.md)
## 接口说明
AbilityStage功能如下:AbilityStage类,拥有context属性,具体的API详见[接口文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md)
**表1** AbilityStage API接口功能介绍
|接口名|描述|
|:------|:------|
|void onCreate()|AbilityStage初始化时被调用。|
|string onAcceptWant(want: Want)|启动指定Ability时被调用。|
|void onConfigurationUpdated(config: Configuration)|全局配置发生变更时被调用。|
Ability功能如下:Ability类,具体的API详见[接口文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-application-ability.md)
**表2** Ability API接口功能介绍
|接口名|描述|
|:------|:------|
|void onCreate(want: Want, param: AbilityConstant.LaunchParam)|Ability生命周期回调,Ability启动时被调用。|
|void onDestroy()|Ability生命周期回调,Ability销毁时被调用。|
|void onWindowStageCreate(windowStage: window.WindowStage)|Ability生命周期回调,创建window stage时被调用,应用开发者可通过window.WindowStage的接口执行页面加载等操作。|
|void onWindowStageDestroy()|Ability生命周期回调,销毁window stage时被调用。|
|void onForeground()|Ability生命周期回调,Ability切换至前台时被调用。|
|void onBackground()|Ability生命周期回调,Ability切换至后台时被调用。|
|void onNewWant(want: Want)|Ability回调,Ability的启动模式设置为单例时被调用。|
|void onConfigurationUpdated(config: Configuration)|Ability回调,Ability的系统配置更新时被调用。|
Ability类拥有context属性,context属性为AbilityContext类,AbilityContext类拥有abilityInfo、currentHapModuleInfo等属性,具体的API详见[接口文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-ability-context.md)
**表3** AbilityContext API接口功能介绍
|接口名|描述|
|:------|:------|
|void startAbility(want: Want, callback: AsyncCallback<void>)|启动Ability。|
|void startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>)|启动Ability。|
|void startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback<void>)|带AccountId启动Ability。|
|void startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback<void>)|带AccountId启动Ability。|
|void startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>)|带返回结果启动Ability。|
|void startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>)|带返回结果启动Ability。|
|void startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback<AbilityResult>)|带返回结果及AccountId启动Ability。|
|void startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback<void>)|带返回结果及AccountId启动Ability。|
|void terminateSelf(callback: AsyncCallback<void>)|销毁当前的Page Ability。|
|void terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>)|带返回结果销毁当前的Page Ability。|
## 开发步骤
### 创建Page Ability应用
创建Stage模型的Page Ability应用,需实现AbilityStage接口及Ability生命周期接口,并使用窗口提供的方法设置页面。具体示例代码如下:
1. 导入AbilityStage模块
```
import AbilityStage from "@ohos.application.AbilityStage"
```
2. 实现AbilityStage接口
```ts
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
}
}
```
3. 导入Ability模块
```
import Ability from '@ohos.application.Ability'
```
4. 实现Ability生命周期接口
`onWindowStageCreate(windowStage)`中通过loadContent接口设置应用要加载的页面,window接口的使用详见[窗口开发指导](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/windowmanager/window-guidelines.md/)
```ts
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("MainAbility onCreate")
}
onDestroy() {
console.log("MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
console.log("MainAbility onWindowStageCreate")
windowStage.loadContent("pages/index").then((data) => {
console.log("MainAbility load content succeed with data: " + JSON.stringify(data))
}).catch((error) => {
console.error("MainAbility load content failed with error: "+ JSON.stringify(error))
})
}
onWindowStageDestroy() {
console.log("MainAbility onWindowStageDestroy")
}
onForeground() {
console.log("MainAbility onForeground")
}
onBackground() {
console.log("MainAbility onBackground")
}
}
```
### 获取AbilityStage及Ability的配置信息
AbilityStage类及Ability类均拥有context属性,应用可以通过`this.context`获取Ability实例的上下文,进而获取详细的配置信息。如下示例展示了AbilityStage通过context属性获取包代码路径、hap包名、ability名以及系统语言的方法。具体示例代码如下:
```ts
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
let context = this.context
console.log("MyAbilityStage bundleCodeDir" + context.bundleCodeDir)
let currentHapModuleInfo = context.currentHapModuleInfo
console.log("MyAbilityStage hap module name" + currentHapModuleInfo.name)
console.log("MyAbilityStage hap module mainAbilityName" + currentHapModuleInfo.mainAbilityName)
let config = this.context.config
console.log("MyAbilityStage config language" + config.language)
}
}
```
如下示例展示了Ability通过context属性获取包代码路径、hap包名、ability名以及系统语言的方法。具体示例代码如下:
```ts
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("MainAbility onCreate")
let context = this.context
console.log("MainAbility bundleCodeDir" + context.bundleCodeDir)
let abilityInfo = this.context.abilityInfo;
console.log("MainAbility ability bundleName" + abilityInfo.bundleName)
console.log("MainAbility ability name" + abilityInfo.name)
let config = this.context.config
console.log("MyAbilityStage config language" + config.language)
}
}
```
### 启动Ability
应用可以通过`this.context`获取Ability实例的上下文,进而使用AbilityContext中的StartAbility相关接口启动Ability。启动Ability可指定Want、StartOptions、accountId,通过callback形式或promise形式实现。具体示例代码如下:
```ts
let context = this.context
var want = {
"deviceId": "",
"bundleName": "com.example.MyApplication",
"abilityName": "MainAbility"
};
var options = {
windowMode: 0,
displayId: 2
};
context.startAbility(want, options).then((data) => {
console.log("Succeed to start ability with data: " + JSON.stringify(data))
}).catch((error) => {
console.error("Failed to start ability with error: "+ JSON.stringify(error))
})
```
### 应用向用户申请授权
应用需要某些权限如存储、位置信息、访问日历时,需要向用户申请授权。具体示例代码如下:
```ts
let context = this.context
let permissions = ohos.permission.READ_CALENDAR
context.requestPermissionsFromUser(permissions).then((data) => {
console.log("Succeed to request permission from user with data: "+ JSON.stringify(data))
}).catch((error) => {
console.log("Failed to request permission from user with error: "+ JSON.stringify(error))
})
```
### 系统环境变化通知给AbilityStage及Ability
全局配置,比如系统语言和颜色模式发生变化时,通过onConfigurationUpdated接口通知给AbilityStage和Ability。如下示例展示了AbilityStage的onConfigurationUpdated回调实现,系统语言和颜色模式发生变化时触发该回调。具体示例代码如下:
```ts
import Ability from '@ohos.application.Ability'
import ConfigurationConstant from '@ohos.application.ConfigurationConstant'
export default class MyAbilityStage extends AbilityStage {
onConfigurationUpdated(config) {
console.log("MyAbilityStage onConfigurationUpdated")
console.log("MyAbilityStage config language" + config.language)
console.log("MyAbilityStage config colorMode" + config.colorMode)
}
}
```
如下示例展示了Ability的onConfigurationUpdated回调实现,系统语言、颜色模式以及Display相关的参数,比如方向、Density,发生变化时触发该回调。具体示例代码如下:
```ts
import Ability from '@ohos.application.Ability'
import ConfigurationConstant from '@ohos.application.ConfigurationConstant'
export default class MainAbility extends Ability { {
onConfigurationUpdated(config) {
console.log("MainAbility onConfigurationUpdated")
console.log("MainAbility config language" + config.language)
console.log("MainAbility config colorMode" + config.colorMode)
console.log("MainAbility config direction" + config.direction)
console.log("MainAbility config screenDensity" + config.screenDensity)
console.log("MainAbility config displayId" + config.displayId)
}
}
```
## 开发实例
针对Stage模型Ability开发,有以下示例工程可供参考:
[eTSStageCallAbility]()
本示例eTSStageCallAbility中,在Application目录的AbilityStage.ts中实现AbilityStage的接口,在MainAbility目录实现Ability的接口并设置"pages/index"中的内容为Ability的界面,在SecondAbility目录实现另一个Ability并设置"pages/second"为Ability的界面。支持MainAbility启动SecondAbility。
\ No newline at end of file
# Call调用开发指导
## 场景介绍
Ability Call调用是Ability能力的扩展,它为Ability提供一种能够被外部调用的能力。使Ability既能被拉起到前台展示UI,也支持Ability在后台被创建并运行。应用开发者可通过Call调用,使用IPC通信实现不同Ability之间的数据共享。Call调用的场景主要包括:
- 创建Callee被调用端。
- 访问Callee被调用端。
本文中的Caller和Callee分别表示调用者和被调用者,Call调用流程示意图如下。
![stage-call](figures/stage-call.png)
## 接口说明
Caller及Callee功能如下:具体的API详见[接口文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-application-ability.md#caller)
**表1** Call API接口功能介绍
|接口名|描述|
|:------|:------|
|Promise<Caller> startAbilityByCall(want: Want)|获取指定通用组件的Caller通信接口,拉起指定通用组件并将其切换到后台。|
|void on(method: string, callback: CaleeCallBack)|Callee.on,通用组件Callee注册method对应的callback方法。|
|void off(method: string)|Callee.off,通用组件Callee去注册method的callback方法。|
|Promise<void> call(method: string, data: rpc.Sequenceable)|Caller.call,向通用组件Callee发送约定序列化数据。|
|Promise<rpc.MessageParcel> callWithResult(method: string, data: rpc.Sequenceable)|Caller.callWithResult,向通用组件Callee发送约定序列化数据, 并将返回的约定序列化数据带回。|
|void release()|Caller.release,释放通用组件的Caller通信接口。|
|void onRelease(callback: OnReleaseCallBack)|Caller.onRelease,注册通用组件通信断开监听通知。|
## 开发步骤
### 创建Callee被调用端
Callee被调用端,需要实现指定方法的数据接收回调函数、数据的序列化及反序列化方法。在需要接收数据期间,通过on接口注册监听,无需接收数据时通过off接口解除监听。
1. 配置Ability的启动模式
配置module.json5,将Callee被调用端所在的Ability配置为单实例"singleton"。
|Json字段|字段说明|
|:------|:------|
|"launchType"|Ability的启动模式,设置为"singleton"类型 |
Ability配置标签示例如下:
```json
"abilities":[{
"name": ".CalleeAbility",
"srcEntrance": "./ets/CalleeAbility/CalleeAbility.ts",
"launchType": "singleton",
"description": "$string:CalleeAbility_desc",
"icon": "$media:icon",
"label": "$string:CalleeAbility_label",
"visible": true
}]
```
2. 导入Ability模块
```
import Ability from '@ohos.application.Ability'
```
3. 定义约定的序列化数据
调用端及被调用端发送接收的数据格式需协商一致,如下示例约定数据由number和string组成。具体示例代码如下:
```ts
export class MySequenceable {
num: number = 0
str: String = ""
constructor(num, string) {
this.num = num
this.str = string
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num)
messageParcel.writeString(this.str)
return true
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt()
this.str = messageParcel.readString()
return true
}
}
```
4. 实现Callee.on监听及Callee.off解除监听
被调用端Callee的监听函数注册时机, 取决于应用开发者。注册监听之前的数据不会被处理,取消监听之后的数据不会被处理。如下示例在Ability的onCreate注册'CalleeSortMethod'监听,在onDestroy取消监听,收到序列化数据后对字符串排序后返回,应用开发者根据实际需要做相应处理。具体示例代码如下:
```ts
let TAG = '[CalleeAbility] '
let method = 'CalleeSortMethod'
function CalleeSortFunc(data) {
let receiveData = new MySequenceable(0, '')
data.readSequenceable(receiveData)
console.log(TAG + 'receiveData[' + receiveData.num + ',' + receiveData.str + ']')
return new MySequenceable(receiveData.num + 1, Array.from(receiveData.str).sort().join(''))
}
export default class CalleeAbility extends Ability {
onCreate(want, launchParam) {
try {
this.callee.on(method, CalleeSortFunc)
} catch (error) {
console.error(TAG + method + 'register failed with error: ' + JSON.stringify(error))
}
}
onDestroy() {
try {
this.callee.off(method)
} catch (error) {
console.error(TAG + method + 'unregister failed with error: ' + JSON.stringify(error))
}
}
}
```
### 访问Callee被调用端
1. 导入Ability模块
```
import Ability from '@ohos.application.Ability'
```
2. 获取Caller通信接口
Ability的context属性实现了startAbilityByCall方法,用于获取指定通用组件的Caller通信接口。如下示例通过`this.context`获取Ability实例的context属性,使用startAbilityByCall拉起Callee被调用端并获取Caller通信接口,注册Caller的onRelease监听。应用开发者根据实际需要做相应处理。具体示例代码如下:
```ts
let TAG = '[MainAbility] '
var caller = undefined
let context = this.context
context.startAbilityByCall({
bundleName: 'com.samples.CallApplication',
abilityName: 'CalleeAbility'
}).then((data) => {
if (data != null) {
caller = data
console.log(TAG + 'get caller success')
// 注册caller的release监听
caller.onRelease((msg) => {
console.log(TAG + 'caller onRelease is called ' + msg)
})
console.log(TAG + 'caller register OnRelease succeed')
}
}).catch((error) => {
console.error(TAG + 'get caller failed with ' + error)
})
```
3. 发送约定序列化数据
向被调用端发送Sequenceable数据有两种方式,一种是不带返回值,一种是获取被调用端返回的数据,method以及序列化数据需要与被调用端协商一致。如下示例调用Call接口,向Calee被调用端发送数据。具体示例代码如下:
```ts
let method = 'CalleeSortMethod'
let msg = new MySequenceable(1, 'call_str')
caller.call(method, msg).then(() => {
console.log(TAG + 'caller call succeed')
}).catch((error) => {
console.error(TAG + 'caller call failed with ' + error)
})
```
如下示例调用CallWithResult接口,向Calee被调用端发送待处理的数据,并将method方法处理完毕的数据赋值给callback。具体示例代码如下:
```ts
let method = 'CalleeSortMethod'
let msg = new MySequenceable(1, sortString)
caller.callWithResult(method, msg)
.then((data) => {
let resultMsg = new MySequenceable(0, '')
data.readSequenceable(resultMsg)
callback(resultMsg.str)
console.log(TAG + 'caller result is [' + resultMsg.num + ',' + resultMsg.str + ']')
}).catch((error) => {
console.error(TAG + 'caller callWithResult failed with ' + error)
})
```
4. 释放Caller通信接口
Caller不再使用后,应用开发者可以通过release接口释放Caller。具体示例代码如下:
```ts
try {
caller.release()
caller = undefined
console.log(TAG + 'caller release succeed')
} catch (error) {
console.error(TAG + 'caller release failed with ' + error)
}
```
## 开发实例
针对Stage模型本地Call功能开发,有以下示例工程可供参考:
[eTSStageCallAbility]()
本示例eTSStageCallAbility中,在Application目录的AbilityStage.ts中实现AbilityStage的接口,在MainAbility目录实现Ability的接口并设置"pages/index"为应用的界面,在CaleeAbility目录实现Callee被调用端。MainAbility获取Caller通信接口后,支持用户输入字符串,做序列化处理后传递给CaleeAbility被调用端处理,Calee将字符串排序,返回序列化数据并将排序结果显示在页面上。
\ No newline at end of file
......@@ -6,191 +6,31 @@
## 导入模块
requestAnimationFrame:无需导入
cancelAnimationFrame:无需导入
createAnimator:
```
import animator from '@ohos.animator';
```
## 权限列表
## createAnimator
## requestAnimationFrame
createAnimator(options: AnimatorOptions): AnimatorResult
requestAnimationFrame(handler[, [ ...args]]): number
定义Animator类。
请求动画帧,逐帧回调JS函数。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
- 参数
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| handler | Function | 是 | 表示要逐帧回调的函数。requestAnimationFrame函数回调handler函数时会在第一个参数位置传入timestamp时间戳。它表示requestAnimationFrame开始去执行回调函数的时刻。 |
| ...args | Array&lt;any&gt; | 否 | 附加参数,函数回调时,他们会作为参数传递给handler。 |
| options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项,详细请参考AnimatorOptions。|
- 返回值
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| number | requestID请求的ID。 |
- 示例
```
<!-- xxx.hml -->
<div class="container">
<button type="capsule" class="btn" onclick="beginAnimation">beginAnimation</button>
</div>
```
```
/* xxx.css */
.container {
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
.btn{
width: 300px;
margin-top: 40px;
}
```
```
/* xxx.js */
export default {
data: {
requestId: 0,
startTime: 0,
},
beginAnimation() {
cancelAnimationFrame(this.requestId);
this.requestId = requestAnimationFrame(this.runAnimation);
},
runAnimation(timestamp) {
if (this.startTime == 0) {
this.startTime = timestamp;
}
var elapsed = timestamp - this.startTime;
if (elapsed < 500) {
console.log('callback handler timestamp: ' + timestamp);
this.requestId = requestAnimationFrame(this.runAnimation);
}
}
}
```
## cancelAnimationFrame
cancelAnimationFrame(requestId: number): void
取消动画帧,取消逐帧回调请求。
- 参数
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| requestId | number | 是 | 逐帧回调函数的标识id。 |
- 示例
```
<!-- xxx.hml -->
<div class="container">
<button type="capsule" class="btn" onclick="beginAnimation">beginAnimation</button>
<button type="capsule" class="btn" onclick="stopAnimation">stopAnimation</button>
</div>
```
| [AnimatorResult](#animatorresult) | Animator结果接口。 |
```
/* xxx.css */
.container {
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
.btn{
width: 300px;
margin-top: 40px;
}
```
**示例:**
```
/* xxx.js */
export default {
data: {
requestId: 0,
startTime: 0,
},
beginAnimation() {
cancelAnimationFrame(this.requestId);
this.requestId = requestAnimationFrame(this.runAnimation);
},
runAnimation(timestamp) {
if (this.startTime == 0) {
this.startTime = timestamp;
}
var elapsed = timestamp - this.startTime;
if (elapsed < 500) {
console.log('callback handler timestamp: ' + timestamp);
this.requestId = requestAnimationFrame(this.runAnimation);
}
},
stopAnimation() {
cancelAnimationFrame(this.requestId);
}
}
```
## createAnimator
createAnimator(options[...]): void
创建动画对象。
- 参数
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| options | Object | 是 | 表示待创建Animator对象的属性,详情见下表options说明。 |
- options说明
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| duration | number | 否 | 动画播放的时长,单位毫秒,默认为0。 |
| easing | string | 否 | 动画插值曲线,默认为'&nbsp;ease&nbsp;'。 |
| delay | number | 否 | 动画延时播放时长,单位毫秒,默认为0,即不延时。 |
| fill | string | 否 | 动画启停模式,默认值none,详情见:[animation-fill-mode](../arkui-js/js-components-common-animation.md) |
| direction | string | 否 | 动画播放模式,默认值normal,详情见:[animation-direction](../arkui-js/js-components-common-animation.md) |
| iterations | number | 否 | 动画播放次数,默认值1,设置为0时不播放,设置为-1时无限次播放。 |
| begin | number | 否 | 动画插值起点,不设置时默认为0。 |
| end | number | 否 | 动画插值终点,不设置时默认为1。 |
- animator支持的接口
| 参数名 | 类型 | 说明 |
| -------- | -------- | -------- |
| update | options | 过程中可以使用这个接口更新动画参数,入参与createAnimator一致。 |
| play | - | 开始动画。 |
| finish | - | 结束动画。 |
| pause | - | 暂停动画。 |
| cancel | - | 取消动画。 |
| reverse | - | 倒播动画。 |
- animator支持的事件:
| 参数名 | 类型 | 说明 |
| -------- | -------- | -------- |
| frame | number | 逐帧插值回调事件,入参为当前帧的插值 |
| cancel | - | 动画被强制取消 |
| finish | - | 动画播放完成 |
| repeat | - | 动画重新播放 |
- 示例
```
<!-- hml -->
<div class="container">
......@@ -237,3 +77,164 @@ createAnimator(options[...]): void
}
}
```
## AnimatorResult
定义Animator结果接口。
### update
update(options: AnimatorOptions): void
更新当前动画器。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。|
**示例:**
```
animator.update(options);
```
### play
play(): void
启动动画。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**示例:**
```
animator.play();
```
### finish
finish(): void
结束动画。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**示例:**
```
animator.finish();
```
### pause
pause(): void
暂停动画。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**示例:**
```
animator.pause();
```
### cancel
cancel(): void
删除动画。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**示例:**
```
animator.cancel();
```
### reverse
reverse(): void
以相反的顺序播放动画。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**示例:**
```
animator.reverse();
```
### onframe
onframe: (progress: number) => void
回调时触发。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| progress | number | 是 | 动画的当前进度。|
**示例:**
```
animator.onframe();
```
### onfinish
onfinish: () => void
动画完成。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**示例:**
```
animator.onfinish();
```
### oncancel
oncancel: () => void
动画被取消。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**示例:**
```
animator.oncancel();
```
### onrepeat
onrepeat: () => void
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**示例:**
```
animator.onrepeat();
```
动画将重复。
## AnimatorOptions
定义动画选项。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full
| 名称 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| duration | number | 是 | 动画播放的时长,单位毫秒,默认为0。 |
| easing | string | 是 | 动画插值曲线,默认为ease'。 |
| delay | number | 是 | 动画延时播放时长,单位毫秒,默认为0,即不延时。 |
| fill | "none" \| "forwards" \| "backwards" \| "both" | 是 | 动画执行后是否恢复到初始状态,默认值为"none"。动画执行后,动画结束时的状态(在最后一个关键帧中定义)将保留。 |
| direction | "normal" \| "reverse" \| "alternate" \| "alternate-reverse" | 是 | 动画播放模式,默认值"normal"。|
| iterations | number | 是 | 动画播放次数,默认值1。设置为0时不播放,设置为-1时无限次播放。 |
| begin | number | 是 | 动画插值起点,不设置时默认为0。 |
| end | number | 是 | 动画插值终点,不设置时默认为1。 |
......@@ -351,7 +351,7 @@ hashMap.forEach((value, key) => {
### entries
entries(): IterableIterator<[K, V]>
entries(): IterableIterator&lt;[K, V]&gt;
返回包含此映射中包含的键值对的新迭代器对象。
......@@ -359,7 +359,7 @@ entries(): IterableIterator<[K, V]>
| 类型 | 说明 |
| -------- | -------- |
| IterableIterator<[K, V]> | 返回一个迭代器。 |
| IterableIterator&lt;[K, V]&gt; | 返回一个迭代器。 |
**示例:**
......@@ -387,7 +387,7 @@ while(temp != undefined) {
| 类型 | 说明 |
| -------- | -------- |
| IterableIterator<[K, V]> | 返回一个迭代器。 |
| IterableIterator&lt;[K, V]&gt; | 返回一个迭代器。 |
**示例:**
```
......
......@@ -578,7 +578,7 @@ getLast(): T
**示例:**
```
let list = new Vector();
let list = new List();
list.add(2);
list.add(4);
list.add(5);
......
......@@ -416,7 +416,7 @@ plainArray.clear();
### forEach
forEach(callbackfn: (value: T, index?: number, PlainArray?: PlainArray<T>) => void, thisArg?: Object): void
forEach(callbackfn: (value: T, index?: number, PlainArray?: PlainArray&lt;T&gt;) => void, thisArg?: Object): void
通过回调函数来遍历实例对象上的元素以及元素对应的下标。
......@@ -432,7 +432,7 @@ callbackfn的参数说明:
| -------- | -------- | -------- | -------- |
| value | T | 是 | 当前遍历到的元素键值对的值。 |
| index | number | 否 | 当前遍历到的元素键值对的键。 |
| plainArray | PlainArray<T> | 否 | 当前调用forEach方法的实例对象。 |
| PlainArray | PlainArray&lt;T&gt;| 否 | 当前调用forEach方法的实例对象。 |
**示例:**
......@@ -456,7 +456,7 @@ plainArray.forEach((value, key) => {
| 类型 | 说明 |
| -------- | -------- |
| IterableIterator<[number, T]> | 返回一个迭代器。 |
| IterableIterator&lt;[number, T]&gt; | 返回一个迭代器。 |
**示例:**
......
......@@ -139,7 +139,7 @@ let result = treeSet.getLastValue();
add(value: T): boolean
TreeSet中添加一组数据。
容器中添加一组数据。
**参数:**
......
此差异已折叠。
......@@ -52,7 +52,7 @@ repo init -u https://gitee.com/openharmony-sig/manifest.git -b master -m devboar
- [标准系统芯片移植指导](standard-system-porting-guide.md)
- [标准系统移植指南](standard-system-porting-guide.md)
- [一种快速移植OpenHarmony Linux内核的方法](porting-linux-kernel.md)
- [轻量和小型系统三方库移植指导]( porting-thirdparty.md)
- [轻量和小型系统三方库移植指导](porting-thirdparty.md)
- [概述](porting-thirdparty-overview.md)
- [CMake方式组织编译的库移植](porting-thirdparty-cmake.md)
- [Makefile方式组织编译的库移植](porting-thirdparty-makefile.md)
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册