未验证 提交 3bed0cd4 编写于 作者: O openharmony_ci 提交者: Gitee

!16502 翻译已完成15595+15911+15694+15884+16008

Merge pull request !16502 from shawn_he/15595-b
# HTTP Data Request # HTTP Data Request
## Use Cases ## When to Use
An application can initiate a data request over HTTP. Common HTTP methods include **GET**, **POST**, **OPTIONS**, **HEAD**, **PUT**, **DELETE**, **TRACE**, and **CONNECT**. An application can initiate a data request over HTTP. Common HTTP methods include **GET**, **POST**, **OPTIONS**, **HEAD**, **PUT**, **DELETE**, **TRACE**, and **CONNECT**.
...@@ -14,40 +14,49 @@ For details about how to apply for permissions, see [Access Control Development] ...@@ -14,40 +14,49 @@ For details about how to apply for permissions, see [Access Control Development]
The following table provides only a simple description of the related APIs. For details, see [API Reference](../reference/apis/js-apis-http.md). The following table provides only a simple description of the related APIs. For details, see [API Reference](../reference/apis/js-apis-http.md).
| API | Description | | API | Description |
| ----------------------------------------- | --------------------------------------------------------- | | ----------------------------------------- | ----------------------------------- |
| createHttp() | Creates an HTTP request. | | createHttp() | Creates an HTTP request. |
| request() | Initiates an HTTP request to a given URL. | | request() | Initiates an HTTP request to a given URL. |
| destroy() | Destroys an HTTP request. | | request2()<sup>10+</sup> | Initiates an HTTP network request based on the URL and returns a streaming response.|
| destroy() | Destroys an HTTP request. |
| on(type: 'headersReceive') | Registers an observer for HTTP Response Header events. | | on(type: 'headersReceive') | Registers an observer for HTTP Response Header events. |
| off(type: 'headersReceive') | Unregisters the observer for HTTP Response Header events. | | off(type: 'headersReceive') | Unregisters the observer for HTTP Response Header events.|
| once\('headersReceive'\)<sup>8+</sup> | Registers a one-time observer for HTTP Response Header events.|
| on\('dataReceive'\)<sup>10+</sup> | Registers an observer for events indicating receiving of HTTP streaming responses. |
| off\('dataReceive'\)<sup>10+</sup> | Unregisters the observer for events indicating receiving of HTTP streaming responses. |
| on\('dataEnd'\)<sup>10+</sup> | Registers an observer for events indicating completion of receiving HTTP streaming responses. |
| off\('dataEnd'\)<sup>10+</sup> | Unregisters the observer for events indicating completion of receiving HTTP streaming responses.|
| on\('dataProgress'\)<sup>10+</sup> | Registers an observer for events indicating progress of receiving HTTP streaming responses. |
| off\('dataProgress'\)<sup>10+</sup> | Unregisters the observer for events indicating progress of receiving HTTP streaming responses.|
## How to Develop ## How to Develop
1. Import the required HTTP module. 1. Import the **http** namespace from **@ohos.net.http.d.ts**.
2. Create an **HttpRequest** object. 2. Call **createHttp()** to create an **HttpRequest** object.
3. (Optional) Listen for HTTP Response Header events. 3. Call **httpRequest.on()** to subscribe to HTTP response header events. This API returns a response earlier than the request. You can subscribe to HTTP response header events based on service requirements.
4. Initiate an HTTP request to a given URL. 4. Call **httpRequest.request()** to initiate a network request. You need to pass in the URL and optional parameters of the HTTP request.
5. (Optional) Process the HTTP Response Header event and the return result of the HTTP request. 5. Parse the returned result based on service requirements.
6. Call **off()** to unsubscribe from HTTP response header events.
7. Call **httpRequest.destroy()** to release resources after the request is processed.
```js ```js
// Import the http namespace.
import http from '@ohos.net.http'; import http from '@ohos.net.http';
// Each HttpRequest corresponds to an HttpRequestTask object and cannot be reused. // Each httpRequest corresponds to an HTTP request task and cannot be reused.
let httpRequest = http.createHttp(); let httpRequest = http.createHttp();
// This API is used to listen for the HTTP Response Header event, which is returned earlier than the result of the HTTP request. It is up to you whether to listen for HTTP Response Header events.
// Subscribe to the HTTP response header, which is returned earlier than HttpRequest. You can subscribe to HTTP Response Header events based on service requirements. // on('headerReceive', AsyncCallback) is replaced by on('headersReceive', Callback) since API version 8.
// on('headerReceive', AsyncCallback) will be replaced by on('headersReceive', Callback) in API version 8. 8+
httpRequest.on('headersReceive', (header) => { httpRequest.on('headersReceive', (header) => {
console.info('header: ' + JSON.stringify(header)); console.info('header: ' + JSON.stringify(header));
}); });
httpRequest.request( httpRequest.request(
// Set the URL of the HTTP request. You need to define the URL. Set the parameters of the request in extraData. // Customize EXAMPLE_URL in extraData on your own. It is up to you whether to add parameters to the URL.
"EXAMPLE_URL", "EXAMPLE_URL",
{ {
method: http.RequestMethod.POST, // Optional. The default value is http.RequestMethod.GET. method: http.RequestMethod.POST, // Optional. The default value is http.RequestMethod.GET.
// You can add the header field based on service requirements. // You can add header fields based on service requirements.
header: { header: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
...@@ -55,21 +64,33 @@ httpRequest.request( ...@@ -55,21 +64,33 @@ httpRequest.request(
extraData: { extraData: {
"data": "data to send", "data": "data to send",
}, },
connectTimeout: 60000, // Optional. The default value is 60000, in ms. expectDataType: http.HttpDataType.STRING, // Optional. This field specifies the type of the return data.
usingCache: true, // Optional. The default value is true.
priority: 1, // Optional. The default value is 1.
connectTimeout: 60000 // Optional. The default value is 60000, in ms.
readTimeout: 60000, // Optional. The default value is 60000, in ms. readTimeout: 60000, // Optional. The default value is 60000, in ms.
usingProtocol: http.HttpProtocol.HTTP1_1, // Optional. The default protocol type is automatically specified by the system.
usingProxy: false, // Optional. By default, network proxy is not used. This field is supported since API 10.
}, (err, data) => { }, (err, data) => {
if (!err) { if (!err) {
// data.result contains the HTTP response. Parse the response based on service requirements. // data.result carries the HTTP response. Parse the response based on service requirements.
console.info('Result:' + data.result); console.info('Result:' + JSON.stringify(data.result));
console.info('code:' + data.responseCode); console.info('code:' + JSON.stringify(data.responseCode));
// data.header contains the HTTP response header. Parse the content based on service requirements. // data.header carries the HTTP response header. Parse the content based on service requirements.
console.info('header:' + JSON.stringify(data.header)); console.info('header:' + JSON.stringify(data.header));
console.info('cookies:' + data.cookies); // 8+ console.info('cookies:' + JSON.stringify(data.cookies)); // 8+
} else { } else {
console.info('error:' + JSON.stringify(err)); console.info('error:' + JSON.stringify(err));
// Call the destroy() method to destroy the request if it is no longer needed. // Unsubscribe from HTTP Response Header events.
httpRequest.off('headersReceive');
// Call the destroy() method to release resources after HttpRequest is complete.
httpRequest.destroy(); httpRequest.destroy();
} }
} }
); );
``` ```
## Samples
The following sample is provided to help you better understand how to develop the HTTP data request feature:
- [`HTTP`: Data Request (ArkTS) (API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/Connectivity/Http)
- [HTTP Communication (ArkTS) (API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/SmartChatEtsOH)
...@@ -49,6 +49,7 @@ TLS Socket connection functions are mainly provided by the **tls_socket** module ...@@ -49,6 +49,7 @@ TLS Socket connection functions are mainly provided by the **tls_socket** module
| API| Description| | API| Description|
| -------- | -------- | | -------- | -------- |
| constructTLSSocketInstance() | Creates a **TLSSocket** object.|
| bind() | Binds the IP address and port number.| | bind() | Binds the IP address and port number.|
| close(type:&nbsp;'error') | Closes a Socket connection.| | close(type:&nbsp;'error') | Closes a Socket connection.|
| connect() | Sets up a connection to the specified IP address and port number.| | connect() | Sets up a connection to the specified IP address and port number.|
...@@ -189,7 +190,7 @@ TLS Socket connection process on the client: ...@@ -189,7 +190,7 @@ TLS Socket connection process on the client:
let tlsTwoWay = socket.constructTLSSocketInstance(); let tlsTwoWay = socket.constructTLSSocketInstance();
// Subscribe to TLS Socket connection events. // Subscribe to TLS Socket connection events.
tcp.on('message', value => { tlsTwoWay.on('message', value => {
console.log("on message") console.log("on message")
let buffer = value.message let buffer = value.message
let dataView = new DataView(buffer) let dataView = new DataView(buffer)
...@@ -199,10 +200,10 @@ TLS Socket connection process on the client: ...@@ -199,10 +200,10 @@ TLS Socket connection process on the client:
} }
console.log("on connect received:" + str) console.log("on connect received:" + str)
}); });
tcp.on('connect', () => { tlsTwoWay.on('connect', () => {
console.log("on connect") console.log("on connect")
}); });
tcp.on('close', () => { tlsTwoWay.on('close', () => {
console.log("on close") console.log("on close")
}); });
...@@ -245,23 +246,23 @@ TLS Socket connection process on the client: ...@@ -245,23 +246,23 @@ TLS Socket connection process on the client:
console.log(data); console.log(data);
}); });
// Enable the TLS Socket connection to be automatically closed after use. Then, disable listening for TLS Socket connection events. // Enable the TCP Socket connection to be automatically closed after use. Then, disable listening for TCP Socket connection events.
tls.close((err) => { tlsTwoWay.close((err) => {
if (err) { if (err) {
console.log("close callback error = " + err); console.log("close callback error = " + err);
} else { } else {
console.log("close success"); console.log("close success");
} }
tls.off('message'); tlsTwoWay.off('message');
tls.off('connect'); tlsTwoWay.off('connect');
tls.off('close'); tlsTwoWay.off('close');
}); });
// Create a TLS Socket connection (for one-way authentication). // Create a TLS Socket connection (for one-way authentication).
let tlsOneWay = socket.constructTLSSocketInstance(); // One way authentication let tlsOneWay = socket.constructTLSSocketInstance(); // One way authentication
// Subscribe to TLS Socket connection events. // Subscribe to TLS Socket connection events.
tcp.on('message', value => { tlsTwoWay.on('message', value => {
console.log("on message") console.log("on message")
let buffer = value.message let buffer = value.message
let dataView = new DataView(buffer) let dataView = new DataView(buffer)
...@@ -271,10 +272,10 @@ TLS Socket connection process on the client: ...@@ -271,10 +272,10 @@ TLS Socket connection process on the client:
} }
console.log("on connect received:" + str) console.log("on connect received:" + str)
}); });
tcp.on('connect', () => { tlsTwoWay.on('connect', () => {
console.log("on connect") console.log("on connect")
}); });
tcp.on('close', () => { tlsTwoWay.on('close', () => {
console.log("on close") console.log("on close")
}); });
...@@ -306,16 +307,16 @@ TLS Socket connection process on the client: ...@@ -306,16 +307,16 @@ TLS Socket connection process on the client:
console.log(data); console.log(data);
}); });
// Enable the TLS Socket connection to be automatically closed after use. Then, disable listening for TLS Socket connection events. // Enable the TCP Socket connection to be automatically closed after use. Then, disable listening for TCP Socket connection events.
tls.close((err) => { tlsTwoWay.close((err) => {
if (err) { if (err) {
console.log("close callback error = " + err); console.log("close callback error = " + err);
} else { } else {
console.log("close success"); console.log("close success");
} }
tls.off('message'); tlsTwoWay.off('message');
tls.off('connect'); tlsTwoWay.off('connect');
tls.off('close'); tlsTwoWay.off('close');
}); });
``` ```
......
...@@ -20,6 +20,10 @@ dial\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void ...@@ -20,6 +20,10 @@ dial\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void
Initiates a call. This API uses an asynchronous callback to return the result. Initiates a call. This API uses an asynchronous callback to return the result.
>**NOTE**
>
>This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9).
**Required Permissions**: ohos.permission.PLACE_CALL **Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
...@@ -46,6 +50,10 @@ dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean ...@@ -46,6 +50,10 @@ dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean
Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result. Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result.
>**NOTE**
>
>This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9).
**Required Permissions**: ohos.permission.PLACE_CALL **Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
...@@ -75,6 +83,10 @@ dial\(phoneNumber: string, options?: DialOptions\): Promise<boolean\> ...@@ -75,6 +83,10 @@ dial\(phoneNumber: string, options?: DialOptions\): Promise<boolean\>
Initiates a call. You can set call options as needed. This API uses a promise to return the result. Initiates a call. You can set call options as needed. This API uses a promise to return the result.
>**NOTE**
>
>This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9).
**Required Permissions**: ohos.permission.PLACE_CALL **Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
...@@ -121,11 +133,12 @@ Initiates a call. This API uses an asynchronous callback to return the result. ...@@ -121,11 +133,12 @@ Initiates a call. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ---------------------------- | ---- | --------------------------------------- | | ----------- | ---------------------------- | ---- | -------------------------------------- |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -140,8 +153,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -140,8 +153,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.dialCall("138xxxxxxxx", (err, data) => { call.dialCall("138xxxxxxxx", (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -161,12 +174,13 @@ Initiates a call. You can set call options as needed. This API uses an asynchron ...@@ -161,12 +174,13 @@ Initiates a call. You can set call options as needed. This API uses an asynchron
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ----------------------------------- | ---- | ------------------------------------ | | ----------- | ----------------------------------- | ---- | ----------------------------------- |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| options | [DialCallOptions](#dialcalloptions9)| Yes | Call options, which carry other configuration information of the call. | | options | [DialCallOptions](#dialcalloptions9)| Yes | Call options, which carry other configuration information of the call. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -186,8 +200,8 @@ call.dialCall("138xxxxxxxx", { ...@@ -186,8 +200,8 @@ call.dialCall("138xxxxxxxx", {
videoState: 0, videoState: 0,
dialScene: 0, dialScene: 0,
dialType: 0, dialType: 0,
}, (err, data) => { }, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -209,15 +223,16 @@ Initiates a call. You can set call options as needed. This API uses a promise to ...@@ -209,15 +223,16 @@ Initiates a call. You can set call options as needed. This API uses a promise to
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ----------------------------------- | ---- | -------------------------------------- | | ----------- | ----------------------------------- | ---- | -------------------------------------- |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| options | [DialCallOptions](#dialcalloptions9)| No | Call option, which indicates whether the call is a voice call or video call.| | options | [DialCallOptions](#dialcalloptions9)| No | Call options, which carry other configuration information of the call.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------- | ------------------------------------------------------------ | | ---------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise used to return the result. | | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -232,12 +247,17 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -232,12 +247,17 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
try { let promise = call.dialCall("138xxxxxxxx", {
call.dialCall('138xxxxxxxx'); accountId: 0,
console.log(`dialCall success, promise: data->${JSON.stringify(data)}`); videoState: 0,
} catch (error) { dialScene: 0,
console.log(`dialCall fail, promise: err->${JSON.stringify(error)}`); dialType: 0,
} });
promise.then(() => {
console.log(`dialCall success.`);
}).catch((err) => {
console.error(`dialCall fail, promise: err->${JSON.stringify(err)}`);
});
``` ```
...@@ -257,6 +277,7 @@ Launches the call screen and displays the dialed number. This API uses an asynch ...@@ -257,6 +277,7 @@ Launches the call screen and displays the dialed number. This API uses an asynch
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -297,6 +318,7 @@ Launches the call screen and displays the dialed number. This API uses a promise ...@@ -297,6 +318,7 @@ Launches the call screen and displays the dialed number. This API uses a promise
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -450,6 +472,7 @@ Checks whether the called number is an emergency number. This API uses an asynch ...@@ -450,6 +472,7 @@ Checks whether the called number is an emergency number. This API uses an asynch
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. - **true**: The called number is an emergency number.<br>- **false**: The called number is not an emergency number.| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. - **true**: The called number is an emergency number.<br>- **false**: The called number is not an emergency number.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -486,6 +509,7 @@ Checks whether the called number is an emergency number based on the phone numbe ...@@ -486,6 +509,7 @@ Checks whether the called number is an emergency number based on the phone numbe
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. - **true**: The called number is an emergency number.<br>- **false**: The called number is not an emergency number.| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. - **true**: The called number is an emergency number.<br>- **false**: The called number is not an emergency number.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -527,6 +551,7 @@ Checks whether the called number is an emergency number based on the phone numbe ...@@ -527,6 +551,7 @@ Checks whether the called number is an emergency number based on the phone numbe
| Promise&lt;boolean&gt; | Promise used to return the result.| | Promise&lt;boolean&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -566,6 +591,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100. ...@@ -566,6 +591,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100.
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -603,6 +629,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100. ...@@ -603,6 +629,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100.
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -648,6 +675,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100. ...@@ -648,6 +675,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100.
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -690,6 +718,7 @@ The phone number must match the specified country code. For example, for a China ...@@ -690,6 +718,7 @@ The phone number must match the specified country code. For example, for a China
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -735,6 +764,7 @@ All country codes are supported. ...@@ -735,6 +764,7 @@ All country codes are supported.
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -775,10 +805,12 @@ Mutes the ringtone while it is playing. It does not work if the ringtone has bee ...@@ -775,10 +805,12 @@ Mutes the ringtone while it is playing. It does not work if the ringtone has bee
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
...@@ -788,8 +820,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -788,8 +820,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.muteRinger((err, data) => { call.muteRinger((err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -813,13 +845,12 @@ Mutes the ringtone while it is playing. It does not work if the ringtone has bee ...@@ -813,13 +845,12 @@ Mutes the ringtone while it is playing. It does not work if the ringtone has bee
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. | | 8300003 | System internal error. |
| 8300999 | Unknown error code. | | 8300999 | Unknown error code. |
...@@ -827,16 +858,15 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -827,16 +858,15 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let promise = call.muteRinger(); call.muteRinger().then(() => {
promise.then(data => { console.log(`muteRinger success.`);
console.log(`muteRinger success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`muteRinger fail, promise: err->${JSON.stringify(err)}`); console.error(`muteRinger fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
## call.answerCall<sup>7+</sup> ## call.answerCall<sup>9+</sup>
answerCall\(callId: number, callback: AsyncCallback<void\>\): void answerCall\(callId: number, callback: AsyncCallback<void\>\): void
...@@ -856,6 +886,7 @@ Answers a call. This API uses an asynchronous callback to return the result. ...@@ -856,6 +886,7 @@ Answers a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -870,13 +901,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -870,13 +901,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.answerCall(1, (err, data) => { call.answerCall(1, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
## call.answerCall<sup>7+</sup> ## call.answerCall<sup>9+</sup>
answerCall(callId?: number\): Promise<void\> answerCall(callId?: number\): Promise<void\>
...@@ -901,6 +932,7 @@ Answers a call. This API uses a promise to return the result. ...@@ -901,6 +932,7 @@ Answers a call. This API uses a promise to return the result.
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -915,10 +947,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -915,10 +947,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let promise = call.answerCall(1); call.answerCall(1).then(() => {
promise.then(data => { console.log(`answerCall success.`);
console.log(`answerCall success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`answerCall fail, promise: err->${JSON.stringify(err)}`); console.error(`answerCall fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -943,6 +974,7 @@ Answers a call. This API uses an asynchronous callback to return the result. ...@@ -943,6 +974,7 @@ Answers a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -957,13 +989,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -957,13 +989,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.answerCall((err, data) => { call.answerCall((err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
## call.hangUpCall<sup>7+</sup> ## call.hangUpCall<sup>9+</sup>
hangUpCall\(callId: number, callback: AsyncCallback<void\>\): void hangUpCall\(callId: number, callback: AsyncCallback<void\>\): void
...@@ -983,6 +1015,7 @@ Ends a call. This API uses an asynchronous callback to return the result. ...@@ -983,6 +1015,7 @@ Ends a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -997,13 +1030,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -997,13 +1030,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.hangUpCall(1, (err, data) => { call.hangUpCall(1, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
## call.hangUpCall<sup>7+</sup> ## call.hangUpCall<sup>9+</sup>
hangUpCall\(callId?: number\): Promise<void\> hangUpCall\(callId?: number\): Promise<void\>
...@@ -1028,6 +1061,7 @@ Ends a call. This API uses a promise to return the result. ...@@ -1028,6 +1061,7 @@ Ends a call. This API uses a promise to return the result.
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1042,10 +1076,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1042,10 +1076,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let promise = call.hangUpCall(1); call.hangUpCall(1).then(() => {
promise.then(data => { console.log(`hangUpCall success.`);
console.log(`hangUpCall success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`hangUpCall fail, promise: err->${JSON.stringify(err)}`); console.error(`hangUpCall fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1070,6 +1103,7 @@ Ends a call. This API uses an asynchronous callback to return the result. ...@@ -1070,6 +1103,7 @@ Ends a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1085,13 +1119,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1085,13 +1119,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.hangUpCall((err, data) => { call.hangUpCall((err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
## call.rejectCall<sup>7+</sup> ## call.rejectCall<sup>9+</sup>
rejectCall(callId: number, callback: AsyncCallback\<void>): void rejectCall(callId: number, callback: AsyncCallback\<void>): void
...@@ -1111,6 +1145,7 @@ Rejects a call. This API uses an asynchronous callback to return the result. ...@@ -1111,6 +1145,7 @@ Rejects a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1126,13 +1161,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1126,13 +1161,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.rejectCall(1, (err, data) => { call.rejectCall(1, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
## call.rejectCall<sup>7+</sup> ## call.rejectCall<sup>9+</sup>
rejectCall\(callId: number, options: RejectMessageOptions, callback: AsyncCallback<void\>\): void rejectCall\(callId: number, options: RejectMessageOptions, callback: AsyncCallback<void\>\): void
...@@ -1153,6 +1188,7 @@ Rejects a call. This API uses an asynchronous callback to return the result. ...@@ -1153,6 +1188,7 @@ Rejects a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1170,13 +1206,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1170,13 +1206,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r
let rejectMessageOptions={ let rejectMessageOptions={
messageContent: "Unknown number blocked" messageContent: "Unknown number blocked"
} }
call.rejectCall(1, rejectMessageOptions, (err, data) => { call.rejectCall(1, rejectMessageOptions, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
## call.rejectCall<sup>7+</sup> ## call.rejectCall<sup>9+</sup>
rejectCall(callId?: number, options?: RejectMessageOptions\): Promise<void\> rejectCall(callId?: number, options?: RejectMessageOptions\): Promise<void\>
...@@ -1202,6 +1238,7 @@ Rejects a call. This API uses a promise to return the result. ...@@ -1202,6 +1238,7 @@ Rejects a call. This API uses a promise to return the result.
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1219,11 +1256,10 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1219,11 +1256,10 @@ For details about the following error codes, see [Telephony Error Codes](../../r
let rejectMessageOptions={ let rejectMessageOptions={
messageContent: "Unknown number blocked" messageContent: "Unknown number blocked"
} }
let promise = call.rejectCall(1, rejectMessageOptions); call.reject(1, rejectMessageOptions).then(() => {
promise.then(data => { console.log(`reject success.`);
console.log(`rejectCall success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => { console.error(`reject fail, promise: err->${JSON.stringify(err)}`);
console.error(`rejectCall fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1247,6 +1283,7 @@ Rejects a call. This API uses an asynchronous callback to return the result. ...@@ -1247,6 +1283,7 @@ Rejects a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1261,8 +1298,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1261,8 +1298,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.rejectCall((err, data) => { call.rejectCall((err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1287,6 +1324,7 @@ Rejects a call. This API uses an asynchronous callback to return the result. ...@@ -1287,6 +1324,7 @@ Rejects a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1304,8 +1342,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1304,8 +1342,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
let rejectMessageOptions={ let rejectMessageOptions={
messageContent: "Unknown number blocked" messageContent: "Unknown number blocked"
} }
call.rejectCall(rejectMessageOptions, (err, data) => { call.rejectCall(rejectMessageOptions, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1330,6 +1368,7 @@ Holds a call based on the specified call ID. This API uses an asynchronous callb ...@@ -1330,6 +1368,7 @@ Holds a call based on the specified call ID. This API uses an asynchronous callb
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1344,8 +1383,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1344,8 +1383,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.holdCall(1, (err, data) => { call.holdCall(1, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1375,6 +1414,7 @@ Holds a call based on the specified call ID. This API uses a promise to return t ...@@ -1375,6 +1414,7 @@ Holds a call based on the specified call ID. This API uses a promise to return t
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1389,10 +1429,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1389,10 +1429,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let promise = call.holdCall(1); call.holdCall(1).then(() => {
promise.then(data => { console.log(`holdCall success.`);
console.log(`holdCall success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`holdCall fail, promise: err->${JSON.stringify(err)}`); console.error(`holdCall fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1417,6 +1456,7 @@ Unholds a call based on the specified call ID. This API uses an asynchronous cal ...@@ -1417,6 +1456,7 @@ Unholds a call based on the specified call ID. This API uses an asynchronous cal
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1431,8 +1471,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1431,8 +1471,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.unHoldCall(1, (err, data) => { call.unHoldCall(1, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1462,6 +1502,7 @@ Unholds a call based on the specified call ID. This API uses a promise to return ...@@ -1462,6 +1502,7 @@ Unholds a call based on the specified call ID. This API uses a promise to return
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1476,10 +1517,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1476,10 +1517,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let promise = call.unHoldCall(1); call.unHoldCall(1).then(() => {
promise.then(data => { console.log(`unHoldCall success.`);
console.log(`unHoldCall success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`unHoldCall fail, promise: err->${JSON.stringify(err)}`); console.error(`unHoldCall fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1504,6 +1544,7 @@ Switches a call. This API uses an asynchronous callback to return the result. ...@@ -1504,6 +1544,7 @@ Switches a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1518,8 +1559,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1518,8 +1559,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.switchCall(1, (err, data) => { call.switchCall(1, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1549,6 +1590,7 @@ Switches a call. This API uses a promise to return the result. ...@@ -1549,6 +1590,7 @@ Switches a call. This API uses a promise to return the result.
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1563,10 +1605,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1563,10 +1605,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let promise = call.switchCall(1); call.switchCall(1).then(() => {
promise.then(data => { console.log(`switchCall success.`);
console.log(`switchCall success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`switchCall fail, promise: err->${JSON.stringify(err)}`); console.error(`switchCall fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1589,6 +1630,7 @@ Combines two calls into a conference call. This API uses an asynchronous callbac ...@@ -1589,6 +1630,7 @@ Combines two calls into a conference call. This API uses an asynchronous callbac
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1602,8 +1644,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1602,8 +1644,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.combineConference(1, (err, data) => { call.combineConference(1, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1631,6 +1673,7 @@ Combines two calls into a conference call. This API uses a promise to return the ...@@ -1631,6 +1673,7 @@ Combines two calls into a conference call. This API uses a promise to return the
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1644,10 +1687,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -1644,10 +1687,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let promise = call.combineConference(1); call.combineConference(1).then(() => {
promise.then(data => { console.log(`combineConference success.`);
console.log(`combineConference success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`combineConference fail, promise: err->${JSON.stringify(err)}`); console.error(`combineConference fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1670,6 +1712,7 @@ Obtains the main call ID. This API uses an asynchronous callback to return the r ...@@ -1670,6 +1712,7 @@ Obtains the main call ID. This API uses an asynchronous callback to return the r
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1713,6 +1756,7 @@ Obtains the main call ID. This API uses a promise to return the result. ...@@ -1713,6 +1756,7 @@ Obtains the main call ID. This API uses a promise to return the result.
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1752,6 +1796,7 @@ Obtains the list of subcall IDs. This API uses an asynchronous callback to retur ...@@ -1752,6 +1796,7 @@ Obtains the list of subcall IDs. This API uses an asynchronous callback to retur
| callback | AsyncCallback<Array<string\>\> | Yes | Callback used to return the result. | | callback | AsyncCallback<Array<string\>\> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1794,6 +1839,7 @@ Obtains the list of subcall IDs. This API uses a promise to return the result. ...@@ -1794,6 +1839,7 @@ Obtains the list of subcall IDs. This API uses a promise to return the result.
| Promise&lt;Array<string\>&gt; | Promise used to return the result.| | Promise&lt;Array<string\>&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1833,6 +1879,7 @@ Obtains the list of call IDs in a conference. This API uses an asynchronous call ...@@ -1833,6 +1879,7 @@ Obtains the list of call IDs in a conference. This API uses an asynchronous call
| callback | AsyncCallback&lt;Array<string\>&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;Array<string\>&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1875,6 +1922,7 @@ Obtains the list of call IDs in a conference. This API uses a promise to return ...@@ -1875,6 +1922,7 @@ Obtains the list of call IDs in a conference. This API uses a promise to return
| Promise&lt;Array<string\>&gt; | Promise used to return the result.| | Promise&lt;Array<string\>&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1916,6 +1964,7 @@ Obtains the call waiting status. This API uses an asynchronous callback to retur ...@@ -1916,6 +1964,7 @@ Obtains the call waiting status. This API uses an asynchronous callback to retur
| callback | AsyncCallback&lt;[CallWaitingStatus](#callwaitingstatus7)\> | Yes | Callback used to return the result.<br> <br>- **0**: Call waiting is disabled.<br>- **1**: Call waiting is enabled.| | callback | AsyncCallback&lt;[CallWaitingStatus](#callwaitingstatus7)\> | Yes | Callback used to return the result.<br> <br>- **0**: Call waiting is disabled.<br>- **1**: Call waiting is enabled.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -1961,6 +2010,7 @@ Obtains the call waiting status. This API uses a promise to return the result. ...@@ -1961,6 +2010,7 @@ Obtains the call waiting status. This API uses a promise to return the result.
| Promise&lt;[CallWaitingStatus](#callwaitingstatus7)&gt; | Promise used to return the result.<br>- **0**: Call waiting is disabled.<br>- **1**: Call waiting is enabled.| | Promise&lt;[CallWaitingStatus](#callwaitingstatus7)&gt; | Promise used to return the result.<br>- **0**: Call waiting is disabled.<br>- **1**: Call waiting is enabled.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2004,6 +2054,7 @@ Sets the call waiting switch. This API uses an asynchronous callback to return t ...@@ -2004,6 +2054,7 @@ Sets the call waiting switch. This API uses an asynchronous callback to return t
| callback | AsyncCallback<void\> | Yes | Callback used to return the result. | | callback | AsyncCallback<void\> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2018,8 +2069,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -2018,8 +2069,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.setCallWaiting(0, true, (err, data) => { call.setCallWaiting(0, true, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -2050,6 +2101,7 @@ Sets the call waiting switch. This API uses a promise to return the result. ...@@ -2050,6 +2101,7 @@ Sets the call waiting switch. This API uses a promise to return the result.
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2064,10 +2116,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -2064,10 +2116,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let promise = call.setCallWaiting(0, true); call.setCallWaiting(0, true).then(() => {
promise.then(data => { console.log(`setCallWaiting success.`);
console.log(`setCallWaiting success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`setCallWaiting fail, promise: err->${JSON.stringify(err)}`); console.error(`setCallWaiting fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -2091,6 +2142,7 @@ Enables DTMF. This API uses an asynchronous callback to return the result. ...@@ -2091,6 +2142,7 @@ Enables DTMF. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback<void\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2104,8 +2156,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -2104,8 +2156,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.startDTMF(1, "0", (err, data) => { call.startDTMF(1, "0", (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -2134,6 +2186,7 @@ Enables DTMF. This API uses a promise to return the result. ...@@ -2134,6 +2186,7 @@ Enables DTMF. This API uses a promise to return the result.
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2147,10 +2200,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -2147,10 +2200,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let promise = call.startDTMF(1, "0"); call.startDTMF(1, "0").then(() => {
promise.then(data => { console.log(`startDTMF success.`);
console.log(`startDTMF success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`startDTMF fail, promise: err->${JSON.stringify(err)}`); console.error(`startDTMF fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -2173,6 +2225,7 @@ Stops DTMF. This API uses an asynchronous callback to return the result. ...@@ -2173,6 +2225,7 @@ Stops DTMF. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2186,8 +2239,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -2186,8 +2239,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.stopDTMF(1, (err, data) => { call.stopDTMF(1, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -2215,6 +2268,7 @@ Stops DTMF. This API uses a promise to return the result. ...@@ -2215,6 +2268,7 @@ Stops DTMF. This API uses a promise to return the result.
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2228,10 +2282,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -2228,10 +2282,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let promise = call.stopDTMF(1); call.stopDTMF(1).then(() => {
promise.then(data => { console.log(`stopDTMF success.`);
console.log(`stopDTMF success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`stopDTMF fail, promise: err->${JSON.stringify(err)}`); console.error(`stopDTMF fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -2255,6 +2308,7 @@ Checks whether a call is an emergency call. This API uses an asynchronous callba ...@@ -2255,6 +2308,7 @@ Checks whether a call is an emergency call. This API uses an asynchronous callba
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2294,6 +2348,7 @@ Checks whether a call is an emergency call. This API uses a promise to return th ...@@ -2294,6 +2348,7 @@ Checks whether a call is an emergency call. This API uses a promise to return th
| Promise&lt;boolean&gt; | Promise used to return the result.| | Promise&lt;boolean&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2332,10 +2387,11 @@ Subscribes to **callDetailsChange** events. This API uses an asynchronous callba ...@@ -2332,10 +2387,11 @@ Subscribes to **callDetailsChange** events. This API uses an asynchronous callba
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------- | ---- | -------------------------- | | -------- | ------------------------------------------------------- | ---- | -------------------------- |
| type | string | Yes | Call details change during a call.| | type | string | Yes | Event type. This field has a fixed value of **callDetailsChange**.|
| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | Yes | Callback used to return the result. | | callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2371,10 +2427,11 @@ Subscribes to **callEventChange** events. This API uses an asynchronous callback ...@@ -2371,10 +2427,11 @@ Subscribes to **callEventChange** events. This API uses an asynchronous callback
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | -------------------------- | | -------- | ------------------------------------------------ | ---- | -------------------------- |
| type | string | Yes | Call event change during a call.| | type | string | Yes | This interface is used to monitor the change of call events during a call. The parameter has a fixed value of callEventChange.|
| callback | Callback<[CallEventOptions](#calleventoptions8)> | Yes | Callback used to return the result. | | callback | Callback<[CallEventOptions](#calleventoptions8)> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2410,10 +2467,11 @@ Subscribes to **callDisconnectedCause** events. This API uses an asynchronous ca ...@@ -2410,10 +2467,11 @@ Subscribes to **callDisconnectedCause** events. This API uses an asynchronous ca
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------ | ---- | -------------------------- | | -------- | ------------------------------------------------------ | ---- | -------------------------- |
| type | string | Yes | Cause of the call disconnection.| | type | string | Yes | Event type. The field has a fixed value of **callDisconnectedCause**.|
| callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | Yes | Callback used to return the result. | | callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2449,10 +2507,11 @@ Subscribes to **mmiCodeResult** events. This API uses an asynchronous callback t ...@@ -2449,10 +2507,11 @@ Subscribes to **mmiCodeResult** events. This API uses an asynchronous callback t
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------------- | ---- | --------------------- | | -------- | -------------------------------------------- | ---- | --------------------- |
| type | string | Yes | Man-machine interface (MMI) code result.| | type | string | Yes | Event type. The field has a fixed value of **mmiCodeResult**.|
| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | Yes | Callback used to return the result. | | callback | Callback<[MmiCodeResults](#mmicoderesults9)> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2488,10 +2547,11 @@ Unsubscribes from **callDetailsChange** events. This API uses an asynchronous ca ...@@ -2488,10 +2547,11 @@ Unsubscribes from **callDetailsChange** events. This API uses an asynchronous ca
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------------------------- | ---- | ---------------------------------- | | -------- | -------------------------------------------------------- | ---- | ---------------------------------- |
| type | string | Yes | IMS registration status changes.| | type | string | Yes | Event type. The field has a fixed value of **callDetailsChange**.|
| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | No | Callback used to return the result. | | callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | No | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2527,10 +2587,11 @@ Unsubscribes from **callEventChange** events. This API uses an asynchronous call ...@@ -2527,10 +2587,11 @@ Unsubscribes from **callEventChange** events. This API uses an asynchronous call
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | ---------------------------------- | | -------- | ------------------------------------------------ | ---- | ---------------------------------- |
| type | string | Yes | Unsubscription from call event changes when a call ends.| | type | string | Yes | Event type. The field has a fixed value of **callEventChange**.|
| callback | Callback<[CallEventOptions](#calleventoptions8)> | No | Callback used to return the result. | | callback | Callback<[CallEventOptions](#calleventoptions8)> | No | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2565,11 +2626,12 @@ Unsubscribes from **callDisconnectedCause** events. This API uses an asynchronou ...@@ -2565,11 +2626,12 @@ Unsubscribes from **callDisconnectedCause** events. This API uses an asynchronou
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------------------- | ---- | -------------------- | | -------- | ---------------------------------------------------------- | ---- | ------------------- |
| type | 'callDisconnectedCause' | Yes | Unsubscription from the call disconnection cause when a call ends.| | type | string | Yes | Event type. The field has a fixed value of **callDisconnectedCause**.|
| callback | Callback**<**[DisconnectedDetails](#disconnecteddetails9)> | No | Callback used to return the result. | | callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | No | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2603,12 +2665,13 @@ Unsubscribes from **mmiCodeResult** events. This API uses an asynchronous callba ...@@ -2603,12 +2665,13 @@ Unsubscribes from **mmiCodeResult** events. This API uses an asynchronous callba
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | ----------- | | -------- | ------------------------------------------------ | ---- | ----------- |
| type | 'mmiCodeResult' | Yes | MMI code result.| | type | string | Yes | Event type. The field has a fixed value of **mmiCodeResult**.|
| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | No | Callback used to return the result. | | callback | Callback<[MmiCodeResults](#mmicoderesults9)> | No | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2645,6 +2708,7 @@ Checks whether a new call is allowed. This API uses an asynchronous callback to ...@@ -2645,6 +2708,7 @@ Checks whether a new call is allowed. This API uses an asynchronous callback to
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2681,6 +2745,7 @@ Checks whether a new call is allowed. This API uses a promise to return the resu ...@@ -2681,6 +2745,7 @@ Checks whether a new call is allowed. This API uses a promise to return the resu
| Promise&lt;boolean&gt; | Promise used to return the result.| | Promise&lt;boolean&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2720,6 +2785,7 @@ Separates calls from a conference call. This API uses an asynchronous callback t ...@@ -2720,6 +2785,7 @@ Separates calls from a conference call. This API uses an asynchronous callback t
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2733,8 +2799,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -2733,8 +2799,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.separateConference(1, (err, data) => { call.separateConference(1, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -2762,6 +2828,7 @@ Separates calls from a conference call. This API uses a promise to return the re ...@@ -2762,6 +2828,7 @@ Separates calls from a conference call. This API uses a promise to return the re
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2775,10 +2842,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -2775,10 +2842,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let promise = call.separateConference(1); call.separateConference(1).then(() => {
promise.then(data => { console.log(`separateConference success.`);
console.log(`separateConference success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`separateConference fail, promise: err->${JSON.stringify(err)}`); console.error(`separateConference fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -2804,6 +2870,7 @@ Obtains the call restriction status. This API uses an asynchronous callback to r ...@@ -2804,6 +2870,7 @@ Obtains the call restriction status. This API uses an asynchronous callback to r
| callback | AsyncCallback&lt;[RestrictionStatus](#restrictionstatus8)&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;[RestrictionStatus](#restrictionstatus8)&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2850,6 +2917,7 @@ Obtains the call restriction status. This API uses a promise to return the resul ...@@ -2850,6 +2917,7 @@ Obtains the call restriction status. This API uses a promise to return the resul
| Promise&lt;[RestrictionStatus](#restrictionstatus8)&gt; | Promise used to return the result.| | Promise&lt;[RestrictionStatus](#restrictionstatus8)&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2893,6 +2961,7 @@ Sets the call restriction status. This API uses an asynchronous callback to retu ...@@ -2893,6 +2961,7 @@ Sets the call restriction status. This API uses an asynchronous callback to retu
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2912,8 +2981,8 @@ let callRestrictionInfo={ ...@@ -2912,8 +2981,8 @@ let callRestrictionInfo={
password: "123456", password: "123456",
mode: 1 mode: 1
} }
call.setCallRestriction(0, callRestrictionInfo, (err, data) => { call.setCallRestriction(0, callRestrictionInfo, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -2944,6 +3013,7 @@ Sets the call restriction status. This API uses a promise to return the result. ...@@ -2944,6 +3013,7 @@ Sets the call restriction status. This API uses a promise to return the result.
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -2963,10 +3033,9 @@ let callRestrictionInfo={ ...@@ -2963,10 +3033,9 @@ let callRestrictionInfo={
password: "123456", password: "123456",
mode: 1 mode: 1
} }
let promise = call.setCallRestriction(0, callRestrictionInfo); call.setCallRestriction(0, callRestrictionInfo).then(() => {
promise.then(data => { console.log(`setCallRestriction success.`);
console.log(`setCallRestriction success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`setCallRestriction fail, promise: err->${JSON.stringify(err)}`); console.error(`setCallRestriction fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -2992,6 +3061,7 @@ Obtains call transfer information. This API uses an asynchronous callback to ret ...@@ -2992,6 +3061,7 @@ Obtains call transfer information. This API uses an asynchronous callback to ret
| callback | AsyncCallback&lt;[CallTransferResult](#calltransferresult8)&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;[CallTransferResult](#calltransferresult8)&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3038,6 +3108,7 @@ Obtains call transfer information. This API uses a promise to return the result. ...@@ -3038,6 +3108,7 @@ Obtains call transfer information. This API uses a promise to return the result.
| Promise&lt;[CallTransferResult](#calltransferresult8)&gt; | Promise used to return the result.| | Promise&lt;[CallTransferResult](#calltransferresult8)&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3081,6 +3152,7 @@ Sets call transfer information. This API uses an asynchronous callback to return ...@@ -3081,6 +3152,7 @@ Sets call transfer information. This API uses an asynchronous callback to return
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3100,8 +3172,8 @@ let callTransferInfo={ ...@@ -3100,8 +3172,8 @@ let callTransferInfo={
type: 1, type: 1,
settingType: 1 settingType: 1
} }
call.setCallTransfer(0, callTransferInfo, (err, data) => { call.setCallTransfer(0, callTransferInfo, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3132,6 +3204,7 @@ Sets call transfer information. This API uses a promise to return the result. ...@@ -3132,6 +3204,7 @@ Sets call transfer information. This API uses a promise to return the result.
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3151,10 +3224,9 @@ let callTransferInfo={ ...@@ -3151,10 +3224,9 @@ let callTransferInfo={
type: 1, type: 1,
settingType: 1 settingType: 1
} }
let promise = call.setCallTransfer(0, callTransferInfo); call.setCallTransfer(0, callTransferInfo).then(() => {
promise.then(data => { console.log(`setCallTransfer success.`);
console.log(`setCallTransfer success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`setCallTransfer fail, promise: err->${JSON.stringify(err)}`); console.error(`setCallTransfer fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3178,6 +3250,7 @@ Checks whether the ringtone is playing. This API uses an asynchronous callback t ...@@ -3178,6 +3250,7 @@ Checks whether the ringtone is playing. This API uses an asynchronous callback t
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3217,6 +3290,7 @@ Checks whether the ringtone is playing. This API uses a promise to return the re ...@@ -3217,6 +3290,7 @@ Checks whether the ringtone is playing. This API uses a promise to return the re
| Promise&lt;boolean&gt; | Promise used to return the result.| | Promise&lt;boolean&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3256,6 +3330,7 @@ Sets call muting. This API uses an asynchronous callback to return the result. ...@@ -3256,6 +3330,7 @@ Sets call muting. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3269,8 +3344,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3269,8 +3344,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.setMuted((err, data) => { call.setMuted((err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3292,6 +3367,7 @@ Sets call muting. This API uses a promise to return the result. ...@@ -3292,6 +3367,7 @@ Sets call muting. This API uses a promise to return the result.
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3305,10 +3381,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3305,10 +3381,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let promise = call.setMuted(); call.setMuted().then(() => {
promise.then(data => { console.log(`setMuted success.`);
console.log(`setMuted success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`setMuted fail, promise: err->${JSON.stringify(err)}`); console.error(`setMuted fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3330,6 +3405,7 @@ Cancels call muting. This API uses an asynchronous callback to return the result ...@@ -3330,6 +3405,7 @@ Cancels call muting. This API uses an asynchronous callback to return the result
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3343,8 +3419,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3343,8 +3419,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.cancelMuted((err, data) => { call.cancelMuted((err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3366,6 +3442,7 @@ Cancels call muting. This API uses a promise to return the result. ...@@ -3366,6 +3442,7 @@ Cancels call muting. This API uses a promise to return the result.
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3379,10 +3456,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3379,10 +3456,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let promise = call.cancelMuted(); call.cancelMuted().then(() => {
promise.then(data => { console.log(`cancelMuted success.`);
console.log(`cancelMuted success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`cancelMuted fail, promise: err->${JSON.stringify(err)}`); console.error(`cancelMuted fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3405,6 +3481,7 @@ Sets the audio device for a call. This API uses an asynchronous callback to retu ...@@ -3405,6 +3481,7 @@ Sets the audio device for a call. This API uses an asynchronous callback to retu
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3418,8 +3495,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3418,8 +3495,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.setAudioDevice(1, (err, data) => { call.setAudioDevice(1, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3443,6 +3520,7 @@ Sets the audio device for a call based on the specified options. This API uses a ...@@ -3443,6 +3520,7 @@ Sets the audio device for a call based on the specified options. This API uses a
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3459,8 +3537,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3459,8 +3537,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
let audioDeviceOptions={ let audioDeviceOptions={
bluetoothAddress: "IEEE 802-2014" bluetoothAddress: "IEEE 802-2014"
} }
call.setAudioDevice(1, audioDeviceOptions, (err, data) => { call.setAudioDevice(1, audioDeviceOptions, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3489,6 +3567,7 @@ Sets the audio device for a call based on the specified options. This API uses a ...@@ -3489,6 +3567,7 @@ Sets the audio device for a call based on the specified options. This API uses a
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3505,10 +3584,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3505,10 +3584,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
let audioDeviceOptions={ let audioDeviceOptions={
bluetoothAddress: "IEEE 802-2014" bluetoothAddress: "IEEE 802-2014"
} }
let promise = call.setAudioDevice(1, audioDeviceOptions); call.setAudioDevice(1, audioDeviceOptions).then(() => {
promise.then(data => { console.log(`setAudioDevice success.`);
console.log(`setAudioDevice success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`setAudioDevice fail, promise: err->${JSON.stringify(err)}`); console.error(`setAudioDevice fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3532,6 +3610,7 @@ Joins a conference call. This API uses an asynchronous callback to return the re ...@@ -3532,6 +3610,7 @@ Joins a conference call. This API uses an asynchronous callback to return the re
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3548,8 +3627,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3548,8 +3627,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
let callNumberList: Array<string> = [ let callNumberList: Array<string> = [
"138XXXXXXXX" "138XXXXXXXX"
]; ];
call.joinConference(1, callNumberList, (err, data) => { call.joinConference(1, callNumberList, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3577,6 +3656,7 @@ Joins a conference call. This API uses a promise to return the result. ...@@ -3577,6 +3656,7 @@ Joins a conference call. This API uses a promise to return the result.
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3593,10 +3673,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3593,10 +3673,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
let callNumberList: Array<string> = [ let callNumberList: Array<string> = [
"138XXXXXXXX" "138XXXXXXXX"
]; ];
let promise = call.joinConference(1, callNumberList); call.joinConference(1, callNumberList).then(() => {
promise.then(data => { console.log(`joinConference success.`);
console.log(`joinConference success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`joinConference fail, promise: err->${JSON.stringify(err)}`); console.error(`joinConference fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3620,6 +3699,7 @@ Updates the IMS call mode. This API uses an asynchronous callback to return the ...@@ -3620,6 +3699,7 @@ Updates the IMS call mode. This API uses an asynchronous callback to return the
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3633,8 +3713,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3633,8 +3713,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.updateImsCallMode(1, 1, (err, data) => { call.updateImsCallMode(1, 1, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3662,6 +3742,7 @@ Updates the IMS call mode. This API uses a promise to return the result. ...@@ -3662,6 +3742,7 @@ Updates the IMS call mode. This API uses a promise to return the result.
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3675,10 +3756,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3675,10 +3756,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let promise = call.updateImsCallMode(1, 1); call.updateImsCallMode(1, 1).then(() => {
promise.then(data => { console.log(`updateImsCallMode success.`);
console.log(`updateImsCallMode success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`updateImsCallMode fail, promise: err->${JSON.stringify(err)}`); console.error(`updateImsCallMode fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3703,6 +3783,7 @@ Enables the IMS switch. This API uses an asynchronous callback to return the res ...@@ -3703,6 +3783,7 @@ Enables the IMS switch. This API uses an asynchronous callback to return the res
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3717,8 +3798,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3717,8 +3798,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.enableImsSwitch(0, (err, data) => { call.enableImsSwitch(0, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3747,6 +3828,7 @@ Enables the IMS switch. This API uses a promise to return the result. ...@@ -3747,6 +3828,7 @@ Enables the IMS switch. This API uses a promise to return the result.
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3761,10 +3843,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3761,10 +3843,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let promise = call.enableImsSwitch(0); call.enableImsSwitch(0).then(() => {
promise.then(data => { console.log(`enableImsSwitch success.`);
console.log(`enableImsSwitch success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`enableImsSwitch fail, promise: err->${JSON.stringify(err)}`); console.error(`enableImsSwitch fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3789,6 +3870,7 @@ Disables the IMS switch. This API uses an asynchronous callback to return the re ...@@ -3789,6 +3870,7 @@ Disables the IMS switch. This API uses an asynchronous callback to return the re
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3803,8 +3885,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3803,8 +3885,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.disableImsSwitch(0, (err, data) => { call.disableImsSwitch(0, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3822,20 +3904,21 @@ Disables the IMS switch. This API uses a promise to return the result. ...@@ -3822,20 +3904,21 @@ Disables the IMS switch. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | 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.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | --------------------------- | | ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -3847,10 +3930,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3847,10 +3930,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let promise = call.disableImsSwitch(0); call.disableImsSwitch(0).then(() => {
promise.then(data => { console.log(`disableImsSwitch success.`);
console.log(`disableImsSwitch success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`disableImsSwitch fail, promise: err->${JSON.stringify(err)}`); console.error(`disableImsSwitch fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3873,6 +3955,7 @@ Checks whether the IMS switch is enabled. This API uses an asynchronous callback ...@@ -3873,6 +3955,7 @@ Checks whether the IMS switch is enabled. This API uses an asynchronous callback
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
...@@ -3914,6 +3997,7 @@ Checks whether the IMS switch is enabled. This API uses a promise to return the ...@@ -3914,6 +3997,7 @@ Checks whether the IMS switch is enabled. This API uses a promise to return the
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
......
# @ohos.geoLocationManager (Geolocation Manager) # @ohos.geoLocationManager (Geolocation Manager)
The **geoLocationManager** module provides a wide array of location services, including GNSS positioning, network positioning, geocoding, reverse geocoding, and geofencing. The **geoLocationManager** module provides location services such as Global Navigation Satellite System (GNSS)-based positioning, network positioning, geofencing, as well as geocoding and reverse geocoding.
> **NOTE** > **NOTE**
> >
...@@ -21,14 +21,14 @@ If your application needs to access the device location information, it must fir ...@@ -21,14 +21,14 @@ If your application needs to access the device location information, it must fir
API versions earlier than 9: Apply for **ohos.permission.LOCATION**. API versions earlier than 9: Apply for **ohos.permission.LOCATION**.
API version 9 and later: Apply for **ohos.permission.APPROXIMATELY_LOCATION**, or apply for **ohos.permission.APPROXIMATELY_LOCATION** and **ohos.permission.LOCATION**. Note that **ohos.permission.LOCATION** cannot be applied for separately. API version 9 and later: Apply for **ohos.permission.APPROXIMATELY\_LOCATION**, or apply for **ohos.permission.APPROXIMATELY\_LOCATION** and **ohos.permission.LOCATION**. Note that **ohos.permission.LOCATION** cannot be applied for separately.
| API Version| Location Permission| Permission Application Result| Location Accuracy| | API Version| Location Permission| Permission Application Result| Location Accuracy|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| Earlier than 9| ohos.permission.LOCATION | Successful| Location accurate to meters.| | Earlier than 9| ohos.permission.LOCATION | Success| Location accurate to meters|
| 9 and later| ohos.permission.LOCATION | Failed| No location obtained.| | 9 and later| ohos.permission.LOCATION | Failure| No location obtained|
| 9 and later| ohos.permission.APPROXIMATELY_LOCATION | Successful| Location accurate to 5 kilometers.| | 9 and later| ohos.permission.APPROXIMATELY_LOCATION | Success| Location accurate to 5 kilometers|
| 9 and later| ohos.permission.APPROXIMATELY_LOCATION and ohos.permission.LOCATION| Successful| Location accurate to meters.| | 9 and later| ohos.permission.APPROXIMATELY_LOCATION and ohos.permission.LOCATION| Success| Location accurate to meters|
If your application needs to access the device location information when running in the background, it must be configured to be able to run in the background and be granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information after your application moves to the background. If your application needs to access the device location information when running in the background, it must be configured to be able to run in the background and be granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information after your application moves to the background.
...@@ -99,7 +99,7 @@ Defines a geographic location. ...@@ -99,7 +99,7 @@ Defines a geographic location.
| addressUrl | string | Yes| No| Website URL.| | addressUrl | string | Yes| No| Website URL.|
| descriptions | Array&lt;string&gt; | Yes| No| Additional descriptions.| | descriptions | Array&lt;string&gt; | Yes| No| Additional descriptions.|
| descriptionsSize | number | Yes| No| Total number of additional descriptions. The value must be greater than or equal to **0**. A value smaller than **10** is recommended.| | descriptionsSize | number | Yes| No| Total number of additional descriptions. The value must be greater than or equal to **0**. A value smaller than **10** is recommended.|
| isFromMock | Boolean | Yes| No| Whether the geographic address is obtained from the mock reverse geocoding function.<br>**System API**: This is a system API.| | isFromMock | Boolean | Yes| No| Whether the geographical name is from the mock reverse geocoding function.<br>**System API**: This is a system API.|
## LocationRequest ## LocationRequest
...@@ -229,12 +229,12 @@ Represents information of the mock reverse geocoding function. ...@@ -229,12 +229,12 @@ Represents information of the mock reverse geocoding function.
| Name| Type| Readable|Writable| Description| | Name| Type| Readable|Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| location | [ReverseGeoCodeRequest](#reversegeocoderequest) | Yes| Yes| Latitude and longitude information.| | location | [ReverseGeoCodeRequest](#reversegeocoderequest) | Yes| Yes| Latitude and longitude information.|
| geoAddress | [GeoAddress](#geoaddress) | Yes| Yes|Geographic address.| | geoAddress | [GeoAddress](#geoaddress) | Yes| Yes|Geographical name.|
## LocationMockConfig ## LocationMockConfig
Represents the mock location configuration. Represents the information of the mock location function.
**System capability**: SystemCapability.Location.Location.Core **System capability**: SystemCapability.Location.Location.Core
...@@ -267,25 +267,25 @@ Sets the priority of the location request. ...@@ -267,25 +267,25 @@ Sets the priority of the location request.
| Name| Value| Description| | Name| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| UNSET | 0x200 | Priority unspecified.<br>If this option is used, [LocationRequestPriority](#locationrequestpriority) is invalid.| | UNSET | 0x200 | Priority unspecified.<br>If this option is used, [LocationRequestPriority](#locationrequestpriority) is invalid.|
| ACCURACY | 0x201 | Location accuracy preferred.<br>This policy mainly uses the GNSS positioning technology. In an open area, the technology can achieve the meter-level location accuracy, depending on the hardware performance of the device. However, in a shielded environment, the location accuracy may significantly decrease.| | ACCURACY | 0x201 | Location accuracy.<br>This policy mainly uses the GNSS positioning technology. In an open area, the technology can achieve the meter-level location accuracy, depending on the hardware performance of the device. However, in a shielded environment, the location accuracy may significantly decrease.|
| LOW_POWER | 0x202 | Power efficiency preferred.<br>This policy mainly uses the base station positioning, WLAN positioning, and Bluetooth positioning technologies to obtain device location in both indoor and outdoor scenarios. The location accuracy depends on the distribution of surrounding base stations, visible WLANs, and Bluetooth devices and therefore may fluctuate greatly. This policy is recommended and can reduce power consumption when your application does not require high location accuracy or when base stations, visible WLANs, and Bluetooth devices are densely distributed.| | LOW_POWER | 0x202 | Power efficiency.<br>This policy mainly uses the base station positioning, WLAN positioning, and Bluetooth positioning technologies to obtain device location in both indoor and outdoor scenarios. The location accuracy depends on the distribution of surrounding base stations, visible WLANs, and Bluetooth devices and therefore may fluctuate greatly. This policy is recommended and can reduce power consumption when your application does not require high location accuracy or when base stations, visible WLANs, and Bluetooth devices are densely distributed.|
| FIRST_FIX | 0x203 | Fast location preferred. Use this option if you want to obtain a location as fast as possible.<br>This policy uses the GNSS positioning, base station positioning, WLAN positioning, and Bluetooth positioning technologies simultaneously to obtain the device location in both the indoor and outdoor scenarios. When all positioning technologies provide a location result, the system provides the most accurate location result for your application. It can lead to significant hardware resource consumption and power consumption.| | FIRST_FIX | 0x203 | Fast location preferred. Use this option if you want to obtain a location as fast as possible.<br>This policy uses the GNSS positioning, base station positioning, WLAN positioning, and Bluetooth positioning technologies simultaneously to obtain the device location in both the indoor and outdoor scenarios. When all positioning technologies provide a location result, the system provides the most accurate location result for your application. It can lead to significant hardware resource consumption and power consumption.|
## LocationRequestScenario ## LocationRequestScenario
Sets the scenario of the location request. Sets the scenario of the location request.
**System capability**: SystemCapability.Location.Location.Core **System capability**: SystemCapability.Location.Location.Core
| Name| Value| Description| | Name| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| UNSET | 0x300 | Scenario unspecified.<br>If this option is used, [LocationRequestScenario](#locationrequestscenario) is invalid.| | UNSET | 0x300 | Scenario unspecified.<br>If this option is used, [LocationRequestScenario](#locationrequestscenario) is invalid.|
| NAVIGATION | 0x301 | Navigation scenario.<br>This option is applicable when your application needs to obtain the real-time location of a mobile device outdoors, such as navigation for driving or walking.<br>In this scenario, GNSS positioning is used to provide location services to ensure the optimal location accuracy of the system.<br>The location result is reported at a minimum interval of 1 second by default.| | NAVIGATION | 0x301 | Navigation.<br>This option is applicable when your application needs to obtain the real-time location of a mobile device outdoors, such as navigation for driving or walking.<br>In this scenario, GNSS positioning is used to provide location services to ensure the optimal location accuracy of the system.<br>The location result is reported at a minimum interval of 1 second by default.|
| TRAJECTORY_TRACKING | 0x302 | Trajectory tracking scenario.<br>This option is applicable when your application needs to record user trajectories, for example, the track recording function of sports applications. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy.<br>The location result is reported at a minimum interval of 1 second by default.| | TRAJECTORY_TRACKING | 0x302 | Trajectory tracking.<br>This option is applicable when your application needs to record user trajectories, for example, the track recording function of sports applications. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy.<br>The location result is reported at a minimum interval of 1 second by default.|
| CAR_HAILING | 0x303 | Ride hailing scenario.<br>This option is applicable when your application needs to obtain the current location of a user who is hailing a taxi.<br>The location result is reported at a minimum interval of 1 second by default.| | CAR_HAILING | 0x303 | Ride hailing.<br>This option is applicable when your application needs to obtain the current location of a user who is hailing a taxi.<br>The location result is reported at a minimum interval of 1 second by default.|
| DAILY_LIFE_SERVICE | 0x304 | Daily life service scenario.<br>This option is applicable when your application only needs the approximate user location for recommendations and push notifications in scenarios such as when the user is browsing news, shopping online, and ordering food.<br>The location result is reported at a minimum interval of 1 second by default.| | DAILY_LIFE_SERVICE | 0x304 | Daily life services.<br>This option is applicable when your application only needs the approximate user location for recommendations and push notifications in scenarios such as when the user is browsing news, shopping online, and ordering food.<br>The location result is reported at a minimum interval of 1 second by default.|
| NO_POWER | 0x305 | Power efficiency scenario.<br>This option is applicable when your application does not proactively start the location service. When responding to another application requesting the same location service, the system marks a copy of the location result to your application. In this way, your application will not consume extra power for obtaining the user location.| | NO_POWER | 0x305 | Power efficiency. Your application does not proactively start the location service. When responding to another application requesting the same location service, the system marks a copy of the location result to your application. In this way, your application will not consume extra power for obtaining the user location.|
## LocationPrivacyType ## LocationPrivacyType
...@@ -299,7 +299,7 @@ Defines the privacy statement type. ...@@ -299,7 +299,7 @@ Defines the privacy statement type.
| Name| Value| Description| | Name| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| OTHERS | 0 | Other scenarios. Reserved field.| | OTHERS | 0 | Other scenarios. Reserved field.|
| STARTUP | 1 | Privacy statement displayed in the startup wizard. | | STARTUP | 1 | Privacy statement displayed in the startup wizard. The user needs to choose whether to agree with the statement.|
| CORE_LOCATION | 2 | Privacy statement displayed when enabling the location service.| | CORE_LOCATION | 2 | Privacy statement displayed when enabling the location service.|
...@@ -323,7 +323,7 @@ on(type: 'locationChange', request: LocationRequest, callback: Callback&lt;Locat ...@@ -323,7 +323,7 @@ on(type: 'locationChange', request: LocationRequest, callback: Callback&lt;Locat
Registers a listener for location changes with a location request initiated. Registers a listener for location changes with a location request initiated.
**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION **Permission required**: ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Core **System capability**: SystemCapability.Location.Location.Core
...@@ -368,7 +368,7 @@ off(type: 'locationChange', callback?: Callback&lt;Location&gt;): void ...@@ -368,7 +368,7 @@ off(type: 'locationChange', callback?: Callback&lt;Location&gt;): void
Unregisters the listener for location changes with the corresponding location request deleted. Unregisters the listener for location changes with the corresponding location request deleted.
**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION **Permission required**: ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Core **System capability**: SystemCapability.Location.Location.Core
...@@ -489,7 +489,7 @@ on(type: 'cachedGnssLocationsChange', request: CachedGnssLocationsRequest, callb ...@@ -489,7 +489,7 @@ on(type: 'cachedGnssLocationsChange', request: CachedGnssLocationsRequest, callb
Registers a listener for cached GNSS location reports. Registers a listener for cached GNSS location reports.
**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION **Permission required**: ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Gnss **System capability**: SystemCapability.Location.Location.Gnss
...@@ -533,7 +533,7 @@ off(type: 'cachedGnssLocationsChange', callback?: Callback&lt;Array&lt;Location& ...@@ -533,7 +533,7 @@ off(type: 'cachedGnssLocationsChange', callback?: Callback&lt;Array&lt;Location&
Unregisters the listener for cached GNSS location reports. Unregisters the listener for cached GNSS location reports.
**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION **Permission required**: ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Gnss **System capability**: SystemCapability.Location.Location.Gnss
...@@ -577,7 +577,7 @@ on(type: 'satelliteStatusChange', callback: Callback&lt;SatelliteStatusInfo&gt;) ...@@ -577,7 +577,7 @@ on(type: 'satelliteStatusChange', callback: Callback&lt;SatelliteStatusInfo&gt;)
Registers a listener for GNSS satellite status change events. Registers a listener for GNSS satellite status change events.
**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION **Permission required**: ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Gnss **System capability**: SystemCapability.Location.Location.Gnss
...@@ -619,7 +619,7 @@ off(type: 'satelliteStatusChange', callback?: Callback&lt;SatelliteStatusInfo&gt ...@@ -619,7 +619,7 @@ off(type: 'satelliteStatusChange', callback?: Callback&lt;SatelliteStatusInfo&gt
Unregisters the listener for GNSS satellite status change events. Unregisters the listener for GNSS satellite status change events.
**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION **Permission required**: ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Gnss **System capability**: SystemCapability.Location.Location.Gnss
...@@ -662,7 +662,7 @@ on(type: 'nmeaMessage', callback: Callback&lt;string&gt;): void; ...@@ -662,7 +662,7 @@ on(type: 'nmeaMessage', callback: Callback&lt;string&gt;): void;
Registers a listener for GNSS NMEA message change events. Registers a listener for GNSS NMEA message change events.
**Permission required**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION **Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Gnss **System capability**: SystemCapability.Location.Location.Gnss
...@@ -705,7 +705,7 @@ off(type: 'nmeaMessage', callback?: Callback&lt;string&gt;): void; ...@@ -705,7 +705,7 @@ off(type: 'nmeaMessage', callback?: Callback&lt;string&gt;): void;
Unregisters the listener for GNSS NMEA message change events. Unregisters the listener for GNSS NMEA message change events.
**Permission required**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION **Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Gnss **System capability**: SystemCapability.Location.Location.Gnss
...@@ -749,7 +749,7 @@ on(type: 'gnssFenceStatusChange', request: GeofenceRequest, want: WantAgent): vo ...@@ -749,7 +749,7 @@ on(type: 'gnssFenceStatusChange', request: GeofenceRequest, want: WantAgent): vo
Registers a listener for status change events of the specified geofence. Registers a listener for status change events of the specified geofence.
**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION **Permission required**: ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Geofence **System capability**: SystemCapability.Location.Location.Geofence
...@@ -807,7 +807,7 @@ off(type: 'gnssFenceStatusChange', request: GeofenceRequest, want: WantAgent): v ...@@ -807,7 +807,7 @@ off(type: 'gnssFenceStatusChange', request: GeofenceRequest, want: WantAgent): v
Unregisters the listener for status change events of the specified geofence. Unregisters the listener for status change events of the specified geofence.
**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION **Permission required**: ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Geofence **System capability**: SystemCapability.Location.Location.Geofence
...@@ -840,7 +840,7 @@ For details about the following error codes, see [Location Error Codes](../error ...@@ -840,7 +840,7 @@ For details about the following error codes, see [Location Error Codes](../error
{ {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
action: "action1" action: "action1",
} }
], ],
operationType: wantAgent.OperationType.START_ABILITY, operationType: wantAgent.OperationType.START_ABILITY,
...@@ -882,7 +882,6 @@ For details about the following error codes, see [Location Error Codes](../error ...@@ -882,7 +882,6 @@ For details about the following error codes, see [Location Error Codes](../error
| ID| Error Message| | ID| Error Message|
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
|3301000 | Location service is unavailable. | |3301000 | Location service is unavailable. |
|3301100 | The location switch is off. |
|3301500 | Failed to query the area information. | |3301500 | Failed to query the area information. |
...@@ -924,7 +923,6 @@ For details about the following error codes, see [Location Error Codes](../error ...@@ -924,7 +923,6 @@ For details about the following error codes, see [Location Error Codes](../error
| ID| Error Message| | ID| Error Message|
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
|3301000 | Location service is unavailable. | |3301000 | Location service is unavailable. |
|3301100 | The location switch is off. |
|3301500 | Failed to query the area information. | |3301500 | Failed to query the area information. |
**Example** **Example**
...@@ -951,7 +949,7 @@ getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback&lt;L ...@@ -951,7 +949,7 @@ getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback&lt;L
Obtains the current location. This API uses an asynchronous callback to return the result. Obtains the current location. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION **Permission required**: ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Core **System capability**: SystemCapability.Location.Location.Core
...@@ -999,7 +997,7 @@ getCurrentLocation(callback: AsyncCallback&lt;Location&gt;): void; ...@@ -999,7 +997,7 @@ getCurrentLocation(callback: AsyncCallback&lt;Location&gt;): void;
Obtains the current location. This API uses an asynchronous callback to return the result. Obtains the current location. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION **Permission required**: ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Core **System capability**: SystemCapability.Location.Location.Core
...@@ -1045,7 +1043,7 @@ getCurrentLocation(request?: CurrentLocationRequest): Promise&lt;Location&gt; ...@@ -1045,7 +1043,7 @@ getCurrentLocation(request?: CurrentLocationRequest): Promise&lt;Location&gt;
Obtains the current location. This API uses a promise to return the result. Obtains the current location. This API uses a promise to return the result.
**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION **Permission required**: ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Core **System capability**: SystemCapability.Location.Location.Core
...@@ -1095,7 +1093,7 @@ getLastLocation(): Location ...@@ -1095,7 +1093,7 @@ getLastLocation(): Location
Obtains the last location. Obtains the last location.
**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION **Permission required**: ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Core **System capability**: SystemCapability.Location.Location.Core
...@@ -1282,7 +1280,7 @@ For details about the following error codes, see [Location Error Codes](../error ...@@ -1282,7 +1280,7 @@ For details about the following error codes, see [Location Error Codes](../error
getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback&lt;Array&lt;GeoAddress&gt;&gt;): void getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback&lt;Array&lt;GeoAddress&gt;&gt;): void
Converts coordinates into geographic descriptions through reverse geocoding. This API uses an asynchronous callback to return the result. Converts coordinates into geographic description through reverse geocoding. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Location.Location.Geocoder **System capability**: SystemCapability.Location.Location.Geocoder
...@@ -1326,7 +1324,7 @@ For details about the following error codes, see [Location Error Codes](../error ...@@ -1326,7 +1324,7 @@ For details about the following error codes, see [Location Error Codes](../error
getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise&lt;Array&lt;GeoAddress&gt;&gt;; getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise&lt;Array&lt;GeoAddress&gt;&gt;;
Converts coordinates into geographic descriptions through reverse geocoding. This API uses a promise to return the result. Converts coordinates into geographic description through reverse geocoding. This API uses a promise to return the result.
**System capability**: SystemCapability.Location.Location.Geocoder **System capability**: SystemCapability.Location.Location.Geocoder
...@@ -1373,7 +1371,7 @@ For details about the following error codes, see [Location Error Codes](../error ...@@ -1373,7 +1371,7 @@ For details about the following error codes, see [Location Error Codes](../error
getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback&lt;Array&lt;GeoAddress&gt;&gt;): void getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback&lt;Array&lt;GeoAddress&gt;&gt;): void
Converts geographic descriptions into coordinates through geocoding. This API uses an asynchronous callback to return the result. Converts geographic description into coordinates through geocoding. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Location.Location.Geocoder **System capability**: SystemCapability.Location.Location.Geocoder
...@@ -1417,7 +1415,7 @@ For details about the following error codes, see [Location Error Codes](../error ...@@ -1417,7 +1415,7 @@ For details about the following error codes, see [Location Error Codes](../error
getAddressesFromLocationName(request: GeoCodeRequest): Promise&lt;Array&lt;GeoAddress&gt;&gt; getAddressesFromLocationName(request: GeoCodeRequest): Promise&lt;Array&lt;GeoAddress&gt;&gt;
Converts geographic descriptions into coordinates through geocoding. This API uses a promise to return the result. Converts geographic description into coordinates through geocoding. This API uses a promise to return the result.
**System capability**: SystemCapability.Location.Location.Geocoder **System capability**: SystemCapability.Location.Location.Geocoder
...@@ -1499,7 +1497,7 @@ getCachedGnssLocationsSize(callback: AsyncCallback&lt;number&gt;): void; ...@@ -1499,7 +1497,7 @@ getCachedGnssLocationsSize(callback: AsyncCallback&lt;number&gt;): void;
Obtains the number of cached GNSS locations. Obtains the number of cached GNSS locations.
**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION **Permission required**: ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Gnss **System capability**: SystemCapability.Location.Location.Gnss
...@@ -1543,7 +1541,7 @@ getCachedGnssLocationsSize(): Promise&lt;number&gt;; ...@@ -1543,7 +1541,7 @@ getCachedGnssLocationsSize(): Promise&lt;number&gt;;
Obtains the number of cached GNSS locations. Obtains the number of cached GNSS locations.
**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION **Permission required**: ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Gnss **System capability**: SystemCapability.Location.Location.Gnss
...@@ -1585,7 +1583,7 @@ flushCachedGnssLocations(callback: AsyncCallback&lt;void&gt;): void; ...@@ -1585,7 +1583,7 @@ flushCachedGnssLocations(callback: AsyncCallback&lt;void&gt;): void;
Obtains all cached GNSS locations and clears the GNSS cache queue. Obtains all cached GNSS locations and clears the GNSS cache queue.
**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION **Permission required**: ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Gnss **System capability**: SystemCapability.Location.Location.Gnss
...@@ -1627,7 +1625,7 @@ flushCachedGnssLocations(): Promise&lt;void&gt;; ...@@ -1627,7 +1625,7 @@ flushCachedGnssLocations(): Promise&lt;void&gt;;
Obtains all cached GNSS locations and clears the GNSS cache queue. Obtains all cached GNSS locations and clears the GNSS cache queue.
**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION **Permission required**: ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Location.Location.Gnss **System capability**: SystemCapability.Location.Location.Gnss
...@@ -2007,7 +2005,7 @@ For details about the following error codes, see [Location Error Codes](../error ...@@ -2007,7 +2005,7 @@ For details about the following error codes, see [Location Error Codes](../error
setReverseGeocodingMockInfo(mockInfos: Array&lt;ReverseGeocodingMockInfo&gt;): void; setReverseGeocodingMockInfo(mockInfos: Array&lt;ReverseGeocodingMockInfo&gt;): void;
Sets information of the mock reverse geocoding function, including the mapping between a location and geographic name. If the location is contained in the configurations during reverse geocoding query, the corresponding geographic name will be returned. Sets information of the mock reverse geocoding function, including the mapping between a location and geographical name. If the location is contained in the configurations during reverse geocoding query, the corresponding geographical name will be returned.
This API can be invoked only after [geoLocationManager.enableReverseGeocodingMock](#geolocationmanagerenablereversegeocodingmock) is called. This API can be invoked only after [geoLocationManager.enableReverseGeocodingMock](#geolocationmanagerenablereversegeocodingmock) is called.
...@@ -2019,7 +2017,7 @@ This API can be invoked only after [geoLocationManager.enableReverseGeocodingMoc ...@@ -2019,7 +2017,7 @@ This API can be invoked only after [geoLocationManager.enableReverseGeocodingMoc
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| mockInfos | Array&lt;[ReverseGeocodingMockInfo](#reversegeocodingmockinfo)&gt; | Yes| Array of information of the mock reverse geocoding function, including a location and a geographic address.| | mockInfos | Array&lt;[ReverseGeocodingMockInfo](#reversegeocodingmockinfo)&gt; | Yes| Array of information of the mock reverse geocoding function, including a location and a geographical name.|
**Error codes** **Error codes**
...@@ -2069,7 +2067,7 @@ Checks whether a user agrees with the privacy statement of the location service. ...@@ -2069,7 +2067,7 @@ Checks whether a user agrees with the privacy statement of the location service.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| boolean | boolean | NA | Whether the user agrees with the privacy statement.| | boolean | boolean | NA | Callback used to return the result, which indicates whether the user agrees with the privacy statement.|
**Error codes** **Error codes**
...@@ -2108,7 +2106,7 @@ Sets the user confirmation status for the privacy statement of the location serv ...@@ -2108,7 +2106,7 @@ Sets the user confirmation status for the privacy statement of the location serv
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | [LocationPrivacyType](#locationprivacytype) | Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when the location service is enabled.| | type | [LocationPrivacyType](#locationprivacytype) | Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when the location service is enabled.|
| isConfirmed | boolean | Yes| Whether the user agrees with the privacy statement.| | isConfirmed | boolean | Yes| Callback used to return the result, which indicates whether the user agrees with the privacy statement.|
**Error codes** **Error codes**
......
# @ohos.hiAppEvent (Application Event Logging) # @ohos.hiAppEvent (Application Event Logging)
The HiAppEvent module provides the application event logging functions, such as writing application events to the event file and managing the event logging configuration. The **hiAppEvent** module provides the application event logging functions, such as writing application events to the event file and managing the event logging configuration.
> **NOTE** > **NOTE**
>
> - The APIs provided by this module are deprecated since API version 9. You are advised to use [`@ohos.hiviewdfx.hiAppEvent`](js-apis-hiviewdfx-hiappevent.md) instead. > - The APIs provided by this module are deprecated since API version 9. You are advised to use [`@ohos.hiviewdfx.hiAppEvent`](js-apis-hiviewdfx-hiappevent.md) instead.
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -19,7 +20,7 @@ Before using application event logging, you need to understand the requirements ...@@ -19,7 +20,7 @@ Before using application event logging, you need to understand the requirements
**Event Name** **Event Name**
An event name is a string that contains a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_). An event name is a string that contains a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (\_).
**Event Type** **Event Type**
...@@ -30,9 +31,10 @@ An event type is an enumerated value of [EventType](#eventtype). ...@@ -30,9 +31,10 @@ An event type is an enumerated value of [EventType](#eventtype).
An event parameter is an object in key-value pair format, where the key is the parameter name and the value is the parameter value. The requirements are as follows: An event parameter is an object in key-value pair format, where the key is the parameter name and the value is the parameter value. The requirements are as follows:
- A parameter name is a string that contains a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (\_). - A parameter name is a string that contains a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (\_).
- The parameter value is a string, number, boolean, or array. - The parameter value can be of the string, number, boolean, or array type.
- When the parameter value is a string, its maximum length is 8*1024 characters. If this limit is exceeded, excess characters will be truncated. - If the parameter value is a string, its maximum length is 8*1024 characters. If this limit is exceeded, excess characters will be discarded.
- When the parameter value is an array, the elements in the array must be of the same type, which can only be string, number, or boolean. In addition, the number of elements must be less than 100. If this limit is exceeded, excess elements will be discarded. - If the parameter value is a number, the value must be within the range of **Number.MIN_SAFE_INTEGER** to **Number.MAX_SAFE_INTEGER**. Otherwise, uncertain values may be generated.
- If the parameter value is an array, the elements in the array must be of the same type, which can only be string, number, or boolean. In addition, the number of elements must be less than 100. If this limit is exceeded, excess elements will be discarded.
- The maximum number of parameters is 32. If this limit is exceeded, excess parameters will be discarded. - The maximum number of parameters is 32. If this limit is exceeded, excess parameters will be discarded.
**Event Callback** **Event Callback**
......
# @ohos.hiviewdfx.hiAppEvent (Application Event Logging) # @ohos.hiviewdfx.hiAppEvent (Application Event Logging)
This module provides application event-related functions, including flushing application events to a disk, querying and clearing application events, and customizing application event logging configuration. The **hiAppEvent** module provides application event-related functions, including flushing application events to a disk, querying and clearing application events, and customizing application event logging configuration.
> **NOTE** > **NOTE**
> >
...@@ -120,12 +120,12 @@ Defines parameters for an **AppEventInfo** object. ...@@ -120,12 +120,12 @@ Defines parameters for an **AppEventInfo** object.
**System capability**: SystemCapability.HiviewDFX.HiAppEvent **System capability**: SystemCapability.HiviewDFX.HiAppEvent
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ----------------------- | ---- | ---------- | | --------- | ----------------------- | ---- | ------------------------------------------------------------ |
| domain | string | Yes | Event domain.| | domain | string | Yes | Event domain. Event domain name, which is a string of up to 32 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_).|
| name | string | Yes | Event name.| | name | string | Yes | Event name. Event name, which is a string of up to 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_).|
| eventType | [EventType](#eventtype) | Yes | Event type.| | eventType | [EventType](#eventtype) | Yes | Event type. |
| params | object | Yes | Event parameters.| | params | object | Yes | Event parameter object, which consists of a parameter name and a parameter value. The specifications are as follows:<br>- The parameter name is a string of up to 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_).<br>- The parameter value can be a string, number, boolean, or array. If the parameter value is a string, its maximum length is 8*1024 characters. If this limit is exceeded, excess characters will be discarded. If the parameter value is a number, the value must be within the range of **Number.MIN_SAFE_INTEGER** to **Number.MAX_SAFE_INTEGER**. Otherwise, uncertain values may be generated. If the parameter value is an array, the elements in the array must be of the same type, which can only be string, number, or boolean. In addition, the number of elements must be less than 100. If this limit is exceeded, excess elements will be discarded.<br>- The maximum number of parameters is 32. If this limit is exceeded, excess parameters will be discarded.|
## hiAppEvent.configure ## hiAppEvent.configure
......
# @ohos.net.http (Data Request) # @ohos.net.http (Data Request)
The **http** module provides the HTTP data request capability. An application can initiate a data request over HTTP. Common HTTP methods include **GET**, **POST**, **OPTIONS**, **HEAD**, **PUT**, **DELETE**, **TRACE**, and **CONNECT**. This module provides the HTTP data request capability. An application can initiate a data request over HTTP. Common HTTP methods include **GET**, **POST**, **OPTIONS**, **HEAD**, **PUT**, **DELETE**, **TRACE**, and **CONNECT**.
>**NOTE** >**NOTE**
> >
...@@ -13,10 +13,10 @@ The **http** module provides the HTTP data request capability. An application ca ...@@ -13,10 +13,10 @@ The **http** module provides the HTTP data request capability. An application ca
import http from '@ohos.net.http'; import http from '@ohos.net.http';
``` ```
## Examples ## Example
```js ```js
// Import the HTTP namespace. // Import the http namespace.
import http from '@ohos.net.http'; import http from '@ohos.net.http';
// Each httpRequest corresponds to an HTTP request task and cannot be reused. // Each httpRequest corresponds to an HTTP request task and cannot be reused.
...@@ -27,7 +27,7 @@ httpRequest.on('headersReceive', (header) => { ...@@ -27,7 +27,7 @@ httpRequest.on('headersReceive', (header) => {
console.info('header: ' + JSON.stringify(header)); console.info('header: ' + JSON.stringify(header));
}); });
httpRequest.request( httpRequest.request(
// Customize EXAMPLE_URL in extraData on your own. It is up to you whether to add parameters to the URL. // Customize EXAMPLE_URL on your own. It is up to you whether to add parameters to the URL.
"EXAMPLE_URL", "EXAMPLE_URL",
{ {
method: http.RequestMethod.POST, // Optional. The default value is http.RequestMethod.GET. method: http.RequestMethod.POST, // Optional. The default value is http.RequestMethod.GET.
...@@ -112,7 +112,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback ...@@ -112,7 +112,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback
**Error codes** **Error codes**
| ID | Error Message | | Code | Error Message |
|---------|-------------------------------------------------------| |---------|-------------------------------------------------------|
| 401 | Parameter error. | | 401 | Parameter error. |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -164,7 +164,7 @@ Initiates an HTTP request containing specified options to a given URL. This API ...@@ -164,7 +164,7 @@ Initiates an HTTP request containing specified options to a given URL. This API
**Error codes** **Error codes**
| ID | Error Message | | Code | Error Message |
|---------|-------------------------------------------------------| |---------|-------------------------------------------------------|
| 401 | Parameter error. | | 401 | Parameter error. |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -231,7 +231,7 @@ httpRequest.request("EXAMPLE_URL", ...@@ -231,7 +231,7 @@ httpRequest.request("EXAMPLE_URL",
request(url: string, options? : HttpRequestOptions): Promise\<HttpResponse\> request(url: string, options? : HttpRequestOptions): Promise\<HttpResponse\>
Initiates an HTTP request containing specified options to a given URL. This API uses a promise to return the result. Initiates an HTTP request to a given URL. This API uses a promise to return the result.
>**NOTE** >**NOTE**
>This API supports only transfer of data not greater than 5 MB. >This API supports only transfer of data not greater than 5 MB.
...@@ -255,7 +255,7 @@ Initiates an HTTP request containing specified options to a given URL. This API ...@@ -255,7 +255,7 @@ Initiates an HTTP request containing specified options to a given URL. This API
**Error codes** **Error codes**
| ID | Error Message | | Code | Error Message |
|---------|-------------------------------------------------------| |---------|-------------------------------------------------------|
| 401 | Parameter error. | | 401 | Parameter error. |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -349,7 +349,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback ...@@ -349,7 +349,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback
**Error codes** **Error codes**
| ID | Error Message | | Code | Error Message |
|---------|-------------------------------------------------------| |---------|-------------------------------------------------------|
| 401 | Parameter error. | | 401 | Parameter error. |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -395,7 +395,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback ...@@ -395,7 +395,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback
**Error codes** **Error codes**
| ID | Error Message | | Code | Error Message |
|---------|-------------------------------------------------------| |---------|-------------------------------------------------------|
| 401 | Parameter error. | | 401 | Parameter error. |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -477,7 +477,7 @@ Initiates an HTTP request containing specified options to a given URL. This API ...@@ -477,7 +477,7 @@ Initiates an HTTP request containing specified options to a given URL. This API
**Error codes** **Error codes**
| ID | Error Message | | Code | Error Message |
|---------|-------------------------------------------------------| |---------|-------------------------------------------------------|
| 401 | Parameter error. | | 401 | Parameter error. |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -513,7 +513,7 @@ Initiates an HTTP request containing specified options to a given URL. This API ...@@ -513,7 +513,7 @@ Initiates an HTTP request containing specified options to a given URL. This API
>**NOTE** >**NOTE**
> For details about the error codes, see [HTTP Error Codes](../errorcodes/errorcode-net-http.md). > For details about the error codes, see [HTTP Error Codes](../errorcodes/errorcode-net-http.md).
> The HTTP error code mapping is in the format of 2300000 + Curl error code. For more common error codes, see: > The HTTP error code mapping is in the format of 2300000 + Curl error code. For more common error codes, see [Curl Error Codes](https://curl.se/libcurl/c/libcurl-errors.html).
**Example** **Example**
...@@ -839,7 +839,7 @@ Enumerates the response codes for an HTTP request. ...@@ -839,7 +839,7 @@ Enumerates the response codes for an HTTP request.
| Name | Value | Description | | Name | Value | Description |
| ----------------- | ---- | ------------------------------------------------------------ | | ----------------- | ---- | ------------------------------------------------------------ |
| OK | 200 | "OK." The request has been processed successfully. This return code is generally used for GET and POST requests. | | OK | 200 | The request is successful. The request has been processed successfully. This return code is generally used for GET and POST requests. |
| CREATED | 201 | "Created." The request has been successfully sent and a new resource is created. | | CREATED | 201 | "Created." The request has been successfully sent and a new resource is created. |
| ACCEPTED | 202 | "Accepted." The request has been accepted, but the processing has not been completed. | | ACCEPTED | 202 | "Accepted." The request has been accepted, but the processing has not been completed. |
| NOT_AUTHORITATIVE | 203 | "Non-Authoritative Information." The request is successful. | | NOT_AUTHORITATIVE | 203 | "Non-Authoritative Information." The request is successful. |
...@@ -1007,7 +1007,7 @@ Disables the cache and deletes the data in it. This API uses a promise to return ...@@ -1007,7 +1007,7 @@ Disables the cache and deletes the data in it. This API uses a promise to return
| Type | Description | | Type | Description |
| --------------------------------- | ------------------------------------- | | --------------------------------- | ------------------------------------- |
| Promise\<void\> | Promise used to return the result.| | Promise\<void\> | Promise used to return the result.|
**Example** **Example**
......
# # @ohos.net.socket (Socket Connection) # Socket Connection
The **socket** module implements data transfer over TCPSocket, UDPSocket, WebSocket, and TLSSocket connections. The **socket** module implements data transfer over TCPSocket, UDPSocket, WebSocket, and TLSSocket connections.
...@@ -364,7 +364,7 @@ udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { ...@@ -364,7 +364,7 @@ udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
setExtraOptions(options: UDPExtraOptions, callback: AsyncCallback\<void\>): void setExtraOptions(options: UDPExtraOptions, callback: AsyncCallback\<void\>): void
Sets other attributes of the UDPSocket connection. This API uses an asynchronous callback to return the result. Sets other properties of the UDPSocket connection. This API uses an asynchronous callback to return the result.
>**NOTE** >**NOTE**
>This API can be called only after **bind** is successfully called. >This API can be called only after **bind** is successfully called.
...@@ -418,7 +418,7 @@ udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1}, err=> { ...@@ -418,7 +418,7 @@ udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1}, err=> {
setExtraOptions(options: UDPExtraOptions): Promise\<void\> setExtraOptions(options: UDPExtraOptions): Promise\<void\>
Sets other attributes of the UDPSocket connection. This API uses a promise to return the result. Sets other properties of the UDPSocket connection. This API uses a promise to return the result.
>**NOTE** >**NOTE**
>This API can be called only after **bind** is successfully called. >This API can be called only after **bind** is successfully called.
...@@ -522,7 +522,7 @@ let callback = value =>{ ...@@ -522,7 +522,7 @@ let callback = value =>{
console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo);
} }
udp.on('message', callback); udp.on('message', callback);
// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. // You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks.
udp.off('message', callback); udp.off('message', callback);
udp.off('message'); udp.off('message');
``` ```
...@@ -582,14 +582,14 @@ let callback1 = () =>{ ...@@ -582,14 +582,14 @@ let callback1 = () =>{
console.log("on listening, success"); console.log("on listening, success");
} }
udp.on('listening', callback1); udp.on('listening', callback1);
// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. // You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks.
udp.off('listening', callback1); udp.off('listening', callback1);
udp.off('listening'); udp.off('listening');
let callback2 = () =>{ let callback2 = () =>{
console.log("on close, success"); console.log("on close, success");
} }
udp.on('close', callback2); udp.on('close', callback2);
// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. // You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks.
udp.off('close', callback2); udp.off('close', callback2);
udp.off('close'); udp.off('close');
``` ```
...@@ -646,7 +646,7 @@ let callback = err =>{ ...@@ -646,7 +646,7 @@ let callback = err =>{
console.log("on error, err:" + JSON.stringify(err)); console.log("on error, err:" + JSON.stringify(err));
} }
udp.on('error', callback); udp.on('error', callback);
// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. // You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks.
udp.off('error', callback); udp.off('error', callback);
udp.off('error'); udp.off('error');
``` ```
...@@ -1426,7 +1426,7 @@ let callback = value =>{ ...@@ -1426,7 +1426,7 @@ let callback = value =>{
console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo);
} }
tcp.on('message', callback); tcp.on('message', callback);
// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. // You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks.
tcp.off('message', callback); tcp.off('message', callback);
tcp.off('message'); tcp.off('message');
``` ```
...@@ -1486,14 +1486,14 @@ let callback1 = () =>{ ...@@ -1486,14 +1486,14 @@ let callback1 = () =>{
console.log("on connect success"); console.log("on connect success");
} }
tcp.on('connect', callback1); tcp.on('connect', callback1);
// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. // You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks.
tcp.off('connect', callback1); tcp.off('connect', callback1);
tcp.off('connect'); tcp.off('connect');
let callback2 = () =>{ let callback2 = () =>{
console.log("on close success"); console.log("on close success");
} }
tcp.on('close', callback2); tcp.on('close', callback2);
// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. // You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks.
tcp.off('close', callback2); tcp.off('close', callback2);
tcp.off('close'); tcp.off('close');
``` ```
...@@ -1550,7 +1550,7 @@ let callback = err =>{ ...@@ -1550,7 +1550,7 @@ let callback = err =>{
console.log("on error, err:" + JSON.stringify(err)); console.log("on error, err:" + JSON.stringify(err));
} }
tcp.on('error', callback); tcp.on('error', callback);
// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. // You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks.
tcp.off('error', callback); tcp.off('error', callback);
tcp.off('error'); tcp.off('error');
``` ```
......
# @system.fetch (Data Request) # @system.fetch (Data Request)
> **NOTE** > **NOTE**
>
> - The APIs of this module are no longer maintained since API version 6. You are advised to use [`@ohos.net.http`](js-apis-http.md) instead. > - The APIs of this module are no longer maintained since API version 6. You are advised to use [`@ohos.net.http`](js-apis-http.md) instead.
> >
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -15,7 +14,7 @@ import fetch from '@system.fetch'; ...@@ -15,7 +14,7 @@ import fetch from '@system.fetch';
``` ```
## fetch.fetch ## fetch.fetch<sup>3+</sup>
fetch(Object): void fetch(Object): void
...@@ -31,9 +30,9 @@ Obtains data through a network. ...@@ -31,9 +30,9 @@ Obtains data through a network.
| header | Object | No| Request header.| | header | Object | No| Request header.|
| method | string | No| Request method. The default value is **GET**. The value can be **OPTIONS**, **GET**, **HEAD**, **POST**, **PUT**, **DELETE **or **TRACE**.| | method | string | No| Request method. The default value is **GET**. The value can be **OPTIONS**, **GET**, **HEAD**, **POST**, **PUT**, **DELETE **or **TRACE**.|
| responseType | string | No| Response type. The return type can be text or JSON. By default, the return type is determined based on **Content-Type** in the header returned by the server. For details, see return values in the **success** callback.| | responseType | string | No| Response type. The return type can be text or JSON. By default, the return type is determined based on **Content-Type** in the header returned by the server. For details, see return values in the **success** callback.|
| success | Function | No| Called when data is obtained successfully. The return value is [FetchResponse](#fetchresponse). | | success | Function | No| Called when the API call is successful. The return value is defined by [FetchResponse](#fetchresponse).|
| fail | Function | No| Called when data failed to be obtained.| | fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when the execution is complete.| | complete | Function | No| Called when the API call is complete.|
**Table 1** Mapping between data and Content-Type **Table 1** Mapping between data and Content-Type
...@@ -46,11 +45,11 @@ Obtains data through a network. ...@@ -46,11 +45,11 @@ Obtains data through a network.
## FetchResponse ## FetchResponse
| Name| Type| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| code | number | Server status code.| | code | number | Yes| No| Server status code.|
| data | string \| Object | The type of the returned data is determined by **responseType**. For details, see the mapping between **responseType** and **data** in **success** callback.| | data | string \| Object | Yes| No| The type of the returned data is determined by **responseType**. For details, see the mapping between **responseType** and **data** in **success** callback.|
| headers | Object | All headers in the response from the server.| | headers | Object | Yes| No| All headers in the response from the server.|
**Table 2** Mapping between responseType and data in success callback **Table 2** Mapping between responseType and data in success callback
...@@ -85,7 +84,7 @@ export default { ...@@ -85,7 +84,7 @@ export default {
``` ```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**
> HTTPS is supported by default. To support HTTP, you need to add **"network"** to the **config.json** file, and set the attribute **"cleartextTraffic"** to **true**. That is: > HTTPS is supported by default. To support HTTP, you need to add **"network"** to the **config.json** file, and set the attribute **"cleartextTraffic"** to **true**. That is:
> >
> ``` > ```
......
...@@ -21,44 +21,22 @@ ohos.permission.LOCATION ...@@ -21,44 +21,22 @@ ohos.permission.LOCATION
## geolocation.getLocation<sup>(deprecated)</sup> ## geolocation.getLocation<sup>(deprecated)</sup>
getLocation(Object): void getLocation(options?: GetLocationOption): void
Obtains the geographic location. Obtains the geographic location.
> **NOTE** > **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation). > This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation).
**Required permissions**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Lite **System capability**: SystemCapability.Location.Location.Lite
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| timeout | number | No| Timeout duration, in ms. The default value is **30000**.<br>The timeout duration is necessary in case the request to obtain the geographic location is rejected for the lack of the required permission, weak positioning signal, or incorrect location settings. After the timeout duration expires, the fail function will be called.<br>The value is a 32-digit positive integer. If the specified value is less than or equal to **0**, the default value will be used.| | options | [GetLocationOption](#getlocationoptiondeprecated) | No| Options of a single location request.|
| coordType | string | No| Coordinate system type. Available types can be obtained by **getSupportedCoordTypes**. The default type is **wgs84**.|
| success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.|
**Return value of success()**
| Name| Type| Description|
| -------- | -------- | -------- |
| longitude | number | Longitude.|
| latitude | number | Latitude.|
| altitude | number | Altitude.|
| accuracy | number | Location accuracy.|
| time | number | Time when the location is obtained.|
**Return value of fail()**
| Error Code| Description|
| -------- | -------- |
| 601 | Failed to obtain the required permission because the user rejected the request.|
| 602 | Permission not declared.|
| 800 | Operation times out due to a poor network condition or GNSS unavailability.|
| 801 | System location disabled.|
| 802 | API called again while the previous execution result is not returned yet.|
**Example** **Example**
...@@ -70,7 +48,7 @@ export default { ...@@ -70,7 +48,7 @@ export default {
console.log('success get location data. latitude:' + data.latitude); console.log('success get location data. latitude:' + data.latitude);
}, },
fail: function(data, code) { fail: function(data, code) {
console.log('fail to get location. code:' + code + ', data:' + data); console.log('fail to get location. code:' + code + ', data:' + data);
} }
}); });
} }
...@@ -80,12 +58,12 @@ export default { ...@@ -80,12 +58,12 @@ export default {
## geolocation.getLocationType<sup>(deprecated)</sup> ## geolocation.getLocationType<sup>(deprecated)</sup>
getLocationType(Object): void getLocationType(options?: GetLocationTypeOption): void
Obtains the supported location types. Obtains the supported location types.
> **NOTE** > **NOTE**
> This API is deprecated since API version 9. The location subsystem supports only two location types: GPS positioning and network positioning. No APIs will be provided to query the supported location types. > This API is deprecated since API version 9. The location subsystem supports only two location types: GNSS positioning and network positioning. No APIs will be provided to query the supported location types.
**System capability**: SystemCapability.Location.Location.Lite **System capability**: SystemCapability.Location.Location.Lite
...@@ -93,15 +71,7 @@ Obtains the supported location types. ...@@ -93,15 +71,7 @@ Obtains the supported location types.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| success | Function | No| Called when API call is successful.| | options | [GetLocationTypeOption](#getlocationtypeoptiondeprecated) | No| Callback used to return the result.|
| fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.|
**Return value of success()**
| Name| Type| Description|
| -------- | -------- | -------- |
| types | Array&lt;string&gt; | Available location types, ['gps', 'network']|
**Example** **Example**
...@@ -123,40 +93,22 @@ export default { ...@@ -123,40 +93,22 @@ export default {
## geolocation.subscribe<sup>(deprecated)</sup> ## geolocation.subscribe<sup>(deprecated)</sup>
subscribe(Object): void subscribe(options: SubscribeLocationOption): void
Listens to the geographic location. If this method is called multiple times, the last call takes effect. Listens to the geographic location. If this method is called multiple times, the last call takes effect.
> **NOTE** > **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('locationChange')](js-apis-geoLocationManager.md#geolocationmanageronlocationchange). > This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('locationChange')](js-apis-geoLocationManager.md#geolocationmanageronlocationchange).
**Required permissions**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Lite **System capability**: SystemCapability.Location.Location.Lite
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| coordType | string | No| Coordinate system type. Available types can be obtained by **getSupportedCoordTypes**. The default type is **wgs84**.| | options | [SubscribeLocationOption](#subscribelocationoptiondeprecated) | Yes| Options for continuous location.|
| success | Function | Yes| Called when the geographic location changes.|
| fail | Function | No| Called when API call has failed.|
**Return value of success()**
| Name| Type| Description|
| -------- | -------- | -------- |
| longitude | number | Longitude.|
| latitude | number | Latitude.|
| altitude | number | Altitude.|
| accuracy | number | Location accuracy.|
| time | number | Time when the location is obtained.|
**Return value of fail()**
| Error Code| Description|
| -------- | -------- |
| 601 | Failed to obtain the required permission because the user rejected the request.|
| 602 | Permission not declared.|
| 801 | System location disabled.|
**Example** **Example**
...@@ -185,6 +137,8 @@ Cancels listening to the geographic location. ...@@ -185,6 +137,8 @@ Cancels listening to the geographic location.
> **NOTE** > **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('locationChange')](js-apis-geoLocationManager.md#geolocationmanagerofflocationchange). > This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('locationChange')](js-apis-geoLocationManager.md#geolocationmanagerofflocationchange).
**Required permissions**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Lite **System capability**: SystemCapability.Location.Location.Lite
**Example** **Example**
...@@ -192,7 +146,7 @@ Cancels listening to the geographic location. ...@@ -192,7 +146,7 @@ Cancels listening to the geographic location.
``` ```
export default { export default {
unsubscribe() { unsubscribe() {
geolocation.unsubscribe(); geolocation.unsubscribe();
} }
} }
``` ```
...@@ -224,3 +178,102 @@ export default { ...@@ -224,3 +178,102 @@ export default {
}, },
} }
``` ```
## GetLocationOption<sup>(deprecated)</sup>
Defines the options of a single location request.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.CurrentLocationRequest](js-apis-geoLocationManager.md#CurrentLocationRequest).
**Required permissions**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Lite
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| timeout | number | No| Timeout duration, in ms. The default value is **30000**.<br>The timeout duration is necessary in case the request to obtain the geographic location is rejected for the lack of the required permission, weak positioning signal, or incorrect location settings. After the timeout duration expires, the fail function will be called.<br>The value is a 32-digit positive integer. If the specified value is less than or equal to **0**, the default value will be used.|
| coordType | string | No| Coordinate system type. Available types can be obtained by **getSupportedCoordTypes**. The default type is **wgs84**.|
| success | (data: [GeolocationResponse](#geolocationresponsedeprecated)) => void | No| Called when API call is successful.|
| fail | (data: string, code: number) => void | No| Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.|
| complete | () => void | No| Called when API call is complete.|
**Return value of fail()**
| Error Code| Description|
| -------- | -------- |
| 601 | Failed to obtain the required permission because the user rejected the request.|
| 602 | Permission not declared.|
| 800 | Operation times out due to a poor network condition or GNSS unavailability.|
| 801 | System location disabled.|
| 802 | API called again while the previous execution result is not returned yet.|
## GeolocationResponse<sup>(deprecated)</sup>
Defines the location information, including the longitude, latitude, and location precision.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.Location](js-apis-geoLocationManager.md#location).
**System capability**: SystemCapability.Location.Location.Lite
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| longitude | number | Yes| No| Longitude.|
| latitude | number | Yes| No| Latitude.|
| altitude | number | Yes| No| Altitude.|
| accuracy | number | Yes| No| Location accuracy.|
| time | number | Yes| No| Time when the location is obtained.|
## GetLocationTypeOption<sup>(deprecated)</sup>
Defines the location type option, which holds the callback function used to return the query result.
> **NOTE**
> This API is deprecated since API version 9.
**System capability**: SystemCapability.Location.Location.Lite
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| success | (data: [GetLocationTypeResponse](#getlocationtyperesponsedeprecated)) => void | No| Called when API call is successful.|
| fail | (data: string, code: number) => void | No| Called when API call has failed.|
| complete | () => void | No| Called when API call is complete.|
## GetLocationTypeResponse<sup>(deprecated)</sup>
Defines the list of location types supported by the current device
> **NOTE**
> This API is deprecated since API version 9.
**System capability**: SystemCapability.Location.Location.Lite
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| types | Array&lt;string&gt; | Yes| No| Available location types, ['gps', 'network']|
## SubscribeLocationOption<sup>(deprecated)</sup>
Defines the options for continuous location.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.CurrentLocationRequest](js-apis-geoLocationManager.md#locationrequest).
**Required permissions**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Lite
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| coordType | string | No| Coordinate system type. Available types can be obtained by **getSupportedCoordTypes**. The default type is **wgs84**.|
| success | (data: [GeolocationResponse](#geolocationresponsedeprecated)) => void | Yes| Called when the geographic location changes.|
| fail | (data: string, code: number) => void | No| Called when API call has failed.|
**Return value of fail()**
| Error Code| Description|
| -------- | -------- |
| 601 | Failed to obtain the required permission because the user rejected the request.|
| 602 | Permission not declared.|
| 801 | System location disabled.|
# @system.network (Network State) # @system.network (Network State)
> **NOTE** > **NOTE**
> > - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.telephony.observer`](js-apis-observer.md).
> - The APIs of this module are no longer maintained since API version 7. It is recommended that you use [`@ohos.telephony.observer`](js-apis-observer.md) instead. >
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -31,17 +31,17 @@ Obtains the network type. ...@@ -31,17 +31,17 @@ Obtains the network type.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| success | Function | No | Called when the execution is successful. The return value is [NetworkResponse](#networkresponse). | | success | Function | No| Called when the API call is successful. The return value is defined by [NetworkResponse](#networkresponse).|
| fail | Function | No | Called when the operation fails. | | fail | Function | No| Called when API call has failed.|
| complete | Function | No | Called when the execution is complete | | complete | Function | No| Called when the API call is complete.|
Return value of the **fail** callback: One of the following error codes will be returned if the API call has failed.
| Error Code | Description | | Error Code| Description|
| -------- | -------- | | -------- | -------- |
| 602 | The current permission is not declared. | | 602 | The current permission is not declared.|
**Example** **Example**
...@@ -71,17 +71,17 @@ Listens to the network connection state. If this method is called multiple times ...@@ -71,17 +71,17 @@ Listens to the network connection state. If this method is called multiple times
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| success | Function | No | Called when the network connection state changes | | success | Function | No| Called when the network state changes. The return value is defined by [NetworkResponse](#networkresponse).|
| fail | Function | No | Called when the multimedia volume fails to be obtained. | | fail | Function | No| Called when API call has failed.|
Return value of the **fail** callback: One of the following error codes will be returned if the API call has failed.
| Error Code | Description | | Error Code| Description|
| -------- | -------- | | -------- | -------- |
| 602 | The current permission is not declared. | | 602 | The current permission is not declared.|
| 200 | The subscription fails. | | 200 | Subscription failed.|
**Example** **Example**
...@@ -119,9 +119,12 @@ export default { ...@@ -119,9 +119,12 @@ export default {
} }
``` ```
## NetworkResponse ## NetworkResponse
| Parameter | Type | Description | **System capability**: SystemCapability.Communication.NetManager.Core
| -------- | -------- | -------- |
| metered | boolean | Whether the billing is based on the data volume. | | Name| Type| Mandatory| Description|
| type | string | Network type. The value can be **2G**, **3G**, **4G**, **5G**, **WiFi**, or **none**. | | -------- | -------- | -------- | -------- |
\ No newline at end of file | metered | boolean | No|Whether to charge by traffic.|
| type | string | Yes|Network type. The value can be **2G**, **3G**, **4G**, **5G**, **WiFi**, or **none**.|
...@@ -64,7 +64,7 @@ ws.connect(defaultIpAddress, (err, value) => { ...@@ -64,7 +64,7 @@ ws.connect(defaultIpAddress, (err, value) => {
## webSocket.createWebSocket ## webSocket.createWebSocket
createWebSocket\(\): WebSocket createWebSocket(): WebSocket
Creates a WebSocket connection. You can use this API to create or close a WebSocket connection, send data over it, or enable or disable listening for the **open**, **close**, **message**, and **error** events. Creates a WebSocket connection. You can use this API to create or close a WebSocket connection, send data over it, or enable or disable listening for the **open**, **close**, **message**, and **error** events.
...@@ -89,7 +89,7 @@ Defines a **WebSocket** object. Before invoking WebSocket APIs, you need to call ...@@ -89,7 +89,7 @@ Defines a **WebSocket** object. Before invoking WebSocket APIs, you need to call
### connect ### connect
connect\(url: string, callback: AsyncCallback<boolean\>\): void connect(url: string, callback: AsyncCallback\<boolean\>): void
Initiates a WebSocket request to establish a WebSocket connection to a given URL. This API uses an asynchronous callback to return the result. Initiates a WebSocket request to establish a WebSocket connection to a given URL. This API uses an asynchronous callback to return the result.
...@@ -128,7 +128,7 @@ ws.connect(url, (err, value) => { ...@@ -128,7 +128,7 @@ ws.connect(url, (err, value) => {
### connect ### connect
connect\(url: string, options: WebSocketRequestOptions, callback: AsyncCallback<boolean\>\): void connect(url: string, options: WebSocketRequestOptions, callback: AsyncCallback\<boolean\>): void
Initiates a WebSocket request carrying specified options to establish a WebSocket connection to a given URL. This API uses an asynchronous callback to return the result. Initiates a WebSocket request carrying specified options to establish a WebSocket connection to a given URL. This API uses an asynchronous callback to return the result.
...@@ -173,7 +173,7 @@ ws.connect(url, { ...@@ -173,7 +173,7 @@ ws.connect(url, {
### connect ### connect
connect\(url: string, options?: WebSocketRequestOptions\): Promise<boolean\> connect(url: string, options?: WebSocketRequestOptions): Promise\<boolean\>
Initiates a WebSocket request carrying specified options to establish a WebSocket connection to a given URL. This API uses a promise to return the result. Initiates a WebSocket request carrying specified options to establish a WebSocket connection to a given URL. This API uses a promise to return the result.
...@@ -217,7 +217,7 @@ promise.then((value) => { ...@@ -217,7 +217,7 @@ promise.then((value) => {
### send ### send
send\(data: string | ArrayBuffer, callback: AsyncCallback<boolean\>\): void send(data: string | ArrayBuffer, callback: AsyncCallback\<boolean\>): void
Sends data through a WebSocket connection. This API uses an asynchronous callback to return the result. Sends data through a WebSocket connection. This API uses an asynchronous callback to return the result.
...@@ -229,7 +229,7 @@ Sends data through a WebSocket connection. This API uses an asynchronous callbac ...@@ -229,7 +229,7 @@ Sends data through a WebSocket connection. This API uses an asynchronous callbac
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | ------------ | | -------- | ------------------------ | ---- | ------------ |
| data | string \| ArrayBuffer <sup>8+</sup> | Yes | Data to send.| | data | string \| ArrayBuffer | Yes | Data to send.<br>Only the string type is supported for API version 6 or earlier. Both the string and ArrayBuffer types are supported for API version 8 or later.|
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -258,7 +258,7 @@ ws.connect(url, (err, value) => { ...@@ -258,7 +258,7 @@ ws.connect(url, (err, value) => {
### send ### send
send\(data: string | ArrayBuffer\): Promise<boolean\> send(data: string | ArrayBuffer): Promise\<boolean\>
Sends data through a WebSocket connection. This API uses a promise to return the result. Sends data through a WebSocket connection. This API uses a promise to return the result.
...@@ -270,7 +270,7 @@ Sends data through a WebSocket connection. This API uses a promise to return the ...@@ -270,7 +270,7 @@ Sends data through a WebSocket connection. This API uses a promise to return the
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------ | | ------ | ------ | ---- | ------------ |
| data | string \| ArrayBuffer <sup>8+</sup> | Yes | Data to send.| | data | string \| ArrayBuffer | Yes | Data to send.<br>Only the string type is supported for API version 6 or earlier. Both the string and ArrayBuffer types are supported for API version 8 or later.|
**Return value** **Return value**
...@@ -303,7 +303,7 @@ ws.connect(url, (err, value) => { ...@@ -303,7 +303,7 @@ ws.connect(url, (err, value) => {
### close ### close
close\(callback: AsyncCallback<boolean\>\): void close(callback: AsyncCallback\<boolean\>): void
Closes a WebSocket connection. This API uses an asynchronous callback to return the result. Closes a WebSocket connection. This API uses an asynchronous callback to return the result.
...@@ -341,7 +341,7 @@ ws.close((err, value) => { ...@@ -341,7 +341,7 @@ ws.close((err, value) => {
### close ### close
close\(options: WebSocketCloseOptions, callback: AsyncCallback<boolean\>\): void close(options: WebSocketCloseOptions, callback: AsyncCallback\<boolean\>): void
Closes a WebSocket connection carrying specified options such as **code** and **reason**. This API uses an asynchronous callback to return the result. Closes a WebSocket connection carrying specified options such as **code** and **reason**. This API uses an asynchronous callback to return the result.
...@@ -383,7 +383,7 @@ ws.close({ ...@@ -383,7 +383,7 @@ ws.close({
### close ### close
close\(options?: WebSocketCloseOptions\): Promise<boolean\> close(options?: WebSocketCloseOptions): Promise\<boolean\>
Closes a WebSocket connection carrying specified options such as **code** and **reason**. This API uses a promise to return the result. Closes a WebSocket connection carrying specified options such as **code** and **reason**. This API uses a promise to return the result.
...@@ -427,9 +427,9 @@ promise.then((value) => { ...@@ -427,9 +427,9 @@ promise.then((value) => {
``` ```
### on\('open'\) ### on('open')
on\(type: 'open', callback: AsyncCallback<Object\>\): void on(type: 'open', callback: AsyncCallback\<Object\>): void
Enables listening for the **open** events of a WebSocket connection. This API uses an asynchronous callback to return the result. Enables listening for the **open** events of a WebSocket connection. This API uses an asynchronous callback to return the result.
...@@ -453,9 +453,9 @@ ws.on('open', (err, value) => { ...@@ -453,9 +453,9 @@ ws.on('open', (err, value) => {
``` ```
### off\('open'\) ### off('open')
off\(type: 'open', callback?: AsyncCallback<Object\>\): void off(type: 'open', callback?: AsyncCallback\<Object\>): void
Disables listening for the **open** events of a WebSocket connection. This API uses an asynchronous callback to return the result. Disables listening for the **open** events of a WebSocket connection. This API uses an asynchronous callback to return the result.
...@@ -484,14 +484,14 @@ ws.off('open', callback1); ...@@ -484,14 +484,14 @@ ws.off('open', callback1);
``` ```
### on\('message'\) ### on('message')
on\(type: 'message', callback: AsyncCallback<string | ArrayBuffer\>\): void on(type: 'message', callback: AsyncCallback\<string | ArrayBuffer\>): void
Enables listening for the **message** events of a WebSocket connection. This API uses an asynchronous callback to return the result. The maximum length of each message is 4 KB. If the length exceeds 4 KB, the message is automatically fragmented. Enables listening for the **message** events of a WebSocket connection. This API uses an asynchronous callback to return the result. The maximum length of each message is 4 KB. If the length exceeds 4 KB, the message is automatically fragmented.
>**NOTE** >**NOTE**
>The data in **AsyncCallback** can be in the format of string\(API 6\) or ArrayBuffer\(API 8\). >The data in **AsyncCallback** can be in the format of string (API version 6) or ArrayBuffer (API version 8).
**System capability**: SystemCapability.Communication.NetStack **System capability**: SystemCapability.Communication.NetStack
...@@ -512,14 +512,14 @@ ws.on('message', (err, value) => { ...@@ -512,14 +512,14 @@ ws.on('message', (err, value) => {
``` ```
### off\('message'\) ### off('message')
off\(type: 'message', callback?: AsyncCallback<string | ArrayBuffer\>\): void off(type: 'message', callback?: AsyncCallback\<string | ArrayBuffer\>): void
Disables listening for the **message** events of a WebSocket connection. This API uses an asynchronous callback to return the result. The maximum length of each message is 4 KB. If the length exceeds 4 KB, the message is automatically fragmented. Disables listening for the **message** events of a WebSocket connection. This API uses an asynchronous callback to return the result. The maximum length of each message is 4 KB. If the length exceeds 4 KB, the message is automatically fragmented.
>**NOTE** >**NOTE**
>The data in **AsyncCallback** can be in the format of string\(API 6\) or ArrayBuffer\(API 8\). >The data in **AsyncCallback** can be in the format of string (API version 6) or ArrayBuffer (API version 8).
>You can pass the callback of the **on** function if you want to cancel listening for a certain type of event. If you do not pass the callback, you will cancel listening for all events. >You can pass the callback of the **on** function if you want to cancel listening for a certain type of event. If you do not pass the callback, you will cancel listening for all events.
**System capability**: SystemCapability.Communication.NetStack **System capability**: SystemCapability.Communication.NetStack
...@@ -539,9 +539,9 @@ ws.off('message'); ...@@ -539,9 +539,9 @@ ws.off('message');
``` ```
### on\('close'\) ### on('close')
on\(type: 'close', callback: AsyncCallback<\{ code: number, reason: string \}\>\): void on(type: 'close', callback: AsyncCallback\<{ code: number, reason: string }\>): void
Enables listening for the **close** events of a WebSocket connection. This API uses an asynchronous callback to return the result. Enables listening for the **close** events of a WebSocket connection. This API uses an asynchronous callback to return the result.
...@@ -552,7 +552,7 @@ Enables listening for the **close** events of a WebSocket connection. This API u ...@@ -552,7 +552,7 @@ Enables listening for the **close** events of a WebSocket connection. This API u
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------- | ---- | ------------------------------ | | -------- | ----------------------------------------------- | ---- | ------------------------------ |
| type | string | Yes | Event type. <br />**close**: event indicating that a WebSocket connection has been closed.| | type | string | Yes | Event type. <br />**close**: event indicating that a WebSocket connection has been closed.|
| callback | AsyncCallback<{ code: number, reason: string }> | Yes | Callback used to return the result. | | callback | AsyncCallback\<{ code: number, reason: string }\> | Yes | Callback used to return the result.<br>**close** indicates the close error code and **reason** indicates the error code description.|
**Example** **Example**
...@@ -564,9 +564,9 @@ ws.on('close', (err, value) => { ...@@ -564,9 +564,9 @@ ws.on('close', (err, value) => {
``` ```
### off\('close'\) ### off('close')
off\(type: 'close', callback?: AsyncCallback<\{ code: number, reason: string \}\>\): void off(type: 'close', callback?: AsyncCallback\<{ code: number, reason: string }\>): void
Disables listening for the **close** events of a WebSocket connection. This API uses an asynchronous callback to return the result. Disables listening for the **close** events of a WebSocket connection. This API uses an asynchronous callback to return the result.
...@@ -580,7 +580,7 @@ Disables listening for the **close** events of a WebSocket connection. This API ...@@ -580,7 +580,7 @@ Disables listening for the **close** events of a WebSocket connection. This API
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------- | ---- | ------------------------------ | | -------- | ----------------------------------------------- | ---- | ------------------------------ |
| type | string | Yes | Event type. <br />**close**: event indicating that a WebSocket connection has been closed.| | type | string | Yes | Event type. <br />**close**: event indicating that a WebSocket connection has been closed.|
| callback | AsyncCallback<{ code: number, reason: string }> | No | Callback used to return the result. | | callback | AsyncCallback\<{ code: number, reason: string }\> | No | Callback used to return the result.<br>**close** indicates the close error code and **reason** indicates the error code description.|
**Example** **Example**
...@@ -590,9 +590,9 @@ ws.off('close'); ...@@ -590,9 +590,9 @@ ws.off('close');
``` ```
### on\('error'\) ### on('error')
on\(type: 'error', callback: ErrorCallback\): void on(type: 'error', callback: ErrorCallback): void
Enables listening for the **error** events of a WebSocket connection. This API uses an asynchronous callback to return the result. Enables listening for the **error** events of a WebSocket connection. This API uses an asynchronous callback to return the result.
...@@ -615,9 +615,9 @@ ws.on('error', (err) => { ...@@ -615,9 +615,9 @@ ws.on('error', (err) => {
``` ```
### off\('error'\) ### off('error')
off\(type: 'error', callback?: ErrorCallback\): void off(type: 'error', callback?: ErrorCallback): void
Disables listening for the **error** events of a WebSocket connection. This API uses an asynchronous callback to return the result. Disables listening for the **error** events of a WebSocket connection. This API uses an asynchronous callback to return the result.
......
...@@ -15,6 +15,7 @@ This error code is reported if the **write** API is called to perform applicatio ...@@ -15,6 +15,7 @@ This error code is reported if the **write** API is called to perform applicatio
The application event logging function is disabled. The application event logging function is disabled.
**Solution** **Solution**
Invoke the **configure** API to enable the application event logging function. Invoke the **configure** API to enable the application event logging function.
```js ```js
...@@ -41,6 +42,7 @@ The specified event domain name does not comply with the following rules: ...@@ -41,6 +42,7 @@ The specified event domain name does not comply with the following rules:
- The event domain name is not empty and contains a maximum of 32 characters. - The event domain name is not empty and contains a maximum of 32 characters.
**Solution** **Solution**
Specify a valid event domain name. Specify a valid event domain name.
## 11101002 Invalid Event Name ## 11101002 Invalid Event Name
......
...@@ -12,15 +12,13 @@ The HiTraceMeter subsystem consists of three parts: ...@@ -12,15 +12,13 @@ The HiTraceMeter subsystem consists of three parts:
- hitrace CLI tool for data collection - hitrace CLI tool for data collection
- smartperf tool for graphical data analysis - smartperf tool for graphical data analysis
Wherein, HiTraceMeter APIs and the hitrace CLI tool run on the device side, and the smartperf tool runs on the PC side. Wherein, HiTraceMeter APIs and the hitrace CLI tool run on the device side, and the smartperf tool runs on the PC side. HiTraceMeter APIs are provided in C++ and JS for event logging, which aims to generate the trace data necessary for performance tracing and analysis during the development process.
HiTraceMeter APIs are provided in C++ and JS for event logging, which aims to generate the trace data necessary for performance tracing and analysis during the development process.
The hitrace CLI tool is used to collect trace data. It captures trace data flows and saves the data as a text file. The hitrace CLI tool is used to collect trace data. It captures trace data flows and saves the data as a text file.
The smartperf tool allows you to perform data analysis manually or use the analysis script for automated data analysis. If you want to get the data analysis done automatically, you need to supply the data file generated by the hitrace CLI tool as the input for the smartperf tool. The smartperf tool allows you to perform data analysis manually or use the analysis script for automated data analysis. If you want to get the data analysis done automatically, you need to supply the data file generated by the hitrace CLI tool as the input for the smartperf tool.
Traces data is classified by trace tag or trace category. Generally, one device subsystem corresponds to one tag. The tag is passed as the **Tag** parameter to event logging APIs. When you use the hitrace CLI tool to collect trace data, only the trace data specified by the **Tag** parameter is collected. Trace data of applications is fixedly labeled as **APP Tag**, and therefore, no **Tag** parameter needs to be passed to JS APIs. The following is a list of trace tags supported by HiTraceMeter. You can view the tags in [hitrace_meter.h](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/interfaces/native/innerkits/include/hitrace_meter/hitrace_meter.h). Traces data is classified by trace tag or trace category. Generally, one device subsystem corresponds to one tag. The tag is passed as the **Tag** parameter to event logging APIs. When you use the hitrace CLI tool to collect trace data, only the trace data specified by the **Tag** parameter is collected. Trace data of applications is fixedly labeled as **APP Tag**, and therefore, no **Tag** parameter needs to be passed to JS APIs. The following is a list of trace tags supported by HiTraceMeter. You can view the tags in [hitrace_meter.h](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/interfaces/native/innerkits/include/hitrace_meter/hitrace_meter.h).
```cpp ```cpp
constexpr uint64_t HITRACE_TAG_NEVER = 0; // This tag is never enabled. constexpr uint64_t HITRACE_TAG_NEVER = 0; // This tag is never enabled.
...@@ -73,7 +71,7 @@ constexpr uint64_t HITRACE_TAG_NOT_READY = (1ULL << 63); // Reserved for initial ...@@ -73,7 +71,7 @@ constexpr uint64_t HITRACE_TAG_NOT_READY = (1ULL << 63); // Reserved for initial
constexpr uint64_t HITRACE_TAG_VALID_MASK = ((HITRACE_TAG_LAST - 1) | HITRACE_TAG_LAST); constexpr uint64_t HITRACE_TAG_VALID_MASK = ((HITRACE_TAG_LAST - 1) | HITRACE_TAG_LAST);
``` ```
## Implementation Principle ## Implementation Principles
HiTraceMeter provides the hitrace CLI tool for capturing trace data in user mode and kernel mode, and provides C++ (innerkits) and JS (kits) APIs for event logging in user mode. Through extending kernel's ftrace functionality, HiTraceMeter can use the trace_marker node of ftrace to write the data, which is written into the user space by event logging APIs, to the kernel buffer. The following figure shows the basic HiTraceMeter architecture. HiTraceMeter provides the hitrace CLI tool for capturing trace data in user mode and kernel mode, and provides C++ (innerkits) and JS (kits) APIs for event logging in user mode. Through extending kernel's ftrace functionality, HiTraceMeter can use the trace_marker node of ftrace to write the data, which is written into the user space by event logging APIs, to the kernel buffer. The following figure shows the basic HiTraceMeter architecture.
...@@ -83,14 +81,13 @@ HiTraceMeter provides the hitrace CLI tool for capturing trace data in user mode ...@@ -83,14 +81,13 @@ HiTraceMeter provides the hitrace CLI tool for capturing trace data in user mode
## Constraints ## Constraints
- The implementation of HiTraceMeter functions and APIs depends on the ftrace functionality, a framework provided by the kernel. It enables developers to add more trace functions via plug-ins. Therefore, make sure that ftrace is enabled before you use HiTraceMeter. - The implementation of HiTraceMeter functions and APIs depends on the ftrace functionality, a framework provided by the kernel. It enables developers to add more trace functions via plug-ins. Therefore, make sure that ftrace is enabled before you use HiTraceMeter.
For most Linux kernels, ftrace is enabled by default. For details, see the ftrace documentation you may obtain. For most Linux kernels, ftrace is enabled by default. For details, see the ftrace documentation you may obtain.
- HiTraceMeter is available only for the mini system and standard system. - HiTraceMeter is available only for the mini system and standard system.
# HiTraceMeter Development # HiTraceMeter Development
...@@ -98,7 +95,6 @@ HiTraceMeter development focuses on two parts: JS/C++ event logging APIs and the ...@@ -98,7 +95,6 @@ HiTraceMeter development focuses on two parts: JS/C++ event logging APIs and the
## When to Use ## When to Use
You may encounter unexpected issues like app freezing during app development or need to view the code's call chain during code debugging. With the APIs provided by HiTraceMeter, you'll be able to trace the application delay and call chain to identify performance problems. You may encounter unexpected issues like app freezing during app development or need to view the code's call chain during code debugging. With the APIs provided by HiTraceMeter, you'll be able to trace the application delay and call chain to identify performance problems.
...@@ -109,20 +105,19 @@ Only C++ APIs are now open for system developers. If you're developing a JS app, ...@@ -109,20 +105,19 @@ Only C++ APIs are now open for system developers. If you're developing a JS app,
**Table 1** Sync APIs **Table 1** Sync APIs
| API | Function |Parameter Description | | Sync trace | Function | Parameter Description |
| :----------------------------------------------------------- | ------------- |------------- | |:---------------------------------------------------------------------------- | --------- | --------------------------------------------------------------------- |
| void StartTrace(uint64_t label, const std::string& value, float limit = -1); | Starts a synchronous trace.|**label**: trace category.<br>**value**: trace data that indicates the specific status, such as the memory size and queue length.| | void StartTrace(uint64_t label, const std::string& value, float limit = -1); | Starts a synchronous trace.| **label**: trace category.<br>**value**: trace data that indicates the specific status, such as the memory size and queue length.|
| void FinishTrace(uint64_t label); | Stops a synchronous trace.|**label**: trace category.| | void FinishTrace(uint64_t label); | Stops a synchronous trace.| **label**: trace category. |
**StartTrace** and **FinishTrace** must be used in pairs, and **FinishTrace** matches the latest **StartTrace**. The two APIs can be used in nested mode. The stack data structure is used for matching during trace data parsing. The **limit** parameter is used for flow control, and you are advised to use the default value. **StartTrace** and **FinishTrace** must be used in pairs, and **FinishTrace** matches the latest **StartTrace**. The two APIs can be used in nested mode. The stack data structure is used for matching during trace data parsing. The **limit** parameter is used for flow control, and you are advised to use the default value.
**Table 2** Async APIs **Table 2** Async APIs
| API | Function |Parameter Description | | Async trace | Function | Parameter Description |
| ------------------------------------------------------------ | ------------- |------------- | | ------------------------------------------------------------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------- |
| void StartAsyncTrace(uint64_t label, const std::string& value, int32_t taskId, float limit = -1); | Starts an asynchronous trace.| **label**: trace category.<br>**value**: trace data that indicates the specific status, such as the memory size and queue length.<br>**taskId**: ID used to indicate the association of APIs in an asynchronous trace.| | void StartAsyncTrace(uint64_t label, const std::string& value, int32_t taskId, float limit = -1); | Starts an asynchronous trace.| **label**: trace category.<br>**value**: trace data that indicates the specific status, such as the memory size and queue length.<br>**taskId**: ID used to indicate the association of APIs in an asynchronous trace.|
| void FinishAsyncTrace(uint64_t label, const std::string& value, int32_t taskId); | Stops an asynchronous trace.| **label**: trace category.<br>**value**: trace data that indicates the specific status, such as the memory size and queue length.<br>**taskId**: ID used to indicate the association of APIs in an asynchronous trace.| | void FinishAsyncTrace(uint64_t label, const std::string& value, int32_t taskId); | Stops an asynchronous trace.| **label**: trace category.<br>**value**: trace data that indicates the specific status, such as the memory size and queue length.<br>**taskId**: ID used to indicate the association of APIs in an asynchronous trace.|
...@@ -130,160 +125,144 @@ The trace data of **StartAsyncTrace** and **FinishAsyncTrace** is matched based ...@@ -130,160 +125,144 @@ The trace data of **StartAsyncTrace** and **FinishAsyncTrace** is matched based
**Table 3** Counter APIs **Table 3** Counter APIs
| API | Function |Parameter Description | | Counter Trace | Function | Parameter Description |
| ------------------------------------------------------------ | --------- |--------- | | ------------------------------------------------------------------ | ------- | -------------------------------------------------------------- |
| void CountTrace(uint64_t label, const std::string& name, int64_t); | Performs a count trace.|**label**: trace category.<br>**name**: trace name displayed in the IDE.| | void CountTrace(uint64_t label, const std::string& name, int64_t); | Count trace.| **label**: trace category.<br>**name**: trace name displayed in the IDE.|
## How to Develop ## How to Develop
1. Add the build dependencies to the build configuration file **base\hiviewdfx\hitrace\cmd\BUILD.gn**. 1. Add the build dependencies to the build configuration file **base\hiviewdfx\hitrace\cmd\BUILD.gn**.
```
external_deps = [ "hitrace_native:hitrace_meter"]
```
```
external_deps = [ "hitrace_native:hitrace_meter"]
```
2. Add the header file dependencies. 2. Add the header file dependencies.
```cpp ```cpp
#include "hitrace_meter.h"// Header file for defining APIs #include "hitrace_meter.h"// Header file for defining APIs
``` ```
3. When calling an API, pass the trace value as an input parameter. After the hitrace command is executed in the shell, the trace data is automatically captured. The captured data includes the function call process and the memory and time consumed during this process. You can use the data to analyze the call process to identify performance problems. 3. When calling an API, pass the trace value as an input parameter. The trace tags currently supported are listed in **hitrace_meter.h**. Assume that the trace tag is **OHOS** and trace data of **func1** and **func2** needs to be captured. After the hitrace command is executed in the shell, the trace data is automatically captured. The captured data includes the function call process and the memory and time consumed during this process. You can use the data to analyze the call process to identify performance problems.
```cpp
```cpp #include "hitrace_meter.h" // Include hitrace_meter.h
using namespace std;
CountTrace(label, "count number", 2000); // Integer trace
int main()
StartTrace(label, "func1Trace", -1); // Trace start point of func1Start {
uint64_t label = BYTRACE_TAG_OHOS;
FinishTrace(label); // Trace end point of func1Trace sleep(1);
CountTrace(label, "count number", 2000); // Integer trace
StartAsyncTrace(label, "asyncTrace1", 1234); // Start point of asyncTrace1
StartTrace(label, "func1Trace", -1); // Trace start point of func1Start
FinishAsyncTrace(label, "asyncTrace2", 3456); // End point of asyncTrace2 sleep(1);
``` StartTrace(label, "func2Trace", -1); // Trace start point of func2Start
sleep(2);
FinishTrace (label); // Trace end point of func2Trace
sleep(1);
FinishTrace(label); // Trace end point of func1Trace
StartAsyncTrace(label, "asyncTrace1", 1234); // Trace start point of asyncTrace1
FinishAsyncTrace(label, "asyncTrace1", 1234); // Trace end point of asyncTrace1
return 0;
}
```
4. On completion of HiTraceMeter building and deployment, start a trace. After you run the application in the shell on the device, trace data will be captured automatically. 4. On completion of HiTraceMeter building and deployment, start a trace. After you run the application in the shell on the device, trace data will be captured automatically.
``` ```
hdc_std shell hitrace -t 10 ohos > .\myapp_demo.ftrace hdc_std shell hitrace -t 10 ohos > .\myapp_demo.ftrace
``` ```
You can open the captured data by clicking **Open trace file** in the smartperf tool or dragging the data to the graphics area. For details, see [smartperf](https://toscode.gitee.com/openharmony-sig/smartperf). You can open the captured data by clicking **Open trace file** in the smartperf tool or dragging the data to the graphics area. For details, see [smartperf](https://toscode.gitee.com/openharmony-sig/smartperf).
## Development Example
You can access a full list of trace tags supported by HiTraceMeter in **hitrace_meter.h**. The following uses the **OHOS** tag as an example to illustrate how to obtain the trace data of the **func1** and **func2** functions.
```cpp
#include "hitrace_meter.h" // Include hitrace_meter.h
using namespace std;
int main()
{
uint64_t label = BYTRACE_TAG_OHOS;
sleep(1);
CountTrace(label, "count number", 2000); // Integer trace
StartTrace(label, "func1Trace", -1); // Trace start point of func1Start
sleep(1);
StartTrace(label, "func2Trace", -1); // Trace start point of func2Start
sleep(2);
FinishTrace (label); // Trace end point of func2Trace
sleep(1);
FinishTrace(label); // Trace end point of func1Trace
return 0;
}
```
## Verification ## Verification
The following is a demo debugging process, where the **StartTrace** and **FinishTrace** APIs are used in synchronization mode. The following is a demo debugging process, where the **StartTrace** and **FinishTrace** APIs are used in synchronization mode.
1. Write the test code file [hitrace_example.cpp](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/cmd/example/hitrace_example.cpp) by adding the **StartTrace** and **FinishTrace** APIs to the code. 1. Write the test code file [hitrace_example.cpp](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/cmd/example/hitrace_example.cpp) by adding the **StartTrace** and **FinishTrace** APIs to the code.
```cpp ```cpp
int main() int main()
{ {
thread t1(ThreadFunc1); thread t1(ThreadFunc1);
t1.join(); t1.join();
StartTrace(LABEL, "testStart"); StartTrace(LABEL, "testStart");
sleep(SLEEP_ONE_SECOND); sleep(SLEEP_ONE_SECOND);
StartTrace(LABEL, "funcAStart", SLEEP_ONE_SECOND); // Trace start point StartTrace(LABEL, "funcAStart", SLEEP_ONE_SECOND); // Trace start point
FuncA(); FuncA();
FinishTrace(LABEL); FinishTrace(LABEL);
sleep(SLEEP_TWO_SECOND); sleep(SLEEP_TWO_SECOND);
thread t2(ThreadFunc2); thread t2(ThreadFunc2);
t2.join(); t2.join();
StartTrace(LABEL, "funcBStart", SLEEP_TWO_SECOND); StartTrace(LABEL, "funcBStart", SLEEP_TWO_SECOND);
FuncB(); FuncB();
FinishTrace(LABEL);// Trace end point FinishTrace(LABEL);// Trace end point
sleep(SLEEP_TWO_SECOND); sleep(SLEEP_TWO_SECOND);
sleep(SLEEP_ONE_SECOND); sleep(SLEEP_ONE_SECOND);
FinishTrace(LABEL); FinishTrace(LABEL);
FuncC(); FuncC();
return 0; return 0;
} }
``` ```
2. Modify the **base\hiviewdfx\hitrace\cmd\BUILD.gn** file, and start building. 2. Modify the **base\hiviewdfx\hitrace\cmd\BUILD.gn** file, and start building.
``` ```
ohos_executable("hitrace_example") { ohos_executable("hitrace_example") {
sources = [ "example/hitrace_example.cpp" ] sources = [ "example/hitrace_example.cpp" ]
external_deps = [ "hitrace_native:hitrace_meter" ] external_deps = [ "hitrace_native:hitrace_meter" ]
subsystem_name = "hiviewdfx" subsystem_name = "hiviewdfx"
part_name = "hitrace_native" part_name = "hitrace_native"
} }
group("hitrace_target") { group("hitrace_target") {
deps = [ deps = [
":hitrace", ":hitrace",
":hitrace_example", ":hitrace_example",
] ]
} }
``` ```
3. Place the **hitrace_example** executable file in the **/system/bin** directory of the device, and run the following commands in sequence in the shell: 3. Place the **hitrace_example** executable file in the **/system/bin** directory of the device, and run the following commands in sequence in the shell:
```shell ```shell
hitrace --trace_begin ohos hitrace --trace_begin ohos
hitrace_exampe hitrace_exampe
hitrace --trace_dump hitrace --trace_dump
``` ```
If the expected trace value is present in the trace data, the capture of trace data is successful. For example: If the expected trace value is present in the trace data, the capture of trace data is successful. For example:
``` ```
<...>-1651 (-------) [002] .... 327.194136: tracing_mark_write: S|1650|H:testAsync 111 <...>-1651 (-------) [002] .... 327.194136: tracing_mark_write: S|1650|H:testAsync 111
<...>-1650 (-------) [001] .... 332.197640: tracing_mark_write: B|1650|H:testStart <...>-1650 (-------) [001] .... 332.197640: tracing_mark_write: B|1650|H:testStart
<...>-1650 (-------) [001] .... 333.198018: tracing_mark_write: B|1650|H:funcAStart <...>-1650 (-------) [001] .... 333.198018: tracing_mark_write: B|1650|H:funcAStart
<...>-1650 (-------) [001] .... 334.198507: tracing_mark_write: E|1650| <...>-1650 (-------) [001] .... 334.198507: tracing_mark_write: E|1650|
<...>-1654 (-------) [003] .... 341.201673: tracing_mark_write: F|1650|H:testAsync 111 <...>-1654 (-------) [003] .... 341.201673: tracing_mark_write: F|1650|H:testAsync 111
<...>-1650 (-------) [001] .... 341.202168: tracing_mark_write: B|1650|H:funcBStart <...>-1650 (-------) [001] .... 341.202168: tracing_mark_write: B|1650|H:funcBStart
<...>-1650 (-------) [001] .... 343.202557: tracing_mark_write: E|1650| <...>-1650 (-------) [001] .... 343.202557: tracing_mark_write: E|1650|
<...>-1650 (-------) [001] .... 346.203178: tracing_mark_write: E|1650| <...>-1650 (-------) [001] .... 346.203178: tracing_mark_write: E|1650|
<...>-1650 (-------) [001] .... 346.203457: tracing_mark_write: C|1650|H:count number 1 <...>-1650 (-------) [001] .... 346.203457: tracing_mark_write: C|1650|H:count number 1
<...>-1650 (-------) [001] .... 347.203818: tracing_mark_write: C|1650|H:count number 2 <...>-1650 (-------) [001] .... 347.203818: tracing_mark_write: C|1650|H:count number 2
<...>-1650 (-------) [001] .... 348.204207: tracing_mark_write: C|1650|H:count number 3 <...>-1650 (-------) [001] .... 348.204207: tracing_mark_write: C|1650|H:count number 3
<...>-1650 (-------) [001] .... 349.204473: tracing_mark_write: C|1650|H:count number 4 <...>-1650 (-------) [001] .... 349.204473: tracing_mark_write: C|1650|H:count number 4
<...>-1650 (-------) [001] .... 350.204851: tracing_mark_write: C|1650|H:count number 5 <...>-1650 (-------) [001] .... 350.204851: tracing_mark_write: C|1650|H:count number 5
<...>-1655 (-------) [001] .... 365.944658: tracing_mark_write: trace_event_clock_sync: realtime_ts=1502021460925 <...>-1655 (-------) [001] .... 365.944658: tracing_mark_write: trace_event_clock_sync: realtime_ts=1502021460925
<...>-1655 (-------) [001] .... 365.944686: tracing_mark_write: trace_event_clock_sync: parent_ts=365.944641 <...>-1655 (-------) [001] .... 365.944686: tracing_mark_write: trace_event_clock_sync: parent_ts=365.944641
``` ```
# Using the hitrace CLI Tool # Using the hitrace CLI Tool
...@@ -291,71 +270,82 @@ The hitrace CLI tool is an executable binary program. On an OpenHarmony-powered ...@@ -291,71 +270,82 @@ The hitrace CLI tool is an executable binary program. On an OpenHarmony-powered
**Table 4** Command list **Table 4** Command list
| Option | Description | | Option | Description |
| ------------------------------ | ------------------------------------------------------------ | | ----------------------------- | -------------------------------------------------------- |
| -h, --help | Views the help Information. | | -h, --help | Views the help Information. |
| -b *n*, --buffer_size *n* | Sets the buffer size for trace data in KB. The default value is **2048**. | | -b *n*, --buffer_size *n* | Sets the buffer size for trace data in KB. The default value is **2048**. |
| -t *n*, --time *n* | Sets the trace uptime in seconds, which depends on the time required for analysis.| | -t *n*, --time *n* | Sets the trace uptime in seconds, which depends on the time required for analysis. |
| --trace_clock clock | Sets the type of the clock for adding a timestamp to a trace. The value can be **boot** (default), **global**, **mono**, **uptime**, or **perf**.| | --trace_clock clock | Sets the type of the clock for adding a timestamp to a trace. The value can be **boot** (default), **global**, **mono**, **uptime**, or **perf**.|
| --trace_begin | Starts capturing trace data. | | --trace_begin | Starts capturing trace data. |
| --trace_dump | Dumps trace data to the specified position. The default position is the console. | | --trace_dump | Dumps trace data to the specified position. The default position is the console. |
| --trace_finish | Stops capturing trace data and dumps trace data to the specified position. The default position is the console. | | --trace_finish | Stops capturing trace data and dumps trace data to the specified position. The default position is the console. |
| -l, --list_categories | Lists the trace categories supported by the device. | | -l, --list_categories | Lists the trace categories supported by the device. |
| --overwrite | Sets the action to take when the buffer is full. If this option is used, the latest trace data is discarded. If this option is not used, the earliest trace data is discarded (default). | | --overwrite | Sets the action to take when the buffer is full. If this option is used, the latest trace data is discarded. If this option is not used, the earliest trace data is discarded (default). |
| -o *filename*, --output *filename*| Outputs trace data to the specified file. | | -o *filename*, --output *filename*| Outputs trace data to the specified file. |
| -z | Compresses the trace data. | | -z | Compresses the trace data. |
Examples: Examples:
- Query supported labels. - Query supported labels.
``` ```
hitrace -l hitrace -l
``` ```
Or, Alternatively, run the following command:
``` ```
hitrace --list_categories hitrace --list_categories
``` ```
- Trace ability information for 10 seconds and store the trace data in a buffer of 4 MB. - Trace ability information for 10 seconds and store the trace data in a buffer of 4 MB.
``` ```
hitrace -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace hitrace -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace
``` ```
- Set the clock type to **mono**. - Set the clock type to **mono**.
``` ```
hitrace --trace_clock mono -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace hitrace --trace_clock mono -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace
``` ```
- Compress the trace data. - Compress the trace data.
``` ```
hitrace -z -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace hitrace -z -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace
``` ```
# FAQs # FAQs
### Incomplete or Empty Data Captured by hitrace ### Incomplete or Empty Data Captured by hitrace
#### Symptom #### Symptom
The data captured by running the hitrace command is incomplete or no data is captured.
#### **Root Cause**
The data captured by running the hitrace command is incomplete or no data is captured. The value of **-t** or **-b** buffer is too small, leading to data loss.
#### Solution #### Solution
Check the value of the **-t** and **-b** parameters. If the value is too small, data loss will occur. You are advised to set **-t** to **60** and **-b** to **204800** to increase the trace capture time and buffer, respectively. You can set **-t** to **60** and **-b** to **204800** to increase the trace time and buffer size.
# References # Reference
For details about HiTraceMeter, see [hiviewdfx_hitrace: A Lightweight Distributed Tracing](https://gitee.com/openharmony/hiviewdfx_hitrace). For details about HiTraceMeter, see [hiviewdfx_hitrace: Lightweight Distributed Tracing](https://gitee.com/openharmony/hiviewdfx_hitrace).
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册