diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index a488a313beff34555f589b57bdea17ddbdbcc752..b19c71404a0273c7813f764a1ef3ef9392ce8891 100644 --- a/en/application-dev/reference/apis/js-apis-call.md +++ b/en/application-dev/reference/apis/js-apis-call.md @@ -1,5191 +1,5146 @@ -# @ohos.telephony.call (Call) +# -The **call** module provides call management functions, including making calls, redirecting to the dial screen, obtaining the call status, and formatting phone numbers. + -To subscribe to the call status, use [`observer.on('callStateChange')`](js-apis-observer.md#observeroncallstatechange). + ->**NOTE** +> > ->The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> -## Modules to Import +## -```js -import call from '@ohos.telephony.call'; + + ``` -## call.dialCall9+ +## -dialCall\(phoneNumber: string, callback: AsyncCallback\\): void + -Initiates a call. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required Permissions**: ohos.permission.PLACE_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ---------------------------- | ---- | -------------------------------------- | -| phoneNumber | string | Yes | Phone number. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.dialCall("138xxxxxxxx", (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.dialCall9+ +## -dialCall\(phoneNumber: string, options: DialCallOptions, callback: AsyncCallback\\): void + -Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required Permissions**: ohos.permission.PLACE_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ----------------------------------- | ---- | ----------------------------------- | -| phoneNumber | string | Yes | Phone number. | -| options | [DialCallOptions](#dialcalloptions9)| Yes | Call options, which carry other configuration information of the call. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| | | | | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.dialCall("138xxxxxxxx", { - accountId: 0, - videoState: 0, - dialScene: 0, - dialType: 0, -}, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + + + ``` -## call.dialCall9+ +## -dialCall\(phoneNumber: string, options?: DialCallOptions\): Promise\ + -Initiates a call. You can set call options as needed. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required Permissions**: ohos.permission.PLACE_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ----------------------------------- | ---- | -------------------------------------- | -| phoneNumber | string | Yes | Phone number. | -| options | [DialCallOptions](#dialcalloptions9)| No | Call options, which carry other configuration information of the call.
If this parameter is not set, the following configuration is used by default. For details, see [DialCallOptions](#dialcalloptions9).
- **accountId**: 0 (card slot 1)
- **videoState**: voice call
- **dialScene**: common call
- **dialType**: carrier call | +| | | | | +| | | |




| -**Return value** + -| Type | Description | +| | | | ---------------------- | ---------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let promise = call.dialCall("138xxxxxxxx", { - accountId: 0, - videoState: 0, - dialScene: 0, - dialType: 0, -}); -promise.then(() => { - console.log(`dialCall success.`); -}).catch((err) => { - console.error(`dialCall fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + + + + + + ``` -## call.dial(deprecated) +## -dial\(phoneNumber: string, callback: AsyncCallback\\): void + -Initiates a call. This API uses an asynchronous callback to return the result. + -> **NOTE** +> > -> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9). The substitute API is available only for system applications. +> -**Required Permissions**: ohos.permission.PLACE_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ---------------------------- | ---- | --------------------------------------- | -| phoneNumber | string | Yes | Phone number. | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.
- **true**: success
- **false**: failure| +| | | | | +| | | | | -**Example** + -```js -call.dial("138xxxxxxxx", (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); + + + + ``` -## call.dial(deprecated) +## -dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback\\): void + -Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result. + -> **NOTE** +> > -> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9). The substitute API is available only for system applications. +> -**Required Permissions**: ohos.permission.PLACE_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ---------------------------- | ---- | --------------------------------------- | -| phoneNumber | string | Yes | Phone number. | -| options | [DialOptions](#dialoptions) | Yes | Call option, which indicates whether the call is a voice call or video call. | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.
- **true**: success
- **false**: failure| - -**Example** - -```js -call.dial("138xxxxxxxx", { - extras: false -}, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | | | +| | | | | +| | | | | + + + + + + + + + ``` -## call.dial(deprecated) +## -dial\(phoneNumber: string, options?: DialOptions\): Promise\ + -Initiates a call. You can set call options as needed. This API uses a promise to return the result. + -> **NOTE** +> > -> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9). The substitute API is available only for system applications. +> -**Required Permissions**: ohos.permission.PLACE_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | --------------------------- | ---- | -------------------------------------- | -| phoneNumber | string | Yes | Phone number. | -| options | [DialOptions](#dialoptions) | No | Call option, which indicates whether the call is a voice call or video call.| +| | | | | +| | | | | -**Return value** + -| Type | Description | +| | | | ---------------------- | ------------------------------------------------------------ | -| Promise<boolean> | Promise used to return the result.
- **true**: success
- **false**: failure| - -**Example** - -```js -let promise = call.dial("138xxxxxxxx", { - extras: false -}); -promise.then(data => { - console.log(`dial success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`dial fail, promise: err->${JSON.stringify(err)}`); -}); +| | | + + + + + + + + + + + + ``` -## call.makeCall7+ +## -makeCall\(phoneNumber: string, callback: AsyncCallback\\): void + -Launches the call screen and displays the dialed number. This API uses an asynchronous callback to return the result. + -**System capability**: SystemCapability.Applications.Contacts + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ------------------------- | ---- | ------------------------------------------ | -| phoneNumber | string | Yes | Phone number. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.makeCall("138xxxxxxxx", err => { - console.log(`makeCall callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.makeCall7+ +## -makeCall\(phoneNumber: string\): Promise\ + -Launches the call screen and displays the dialed number. This API uses a promise to return the result. + -**System capability**: SystemCapability.Applications.Contacts + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ------ | ---- | ---------- | -| phoneNumber | string | Yes | Phone number.| +| | | | | -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let promise = call.makeCall("138xxxxxxxx"); -promise.then(() => { - console.log(`makeCall success`); -}).catch(err => { - console.error(`makeCall fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + ``` -## call.hasCall +## -hasCall\(callback: AsyncCallback\\): void + -Checks whether a call is in progress. This API uses an asynchronous callback to return the result. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ---------------------------- | ---- | ------------------------------------------------------------ | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. Callback used to return the result.
- **true**: A call is in progress.
- **false**: No call is in progress.| +| | | | | -**Example** + -```js -call.hasCall((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); + + + + ``` -## call.hasCall +## -hasCall\(\): Promise\ + -Checks whether a call is in progress. This API uses a promise to return the result. + -**System capability**: SystemCapability.Telephony.CallManager + -**Return value** + -| Type | Description | +| | | | ---------------------- | --------------------------------------- | -| Promise<boolean> | Promise used to return the result.| +| | | -**Example** + -```js -let promise = call.hasCall(); -promise.then(data => { - console.log(`hasCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`hasCall fail, promise: err->${JSON.stringify(err)}`); -}); + + + + + + + ``` -## call.getCallState +## -getCallState\(callback: AsyncCallback\\): void + -Obtains the call status. This API uses an asynchronous callback to return the result. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | -------------------------------------------- | ---- | ------------------------------------ | -| callback | AsyncCallback<[CallState](#callstate)> | Yes | Callback used to return the result.| +| | | | | -**Example** + -```js -call.getCallState((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); + + + + ``` -## call.getCallState +## -getCallState\(\): Promise\ + -Obtains the call status. This API uses a promise to return the result. + -**System capability**: SystemCapability.Telephony.CallManager + -**Return value** + -| Type | Description | +| | | | -------------------------------------- | --------------------------------------- | -| Promise<[CallState](#callstate)> | Promise used to return the result.| +| | | -**Example** + -```js -let promise = call.getCallState(); -promise.then(data => { - console.log(`getCallState success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`getCallState fail, promise: err->${JSON.stringify(err)}`); -}); + + + + + + + ``` -## call.hasVoiceCapability7+ +## -hasVoiceCapability\(\): boolean + -Checks whether a device supports voice calls. + -**System capability**: SystemCapability.Telephony.CallManager + -**Return value** + -| Type | Description | +| | | | ------- | ------------------------------------------------------------ | -| boolean | - **true**: The device supports voice calls.
- **false**: The device does not support voice calls.| +| | | -```js -let result = call.hasVoiceCapability(); -console.log(`hasVoiceCapability: ${JSON.stringify(result)}`); + + + ``` -## call.isEmergencyPhoneNumber7+ +## -isEmergencyPhoneNumber\(phoneNumber: string, callback: AsyncCallback\\): void + -Checks whether the called number is an emergency number. This API uses an asynchronous callback to return the result. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ---------------------------- | ---- | ------------------------------------------------------------ | -| phoneNumber | string | Yes | Phone number. | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. - **true**: The called number is an emergency number.
- **false**: The called number is not an emergency number.| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.isEmergencyPhoneNumber("138xxxxxxxx", (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.isEmergencyPhoneNumber7+ +## -isEmergencyPhoneNumber\(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback\\): void + -Checks whether the called number is an emergency number based on the phone number. This API uses an asynchronous callback to return the result. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ | -| phoneNumber | string | Yes | Phone number. | -| options | [EmergencyNumberOptions](#emergencynumberoptions7) | Yes | Phone number. | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. - **true**: The called number is an emergency number.
- **false**: The called number is not an emergency number.| +| | | | | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.isEmergencyPhoneNumber7+ +## -isEmergencyPhoneNumber\(phoneNumber: string, options?: EmergencyNumberOptions\): Promise\ + -Checks whether the called number is an emergency number based on the phone number. This API uses a promise to return the result. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | -------------------------------------------------- | ---- | -------------- | -| phoneNumber | string | Yes | Phone number. | -| options | [EmergencyNumberOptions](#emergencynumberoptions7) | No | Phone number.| +| | | | | +| | | | | -**Return value** + -| Type | Description | +| | | | ---------------------- | --------------------------------------------------- | -| Promise<boolean> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let promise = call.isEmergencyPhoneNumber("138xxxxxxxx", {slotId: 1}); -promise.then(data => { - console.log(`isEmergencyPhoneNumber success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`isEmergencyPhoneNumber fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + ``` -## call.formatPhoneNumber7+ +## -formatPhoneNumber\(phoneNumber: string, callback: AsyncCallback\\): void + -Formats a phone number. This API uses an asynchronous callback to return the result. + -A formatted phone number is a standard numeric string, for example, 555 0100. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | --------------------------- | ---- | ------------------------------------ | -| phoneNumber | string | Yes | Phone number. | -| callback | AsyncCallback<string> | Yes | Callback used to return the result.| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.formatPhoneNumber("138xxxxxxxx", (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.formatPhoneNumber7+ +## -formatPhoneNumber\(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback\\): void + -Formats a phone number based on specified formatting options. This API uses an asynchronous callback to return the result. + -A formatted phone number is a standard numeric string, for example, 555 0100. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | -------------------------------------------- | ---- | ------------------------------------ | -| phoneNumber | string | Yes | Phone number. | -| options | [NumberFormatOptions](#numberformatoptions7) | Yes | Number formatting options, for example, country code. | -| callback | AsyncCallback<string> | Yes | Callback used to return the result.| +| | | | | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.formatPhoneNumber("138xxxxxxxx", { - countryCode: "CN" -}, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.formatPhoneNumber7+ +## -formatPhoneNumber\(phoneNumber: string, options?: NumberFormatOptions\): Promise\ + -Formats a phone number based on specified formatting options. This API uses a promise to return the result. + -A formatted phone number is a standard numeric string, for example, 555 0100. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | -------------------------------------------- | ---- | ---------------------- | -| phoneNumber | string | Yes | Phone number. | -| options | [NumberFormatOptions](#numberformatoptions7) | No | Number formatting options, for example, country code.| +| | | | | +| | | | | -**Return value** + -| Type | Description | +| | | | --------------------- | ------------------------------------------- | -| Promise<string> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let promise = call.formatPhoneNumber("138xxxxxxxx", { - countryCode: "CN" -}); -promise.then(data => { - console.log(`formatPhoneNumber success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`formatPhoneNumber fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + + + ``` -## call.formatPhoneNumberToE1647+ +## -formatPhoneNumberToE164\(phoneNumber: string, countryCode: string, callback: AsyncCallback\\): void + -Converts a phone number into the E.164 format. This API uses an asynchronous callback to return the result. + -The phone number must match the specified country code. For example, for a China phone number, the country code must be **CN**. Otherwise, **null** will be returned. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | --------------------------- | ---- | ----------------------------------------------------- | -| phoneNumber | string | Yes | Phone number. | -| countryCode | string | Yes | Country code, for example, **CN** (China). All country codes are supported. | -| callback | AsyncCallback<string> | Yes | Callback used to return the result.| +| | | | | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.formatPhoneNumberToE164("138xxxxxxxx", "CN", (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.formatPhoneNumberToE1647+ +## -formatPhoneNumberToE164\(phoneNumber: string, countryCode: string\): Promise\ + -Converts a phone number into the E.164 format. This API uses a promise to return the result. + -The phone number must match the specified country code. For example, for a China phone number, the country code must be **CN**. Otherwise, **null** will be returned. + -All country codes are supported. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ------ | ---- | ---------------------------------------- | -| phoneNumber | string | Yes | Phone number. | -| countryCode | string | Yes | Country code, for example, **CN** (China). All country codes are supported.| +| | | | | +| | | | | -**Return value** + -| Type | Description | +| | | | --------------------- | ------------------------------------------------------------ | -| Promise<string> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let promise = call.formatPhoneNumberToE164("138xxxxxxxx", "CN"); -promise.then(data => { - console.log(`formatPhoneNumberToE164 success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`formatPhoneNumberToE164 fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + ``` -## call.muteRinger8+ +## -muteRinger\(callback: AsyncCallback\\): void + -Mutes the ringtone while it is playing. It does not work if the ringtone has been muted. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ------------------------- | ---- | ---------- | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.muteRinger((err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.muteRinger8+ +## -muteRinger\(\): Promise\ + -Mutes the ringtone while it is playing. It does not work if the ringtone has been muted. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.muteRinger().then(() => { - console.log(`muteRinger success.`); -}).catch((err) => { - console.error(`muteRinger fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.answerCall9+ +## -answerCall\(callId: number, callback: AsyncCallback\\): void + -Answers a call. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.ANSWER_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------- | ---- | ----------------------------------------------- | -| callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.answerCall(1, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.answerCall9+ +## -answerCall(callId?: number\): Promise\ + -Answers a call. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.ANSWER_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ------ | ---- | ------------------------------------------------------------ | -| callId | number | No | Call ID. You can obtain the value by subscribing to **callDetailsChange** events. This parameter is optional from API version 9.
If this parameter is not set, the latest ringing call will be connected.| +| | | |
| -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.answerCall(1).then(() => { - console.log(`answerCall success.`); -}).catch((err) => { - console.error(`answerCall fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.answerCall9+ +## -answerCall\(callback: AsyncCallback\\): void + -Answers a call. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.ANSWER_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------- | ---- | ---------- | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.answerCall((err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.hangUpCall9+ +## -hangUpCall\(callId: number, callback: AsyncCallback\\): void + -Ends a call. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.ANSWER_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------- | ---- | ----------------------------------------------- | -| callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.hangUpCall(1, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.hangUpCall9+ +## -hangUpCall\(callId?: number\): Promise\ + -Ends a call. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.ANSWER_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ------ | ---- | ------------------------------------------------------------ | -| callId | number | No | Call ID. You can obtain the value by subscribing to **callDetailsChange** events. This parameter is optional from API version 9.
If this parameter is not set, the latest ongoing, dialed, or connected call will be ended.| +| | | |
| -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.hangUpCall(1).then(() => { - console.log(`hangUpCall success.`); -}).catch((err) => { - console.error(`hangUpCall fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.hangUpCall9+ +## -hangUpCall\(callback: AsyncCallback\\): void + -Ends a call. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.ANSWER_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------- | ---- | ---------- | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | +| | | +| | | +| | | +| | | +| | | +| | | +| | | -**Example** + -```js -call.hangUpCall((err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); + + + + ``` -## call.rejectCall9+ +## -rejectCall\(callId: number, callback: AsyncCallback\\): void + -Rejects a call. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.ANSWER_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------- | ---- | ----------------------------------------------- | -| callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | +| | | +| | | +| | | +| | | +| | | +| | | +| | | -**Example** + -```js -call.rejectCall(1, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); + + + + ``` -## call.rejectCall9+ +## -rejectCall\(callId: number, options: RejectMessageOptions, callback: AsyncCallback\\): void + -Rejects a call. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.ANSWER_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ---------------------------------------------- | ---- | ----------------------------------------------- | -| callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.| -| options | [RejectMessageOptions](#rejectmessageoptions7) | Yes | Options for the call rejection message. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| | | | | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let rejectMessageOptions={ - messageContent: "Unknown number blocked" +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + } -call.rejectCall(1, rejectMessageOptions, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); + + + ``` -## call.rejectCall9+ +## -rejectCall\(callId?: number, options?: RejectMessageOptions\): Promise\ + -Rejects a call. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.ANSWER_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ | -| callId | number | No | Call ID. You can obtain the value by subscribing to **callDetailsChange** events. This parameter is optional from API version 9.
If this parameter is not set, the latest ringing call will be rejected.| -| options | [RejectMessageOptions](#rejectmessageoptions7) | No | Options for the call rejection message. If this parameter is not set, no call rejection message will be sent.| +| | | |
| +| | | | | -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let rejectMessageOptions={ - messageContent: "Unknown number blocked" +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + } -call.rejectCall(1, rejectMessageOptions).then(() => { - console.log(`rejectCall success.`); -}).catch((err) => { - console.error(`rejectCall fail, promise: err->${JSON.stringify(err)}`); -}); + + + + + ``` -## call.rejectCall9+ +## -rejectCall\(callback: AsyncCallback\\): void + -Rejects a call. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.ANSWER_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------- | ---- | ---------- | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.rejectCall((err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.rejectCall9+ +## -rejectCall\(options: RejectMessageOptions, callback: AsyncCallback\\): void + -Rejects a call. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.ANSWER_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ---------------------------------------------- | ---- | -------------- | -| options | [RejectMessageOptions](#rejectmessageoptions7) | Yes | Options for the call rejection message.| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let rejectMessageOptions={ - messageContent: "Unknown number blocked" +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + } -call.rejectCall(rejectMessageOptions, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); + + + ``` -## call.holdCall7+ +## -holdCall\(callId: number, callback: AsyncCallback\\): void + -Holds a call based on the specified call ID. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.ANSWER_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------- | ---- | ---------- | -| callId | number | Yes | Call ID. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.holdCall(1, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.holdCall7+ +## -holdCall\(callId: number\): Promise\ + -Holds a call based on the specified call ID. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.ANSWER_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ------ | ---- | -------- | -| callId | number | Yes | Call ID.| +| | | | | -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.holdCall(1).then(() => { - console.log(`holdCall success.`); -}).catch((err) => { - console.error(`holdCall fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.unHoldCall7+ +## -unHoldCall\(callId: number, callback: AsyncCallback\\): void + -Unholds a call based on the specified call ID. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.ANSWER_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------- | ---- | ---------- | -| callId | number | Yes | Call ID. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.unHoldCall(1, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.unHoldCall7+ +## -unHoldCall\(callId: number\): Promise\ + -Unholds a call based on the specified call ID. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.ANSWER_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ------ | ---- | -------- | -| callId | number | Yes | Call ID.| +| | | | | -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.unHoldCall(1).then(() => { - console.log(`unHoldCall success.`); -}).catch((err) => { - console.error(`unHoldCall fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.switchCall7+ +## -switchCall\(callId: number, callback: AsyncCallback\\): void + -Switches a call. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.ANSWER_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------- | ---- | ---------- | -| callId | number | Yes | Call ID. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.switchCall(1, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.switchCall7+ +## -switchCall\(callId: number\): Promise\ + -Switches a call. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.ANSWER_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ------ | ---- | -------- | -| callId | number | Yes | Call ID.| +| | | | | -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.switchCall(1).then(() => { - console.log(`switchCall success.`); -}).catch((err) => { - console.error(`switchCall fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.combineConference7+ +## -combineConference\(callId: number, callback: AsyncCallback\\): void + -Combines two calls into a conference call. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------- | ---- | ---------- | -| callId | number | Yes | Call ID. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -call.combineConference(1, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.combineConference7+ +## -combineConference\(callId: number\): Promise\ + -Combines two calls into a conference call. This API uses a promise to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ------ | ---- | -------- | -| callId | number | Yes | Call ID.| +| | | | | -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -call.combineConference(1).then(() => { - console.log(`combineConference success.`); -}).catch((err) => { - console.error(`combineConference fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.getMainCallId7+ +## -getMainCallId\(callId: number, callback: AsyncCallback\\): void + -Obtains the main call ID. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | --------------------------- | ---- | ------------------------ | -| callId | number | Yes | Call ID. | -| callback | AsyncCallback<number> | Yes | Callback used to return the result. | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | +| | | +| | | +| | | +| | | +| | | -**Example** + -```js -call.getMainCallId(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); + + + + ``` -## call.getMainCallId7+ +## -getMainCallId\(callId: number\): Promise\ + -Obtains the main call ID. This API uses a promise to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ------ | ---- | -------- | -| callId | number | Yes | Call ID.| +| | | | | -**Return value** + -| Type | Description | +| | | | ------------------- | ------------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - - -**Example** - -```js -let promise = call.getMainCallId(1); -promise.then(data => { - console.log(`getMainCallId success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`getMainCallId fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + + ``` -## call.getSubCallIdList7+ +## -getSubCallIdList\(callId: number, callback: AsyncCallback\\>\): void + -Obtains the list of subcall IDs. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------------ | ---- | ---------------------------- | -| callId | number | Yes | Call ID. | -| callback | AsyncCallback\> | Yes | Callback used to return the result. | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -call.getSubCallIdList(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.getSubCallIdList7+ +## -getSubCallIdList\(callId: number\): Promise\\> + -Obtains the list of subcall IDs. This API uses a promise to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ------ | ---- | -------- | -| callId | number | Yes | Call ID.| +| | | | | -**Return value** + -| Type | Description | +| | | | ----------------------------- | ----------------------------------- | -| Promise<Array> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -let promise = call.getSubCallIdList(1); -promise.then(data => { - console.log(`getSubCallIdList success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`getSubCallIdList fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + ``` -## call.getCallIdListForConference7+ +## -getCallIdListForConference\(callId: number, callback: AsyncCallback\\>\): void + -Obtains the list of call IDs in a conference. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ----------------------------------- | ---- | -------------------------------- | -| callId | number | Yes | Call ID. | -| callback | AsyncCallback<Array> | Yes | Callback used to return the result. | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -call.getCallIdListForConference(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.getCallIdListForConference7+ +## -getCallIdListForConference\(callId: number\): Promise\\> + -Obtains the list of call IDs in a conference. This API uses a promise to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ------ | ---- | -------- | -| callId | number | Yes | Call ID.| +| | | | | -**Return value** + -| Type | Description | +| | | | ----------------------------- | --------------------------------------- | -| Promise<Array> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -let promise = call.getCallIdListForConference(1); -promise.then(data => { - console.log(`getCallIdListForConference success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`getCallIdListForConference fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + ``` -## call.getCallWaitingStatus7+ +## -getCallWaitingStatus\(slotId: number, callback: AsyncCallback\\): void + -Obtains the call waiting status. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.GET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | -| callback | AsyncCallback<[CallWaitingStatus](#callwaitingstatus7)\> | Yes | Callback used to return the result.

- **0**: Call waiting is disabled.
- **1**: Call waiting is enabled.| +| | | |

| +| | | |


| -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -call.getCallWaitingStatus(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.getCallWaitingStatus7+ +## -getCallWaitingStatus\(slotId: number\): Promise\ + -Obtains the call waiting status. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.GET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ------ | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| | | |

| -**Return value** + -| Type | Description | +| | | | ------------------------------------------------------- | ------------------------------------------------------------ | -| Promise<[CallWaitingStatus](#callwaitingstatus7)> | Promise used to return the result.
- **0**: Call waiting is disabled.
- **1**: Call waiting is enabled.| +| |

| -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -let promise = call.getCallWaitingStatus(0); -promise.then(data => { - console.log(`getCallWaitingStatus success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`getCallWaitingStatus fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + ``` -## call.setCallWaiting7+ +## -setCallWaiting\(slotId: number, activate: boolean, callback: AsyncCallback\\): void + -Specifies whether to enable the call waiting service. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | -------------------- | ---- | ------------------------------------------------------------ | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | -| activate | boolean | Yes | Whether to enable call waiting.
- **false**: Disable call waiting.
- **true**: Enable call waiting.| -| callback | AsyncCallback | Yes | Callback used to return the result. | +| | | |

| +| | | |

| +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -call.setCallWaiting(0, true, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.setCallWaiting7+ +## -setCallWaiting\(slotId: number, activate: boolean\): Promise\ + -Specifies whether to enable the call waiting service. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------- | ---- | ------------------------------------------------------------ | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | -| activate | boolean | Yes | Whether to enable call waiting.
- **false**: Disable call waiting.
- **true**: Enable call waiting.| +| | | |

| +| | | |

| -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -call.setCallWaiting(0, true).then(() => { - console.log(`setCallWaiting success.`); -}).catch((err) => { - console.error(`setCallWaiting fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.startDTMF7+ +## -startDTMF\(callId: number, character: string, callback: AsyncCallback\\): void + -Enables DTMF. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | --------- | -------------------- | ---- | ---------- | -| callId | number | Yes | Call ID. | -| character | string | Yes | DTMF code. | -| callback | AsyncCallback | Yes | Callback used to return the result.| +| | | | | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -call.startDTMF(1, "0", (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.startDTMF7+ +## -startDTMF\(callId: number, character: string\): Promise\ + -Enables DTMF. This API uses a promise to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | --------- | ------ | ---- | -------- | -| callId | number | Yes | Call ID.| -| character | string | Yes | DTMF code.| +| | | | | +| | | | | -**Return value** + -| Type | Description | +| | | | ------------------- | ----------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -call.startDTMF(1, "0").then(() => { - console.log(`startDTMF success.`); -}).catch((err) => { - console.error(`startDTMF fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.stopDTMF7+ +## -stopDTMF\(callId: number, callback: AsyncCallback\\): void + -Stops DTMF. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------- | ---- | ---------- | -| callId | number | Yes | Call ID. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -call.stopDTMF(1, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.stopDTMF7+ +## -stopDTMF\(callId: number\): Promise\ + -Stops DTMF. This API uses a promise to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ------ | ---- | -------- | -| callId | number | Yes | Call ID.| +| | | | | -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -call.stopDTMF(1).then(() => { - console.log(`stopDTMF success.`); -}).catch((err) => { - console.error(`stopDTMF fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.isInEmergencyCall7+ +## -isInEmergencyCall\(callback: AsyncCallback\\): void + -Checks whether a call is an emergency call. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ---------------------------- | ---- | ---------- | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.| +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.isInEmergencyCall((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.isInEmergencyCall7+ +## -isInEmergencyCall\(\): Promise\ + -Checks whether a call is an emergency call. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Return value** + -| Type | Description | +| | | | ---------------------- | --------------------------- | -| Promise<boolean> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let promise = call.isInEmergencyCall(); -promise.then(data => { - console.log(`isInEmergencyCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`isInEmergencyCall fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + ``` -## call.on('callDetailsChange')7+ +## -on\(type: 'callDetailsChange', callback: Callback\\): void + -Subscribes to **callDetailsChange** events. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------------------------------------- | ---- | -------------------------- | -| type | string | Yes | Call event change. This field has a fixed value of **callDetailsChange**.| -| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | Yes | Callback used to return the result. | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.on('callDetailsChange', data => { - console.log(`callback: data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.on('callEventChange')8+ +## -on\(type: 'callEventChange', callback: Callback\\): void + -Subscribes to **callEventChange** events. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------------------------------ | ---- | -------------------------- | -| type | string | Yes | Call event change. This field has a fixed value of **callEventChange**.| -| callback | Callback<[CallEventOptions](#calleventoptions8)> | Yes | Callback used to return the result. | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.on('callEventChange', data => { - console.log(`callback: data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.on('callDisconnectedCause')8+ +## -on\(type: 'callDisconnectedCause', callback: Callback\\): void + -Subscribes to **callDisconnectedCause** events. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------------------------------------ | ---- | -------------------------- | -| type | string | Yes | Call disconnection cause. This field has a fixed value of **callDisconnectedCause**.| -| callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | Yes | Callback used to return the result. | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.on('callDisconnectedCause', data => { - console.log(`callback: data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.on('mmiCodeResult')9+ +## -on\(type: 'mmiCodeResult', callback: Callback\\): void + -Subscribes to **mmiCodeResult** events. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | -------------------------------------------- | ---- | --------------------- | -| type | string | Yes | MMI code result. This field has a fixed value of **mmiCodeResult**.| -| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | Yes | Callback used to return the result. | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.on('mmiCodeResult', data => { - console.log(`callback: data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.off('callDetailsChange')7+ +## -off\(type: 'callDetailsChange', callback?: Callback\\): void + -Unsubscribes from **callDetailsChange** events. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | -------------------------------------------------------- | ---- | ---------------------------------- | -| type | string | Yes | Call details change. This field has a fixed value of **callDetailsChange**.| -| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | No | Callback used to return the result. If this parameter is not set, no subscription cancellation result will be received.| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.off('callDetailsChange', data => { - console.log(`callback: data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.off('callEventChange')8+ +## -off\(type: 'callEventChange', callback?: Callback\\): void + -Unsubscribes from **callEventChange** events. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------------------------------ | ---- | ---------------------------------- | -| type | string | Yes | Call event change. This field has a fixed value of **callEventChange**.| -| callback | Callback<[CallEventOptions](#calleventoptions8)> | No | Callback used to return the result. If this parameter is not set, no subscription cancellation result will be received.| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.off('callEventChange', data => { - console.log(`callback: data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.off('callDisconnectedCause')8+ +## -off\(type: 'callDisconnectedCause', callback?: Callback\\): void + -Unsubscribes from **callDisconnectedCause** events. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ---------------------------------------------------------- | ---- | ------------------- | -| type | string | Yes | Call disconnection cause. This field has a fixed value of **callDisconnectedCause**.| -| callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | No | Callback used to return the result. If this parameter is not set, no subscription cancellation result will be received.| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.off('callDisconnectedCause', data => { - console.log(`callback: data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.off('mmiCodeResult')9+ +## -off\(type: 'mmiCodeResult', callback?: Callback\\): void + -Unsubscribes from **mmiCodeResult** events. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------------------------------ | ---- | ----------- | -| type | string | Yes | MMI code result. This field has a fixed value of **mmiCodeResult**.| -| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | No | Callback used to return the result. If this parameter is not set, no subscription cancellation result will be received.| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.off('mmiCodeResult', data => { - console.log(`callback: data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.on('audioDeviceChange')10+ +## -on\(type: 'audioDeviceChange', callback: Callback\\): void + -Subscribes to audio device change events. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ----------------------------------------------- | ---- | --------------------------------------------------- | -| type | string | Yes | Audio device change. This field has a fixed value of **audioDeviceChange**.| -| callback | Callback<[AudioDeviceInfo](#audiodeviceinfo10)> | Yes | Callback used to return the result. | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.on('audioDeviceChange', data => { - console.log(`callback: data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.off('audioDeviceChange')10+ +## -off\(type: 'audioDeviceChange', callback?: Callback\\): void + -Unsubscribes from **audioDeviceChange** events. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory | Description | +| | | | | | -------- | ---------------------------------------------------------- | ---- | --------------------------------------------------- | -| type | string | Yes | Audio device change. This field has a fixed value of **audioDeviceChange**.| -| callback | Callback<[AudioDeviceInfo](#audiodeviceinfo10)> | No | Callback used to return the result. If this parameter is not set, no subscription cancellation result will be received. | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.off('audioDeviceChange', data => { - console.log(`callback: data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.isNewCallAllowed8+ +## -isNewCallAllowed\(callback: AsyncCallback\\): void + -Checks whether a new call is allowed. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ---------------------------- | ---- | ---------- | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.| +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.isNewCallAllowed((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.isNewCallAllowed8+ +## -isNewCallAllowed\(\): Promise\ + -Checks whether a new call is allowed. This API uses a promise to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Return value** + -| Type | Description | +| | | | ---------------------- | --------------------------- | -| Promise<boolean> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let promise = call.isNewCallAllowed(); -promise.then(data => { - console.log(`isNewCallAllowed success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`isNewCallAllowed fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | + + + + + + + + + + ``` -## call.separateConference8+ +## -separateConference\(callId: number, callback: AsyncCallback\\): void + -Separates calls from a conference call. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------- | ---- | ---------- | -| callId | number | Yes | Call ID. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.separateConference(1, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.separateConference8+ +## -separateConference\(callId: number\): Promise\ + -Separates calls from a conference call. This API uses a promise to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ------ | ---- | -------- | -| callId | number | Yes | Call ID.| +| | | | | -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.separateConference(1).then(() => { - console.log(`separateConference success.`); -}).catch((err) => { - console.error(`separateConference fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.getCallRestrictionStatus8+ +## -getCallRestrictionStatus\(slotId: number, type: CallRestrictionType, callback: AsyncCallback\\): void + -Obtains the call restriction status. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.GET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| -| type | [CallRestrictionType](#callrestrictiontype8) | Yes | Call restriction type. | -| callback | AsyncCallback<[RestrictionStatus](#restrictionstatus8)> | Yes | Callback used to return the result. | +| | | |

| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -call.getCallRestrictionStatus(0, 1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.getCallRestrictionStatus8+ +## -getCallRestrictionStatus\(slotId: number, type: CallRestrictionType\): Promise\ + -Obtains the call restriction status. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.GET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | -------------------------------------------- | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| -| type | [CallRestrictionType](#callrestrictiontype8) | Yes | Call restriction type. | +| | | |

| +| | | | | -**Return value** + -| Type | Description | +| | | | ------------------------------------------------------- | --------------------------- | -| Promise<[RestrictionStatus](#restrictionstatus8)> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -let promise = call.getCallRestrictionStatus(0, 1); -promise.then(data => { - console.log(`getCallRestrictionStatus success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`getCallRestrictionStatus fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + ``` -## call.setCallRestriction8+ +## -setCallRestriction\(slotId: number, info: CallRestrictionInfo, callback: AsyncCallback\\): void + -Sets the call restriction status. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------------------------- | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| -| info | [CallRestrictionInfo](#callrestrictioninfo8) | Yes | Call restriction information. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| | | |

| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -let callRestrictionInfo={ - type: 1, - password: "123456", - mode: 1 +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + } -call.setCallRestriction(0, callRestrictionInfo, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); + + + ``` -## call.setCallRestriction8+ +## -setCallRestriction\(slotId: number, info: CallRestrictionInfo\): Promise\ + -Sets the call restriction status. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | -------------------------------------------- | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| -| info | [CallRestrictionInfo](#callrestrictioninfo8) | Yes | Call restriction information. | +| | | |

| +| | | | | -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -let callRestrictionInfo={ - type: 1, - password: "123456", - mode: 1 +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + } -call.setCallRestriction(0, callRestrictionInfo).then(() => { - console.log(`setCallRestriction success.`); -}).catch((err) => { - console.error(`setCallRestriction fail, promise: err->${JSON.stringify(err)}`); -}); + + + + + ``` -## call.getCallTransferInfo8+ +## -getCallTransferInfo\(slotId: number, type: CallTransferType, callback: AsyncCallback\\): void + -Obtains call transfer information. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.GET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| -| type | [CallTransferType](#calltransfertype8) | Yes | Call transfer type. | -| callback | AsyncCallback<[CallTransferResult](#calltransferresult8)> | Yes | Callback used to return the result. | +| | | |

| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -call.getCallTransferInfo(0, call.CallTransferType.TRANSFER_TYPE_BUSY, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.getCallTransferInfo8+ +## -getCallTransferInfo\(slotId: number, type: CallTransferType\): Promise\ + -Obtains call transfer information. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.GET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | -------------------------------------- | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| -| type | [CallTransferType](#calltransfertype8) | Yes | Call transfer type. | +| | | |

| +| | | | | -**Return value** + -| Type | Description | +| | | | --------------------------------------------------------- | --------------------------- | -| Promise<[CallTransferResult](#calltransferresult8)> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -let promise = call.getCallTransferInfo(0, call.CallTransferType.TRANSFER_TYPE_BUSY); -promise.then(data => { - console.log(`getCallTransferInfo success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`getCallTransferInfo fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + ``` -## call.setCallTransfer8+ +## -setCallTransfer\(slotId: number, info: CallTransferInfo, callback: AsyncCallback\\): void + -Sets call transfer information. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------------------- | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| -| info | [CallTransferInfo](#calltransferinfo8) | Yes | Call transfer information. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| | | |

| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -let callTransferInfo={ - transferNum: "111", - type: 1, - settingType: 1 +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + } -call.setCallTransfer(0, callTransferInfo, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); + + + ``` -## call.setCallTransfer8+ +## -setCallTransfer\(slotId: number, info: CallTransferInfo\): Promise\ + -Sets call transfer information. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ------------------------------------- | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| -| info | [CallTransferInfo](#calltransferinfo8) | Yes | Call transfer information. | +| | | |

| +| | | | | -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -let callTransferInfo={ - transferNum: "111", - type: 1, - settingType: 1 +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + } -call.setCallTransfer(0, callTransferInfo).then(() => { - console.log(`setCallTransfer success.`); -}).catch((err) => { - console.error(`setCallTransfer fail, promise: err->${JSON.stringify(err)}`); -}); + + + + + ``` -## call.isRinging8+ +## -isRinging\(callback: AsyncCallback\\): void + -Checks whether the ringtone is playing. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ---------------------------- | ---- | ---------- | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.| +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.isRinging((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.isRinging8+ +## -isRinging\(\): Promise\ + -Checks whether the ringtone is playing. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Return value** + -| Type | Description | +| | | | ---------------------- | --------------------------- | -| Promise<boolean> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let promise = call.isRinging(); -promise.then(data => { - console.log(`isRinging success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`isRinging fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + ``` -## call.setMuted8+ +## -setMuted\(callback: AsyncCallback\\): void + -Sets call muting. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------- | ---- | ---------- | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.setMuted((err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.setMuted8+ +## -setMuted\(\): Promise\ + -Sets call muting. This API uses a promise to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.setMuted().then(() => { - console.log(`setMuted success.`); -}).catch((err) => { - console.error(`setMuted fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.cancelMuted8+ +## -cancelMuted\(callback: AsyncCallback\\): void + -Cancels call muting. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------- | ---- | ---------- | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.cancelMuted((err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.cancelMuted8+ +## -cancelMuted\(\): Promise\ + -Cancels call muting. This API uses a promise to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.cancelMuted().then(() => { - console.log(`cancelMuted success.`); -}).catch((err) => { - console.error(`cancelMuted fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.setAudioDevice8+ +## -setAudioDevice\(device: AudioDevice, callback: AsyncCallback\\): void + -Sets the audio device for a call. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | -| -------- | ---------------------------- | ---- | ---------- | -| device | [AudioDevice](#audiodevice8) | Yes | Audio device.| -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| - -**Error codes** - -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). - -| ID| Error Message | -| -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.setAudioDevice(1, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); -``` - - -## call.setAudioDevice9+ - -setAudioDevice\(device: AudioDevice, options: AudioDeviceOptions, callback: AsyncCallback\\): void - -Sets the audio device for a call. This API uses an asynchronous callback to return the result. - -**System API**: This is a system API. - -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------ | ---- | -------------- | -| device | [AudioDevice](#audiodevice8) | Yes | Audio device. | -| options | [AudioDeviceOptions](#audiodeviceoptions9) | Yes | Audio device parameters.| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| | | | | +| -------- | ---------------------------- | ---- | ---------- | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let audioDeviceOptions={ - bluetoothAddress: "IEEE 802-2014" +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + } -call.setAudioDevice(1, audioDeviceOptions, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); + + + ``` +## -## call.setAudioDevice9+ + -setAudioDevice\(device: AudioDevice, options?: AudioDeviceOptions\): Promise\ + -Sets the audio device for a call based on the specified options. This API uses a promise to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | -| ------- | ------------------------------------------ | ---- | ------------------ | -| device | [AudioDevice](#audiodevice8) | Yes | Audio device. | -| options | [AudioDeviceOptions](#audiodeviceoptions9) | No | Audio device parameters.| +| | | | | +| -------- | ---------------------------- | ---- | ---------- | +| | | | | -**Return value** + -| Type | Description | -| ------------------- | ------------------------------- | -| Promise<void> | Promise used to return the result.| +| | | +| ------------------- | --------------------------- | +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let audioDeviceOptions={ - bluetoothAddress: "IEEE 802-2014" +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + } -call.setAudioDevice(1, audioDeviceOptions).then(() => { - console.log(`setAudioDevice success.`); -}).catch((err) => { - console.error(`setAudioDevice fail, promise: err->${JSON.stringify(err)}`); -}); + + + + + ``` -## call.joinConference8+ +## -joinConference\(mainCallId: number, callNumberList: Array\, callback: AsyncCallback\\): void + -Joins a conference call. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------------- | ------------------------- | ---- | --------------- | -| mainCallId | number | Yes | Main call ID. | -| callNumberList | Array | Yes | List of call numbers.| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| | | | | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let callNumberList: Array = [ - "138XXXXXXXX" -]; -call.joinConference(1, callNumberList, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + ``` -## call.joinConference8+ +## -joinConference\(mainCallId: number, callNumberList: Array\\): Promise\ + -Joins a conference call. This API uses a promise to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------------- | -------------- | ---- | --------------- | -| mainCallId | number | Yes | Main call ID. | -| callNumberList | Array | Yes | List of call numbers.| +| | | | | +| | | | | -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let callNumberList: Array = [ - "138XXXXXXXX" -]; -call.joinConference(1, callNumberList).then(() => { - console.log(`joinConference success.`); -}).catch((err) => { - console.error(`joinConference fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + + + ``` -## call.updateImsCallMode8+ +## -updateImsCallMode\(callId: number, mode: ImsCallMode, callback: AsyncCallback\\): void + -Updates the IMS call mode. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ---------------------------- | ---- | -------------- | -| callId | number | Yes | Call ID. | -| mode | [ImsCallMode](#imscallmode8) | Yes | IMS call mode.| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| | | | | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.updateImsCallMode(1, 1, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.updateImsCallMode8+ +## -updateImsCallMode\(callId: number, mode: ImsCallMode\): Promise\ + -Updates the IMS call mode. This API uses a promise to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ---------------------------- | ---- | -------------- | -| callId | number | Yes | Call ID. | -| mode | [ImsCallMode](#imscallmode8) | Yes | IMS call mode.| +| | | | | +| | | | | -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.updateImsCallMode(1, 1).then(() => { - console.log(`updateImsCallMode success.`); -}).catch((err) => { - console.error(`updateImsCallMode fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.enableImsSwitch8+ +## -enableImsSwitch\(slotId: number, callback: AsyncCallback\\): void + -Enables the IMS service. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------- | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| | | |

| +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.enableImsSwitch(0, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.enableImsSwitch8+ +## -enableImsSwitch\(slotId: number\): Promise\ + -Enables the IMS service. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ------ | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| | | |

| -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.enableImsSwitch(0).then(() => { - console.log(`enableImsSwitch success.`); -}).catch((err) => { - console.error(`enableImsSwitch fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.disableImsSwitch8+ +## -disableImsSwitch\(slotId: number, callback: AsyncCallback\\): void + -Disables the IMS service. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------- | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| | | |

| +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.disableImsSwitch(0, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.disableImsSwitch8+ +## -disableImsSwitch\(slotId: number\): Promise\ + -Disables the IMS service. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ------ | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| | | |

| -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result. | +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.disableImsSwitch(0).then(() => { - console.log(`disableImsSwitch success.`); -}).catch((err) => { - console.error(`disableImsSwitch fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.isImsSwitchEnabled8+ +## -isImsSwitchEnabled\(slotId: number, callback: AsyncCallback\\): void + -Checks whether the IMS service is enabled. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ---------------------------- | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| -| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. | +| | | |

| +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -call.isImsSwitchEnabled(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.isImsSwitchEnabled8+ +## -isImsSwitchEnabled\(slotId: number\): Promise\ + -Checks whether the IMS service is enabled. This API uses a promise to return the result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ------ | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| | | |

| -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let promise = call.isImsSwitchEnabled(0); -promise.then(data => { - console.log(`isImsSwitchEnabled success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`isImsSwitchEnabled fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + ``` -## call.closeUnfinishedUssd10+ +## -closeUnfinishedUssd\(slotId: number, callback: AsyncCallback\\): void + -Cancels the unfinished USSD services. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | -------- | ------------------------- | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| | | |

| +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let slotId = 0; -call.closeUnfinishedUssd(slotId, (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + ``` -## call.closeUnfinishedUssd10+ +## -closeUnfinishedUssd\(slotId: number\): Promise\ + -Cancels the unfinished USSD services. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name| Type | Mandatory| Description | +| | | | | | ------ | ------ | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| | | |

| -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result. | +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let slotId = 0; -call.closeUnfinishedUssd(slotId).then(() => { - console.log(`closeUnfinishedUssd success.`); -}).catch((err) => { - console.error(`closeUnfinishedUssd fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + ``` -## call.setVoNRState10+ +## -setVoNRState\(slotId: number, state: VoNRState, callback: AsyncCallback\\): void + -Sets the status of the VoNR switch. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ----------------------------- | ---- | ---------------------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | -| state | [VoNRState](#vonrstate10) | Yes | Status of the VoNR switch. | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. Callback used to return the result. The value **true** indicates that the operation is successful, and value **false** indicates the opposite.| +| | | |

| +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let slotId = 0; -let state = 1; -call.setVoNRState(slotId, state, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + ``` -## call.setVoNRState10+ +## -setVoNRState\(slotId: number, state: VoNRState\): Promise\ + -Sets the status of the VoNR switch. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.SET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ----------------------------- | ---- | ------------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | -| state | [VoNRState](#vonrstate10) | Yes | Status of the VoNR switch. | +| | | |

| +| | | | | -**Return value** + -| Type | Description | +| | | | ---------------------- | --------------------------------------------- | -| Promise<boolean> | Promise used to return the result. | +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let slotId = 0; -let state = 1; -call.setVoNRState(slotId, state).then(() => { - console.log(`setVoNRState success, promise: data->${JSON.stringify(data)}`); -}).catch((err) => { - console.error(`setVoNRState fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + + ``` -## call.getVoNRState10+ +## -getVoNRState\(slotId: number, callback: AsyncCallback\\): void + -Obtains the status of the VoNR switch. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.GET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory | Description | +| | | | | | ----------- | --------------------------------------------- | ---- | ------------------------------------------------------ | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | -| callback | AsyncCallback<[VoNRState](#vonrstate10)>| Yes | Callback used to return the result. | +| | | |

| +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let slotId = 0; -call.getVoNRState(slotId, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + ``` -## call.getVoNRState10+ +## -getVoNRState\(slotId: number\): Promise\ + -Obtains the status of the VoNR switch. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.GET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ----------------------------- | ---- | ------------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| | | |

| -**Return value** + -| Type | Description | +| | | | ---------------------------------------- | ------------------------------------------- | -| Promise<[VoNRState](#vonrstate10)> | Promise used to return the result. | +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let slotId = 0; -let promise = call.getVoNRState(slotId); -promise.then(data => { - console.log(`getVoNRState success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`getVoNRState fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + + ``` -## call.canSetCallTransferTime10+ +## -canSetCallTransferTime\(slotId: number, callback: AsyncCallback\\): void + -Checks whether the call forwarding time can be set. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.GET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ----------------------------- | ---- | ----------------------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. Callback used to return the result. The value **true** indicates that the call forwarding time can be set, and the value **false** indicates the opposite.| +| | | |

| +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let slotId = 0; -call.canSetCallTransferTime(slotId, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + ``` -## call.canSetCallTransferTime10+ +## -canSetCallTransferTime\(slotId: number\): Promise\ + -Checks whether the call forwarding time can be set. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required permission**: ohos.permission.GET_TELEPHONY_STATE + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ----------------------------- | ---- | ------------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| | | |

| -**Return value** + -| Type | Description | +| | | | ---------------------- | --------------------------------------------- | -| Promise<boolean> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - -**Example** - -```js -let slotId = 0; -call.canSetCallTransferTime(slotId).then(() => { - console.log(`canSetCallTransferTime success, promise: data->${JSON.stringify(data)}`); -}).catch((err) => { - console.error(`canSetCallTransferTime fail, promise: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + + ``` -## call.inputDialerSpecialCode10+ +## -inputDialerSpecialCode\(inputCode: string, callback: AsyncCallback\\): void + -Performs a secret code broadcast. This API uses an asynchronous callback to return the result. + -**System API**: This is a system API. + -**Required Permissions**: ohos.permission.PLACE_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ---------------------------- | ---- | ----------------------------------------- | -| inputCode | string | Yes | Secret code, for example, **2846579** (project menu).| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| | | | | +| | | | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -call.inputDialerSpecialCode('2846579', (err) => { - console.log(`callback: err->${JSON.stringify(err)}`); -}); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + ``` -## call.inputDialerSpecialCode10+ +## -inputDialerSpecialCode\(inputCode: string\): Promise\ + -Performs a secret code broadcast. This API uses a promise to return the result. + -**System API**: This is a system API. + -**Required Permissions**: ohos.permission.PLACE_CALL + -**System capability**: SystemCapability.Telephony.CallManager + -**Parameters** + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ---------------------------- | ---- | ----------------------------------------- | -| inputCode | string | Yes | Secret code, for example, **2846579** (project menu).| +| | | | | -**Return value** + -| Type | Description | +| | | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| | | -**Error codes** + -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + -| ID| Error Message | +| | | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | - -**Example** - -```js -try { - call.inputDialerSpecialCode('2846579'); - console.log(`inputDialerSpecialCode success`); -} catch (error) { - console.log(`inputDialerSpecialCode fail, promise: err->${JSON.stringify(error)}`); +| | | +| | | +| | | +| | | +| | | +| | | + + + + + + + + + } ``` -## DialOptions +## -Provides an option for determining whether a call is a video call. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Type | Mandatory| Description | +| | | | | | ------------------------ | ---------------------------------- | ---- | ----------------------------------------------------------------------------------------------- | -| extras | boolean | No | Indication of a video call.
- **true**: video call
- **false** (default): voice call | -| accountId 8+ | number | No | Account ID.
- **0**: card slot 1
- **1**: card slot 2
This is a system API. | -| videoState 8+ | [VideoStateType](#videostatetype7) | No | Video state type. This is a system API. | -| dialScene 8+ | [DialScene](#dialscene8) | No | Dialup scenario. This is a system API. | -| dialType 8+ | [DialType](#dialtype8) | No | Dialup type. This is a system API. | +| | | |

| +| | | |


| +| | | | | +| | | | | +| | | | | -## DialCallOptions9+ +## -Defines options for initiating a call. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Type | Mandatory| Description | +| | | | | | ------------------------ | ---------------------------------- | ---- | ------------------------------------------- | -| accountId 9+ | number | No | Account ID.
- **0**: card slot 1
- **1**: card slot 2
| -| videoState 9+ | [VideoStateType](#videostatetype7) | No | Video state type. | -| dialScene 9+ | [DialScene](#dialscene8) | No | Dialup scenario. | -| dialType 9+ | [DialType](#dialtype8) | No | Dialup type. | +| | | |


| +| | | | | +| | | | | +| | | | | -## CallState +## -Enumerates call states. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | ------------------ | ---- | ------------------------------------------------------------ | -| CALL_STATE_UNKNOWN | -1 | The call status fails to be obtained and is unknown. | -| CALL_STATE_IDLE | 0 | No call is in progress. | -| CALL_STATE_RINGING | 1 | The call is in the ringing or waiting state. | -| CALL_STATE_OFFHOOK | 2 | At least one call is in dialing, active, or on hold, and no new incoming call is ringing or waiting.| +| | | | +| | | | +| | | | +| | | | -## EmergencyNumberOptions7+ +## -Provides an option for determining whether a number is an emergency number for the SIM card in the specified slot. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Type | Mandatory| Description | +| | | | | | ------ | ------ | ---- | ---------------------------------------------- | -| slotId | number | No | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| | | |

| -## NumberFormatOptions7+ +## -Provides an option for number formatting. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Type | Mandatory| Description | +| | | | | | ----------- | ------ | ---- | ---------------------------------------------------------- | -| countryCode | string | No | Country code, for example, **CN** (China). All country codes are supported. The default value is **CN**.| +| | | | | -## ImsCallMode8+ +## -Enumerates IMS call modes. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | ---------------------- | ---- | ------------------ | -| CALL_MODE_AUDIO_ONLY | 0 | Audio call only. | -| CALL_MODE_SEND_ONLY | 1 | Sending calls only. | -| CALL_MODE_RECEIVE_ONLY | 2 | Receiving calls only. | -| CALL_MODE_SEND_RECEIVE | 3 | Sending and receiving calls.| -| CALL_MODE_VIDEO_PAUSED | 4 | Pausing video calls. | +| | | | +| | | | +| | | | +| | | | +| | | | -## VoNRState10+ +## -Enumerates VoNR switch states. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | ---------------------- | ---- | ----------------- | -| VONR_STATE_OFF | 0 | Disabled. | -| VONR_STATE_ON | 1 | Enabled. | +| | | | +| | | | -## AudioDevice8+ +## -Enumerates audio devices. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | -| -------------------- | ---- | ------------ | -| DEVICE_EARPIECE | 0 | Headset device. | -| DEVICE_SPEAKER | 1 | Speaker device.| -| DEVICE_WIRED_HEADSET | 2 | Wired headset device.| -| DEVICE_BLUETOOTH_SCO | 3 | Bluetooth SCO device. | -| DEVICE_MIC | 4 | Microphone device| +| | | | | +| --------------------------------- | ------------------------------------- | ---- | ---------------- | +| | | | | +| | | | | -## AudioDeviceType10+ +## -Enumerates audio device types. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | -------------------- | ---- | ----------- | -| DEVICE_EARPIECE | 0 | Headset device. | -| DEVICE_SPEAKER | 1 | Speaker device. | -| DEVICE_WIRED_HEADSET | 2 | Wired headset device.| -| DEVICE_BLUETOOTH_SCO | 3 | Bluetooth SCO device. | +| | | | +| | | | +| | | | +| | | | -## AudioDeviceInfo10+ +## -Defines the audio device information. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Type | Mandatory | Description | +| | | | | | --------------------------------- | ------------------------------------- | ---- | ---------------- | -| audioDeviceList 10+ | [Array\](#audiodevice8) | Yes | Audio device list. | -| currentAudioDevice 10+ | [AudioDevice](#audiodevice8) | Yes | Audio device type. | -| isMuted 10+ | boolean | Yes | Whether the audio device is muted. | +| | | | | +| | | | | +| | | | | -## CallRestrictionType8+ +## -Enumerates call restriction types. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | --------------------------------------------- | ---- | -------------------------- | -| RESTRICTION_TYPE_ALL_INCOMING | 0 | Barring of all incoming calls. | -| RESTRICTION_TYPE_ALL_OUTGOING | 1 | Barring of all outgoing calls. | -| RESTRICTION_TYPE_INTERNATIONAL | 2 | Barring of international calls. | -| RESTRICTION_TYPE_INTERNATIONAL_EXCLUDING_HOME | 3 | Barring of international calls except those in the home country.| -| RESTRICTION_TYPE_ROAMING_INCOMING | 4 | Barring of incoming roaming calls. | -| RESTRICTION_TYPE_ALL_CALLS | 5 | Barring of all calls. | -| RESTRICTION_TYPE_OUTGOING_SERVICES | 6 | Barring of outgoing services. | -| RESTRICTION_TYPE_INCOMING_SERVICES | 7 | Barring of incoming services. | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | -## CallTransferInfo8+ +## -Defines the call transfer information. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Type | Mandatory| Description | +| | | | | | ------------------------ | ---------------------------------------------------- | ---- | ---------------- | -| transferNum | string | Yes | Call transfer number. | -| type | [CallTransferType](#calltransfertype8) | Yes | Call transfer type. | -| settingType | [CallTransferSettingType](#calltransfersettingtype8) | Yes | Call transfer setting type.| -| startHour9+ | number | No | Hour in the start time.| -| startMinute9+ | number | No | Minute in the start time.| -| endHour9+ | number | No | Minute in the end time.| -| endMinute9+ | number | No | Minute in the end time.| +| | | | | +| | | | | +| | | | | +| | | | | +| | | | | +| | | | | +| | | | | -## CallTransferType8+ +## -Enumerates call transfer types. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | --------------------------- | ---- | ------------ | -| TRANSFER_TYPE_UNCONDITIONAL | 0 | Call forwarding unconditional. | -| TRANSFER_TYPE_BUSY | 1 | Call forwarding busy. | -| TRANSFER_TYPE_NO_REPLY | 2 | Call forwarding on no reply. | -| TRANSFER_TYPE_NOT_REACHABLE | 3 | Call forwarding on no user not reachable.| +| | | | +| | | | +| | | | +| | | | -## CallTransferSettingType8+ +## -Enumerates call transfer setting types. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | -------------------------- | ---- | ------------ | -| CALL_TRANSFER_DISABLE | 0 | Disabling of call transfer.| -| CALL_TRANSFER_ENABLE | 1 | Enabling of call transfer.| -| CALL_TRANSFER_REGISTRATION | 3 | Registration of call transfer.| -| CALL_TRANSFER_ERASURE | 4 | Erasing of call transfer.| +| | | | +| | | | +| | | | +| | | | -## CallAttributeOptions7+ +## -Defines the call attribute options. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Type | Mandatory| Description | +| | | | | | --------------- | ---------------------------------------- | ---- | -------------- | -| accountNumber | string | Yes | Account number. | -| speakerphoneOn | boolean | Yes | Speakerphone on.| -| accountId | number | Yes | Account ID. | -| videoState | [VideoStateType](#videostatetype7) | Yes | Video state type. | -| startTime | number | Yes | Start time. | -| isEcc | boolean | Yes | Whether the call is an ECC. | -| callType | [CallType](#calltype7) | Yes | Call type. | -| callId | number | Yes | Call ID. | -| callState | [DetailedCallState](#detailedcallstate7) | Yes | Detailed call state. | -| conferenceState | [ConferenceState](#conferencestate7) | Yes | Conference state. | +| | | | | +| | | | | +| | | | | +| | | | | +| | | | | +| | | | | +| | | | | +| | | | | +| | | | | +| | | | | -## ConferenceState7+ +## -Enumerates conference states. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | ---------------------------- | ---- | -------------- | -| TEL_CONFERENCE_IDLE | 0 | Idle state. | -| TEL_CONFERENCE_ACTIVE | 1 | Active state. | -| TEL_CONFERENCE_DISCONNECTING | 2 | Disconnecting state. | -| TEL_CONFERENCE_DISCONNECTED | 3 | Disconnected state.| +| | | | +| | | | +| | | | +| | | | -## CallType7+ +## -Enumerates call types. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | ------------- | ---- | ------------ | -| TYPE_CS | 0 | CS call. | -| TYPE_IMS | 1 | IMS call. | -| TYPE_OTT | 2 | OTT call. | -| TYPE_ERR_CALL | 3 | Error call type.| +| | | | +| | | | +| | | | +| | | | -## VideoStateType7+ +## -Video state type. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | ---------- | ---- | -------- | -| TYPE_VOICE | 0 | Voice state.| -| TYPE_VIDEO | 1 | Video state.| +| | | | +| | | | -## DetailedCallState7+ +## -Enumerates detailed call states. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | ------------------------- | ---- | -------------- | -| CALL_STATUS_ACTIVE | 0 | Active state. | -| CALL_STATUS_HOLDING | 1 | Hold state. | -| CALL_STATUS_DIALING | 2 | Dialing state. | -| CALL_STATUS_ALERTING | 3 | Alerting state. | -| CALL_STATUS_INCOMING | 4 | Incoming state. | -| CALL_STATUS_WAITING | 5 | Waiting state. | -| CALL_STATUS_DISCONNECTED | 6 | Disconnected state.| -| CALL_STATUS_DISCONNECTING | 7 | Disconnecting state. | -| CALL_STATUS_IDLE | 8 | Idle state. | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | -## CallRestrictionInfo8+ +## -Defines the call restriction information. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Type | Mandatory| Description | +| | | | | | -------- | -------------------------------------------- | ---- | ------------ | -| type | [CallRestrictionType](#callrestrictiontype8) | Yes | Call restriction type.| -| password | string | Yes | Password. | -| mode | [CallRestrictionMode](#callrestrictionmode8) | Yes | Call restriction mode.| +| | | | | +| | | | | +| | | | | -## CallRestrictionMode8+ +## -Enumerates call restriction modes. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | ----------------------------- | ---- | ------------ | -| RESTRICTION_MODE_DEACTIVATION | 0 | Call restriction deactivated.| -| RESTRICTION_MODE_ACTIVATION | 1 | Call restriction activated.| +| | | | +| | | | -## CallEventOptions8+ +## -Defines the call event options. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Type | Mandatory| Description | +| | | | | | ------- | ------------------------------------------ | ---- | -------------- | -| eventId | [CallAbilityEventId](#callabilityeventid8) | Yes | Call ability event ID.| +| | | | | -## CallAbilityEventId8+ +## -Enumerates call ability event IDs. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | ------------------------ | ---- | --------------- | -| EVENT_DIAL_NO_CARRIER | 1 | No available carrier during dialing. | -| EVENT_INVALID_FDN_NUMBER | 2 | Invalid FDN.| +| | | | +| | | | -## DialScene8+ +## -Enumerates dialup scenarios. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | --------------- | ---- | ------------ | -| CALL_NORMAL | 0 | Common call. | -| CALL_PRIVILEGED | 1 | Privileged call. | -| CALL_EMERGENCY | 2 | Emergency call.| +| | | | +| | | | +| | | | -## DialType8+ +## -Enumerates dialup types. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | -------------------- | ---- | ---------------- | -| DIAL_CARRIER_TYPE | 0 | Carrier. | -| DIAL_VOICE_MAIL_TYPE | 1 | Voice mail.| -| DIAL_OTT_TYPE | 2 | OTT. | +| | | | +| | | | +| | | | -## RejectMessageOptions7+ +## -Defines options for the call rejection message. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Type | Mandatory| Description | +| | | | | | -------------- | ------ | ---- | -------- | -| messageContent | string | Yes | Message content.| +| | | | | -## CallTransferResult8+ +## -Defines the call transfer result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Type | Mandatory| Description | +| | | | | | ------------------------ | ---------------------------------- | ---- | ---------------- | -| status | [TransferStatus](#transferstatus8) | Yes | Call transfer status. | -| number | string | Yes | Call transfer number. | -| startHour9+ | number | Yes | Hour in the start time.| -| startMinute9+ | number | Yes | Minute in the start time.| -| endHour9+ | number | Yes | Minute in the end time.| -| endMinute9+ | number | Yes | Minute in the end time.| +| | | | | +| | | | | +| | | | | +| | | | | +| | | | | +| | | | | -## CallWaitingStatus7+ +## -Enumerates call waiting states. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | -------------------- | ---- | ------------ | -| CALL_WAITING_DISABLE | 0 | Call waiting disabled.| -| CALL_WAITING_ENABLE | 1 | Call waiting enabled.| +| | | | +| | | | -## RestrictionStatus8+ +## -Enumerates call restriction states. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | ------------------- | ---- | -------- | -| RESTRICTION_DISABLE | 0 | Call restriction disabled.| -| RESTRICTION_ENABLE | 1 | Call restriction enabled.| +| | | | +| | | | -## TransferStatus8+ +## -Enumerates call transfer states. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | ---------------- | ---- | -------- | -| TRANSFER_DISABLE | 0 | Call transfer disabled.| -| TRANSFER_ENABLE | 1 | Call transfer enabled.| +| | | | +| | | | -## DisconnectedDetails9+ +## -Defines the call disconnection cause. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Type | Mandatory| Description | +| | | | | | ------- | ------------------------------------------ | ---- | --------------- | -| reason | [DisconnectedReason](#disconnectedreason8) | Yes | Call disconnection cause. | -| message | string | Yes | Call ending message.| +| | | | | +| | | | | -## DisconnectedReason8+ +## -Enumerates call disconnection causes. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | ------------------------------------------------------------ | ---- | --------------------------------------- | -| UNASSIGNED_NUMBER | 1 | Unallocated (unassigned) number. | -| NO_ROUTE_TO_DESTINATION | 3 | No route to destination. | -| CHANNEL_UNACCEPTABLE | 6 | Channel unacceptable. | -| OPERATOR_DETERMINED_BARRING | 8 | Operator determined barring (ODB). | -| CALL_COMPLETED_ELSEWHERE9+ | 13 | Call completed elsewhere. | -| NORMAL_CALL_CLEARING | 16 | Normal call clearing. | -| USER_BUSY | 17 | User busy. | -| NO_USER_RESPONDING | 18 | No user responding. | -| USER_ALERTING_NO_ANSWER | 19 | User alerting, no answer. | -| CALL_REJECTED | 21 | Call rejected. | -| NUMBER_CHANGED | 22 | Number changed. | -| CALL_REJECTED_DUE_TO_FEATURE_AT_THE_DESTINATION9+ | 24 | Call rejected due to feature at the destination.| -| FAILED_PRE_EMPTION9+ | 25 | Failed preemption. | -| NON_SELECTED_USER_CLEARING9+ | 26 | Non-selected user clearing. | -| DESTINATION_OUT_OF_ORDER | 27 | Destination out of order. | -| INVALID_NUMBER_FORMAT | 28 | Invalid number format (incomplete number). | -| FACILITY_REJECTED9+ | 29 | Facility rejected. | -| RESPONSE_TO_STATUS_ENQUIRY9+ | 30 | Response to status enquiry. | -| NORMAL_UNSPECIFIED9+ | 31 | Normal, unspecified. | -| NO_CIRCUIT_CHANNEL_AVAILABLE9+ | 34 | No circuit/channel available. | -| NETWORK_OUT_OF_ORDER | 38 | Network fault. | -| TEMPORARY_FAILURE | 41 | Temporary failure. | -| SWITCHING_EQUIPMENT_CONGESTION9+ | 42 | Switching equipment congestion. | -| ACCESS_INFORMATION_DISCARDED9+ | 43 | Access information discarded. | -| REQUEST_CIRCUIT_CHANNEL_NOT_AVAILABLE9+ | 44 | Requested circuit/channel unavailable | -| RESOURCES_UNAVAILABLE_UNSPECIFIED9+ | 47 | Resources unavailable, unspecified. | -| QUALITY_OF_SERVICE_UNAVAILABLE9+ | 49 | QoS unavailable. | -| REQUESTED_FACILITY_NOT_SUBSCRIBED9+ | 50 | Requested facility not subscribed. | -| INCOMING_CALLS_BARRED_WITHIN_THE_CUG9+ | 55 | Incoming calls barred within the CUG. | -| BEARER_CAPABILITY_NOT_AUTHORIZED9+ | 57 | Bearer capability not authorized. | -| BEARER_CAPABILITY_NOT_PRESENTLY_AVAILABLE9+ | 58 | Bearer capability presently available. | -| SERVICE_OR_OPTION_NOT_AVAILABLE_UNSPECIFIED9+ | 63 | Service or option not available, unspecified. | -| BEARER_SERVICE_NOT_IMPLEMENTED9+ | 65 | Bearer service not implemented. | -| ACM_EQUALTO_OR_GREATER_THAN_THE_MAXIMUM_VALUE9+ | 68 | ACM greater than or equal to the maximum value. | -| REQUESTED_FACILITY_NOT_IMPLEMENTED9+ | 69 | Requested facility not implemented. | -| ONLY_RESTRICTED_DIGITAL_INFO_BEARER_CAPABILITY_IS_AVAILABLE9+ | 70 | Only restricted digital information bearer capability available. | -| SERVICE_OR_OPTION_NOT_IMPLEMENTED_UNSPECIFIED9+ | 79 | Service or option not implemented, unspecified. | -| INVALID_TRANSACTION_IDENTIFIER_VALUE9+ | 81 | Invalid transaction identifier value. | -| USER_NOT_MEMBER_OF_CUG9+ | 87 | User not member of CUG. | -| INCOMPATIBLE_DESTINATION9+ | 88 | Incompatible destination. | -| INVALID_TRANSIT_NETWORK_SELECTION9+ | 91 | Invalid transit network selection. | -| SEMANTICALLY_INCORRECT_MESSAGE9+ | 95 | Semantically incorrect message. | -| INVALID_MANDATORY_INFORMATION9+ | 96 | Invalid mandatory information. | -| MESSAGE_TYPE_NON_EXISTENT_OR_NOT_IMPLEMENTED9+ | 97 | Message type non-existent or not implemented. | -| MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE9+ | 98 | Message type not compatible with protocol state. | -| INFORMATION_ELEMENT_NON_EXISTENT_OR_NOT_IMPLEMENTED9+ | 99 | IE non-existent or not implemented. | -| CONDITIONAL_IE_ERROR9+ | 100 | Conditional IE error. | -| MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE9+ | 101 | Message not compatible with protocol state. | -| RECOVERY_ON_TIMER_EXPIRED9+ | 102 | Recovery on timer expiry. | -| PROTOCOL_ERROR_UNSPECIFIED9+ | 111 | Protocol error, unspecified. | -| INTERWORKING_UNSPECIFIED9+ | 127 | Interworking, unspecified. | -| CALL_BARRED9+ | 240 | Call barred. | -| FDN_BLOCKED9+ | 241 | FDN blocked. | -| IMSI_UNKNOWN_IN_VLR9+ | 242 | IMSI unknown in VLR. | -| IMEI_NOT_ACCEPTED9+ | 243 | IMEI not accepted. | -| DIAL_MODIFIED_TO_USSD9+ | 244 | Dial request modified to USSD request. | -| DIAL_MODIFIED_TO_SS9+ | 245 | Dial request modified to SS request. | -| DIAL_MODIFIED_TO_DIAL9+ | 246 | Dial request modified to dial with different number. | -| RADIO_OFF9+ | 247 | Radio off. | -| OUT_OF_SERVICE9+ | 248 | Out of service. | -| NO_VALID_SIM9+ | 249 | No valid SIM. | -| RADIO_INTERNAL_ERROR9+ | 250 | Radio internal error. | -| NETWORK_RESP_TIMEOUT9+ | 251 | Network response timeout. | -| NETWORK_REJECT9+ | 252 | Request rejected by network. | -| RADIO_ACCESS_FAILURE9+ | 253 | Radio access failure. | -| RADIO_LINK_FAILURE9+ | 254 | Radio link failure. | -| RADIO_LINK_LOST9+ | 255 | Radio link lost. | -| RADIO_UPLINK_FAILURE9+ | 256 | Radio uplink failure. | -| RADIO_SETUP_FAILURE9+ | 257 | Radio setup failure. | -| RADIO_RELEASE_NORMAL9+ | 258 | Radio release normal. | -| RADIO_RELEASE_ABNORMAL9+ | 259 | Radio release abnormal. | -| ACCESS_CLASS_BLOCKED9+ | 260 | Access class blocked. | -| NETWORK_DETACH9+ | 261 | Network detached. | -| INVALID_PARAMETER | 1025 | Invalid parameter. | -| SIM_NOT_EXIT | 1026 | SIM not exit. | -| SIM_PIN_NEED | 1027 | SIM PIN needed. | -| CALL_NOT_ALLOW | 1029 | Call not allowed. | -| SIM_INVALID | 1045 | No valid SIM. | -| UNKNOWN | 1279 | Unknown reason. | - -## MmiCodeResults9+ - -Defines the MMI code result. - -**System API**: This is a system API. - -**System capability**: SystemCapability.Telephony.CallManager - -| Name | Type | Mandatory| Description | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | + +## + + + + + + + +| | | | | | ------- | -------------------------------- | ---- | --------------- | -| result | [MmiCodeResult](#mmicoderesult9) | Yes | MMI code result.| -| message | string | Yes | MMI code message.| +| | | | | +| | | | | -## MmiCodeResult9+ +## -Defines the MMI code result. + -**System API**: This is a system API. + -**System capability**: SystemCapability.Telephony.CallManager + -| Name | Value | Description | +| | | | | ---------------- | ---- | ------------- | -| MMI_CODE_SUCCESS | 0 | Success.| -| MMI_CODE_FAILED | 1 | Failure.| - -## AudioDeviceOptions9+ - -Defines audio device options. - -**System API**: This is a system API. - -**System capability**: SystemCapability.Telephony.CallManager - -| Name | Type | Mandatory| Description | -| ---------------- | ------ | ---- | -------- | -| bluetoothAddress | string | No | Bluetooth address.| +| | | | +| | | | diff --git a/en/application-dev/reference/apis/js-apis-devicestatus-cooperate.md b/en/application-dev/reference/apis/js-apis-devicestatus-cooperate.md index cada3fc494deced44ecf150dae636786f167bb3a..737c91f0036c5217469a254aaad8974913eed1d9 100644 --- a/en/application-dev/reference/apis/js-apis-devicestatus-cooperate.md +++ b/en/application-dev/reference/apis/js-apis-devicestatus-cooperate.md @@ -455,3 +455,4 @@ Represents a screen hopping message notification. | COOPERATE_ACTIVATE_FAIL | 4 | Starting screen hopping fails.| | COOPERATE_DEACTIVATE_SUCCESS | 5 | Stopping screen hopping succeeds.| | COOPERATE_DEACTIVATE_FAIL | 6 | Stopping screen hopping fails.| +| COOPERATE_SESSION_DISCONNECTED | 7 | The screen hopping session is disconnected.| diff --git a/en/application-dev/reference/apis/js-apis-hilog.md b/en/application-dev/reference/apis/js-apis-hilog.md index 54355b12b723cf9cad06f5a4064568d5d772bea5..d643cbf1d8accc521e5baf11fa3e1ee23ce2734c 100644 --- a/en/application-dev/reference/apis/js-apis-hilog.md +++ b/en/application-dev/reference/apis/js-apis-hilog.md @@ -1,8 +1,9 @@ # @ohos.hilog (HiLog) -The **hilog** module allows your applications or services to output logs based on the specified type, level, and format string. Such logs help you learn the running status of applications and better debug programs. +The HiLog subsystem allows your applications or services to output logs based on the specified type, level, and format string. Such logs help you learn the running status of applications and better debug programs. -> **NOTE**
+> **NOTE** +> > 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. ## Modules to Import @@ -23,7 +24,7 @@ Checks whether logs are printable based on the specified service domain, log tag | Name| Type | Mandatory| Description | | ------ | --------------------- | ---- | ------------------------------------------------------------ | -| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.| +| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**.
You can define the value as required.| | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| | level | [LogLevel](#loglevel) | Yes | Log level. | @@ -41,11 +42,11 @@ hilog.isLoggable(0x0001, "testTag", hilog.LogLevel.INFO); ## LogLevel -Enumerates the log levels. +Log level. **System capability**: SystemCapability.HiviewDFX.HiLog -| Name | Value| Description | +| Name | Value | Description | | ----- | ------ | ------------------------------------------------------------ | | DEBUG | 3 | Log level used to record more detailed process information than INFO logs to help developers analyze service processes and locate faults.| | INFO | 4 | Log level used to record key service process nodes and exceptions that occur during service running,
for example, no network signal or login failure.
These logs should be recorded by the dominant module in the service to avoid repeated logging conducted by multiple invoked modules or low-level functions.| @@ -67,9 +68,9 @@ DEBUG logs are not recorded in official versions by default. They are available | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.| +| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**.
You can define the value as required.| | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| -| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.| +| format | string | Yes | Format string used to output logs in a specified format. It can contain several elements, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\**.| | args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.| **Example** @@ -98,9 +99,9 @@ Prints INFO logs. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.| +| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**.
You can define the value as required. | | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| -| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.| +| format | string | Yes | Format string used to output logs in a specified format. It can contain several elements, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\**.| | args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.| **Example** @@ -129,9 +130,9 @@ Prints WARN logs. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.| +| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**.
You can define the value as required. | | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| -| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.| +| format | string | Yes | Format string used to output logs in a specified format. It can contain several elements, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\**.| | args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.| **Example** @@ -160,9 +161,9 @@ Prints ERROR logs. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.| +| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**.
You can define the value as required. | | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| -| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.| +| format | string | Yes | Format string used to output logs in a specified format. It can contain several elements, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\**.| | args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.| **Example** @@ -191,9 +192,9 @@ Prints FATAL logs. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.| +| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**.
You can define the value as required. | | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| -| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.| +| format | string | Yes | Format string used to output logs in a specified format. It can contain several elements, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\**.| | args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.| **Example** @@ -209,3 +210,43 @@ If `"hello"` is filled in `%{public}s` and `3` in `%{private}d`, the output log ``` 08-05 12:21:47.579 2695-2703/com.example.myapplication F 00001/testTag: hello World ``` + +## Parameter Format + +Parameters in the log are printed in the following format: + +%[private flag]specifier + +| Privacy Flag| Description| +| ------------ | ---- | +| Unspecified | The default value is **private**, indicating that parameters in plaintext are not printed.| +| private | Prints private parameters.| +| public | Prints parameters in plaintext.| + +| Specifier| Description| Example| +| ------------ | ---- | ---- | +| d/i | Prints logs of the **number** and **bigint** types.| 123 | +| s | Prints logs of the **string undefined bool** and **null** types.| "123" | + +**Example** +```js +let obj2 = new Object({name:"Jack", age:22}); +let isBol = true; +let bigNum = BigInt(1234567890123456789); +hilog.info(0x0001, "jsHilogTest", "print object: %{public}s", JSON.stringify(obj2)); +hilog.info(0x0001, "jsHilogTest", "private flag: %{private}s %s, print null: %{public}s", "hello", "world", null); +hilog.info(0x0001, "jsHilogTest", "print undefined: %{public}s", undefined); +hilog.info(0x0001, "jsHilogTest", "print number: %{public}d %{public}i", 123, 456); +hilog.info(0x0001, "jsHilogTest", "print bigNum: %{public}d %{public}i", bigNum, bigNum); +hilog.info(0x0001, "jsHilogTest", "print boolean: %{public}s", isBol); +``` + +Log printing result: +``` +08-09 13:26:29.094 2266 2266 I A00001/jsHilogTest: print object: {"name":"Jack","age":22} +08-09 13:26:29.094 2266 2266 I A00001/jsHilogTest: private flag: , print null: null +08-09 13:26:29.094 2266 2266 I A00001/jsHilogTest: print undefined: undefined +08-09 13:26:29.094 2266 2266 I A00001/jsHilogTest: print number: 123 456 +08-09 13:26:29.095 2266 2266 I A00001/jsHilogTest: print bigNum: 1234567890123456768 1234567890123456768 +08-09 13:26:29.095 2266 2266 I A00001/jsHilogTest: print boolean: true +``` diff --git a/en/application-dev/reference/apis/js-apis-i18n.md b/en/application-dev/reference/apis/js-apis-i18n.md index fe9a116b82379a17518731accb378484eb71dfc2..74c5bad2a012c1b222eca0c87c56b318fababbff 100644 --- a/en/application-dev/reference/apis/js-apis-i18n.md +++ b/en/application-dev/reference/apis/js-apis-i18n.md @@ -1059,7 +1059,7 @@ Creates a **PhoneNumberFormat** object. | Name | Type | Mandatory | Description | | ------- | ---------------------------------------- | ---- | ---------------- | | country | string | Yes | Country or region to which the phone number to be formatted belongs.| -| options | [PhoneNumberFormatOptions](#phonenumberformatoptions9) | No | Options of the **PhoneNumberFormat** object. | +| options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | No | Options of the **PhoneNumberFormat** object. | **Example** ```js @@ -1149,7 +1149,7 @@ Obtains the home location of a phone number. ``` -## PhoneNumberFormatOptions9+ +## PhoneNumberFormatOptions8+ Defines the options for this PhoneNumberFormat object. @@ -1157,7 +1157,7 @@ Defines the options for this PhoneNumberFormat object. | Name | Type | Readable | Writable | Description | | ---- | ------ | ---- | ---- | ---------------------------------------- | -| type | string | Yes | Yes | Format type of a phone number. The available options are as follows: E164, INTERNATIONAL, NATIONAL, and RFC3966.| +| type | string | Yes | Yes | Format type of a phone number. The available options are as follows: E164, INTERNATIONAL, NATIONAL, and RFC3966.
- In API version 8, **type** is mandatory.
- In API version 9 or later, **type** is optional.| ## UnitInfo8+ @@ -1786,8 +1786,8 @@ Obtains a list of IDs supported by the **Transliterator** object. **Example** ```ts - // ids = ["ASCII-Latin", "Accents-Any", "Amharic-Latin/BGN", ...], 671 IDs supported in total - // Each ID consists of two parts separated by a hyphen (-). The format is source-destination. + // A total of 671 IDs are supported. One ID is comprised of two parts separated by a hyphen (-) in the format of source-destination. For example, in **ids = ["Han-Latin","Latin-ASCII", "Amharic-Latin/BGN","Accents-Any", ...]**, **Han-Latin** indicates conversion from Chinese to Latin, and **Amharic-Latin** indicates conversion from Amharic to Latin. + // For more information, see ISO-15924. let ids = I18n.Transliterator.getAvailableIDs(); ``` @@ -2210,6 +2210,157 @@ Enumerates text normalization modes. | NFKD | 4 | NFKD.| +## SystemLocaleManager10+ + + +### constructor10+ + +constructor() + +Creates a **SystemLocaleManager** object. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Global.I18n + +**Example** + ```js + let systemLocaleManager= new I18n.SystemLocaleManager(); + ``` + + +### getLanguageInfoArray10+ + +getLanguageInfoArray(languages: Array<string>, options?: SortOptions): Array<LocaleItem> + +Obtains the language sorting array. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Global.I18n + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------- | ---- | ------------- | +| languages | Array<string> | Yes | List of languages to be sorted.| +| options | [SortOptions](#sortoptions10) | No | Language sorting option.| + +**Return value** + +| Type | Description | +| ----------------- | -------------------- | +| Array<[LocaleItem](#localeitem10)> | Language list after sorting.| + +**Error codes** + +For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md). + +| ID | Error Message | +| ------ | ---------------------- | +| 890001 | param value not valid | + +**Example** + ```js + // Assume that the system language is zh-Hans, the system region is CN, and the system locale is zh-Hans-CN. + let systemLocaleManager = new I18n.SystemLocaleManager(); + var languages = ["zh-Hans", "en-US", "pt", "ar"]; + var sortOptions = {locale: "zh-Hans-CN", isUseLocalName: true, isSuggestedFirst: true}; + try { + // The language list after sorting is [zh-Hans, en-US, pt, ar]. + let sortedLanguages = systemLocaleManager.getLanguageInfoArray(languages, sortOptions); + } catch(error) { + console.error(`call systemLocaleManager.getLanguageInfoArray failed, error code: ${error.code}, message: ${error.message}.`); + } + ``` + + +### getRegionInfoArray10+ + +getRegionInfoArray(regions: Array<string>, options?: SortOptions): Array<LocaleItem> + +Obtains the country/region sorting array. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Global.I18n + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------- | ---- | ------------- | +| regions | Array<string> | Yes | List of countries/regions to be sorted.| +| options | [SortOptions](#sortoptions10) | No | Country/region sorting option.| + +**Return value** + +| Type | Description | +| ----------------- | -------------------- | +| Array<[LocaleItem](#localeitem10)> | Country/region list after sorting.| + +**Error codes** + +For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md). + +| ID | Error Message | +| ------ | ---------------------- | +| 890001 | param value not valid | + +**Example** + ```js + // Assume that the system language is zh-Hans, the system region is CN, and the system locale is zh-Hans-CN. + let systemLocaleManager = new I18n.SystemLocaleManager(); + var regions = ["CN", "US", "PT", "EG"]; + var sortOptions = {locale: "zh-Hans-CN", isUseLocalName: false, isSuggestedFirst: true}; + try { + // The country/region list after sorting is [CN, EG, US, PT]. + let sortedRegions = systemLocaleManager.getRegionInfoArray(regions, sortOptions); + } catch(error) { + console.error(`call systemLocaleManager.getRegionInfoArray failed, error code: ${error.code}, message: ${error.message}.`); + } + ``` + + +## LocaleItem10+ + +Represents the list of languages or countries/regions sorted by **SystemLocaleManager**. + +**System capability**: SystemCapability.Global.I18n + +| Name | Type | Mandatory | Description | +| --------------- | --------------- | ------ | --------------------------------------- | +| id | string | Yes | Language code or country/region code, for example, **zh** or **CN**. | +| suggestionType | [SuggestionType](#suggestiontype10) | Yes | Language or country/region suggestion type. | +| displayName | string | Yes | Displayed name of the ID in the locale of **SystemLocaleManager**.| +| localName | string | No | Local name of the ID. | + + +## SuggestionType10+ + +Represents the language or country/region suggestion type. + +**System capability**: SystemCapability.Global.I18n + +| Name | Value | Description | +| ---------------------- | ---- | ---- | +| SUGGESTION_TYPE_NONE | 0x00 | Not a recommended language or country/region.| +| SUGGESTION_TYPE_RELATED| 0x01 | Country/region recommended by the system language or language recommended by the system country/region.| +| SUGGESTION_TYPE_SIM | 0x02 | Language recommended by the country/region of the SIM card.| + + +## SortOptions10+ + +Represents the language or country/region sorting option. + +**System capability**: SystemCapability.Global.I18n + +| Name | Type | Mandatory| Description | +| --------------- | --------------- | ---- | --------------------------------------- | +| locale | string | No | System locale, for example, **zh-Hans-CN**. | +| isUseLocalName | boolean | No | Whether to use the local name for sorting. | +| isSuggestedFirst | boolean | No | Whether to move the recommended language or country/region to the top in the sorting result. | + + ## I18n.getDisplayCountry(deprecated) getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string diff --git a/en/application-dev/reference/apis/js-apis-inputdevice.md b/en/application-dev/reference/apis/js-apis-inputdevice.md index 880a4db59490823365a39f4678bca7440ab07323..d07a232664c8e095c9dd7dbf33f41b571c33f3e4 100644 --- a/en/application-dev/reference/apis/js-apis-inputdevice.md +++ b/en/application-dev/reference/apis/js-apis-inputdevice.md @@ -1,15 +1,21 @@ # @ohos.multimodalInput.inputDevice (Input Device) -The **inputDevice** module implements listening for connection, disconnection, and update events of input devices and displays information about input devices. For example, it can be used to listen for mouse insertion and removal and obtain information such as the ID, name, and pointer speed of the mouse. -> **NOTE**
+The **inputDevice** module allows you to listen for hot swap events of input devices and query information about input devices. + + +> **NOTE** +> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + ## Modules to Import + ```js import inputDevice from '@ohos.multimodalInput.inputDevice'; ``` + ## inputDevice.getDeviceList9+ getDeviceList(callback: AsyncCallback<Array<number>>): void @@ -20,25 +26,23 @@ Obtains the IDs of all input devices. This API uses an asynchronous callback to **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------------- | ---- | ---------- | +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | | callback | AsyncCallback<Array<number>> | Yes | Callback used to return the result.| **Example** ```js try { - inputDevice.getDeviceIds((error, ids) => { + inputDevice.getDeviceList((error, ids) => { if (error) { - console.log(`Failed to get device list. - error code=${err.code} msg=${err.message}`); + console.log(`Failed to get device id list, error: ${JSON.stringify(error, [`code`, `message`])}`); return; } - this.data = ids; - console.log("The device ID list is: " + ids); + console.log(`Device id list: ${JSON.stringify(ids)}`); }); } catch (error) { - console.info("getDeviceList " + error.code + " " + error.message); + console.log(`Failed to get device id list, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -52,19 +56,19 @@ Obtains the IDs of all input devices. This API uses a promise to return the resu **Return value** -| Name | Description | -| ---------------------------------- | ------------------------------- | +| Parameters | Description | +| ---------------------------------- | ------------------------------------------- | | Promise<Array<number>> | Promise used to return the result.| **Example** ```js try { - inputDevice.getDeviceIds().then((ids) => { - console.log("The device ID list is: " + ids); + inputDevice.getDeviceList().then((ids) => { + console.log(`Device id list: ${JSON.stringify(ids)}`); }); } catch (error) { - console.info("getDeviceList " + error.code + " " + error.message); + console.log(`Failed to get device id list, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -88,16 +92,15 @@ Obtains information about an input device. This API uses an asynchronous callbac ```js // Obtain the name of the device whose ID is 1. try { - inputDevice.getDeviceInfo(1, (error, inputDevice) => { + inputDevice.getDeviceInfo(1, (error, deviceData) => { if (error) { - console.log(`Failed to get device information. - error code=${err.code} msg=${err.message}`); + console.log(`Failed to get device info, error: ${JSON.stringify(error, [`code`, `message`])}`); return; } - console.log("The device name is: " + inputDevice.name); + console.log(`Device info: ${JSON.stringify(deviceData)}`); }); } catch (error) { - console.info("getDeviceInfo " + error.code + " " + error.message); + console.log(`Failed to get device info, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -117,7 +120,7 @@ Obtains information about an input device. This API uses a promise to return the **Return value** -| Name | Description | +| Parameters | Description | | -------------------------------------------------- | ------------------------------- | | Promise<[InputDeviceData](#inputdevicedata)> | Promise used to return the result.| @@ -126,20 +129,19 @@ Obtains information about an input device. This API uses a promise to return the ```js // Obtain the name of the device whose ID is 1. try { - inputDevice.getDeviceInfo(id).then((inputDevice) => { - console.log("The device name is: " + inputDevice.name); + inputDevice.getDeviceInfo(1).then((deviceData) => { + console.log(`Device info: ${JSON.stringify(deviceData)}`); }); } catch (error) { - console.info("getDeviceInfo " + error.code + " " + error.message); + console.log(`Failed to get device info, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` - ## inputDevice.on9+ on(type: "change", listener: Callback<DeviceListener>): void -Enables listening for hot swap events of an input device. +Enables listening for device hot swap events. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice @@ -156,13 +158,13 @@ Enables listening for hot swap events of an input device. let isPhysicalKeyboardExist = true; try { inputDevice.on("change", (data) => { - console.log("type: " + data.type + ", deviceId: " + data.deviceId); - inputDevice.getKeyboardType(data.deviceId, (err, ret) => { - console.log("The keyboard type of the device is: " + ret); - if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') { + console.log(`Device event info: ${JSON.stringify(data)}`); + inputDevice.getKeyboardType(data.deviceId, (err, type) => { + console.log("The keyboard type is: " + type); + if (type == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') { // The physical keyboard is connected. isPhysicalKeyboardExist = true; - } else if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'remove') { + } else if (type == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'remove') { // The physical keyboard is disconnected. isPhysicalKeyboardExist = false; } @@ -170,7 +172,7 @@ try { }); // Check whether the soft keyboard is open based on the value of isPhysicalKeyboardExist. } catch (error) { - console.info("oninputdevcie " + error.code + " " + error.message); + console.log(`Get device info failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -178,7 +180,7 @@ try { off(type: "change", listener?: Callback<DeviceListener>): void -Disables listening for hot swap events of an input device. +Disables listening for device hot swap events. This API is called before the application exits. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice @@ -192,33 +194,29 @@ Disables listening for hot swap events of an input device. **Example** ```js -callback: function(data) { - console.log("type: " + data.type + ", deviceId: " + data.deviceId); -} +function callback(data) { + console.log(`Report device event info: ${JSON.stringify(data, [`type`, `deviceId`])}`); +}; try { - inputDevice.on("change", this.callback); + inputDevice.on("change", callback); } catch (error) { - console.info("oninputdevcie " + error.code + " " + error.message) + console.log(`Listen device event failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } -// Enable listening for hot swap events of an input device. -inputDevice.on("change", listener); - // Disable this listener. try { - inputDevice.off("change", this.callback); + inputDevice.off("change", callback); } catch (error) { - console.info("offinputdevcie " + error.code + " " + error.message) + console.log(`Cancel listening device event failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } // Disable all listeners. try { inputDevice.off("change"); } catch (error) { - console.info("offinputdevcie " + error.code + " " + error.message); + console.log(`Cancel all listening device event failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } -// By default, the soft keyboard is closed when listening is disabled. ``` ## inputDevice.getDeviceIds(deprecated) @@ -233,9 +231,9 @@ This API is deprecated since API version 9. You are advised to use [inputDevice. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ----- | -| callback | AsyncCallback<Array<number>> | Yes | Callback used to return the result.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| callback | AsyncCallback<Array<number>> | Yes | Callback used to return the result.| **Example** @@ -248,7 +246,6 @@ inputDevice.getDeviceIds((error, ids) => { console.log(`Device id list: ${JSON.stringify(ids)}`); }); ``` -``` ## inputDevice.getDeviceIds(deprecated) @@ -262,8 +259,8 @@ This API is deprecated since API version 9. You are advised to use [inputDevice. **Return value** -| Parameter | Description | -| ---------------------------------- | ------------------- | +| Parameters | Description | +| ---------------------------------- | ------------------------------------------- | | Promise<Array<number>> | Promise used to return the result.| **Example** @@ -286,10 +283,10 @@ This API is deprecated since API version 9. You are advised to use [inputDevice. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------------------------- | -| deviceId | number | Yes | ID of the input device. | -| callback | AsyncCallback<[InputDeviceData](#inputdevicedata)> | Yes | Callback used to return the result, which is an **InputDeviceData** object.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------------------------- | ---- | -------------------------------- | +| deviceId | number | Yes | ID of the input device. | +| callback | AsyncCallback<[InputDeviceData](#inputdevicedata)> | Yes | Callback used to return the result, which is an **InputDeviceData** object.| **Example** @@ -316,14 +313,14 @@ This API is deprecated since API version 9. You are advised to use [inputDevice. **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory| Description | | -------- | ------ | ---- | ------------ | -| deviceId | number | Yes | ID of the input device.| +| deviceId | number | Yes | ID of the input device.| **Return value** -| Parameter | Description | -| ---------------------------------------- | ------------------- | +| Parameters | Description | +| -------------------------------------------------- | ----------------------------------- | | Promise<[InputDeviceData](#inputdevicedata)> | Promise used to return the result.| **Example** @@ -345,22 +342,22 @@ Obtains the key codes supported by the input device. This API uses an asynchrono **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------------ | ---- | --------------------------------- | -| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| -| keys | Array<KeyCode> | Yes | Key codes to be queried. A maximum of five key codes can be specified. | -| callback | AsyncCallback<Array<boolean>> | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------- | ---- | ------------------------------------------------------ | +| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| +| keys | Array<KeyCode> | Yes | Key codes to be queried. A maximum of five key codes can be specified. | +| callback | AsyncCallback<Array<boolean>> | Yes | Callback used to return the result. | **Example** ```js // Check whether the input device whose ID is 1 supports key codes 17, 22, and 2055. try { - inputDevice.supportKeys(1, [17, 22, 2055], (error, ret) => { - console.log("The query result is as follows: " + ret); + inputDevice.supportKeys(1, [17, 22, 2055], (error, supportResult) => { + console.log(`Query result: ${JSON.stringify(supportResult)}`); }); } catch (error) { - console.info("supportKeys " + error.code + " " + error.message); + console.log(`Query failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -374,15 +371,15 @@ Obtains the key codes supported by the input device. This API uses a promise to **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------------------- | ---- | --------------------------------- | -| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| -| keys | Array<KeyCode> | Yes | Key codes to be queried. A maximum of five key codes can be specified. | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------------------------------------ | +| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| +| keys | Array<KeyCode> | Yes | Key codes to be queried. A maximum of five key codes can be specified. | **Return value** -| Parameter | Description | -| ----------------------------------- | ------------------- | +| Parameters | Description | +| ----------------------------------- | ------------------------------- | | Promise<Array<boolean>> | Promise used to return the result.| **Example** @@ -390,11 +387,11 @@ Obtains the key codes supported by the input device. This API uses a promise to ```js // Check whether the input device whose ID is 1 supports key codes 17, 22, and 2055. try { - inputDevice.supportKeys(1, [17, 22, 2055]).then((ret) => { - console.log("The query result is as follows: " + ret); + inputDevice.supportKeys(1, [17, 22, 2055]).then((supportResult) => { + console.log(`Query result: ${JSON.stringify(supportResult)}`); }); } catch (error) { - console.info("supportKeys " + error.code + " " + error.message); + console.log(`Query failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -408,41 +405,46 @@ Obtains the keyboard type of an input device. This API uses an asynchronous call **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------------------------------- | -| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| -| callback | AsyncCallback<[KeyboardType](#keyboardtype9)> | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | +| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| +| callback | AsyncCallback<[KeyboardType](#keyboardtype9)> | Yes | Callback used to return the result. | **Example** ```js // Query the keyboard type of the input device whose ID is 1. try { - inputDevice.getKeyboardType(1, (error, number) => { + inputDevice.getKeyboardType(1, (error, type) => { if (error) { - console.log(`Failed to get keyboardtype. - error code=${err.code} msg=${err.message}`); + console.log(`Failed to get keyboard type, error: ${JSON.stringify(error, [`code`, `message`])}`); return; } - console.log("The keyboard type of the device is: " + number); + console.log(`Keyboard type: ${JSON.stringify(type)}`); }); } catch (error) { - console.info("getKeyboardType " + error.code + " " + error.message); + console.log(`Failed to get keyboard type, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` ## inputDevice.getKeyboardType9+ -getKeyboardType(deviceId: number,): Promise<KeyboardType> +getKeyboardType(deviceId: number): Promise<KeyboardType> -Obtains the keyboard type of an input device. This API uses a promise to return the result. +Obtains the keyboard type of an input device. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ------------------------------------------------------------ | +| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| + **Return value** -| Parameter | Description | -| ---------------------------------------- | ------------------- | +| Parameters | Description | +| --------------------------------------------- | ------------------------------- | | Promise<[KeyboardType](#keyboardtype9)> | Promise used to return the result.| **Example** @@ -450,11 +452,137 @@ Obtains the keyboard type of an input device. This API uses a promise to return ```js // Query the keyboard type of the input device whose ID is 1. try { - inputDevice.getKeyboardType(1).then((number) => { - console.log("The keyboard type of the device is: " + number); + inputDevice.getKeyboardType(1).then((type) => { + console.log(`Keyboard type: ${JSON.stringify(type)}`); + }); +} catch (error) { + console.log(`Failed to get keyboard type, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputDevice.setKeyboardRepeatDelay10+ + +setKeyboardRepeatDelay(delay: number, callback: AsyncCallback<void>): void + +Sets the keyboard repeat delay. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ------------------------------------------------------------ | +| delay | number | Yes | Keyboard repeat delay, in ms. The value range is [300 ms, 1000 ms] and the default value is **500**.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| + +**Example** + +```js +try { + inputDevice.setKeyboardRepeatDelay(350, (error) => { + if (error) { + console.log(`Set keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + return; + } + console.log(`Set keyboard repeat delay success`); + }); +} catch (error) { + console.log(`Set keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputDevice.setKeyboardRepeatDelay10+ + +setKeyboardRepeatDelay(delay: number): Promise<void> + +Sets the keyboard repeat delay. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----------------------------------- | +| delay | number | Yes | Keyboard repeat delay, in ms. The value range is [300, 1000] and the default value is **500**.| + +**Return value** + +| Parameters | Description | +| ------------------- | ---------------- | +| Promise<void> | Promise used to return the result.| + +**Example** + +```js +try { + inputDevice.setKeyboardRepeatDelay(350).then(() => { + console.log(`Set keyboard repeat delay success`); + }); +} catch (error) { + console.log(`Set keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputDevice.setKeyboardRepeatRate10+ + +setKeyboardRepeatRate(rate: number, callback: AsyncCallback<void>): void + +Sets the keyboard repeat rate. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ------------------------------------------------------------ | +| rate | number | Yes | Keyboard repeat rate, in ms/time. The value range is [36, 100] and the default value is 50.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| + +**Example** + +```js +try { + inputDevice.setKeyboardRepeatRate(60, (error) => { + if (error) { + console.log(`Set keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + return; + } + console.log(`Set keyboard repeat rate success`); + }); +} catch (error) { + console.log(`Set keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputDevice.setKeyboardRepeatRate10+ + +setKeyboardRepeatRate(rate: number): Promise<void> + +Sets the keyboard repeat rate. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----------------------------------- | +| rate | number | Yes | Keyboard repeat rate, in ms/time. The value range is [36, 100] and the default value is 50.| + +**Return value** + +| Parameters | Description | +| ------------------- | ---------------- | +| Promise<void> | Promise used to return the result.| + +**Example** + +```js +try { + inputDevice.setKeyboardRepeatRate(60).then(() => { + console.log(`Set keyboard repeat rate success`); }); } catch (error) { - console.info("getKeyboardType " + error.code + " " + error.message); + console.log(`Set keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -496,15 +624,15 @@ Defines the axis type of an input device. | Name | Type | Readable | Writable | Description | | --------- | ------ | ---- | ---- | ------- | -| touchmajor | string | Yes| No| touchmajor axis. | -| touchminor | string | Yes| No| touchminor axis. | -| toolminor | string | Yes| No| toolminor axis. | -| toolmajor | string | Yes| No| toolmajor axis. | +| touchmajor | string | Yes| No| **touchmajor** axis. | +| touchminor | string | Yes| No| **touchminor** axis. | +| toolminor | string | Yes| No| **toolminor** axis. | +| toolmajor | string | Yes| No| **toolmajor** axis. | | orientation | string | Yes| No| Orientation axis.| | pressure | string | Yes| No| Pressure axis. | | x | string | Yes| No| X axis. | | y | string | Yes| No| Y axis. | -| NULL | string | Yes| No| None. | +| null | string | Yes| No| None. | ## AxisRange @@ -524,7 +652,7 @@ Defines the axis range of an input device. ## SourceType9+ -Enumerates the input source types. For example, if a mouse reports an x-axis event, the source of the x-axis is the mouse. +Input source type of the axis. For example, if a mouse reports an x-axis event, the input source of the x-axis is the mouse. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice diff --git a/en/application-dev/reference/apis/js-apis-mindSporeLite.md b/en/application-dev/reference/apis/js-apis-mindSporeLite.md new file mode 100644 index 0000000000000000000000000000000000000000..dfa2aa0e22c175001ed2598102da9313f7a588b1 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-mindSporeLite.md @@ -0,0 +1,626 @@ +# @ohos.ai.mindSporeLite (Inference) + +The **mindSporeLite** module provides APIs for the MindSpore Lite inference engine to implment model inference. + +MindSpore Lite is an AI engine that implements AI model inference for different hardware devices. It has been used in a wide range of fields, such as image classification, target recognition, facial recognition, and character recognition. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. Unless otherwise stated, the MindSpore model is used in the sample code. +> + +## Modules to Import +```js +import mindSporeLite from '@ohos.ai.mindSporeLite'; +``` + +## Context + +Defines the configuration information of the running environment. + +### Attributes + +**System capability**: SystemCapability.AI.MindSporeLite + + +| Name | Type | Readable| Writable| Description | +| ------ | ------------------------- | ---- | ---- | ------------------------------------------------------------ | +| target | string[] | Yes | Yes | Target backend. The value can be **cpu** or **nnrt**. The default value is **cpu**. | +| cpu | [CpuDevice](#cpudevice) | Yes | Yes | CPU backend device option. Set this parameter set only when **target** is set to **cpu**. The default value is the combination of the default value of each **CpuDevice** option.| +| nnrt | [NNRTDevice](#nnrtdevice) | Yes | Yes | NNRt backend device option. Set this parameter set only when **target** is set to **nnrt**. Currently, this parameter is empty.| + +**Example** + +```js +let context: mindSporeLite.Context = {}; +context.target = ['cpu','nnrt']; +``` + +## CpuDevice + +Defines the CPU backend device option. + +### Attributes + +**System capability**: SystemCapability.AI.MindSporeLite + +| Name | Type | Readable| Writable| Description | +| ---------------------- | ----------------------------------------- | ---- | ---- | ------------------------------------------------------------ | +| threadNum | number | Yes | Yes | Number of runtime threads. The default value is **2**. | +| threadAffinityMode | [ThreadAffinityMode](#threadaffinitymode) | Yes | Yes | Affinity mode for binding runtime threads to CPU cores. The default value is **mindSporeLite.ThreadAffinityMode.NO_AFFINITIES**.| +| threadAffinityCoreList | number[] | Yes | Yes | List of CPU cores bound to runtime threads. Set this parameter only when **threadAffinityMode** is set. If **threadAffinityMode** is set to **mindSporeLite.ThreadAffinityMode.NO_AFFINITIES**, this parameter is empty. The number in the list indicates the SN of the CPU core. The default value is **[]**.| +| precisionMode | string | Yes | Yes | Whether to enable the Float16 inference mode. The value **preferred_fp16** means to enable half-precision inference and the default value **force_fp32** means to disable half-precision inference. Other settings are not supported.| + +**Float16 inference mode**: a mode that uses half-precision inference. Float16 uses 16 bits to represent a number and therefore it is also called half-precision. + +**Example** + +```js +let context: mindSporeLite.Context = {}; +context.cpu = {}; +context.target = ['cpu']; +context.cpu.threadAffinityMode = 0; +context.cpu.precisionMode = 'preferred_fp16'; +context.cpu.threadAffinityCoreList = [0, 1, 2]; +``` + +## NNRTDevice + +Represents an NNRt device. Neural Network Runtime (NNRt) is a bridge that connects the upper-layer AI inference framework to the bottom-layer acceleration chip to implement cross-chip inference and computing of AI models. An NNRt backend can be configured for MindSpore Lite. Currently, this API is not supported. + +**System capability**: SystemCapability.AI.MindSporeLite + +## ThreadAffinityMode + +Specifies the affinity mode for binding runtime threads to CPU cores. + +**System capability**: SystemCapability.AI.MindSporeLite + +| Name | Value | Description | +| ------------------ | ---- | ------------ | +| NO_AFFINITIES | 0 | No affinities. | +| BIG_CORES_FIRST | 1 | Big cores first.| +| LITTLE_CORES_FIRST | 2 | Medium cores first.| + +## mindSporeLite.loadModelFromFile + +loadModelFromFile(model: string, callback: Callback<Model>): void + +Loads the input model from the full path for model inference. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.AI.MindSporeLite + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ------------------------ | +| model | string | Yes | Complete path of the input model. | +| callback | Callback<[Model](#model)> | Yes | Callback used to return the result, which is a **Model** object.| + +**Example** + +```js +let model_file = '/path/to/xxx.ms'; +mindSporeLite.loadModelFromFile(model_file, (result) => { + const modelInputs = result.getInputs(); + console.log(modelInputs[0].name); +}) +``` +## mindSporeLite.loadModelFromFile + +loadModelFromFile(model: string, context: Context, callback: Callback<Model>): void + +Loads the input model from the full path for model inference. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.AI.MindSporeLite + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------- | ---- | ---------------------- | +| model | string | Yes | Complete path of the input model. | +| context | [Context](#context) | Yes| Configuration information of the running environment.| +| callback | Callback<[Model](#model)> | Yes | Callback used to return the result, which is a **Model** object.| + +**Example** + +```js +let context: mindSporeLite.Context = {}; +let context = {'target': ['cpu']}; +let model_file = '/path/to/xxx.ms'; +mindSporeLite.loadModelFromFile(model_file, context, (result) => { + const modelInputs = result.getInputs(); + console.log(modelInputs[0].name); +}) +``` +## mindSporeLite.loadModelFromFile + +loadModelFromFile(model: string, context?: Context): Promise<Model> + +Loads the input model from the full path for model inference. This API uses a promise to return the result. + +**System capability**: SystemCapability.AI.MindSporeLite + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------------------- | ---- | -------------------- | +| model | string | Yes | Complete path of the input model.| +| context | [Context](#context) | No | Configuration information of the running environment.| + +**Return value** + +| Type | Description | +| ------------------------- | ---------------------------- | +| Promise<[Model](#model)> | Promise used to return the result, which is a **Model** object.| + +**Example** + +```js +let model_file = '/path/to/xxx.ms'; +mindSporeLite.loadModelFromFile(model_file).then((result) => { + const modelInputs = result.getInputs(); + console.log(modelInputs[0].name); +}) +``` +## mindSporeLite.loadModelFromBuffer + +loadModelFromBuffer(model: ArrayBuffer, callback: Callback<Model>): void + +Loads the input model from the memory for inference. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.AI.MindSporeLite + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ------------------------ | +| model | ArrayBuffer | Yes | Memory that contains the input model. | +| callback | Callback<[Model](#model)> | Yes | Callback used to return the result, which is a **Model** object.| + +**Example** + +```js +import resourceManager from '@ohos.resourceManager' +@State modelName: string = 'xxx.ms'; +let syscontext = globalThis.context; +syscontext.resourceManager.getRawFileContent(this.modelName).then((buffer) => { + this.modelBuffer = buffer; +}).catch(error => { + console.error('Failed to get buffer, error code: ${error.code},message:${error.message}.'); +}) +mindSporeLite.loadModelFromBuffer(this.modelBuffer.buffer, (result) => { + const modelInputs = result.getInputs(); + console.log(modelInputs[0].name); +}) +``` +## mindSporeLite.loadModelFromBuffer + +loadModelFromBuffer(model: ArrayBuffer, context: Context, callback: Callback<Model>): void + +Loads the input model from the memory for inference. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.AI.MindSporeLite + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------- | ---- | ---------------------- | +| model | ArrayBuffer | Yes | Memory that contains the input model.| +| context | [Context](#context) | Yes | Configuration information of the running environment.| +| callback | Callback<[Model](#model)> | Yes | Callback used to return the result, which is a **Model** object.| + +**Example** + +```js +import resourceManager from '@ohos.resourceManager' +@State modelName: string = 'xxx.ms'; +let syscontext = globalThis.context; +syscontext.resourceManager.getRawFileContent(this.modelName).then((error,buffer) => { + this.modelBuffer = buffer; +}).catch(error => { + console.error('Failed to get buffer, error code: ${error.code},message:${error.message}.'); +}) +let context: mindSporeLite.Context = {}; +context = {'target': ['cpu']}; +mindSporeLite.loadModelFromBuffer(this.modelBuffer.buffer, context, (result) => { + const modelInputs = result.getInputs(); + console.log(modelInputs[0].name); +}) +``` +## mindSporeLite.loadModelFromBuffer + +loadModelFromBuffer(model: ArrayBuffer, context?: Context): Promise<Model> + +Loads the input model from the memory for inference. This API uses a promise to return the result. + +**System capability**: SystemCapability.AI.MindSporeLite + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------------------- | ---- | -------------------- | +| model | ArrayBuffer | Yes | Memory that contains the input model. | +| context | [Context](#context) | No | Configuration information of the running environment.| + +**Return value** + +| Type | Description | +| ------------------------------- | ---------------------------- | +| Promise<[Model](#model)> | Promise used to return the result, which is a **Model** object.| + +**Example** + +```js +import resourceManager from '@ohos.resourceManager' +@State modelName: string = 'xxx.ms'; +let syscontext = globalThis.context; +syscontext.resourceManager.getRawFileContent(this.modelName).then((buffer) => { + this.modelBuffer = buffer; +}).catch(error => { + console.error('Failed to get buffer, error code: ${error.code},message:${error.message}.'); +}) +mindSporeLite.loadModelFromBuffer(model_file).then((result) => { + const modelInputs = result.getInputs(); + console.log(modelInputs[0].name); +}) +``` +## mindSporeLite.loadModelFromFd + +loadModelFromFd(model: number, callback: Callback<Model>): void + +Loads the input model based on the specified file descriptor for inference. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.AI.MindSporeLite + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------- | ---- | ---------------------- | +| model | number | Yes | File descriptor of the input model.| +| callback | Callback<[Model](#model)> | Yes | Callback used to return the result, which is a **Model** object.| + +**Example** + +```js +import fs from '@ohos.file.fs'; +let model_file = '/path/to/xxx.ms'; +let file = await fs.open(model_file, 0); +mindSporeLite.loadModelFromFd(file.fd, (result) => { + const modelInputs = result.getInputs(); + console.log(modelInputs[0].name); +}) +``` +## mindSporeLite.loadModelFromFd + +loadModelFromFd(model: number, context: Context, callback: Callback<Model>): void + +Loads the input model based on the specified file descriptor for inference. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.AI.MindSporeLite + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------- | ---- | ---------------------- | +| model | number | Yes | File descriptor of the input model.| +| context | [Context](#context) | Yes | Configuration information of the running environment.| +| callback | Callback<[Model](#model)> | Yes | Callback used to return the result, which is a **Model** object.| + +**Example** + +```js +import fs from '@ohos.file.fs'; +let model_file = '/path/to/xxx.ms'; +let context : mindSporeLite.Context = {}; +context = {'target': ['cpu']}; +let file = await fs.open(model_file, 0); +mindSporeLite.loadModelFromFd(file.fd, context, (result) => { + const modelInputs = result.getInputs(); + console.log(modelInputs[0].name); +}) +``` +## mindSporeLite.loadModelFromFd + +loadModelFromFd(model: number, context?: Context): Promise< Model> + +Loads the input model based on the specified file descriptor for inference. This API uses a promise to return the result. + +**System capability**: SystemCapability.AI.MindSporeLite + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------------------- | ---- | -------------------- | +| model | number | Yes | File descriptor of the input model. | +| context | [Context](#context) | No | Configuration information of the running environment.| + +**Return value** + +| Type | Description | +| ------------------------- | ---------------------------- | +| Promise<[Model](#model)> | Promise used to return the result, which is a **Model** object.| + +**Example** + +```js +import fs from '@ohos.file.fs'; +let model_file = '/path/to/xxx.ms'; +let file = await fs.open(model_file, 0); +let mindSporeLiteModel = await mindSporeLite.loadModelFromFd(file.fd); +mindSporeLite.loadModelFromFd(file.fd).then((result) => { + const modelInputs = result.getInputs(); + console.log(modelInputs[0].name); +}) +``` +## Model + +Represents a **Model** instance, with properties and APIs defined. + +In the following sample code, you first need to use [loadModelFromFile()](#mindsporeliteloadmodelfromfile), [loadModelFromBuffer()](#mindsporeliteloadmodelfrombuffer), or [loadModelFromFd()](#mindsporeliteloadmodelfromfd) to obtain a **Model** instance before calling related APIs. + +### getInputs + +getInputs(): MSTensor[] + +Obtains the model input for inference. + +**System capability**: SystemCapability.AI.MindSporeLite + +**Return value** + +| Type | Description | +| ----------------------- | ------------------ | +| [MSTensor](#mstensor)[] | **MSTensor** object.| + +**Example** + +```js +let model_file = '/path/to/xxx.ms'; +mindSporeLite.loadModelFromFile(model_file).then((result) => { + const modelInputs = result.getInputs(); + console.log(modelInputs[0].name); +}) +``` +### predict + +predict(inputs: MSTensor[], callback: Callback<Model>): void + +Executes the inference model. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.AI.MindSporeLite + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ----------------------- | ---- | -------------------------- | +| inputs | [MSTensor](#mstensor)[] | Yes | Model input, which is an **MSTensor** object.| +| callback | Callback<[Model](#model)> | Yes | Callback used to return the result, which is a **Model** object.| + +**Example** + +```js +import resourceManager from '@ohos.resourceManager' +@State inputName: string = 'input_data.bin'; +let syscontext = globalThis.context; +syscontext.resourceManager.getRawFileContent(this.inputName).then((buffer) => { + this.inputBuffer = buffer; + let model_file = '/path/to/xxx.ms'; + let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file); + const modelInputs = mindSporeLiteModel.getInputs(); + modelInputs[0].setData(this.inputBuffer.buffer); + result.predict(modelInputs, (result) => { + let output = new Float32Array(result[0].getData()); + for (let i = 0; i < output.length; i++) { + console.log(output[i].toString()); + } + }) +}) +``` +### predict + +predict(inputs: MSTensor[]): Promise<MSTensor[]> + +Executes the inference model. This API uses a promise to return the result. + +**System capability**: SystemCapability.AI.MindSporeLite + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ----------------------- | ---- | -------------------------- | +| inputs | [MSTensor](#mstensor)[] | Yes | Model input, which is an **MSTensor** object.| + +**Return value** + +| Type | Description | +| ----------------------- | ------------------ | +| [MSTensor](#mstensor)[] | **MSTensor** object.| + +**Example** + +```js +import resourceManager from '@ohos.resourceManager' +@State inputName: string = 'input_data.bin'; +let syscontext = globalThis.context; +syscontext.resourceManager.getRawFileContent(this.inputName).then((buffer) => { + this.inputBuffer = buffer; + let model_file = '/path/to/xxx.ms'; + let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file); + const modelInputs = mindSporeLiteModel.getInputs(); + modelInputs[0].setData(this.inputBuffer.buffer); + result.predict(modelInputs).then((result) => { + let output = new Float32Array(result[0].getData()); + for (let i = 0; i < output.length; i++) { + console.log(output[i].toString()); + } + }) +}) +``` + +### resize + +resize(inputs: MSTensor[], dims: Array<Array<number>>): boolean + +Resets the tensor size. + +**System capability**: SystemCapability.AI.MindSporeLite + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | --------------------- | ---- | ----------------------------- | +| inputs | [MSTensor](#mstensor)[] | Yes | Model input, which is an **MSTensor** object. | +| dims | Array<Array<number>> | Yes | Target tensor size.| + +**Return value** + +| Type | Description | +| ------- | ------------------------------------------------------------ | +| boolean | Result indicating whether the setting is successful. The value **true** indicates that the tensor size is successfully reset, and the value **false** indicates the opposite.| + +**Example** + +```js +let model_file = '/path/to/xxx.ms'; +mindSporeLite.loadModelFromFile(model_file).then((mindSporeLiteModel) => { + const modelInputs = mindSporeLiteModel.getInputs(); + let new_dim = new Array([1,32,32,1]); + mindSporeLiteModel.resize(modelInputs, new_dim); +}) +``` + +## MSTensor + +Represents an **MSTensor** instance, with properties and APIs defined. It is a special data structure similar to arrays and matrices. It is the basic data structure used in MindSpore Lite network operations. + +In the following sample code, you first need to use [getInputs()](#getinputs) to obtain an **MSTensor** instance before calling related APIs. + +### Attributes + +**System capability**: SystemCapability.AI.MindSporeLite + +| Name | Type | Readable| Writable| Description | +| ---------- | --------------------- | ---- | ---- | ---------------------------------------------------- | +| name | string | Yes | Yes | Tensor name. The default value is **null**. | +| shape | number[] | Yes | Yes | Tensor dimension array. The default value is **0**. | +| elementNum | number | Yes | Yes | Length of the tensor dimension array. The default value is **0**. | +| dataSize | number | Yes | Yes | Length of tensor data. The default value is **0**. | +| dtype | [DataType](#datatype) | Yes | Yes | Tensor data type. The default value is **0**, indicating **TYPE_UNKNOWN**. | +| format | [Format](#format) | Yes | Yes | Tensor data format. The default value is **-1**, indicating **DEFAULT_FORMAT**.| + +**Example** + +```js +let model_file = '/path/to/xxx.ms'; +mindSporeLite.loadModelFromFile(model_file).then((mindSporeLiteModel) => { + const modelInputs = mindSporeLiteModel.getInputs(); + console.log(modelInputs[0].name); + console.log(modelInputs[0].shape.toString()); + console.log(modelInputs[0].elementNum.toString()); + console.log(modelInputs[0].dtype.toString()); + console.log(modelInputs[0].format.toString()); + console.log(modelInputs[0].dataSize.toString()); +}) +``` + +### getData + +getData(): ArrayBuffer + +Obtains tensor data. + +**System capability**: SystemCapability.AI.MindSporeLite + +**Return value** + +| Type | Description | +| ----------- | -------------------- | +| ArrayBuffer | Pointer to the tensor data.| + +**Example** + +```js +import resourceManager from '@ohos.resourceManager' +@State inputName: string = 'input_data.bin'; +let syscontext = globalThis.context; +syscontext.resourceManager.getRawFileContent(this.inputName).then((buffer) => { + this.inputBuffer = buffer; + let model_file = '/path/to/xxx.ms'; + let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file); + const modelInputs = mindSporeLiteModel.getInputs(); + modelInputs[0].setData(this.inputBuffer.buffer); + result.predict(modelInputs).then((result) => { + let output = new Float32Array(result[0].getData()); + for (let i = 0; i < output.length; i++) { + console.log(output[i].toString()); + } + }) +}) +``` + +### setData + +setData(inputArray: ArrayBuffer): void + +Sets the tensor data. + +**System capability**: SystemCapability.AI.MindSporeLite + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ----------- | ---- | ---------------------- | +| inputArray | ArrayBuffer | Yes | Input data buffer of the tensor.| + +**Example** + +```js +import resourceManager from '@ohos.resourceManager' +@State inputName: string = 'input_data.bin'; +let syscontext = globalThis.context; +syscontext.resourceManager.getRawFileContent(this.inputName).then((buffer) => { + this.inputBuffer = buffer; +}) +let model_file = '/path/to/xxx.ms'; +let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file); +const modelInputs = mindSporeLiteModel.getInputs(); +modelInputs[0].setData(this.inputBuffer.buffer); +``` + +## DataType + +Tensor data type. + +**System capability**: SystemCapability.AI.MindSporeLite + +| Name | Value | Description | +| ------------------- | ---- | ------------------- | +| TYPE_UNKNOWN | 0 | Unknown type. | +| NUMBER_TYPE_INT8 | 32 | Int8 type. | +| NUMBER_TYPE_INT16 | 33 | Int16 type. | +| NUMBER_TYPE_INT32 | 34 | Int32 type. | +| NUMBER_TYPE_INT64 | 35 | Int64 type. | +| NUMBER_TYPE_UINT8 | 37 | UInt8 type. | +| NUMBER_TYPE_UINT16 | 38 | UInt16 type. | +| NUMBER_TYPE_UINT32 | 39 | UInt32 type. | +| NUMBER_TYPE_UINT64 | 40 | UInt64 type. | +| NUMBER_TYPE_FLOAT16 | 42 | Float16 type.| +| NUMBER_TYPE_FLOAT32 | 43 | Float32 type.| +| NUMBER_TYPE_FLOAT64 | 44 | Float64 type.| + +## Format + +Enumerates tensor data formats. + +**System capability**: SystemCapability.AI.MindSporeLite + +| Name | Value | Description | +| -------------- | ---- | --------------------- | +| DEFAULT_FORMAT | -1 | Unknown data format. | +| NCHW | 0 | NCHW format. | +| NHWC | 1 | NHWC format. | +| NHWC4 | 2 | NHWC4 format.| +| HWKC | 3 | HWKC format. | +| HWCK | 4 | HWCK format. | +| KCHW | 5 | KCHW format. | diff --git a/en/application-dev/reference/apis/js-apis-net-connection.md b/en/application-dev/reference/apis/js-apis-net-connection.md index 90174ee7e911031dd208e39669dd671b5b84efa5..0bd9b716421a85fdc2e28582d2799ced24b12109 100644 --- a/en/application-dev/reference/apis/js-apis-net-connection.md +++ b/en/application-dev/reference/apis/js-apis-net-connection.md @@ -58,9 +58,9 @@ Obtains the default active data network. This API uses an asynchronous callback **Parameters** -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\<[NetHandle](#nethandle)> | Yes | Callback used to return the result. If the default activated data network is obtained successfully, err is undefined and data is the default activated data network. Otherwise, err is an error object.| +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback\<[NetHandle](#nethandle)> | Yes | Callback used to return the result. If the default activated data network is obtained successfully, **error** is **undefined** and **data** is the default activated data network. Otherwise, **error** is an error object.| **Error codes** @@ -156,9 +156,9 @@ Obtains the global HTTP proxy configuration of the network. This API uses an asy **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------------------------------------------------------------ | ---- | ---------------- | -| callback | AsyncCallback\<[HttpProxy](#httpproxy)> | Yes | Callback used to return the result. If the global HTTP proxy configuration of the network is obtained successfully, **err** is **undefined** and **data** is the global HTTP proxy configuration. Otherwise, **err** is an error object.| +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback\<[HttpProxy](#httpproxy)> | Yes | Callback used to return the result. If the global HTTP proxy configuration of the network is obtained successfully, **error** is **undefined** and **data** is the global HTTP proxy configuration. Otherwise, **error** is an error object.| **Error codes** @@ -227,10 +227,10 @@ Sets the global HTTP proxy configuration of the network. This API uses an asynch **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------------------------------------------------------------ | ---- | ---------------- | -| httpProxy | [HttpProxy](#httpproxy) | Yes | Global HTTP proxy configuration of the network.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the global HTTP proxy configuration of the network is set successfully, **err** is **undefined**. Otherwise, **err** is an error object.| +| Name | Type | Mandatory| Description | +| --------- | ----------------------- | ---- | ------------------------------------------------------------ | +| httpProxy | [HttpProxy](#httpproxy) | Yes | Global HTTP proxy configuration of the network. | +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the global HTTP proxy configuration of the network is set successfully, **error** is **undefined**. Otherwise, **error** is an error object.| **Error codes** @@ -310,6 +310,71 @@ connection.setGlobalHttpProxy(httpProxy).then(() => { }) ``` +## connection.getDefaultHttpProxy10+ + +getDefaultHttpProxy(callback: AsyncCallback\): void + +Obtains the default HTTP proxy configuration of the network. +If the global proxy is set, the global HTTP proxy configuration is returned. If [setAppNet](#connectionsetappnet) is used to bind the application to the network specified by [NetHandle](#nethandle), the HTTP proxy configuration of this network is returned. In other cases, the HTTP proxy configuration of the default network is returned. +This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Communication.NetManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback<[HttpProxy](#httpproxy)> | Yes | Callback used to return the result. If the global HTTP proxy configuration of the network is obtained successfully, **error** is **undefined** and **data** is the global HTTP proxy configuration. Otherwise, **error** is an error object.| + +**Error codes** + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 2100002 | Operation failed. Cannot connect to service. | +| 2100003 | System internal error. | + +**Example** + +```js +connection.getDefaultHttpProxy((error, data) => { + console.info(JSON.stringify(error)); + console.info(JSON.stringify(data)); +}) +``` + +## connection.getDefaultHttpProxy10+ + +getDefaultHttpProxy(): Promise\; + +Obtains the default proxy configuration of the network. +If the global proxy is set, the global proxy configuration is returned. If [setAppNet](#connectionsetappnet) is used to bind the application to the network specified by [NetHandle](#nethandle), the proxy configuration of this network is returned. In other cases, the HTTP proxy configuration of the default network is returned. +This API uses a promise to return the result. + +**System capability**: SystemCapability.Communication.NetManager.Core + +**Return value** + +| Type | Description | +| -------------------------------- | ----------------------------------------- | +| Promise<[HttpProxy](#httpproxy)> | Promise used to return the result.| + +**Error codes** + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 2100002 | Operation failed. Cannot connect to service. | +| 2100003 | System internal error. | + +**Example** + +```js +connection.getDefaultHttpProxy().then((data) => { + console.info(JSON.stringify(data)); +}).catch(error => { + console.info(JSON.stringify(error)); +}) +``` + ## connection.getAppNet9+ getAppNet(callback: AsyncCallback\): void @@ -320,9 +385,9 @@ Obtains information about the network bound to an application. This API uses an **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------------------------------------------------------------ | ---- | ---------------- | -| callback | AsyncCallback\<[NetHandle](#nethandle)> | Yes | Callback used to return the result. If information about the network bound to the application is successfully obtained, **err** is **undefined** and **data** is the obtained network information. Otherwise, **err** is an error object.| +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback\<[NetHandle](#nethandle)> | Yes | Callback used to return the result. If information about the network bound to the application is successfully obtained, **error** is **undefined** and **data** is the obtained network information. Otherwise, **error** is an error object.| **Error codes** @@ -385,10 +450,10 @@ Binds an application to the specified network, so that the application can acces **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------------------------------------------------------------ | ---- | ---------------- | -| netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the application is successfully bound to the specified network, **err** is **undefined**. Otherwise, **err** is an error object.| +| Name | Type | Mandatory| Description | +| --------- | ----------------------- | ---- | ------------------------------------------------------------ | +| netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network. | +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the application is successfully bound to the specified network, **error** is **undefined**. Otherwise, **error** is an error object.| **Error codes** @@ -469,7 +534,7 @@ Obtains the list of all connected networks. This API uses an asynchronous callba | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| callback | AsyncCallback<Array<[NetHandle](#nethandle)>> | Yes| Callback used to return the result. If the list of all connected networks is obtained successfully, **err** is **undefined** and **data** is the list of activated data networks. Otherwise, **err** is an error object.| +| callback | AsyncCallback<Array<[NetHandle](#nethandle)>> | Yes| Callback used to return the result. If the list of all connected networks is obtained successfully, **error** is **undefined** and **data** is the list of activated data networks. Otherwise, **error** is an error object.| **Error codes** @@ -534,10 +599,10 @@ Obtains connection properties of the network corresponding to the **netHandle**. **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------------------------------------------------------------ | ---- | ---------------- | -| netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network.| -| callback | AsyncCallback\<[ConnectionProperties](#connectionproperties)> | Yes | Callback used to return the result. If the connection properties of the network corresponding to the **netHandle** is obtained successfully, **err** is **undefined** and **data** is the obtained network connection information. Otherwise, **err** is an error object.| +| Name | Type | Mandatory| Description | +| --------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network. | +| callback | AsyncCallback\<[ConnectionProperties](#connectionproperties)> | Yes | Callback used to return the result. If the connection properties of the network corresponding to the **netHandle** is obtained successfully, **error** is **undefined** and **data** is the obtained network connection information. Otherwise, **error** is an error object.| **Error codes** @@ -614,10 +679,10 @@ Obtains capability information of the network corresponding to the **netHandle** **Parameters** -| Name | Type | Mandatory| Description | -| --------- | --------------------------------------------------- | ---- | ---------------- | -| netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network.| -| callback | AsyncCallback\<[NetCapabilities](#netcapabilities)> | Yes | Callback used to return the result. If the capability information of the network corresponding to the **netHandle** is obtained successfully, **err** is **undefined** and **data** is the obtained network capability information. Otherwise, **err** is an error object. | +| Name | Type | Mandatory| Description | +| --------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | +| netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network. | +| callback | AsyncCallback\<[NetCapabilities](#netcapabilities)> | Yes | Callback used to return the result. If the capability information of the network corresponding to the **netHandle** is obtained successfully, **error** is **undefined** and **data** is the obtained network capability information. Otherwise, **error** is an error object.| **Error codes** @@ -904,7 +969,7 @@ Disables the airplane mode. This API uses an asynchronous callback to return the | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------- | ---- | ------------------ | -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the airplane mode is disabled successfully, **err** is **undefined**. Otherwise, **err** is an error object.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the airplane mode is disabled successfully, **error** is **undefined**. Otherwise, **error** is an error object.| **Error codes** @@ -975,7 +1040,7 @@ Reports connection of the data network to the network management module. This AP | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| -| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the network status is reported successfully, **err** is **undefined**. Otherwise, **err** is an error object.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the network status is reported successfully, **error** is **undefined**. Otherwise, **error** is an error object.| **Error codes** @@ -1053,7 +1118,7 @@ Reports disconnection of the data network to the network management module. This | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| -| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the network status is reported successfully, **err** is **undefined**. Otherwise, **err** is an error object.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the network status is reported successfully, **error** is **undefined**. Otherwise, **error** is an error object.| **Error codes** @@ -1128,10 +1193,10 @@ Resolves the host name by using the default network to obtain all IP addresses. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------- | ---- | ------------------ | -| host | string | Yes | Host name to resolve.| -| callback | AsyncCallback\> | Yes | Callback used to return the result. If all IP addresses are successfully obtained, **err** is **undefined**, and **data** is the list of all obtained IP addresses. Otherwise, **err** is an error object.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | +| host | string | Yes | Host name to resolve. | +| callback | AsyncCallback\> | Yes | Callback used to return the result. If all IP addresses are successfully obtained, **error** is **undefined**, and **data** is the list of all obtained IP addresses. Otherwise, **error** is an error object.| **Error codes** @@ -1215,9 +1280,9 @@ Registers a listener for network status changes. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ---------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result. If a listener for network status changes is registered successfully, **err** is **undefined**. Otherwise, **err** is an error object.| +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback\ | Yes | Callback used to return the result. If a listener for network status changes is registered successfully, **error** is **undefined**. Otherwise, **error** is an error object.| **Error codes** @@ -1248,9 +1313,9 @@ Unregisters the listener for network status changes. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ---------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result. If a listener for network status changes is unregistered successfully, **err** is **undefined**. Otherwise, **err** is an error object.| +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback\ | Yes | Callback used to return the result. If a listener for network status changes is unregistered successfully, **error** is **undefined**. Otherwise, **error** is an error object.| **Error codes** @@ -1532,7 +1597,7 @@ Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses | Name | Type | Mandatory| Description | | ----------- | ------------------------ | ---- | -------------------------------| | socketParam | [TCPSocket](js-apis-socket.md#tcpsocket) \| [UDPSocket](js-apis-socket.md#udpsocket) | Yes| **TCPSocket** or **UDPSocket** object.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the **TCPSocket** or **UDPSocket** object is successfully bound to the current network, **err** is **undefined**. Otherwise, **err** is an error object.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the **TCPSocket** or **UDPSocket** object is successfully bound to the current network, **error** is **undefined**. Otherwise, **error** is an error object.| **Error codes** @@ -1684,10 +1749,10 @@ Resolves the host name by using the corresponding network to obtain all IP addre **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------- | ---- | ------------------ | -| host | string | Yes | Host name to resolve.| -| callback | AsyncCallback\> | Yes | Callback used to return the result. If all IP addresses are successfully obtained, **err** is **undefined**, and **data** is the list of all obtained IP addresses. Otherwise, **err** is an error object.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | +| host | string | Yes | Host name to resolve. | +| callback | AsyncCallback\> | Yes | Callback used to return the result. If all IP addresses are successfully obtained, **error** is **undefined**, and **data** is the list of all obtained IP addresses. Otherwise, **error** is an error object.| **Error codes** @@ -1766,10 +1831,10 @@ Resolves the host name by using the corresponding network to obtain the first IP **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------------------------- | ---- | ------------------ | -| host | string | Yes | Host name to resolve.| -| callback | AsyncCallback\<[NetAddress](#netaddress)> | Yes | Callback used to return the result. If the first IP address is obtained successfully, **err** is **undefined**, and **data** is the first obtained IP address. Otherwise, **err** is an error object. | +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | +| host | string | Yes | Host name to resolve. | +| callback | AsyncCallback\<[NetAddress](#netaddress)> | Yes | Callback used to return the result. If the first IP address is obtained successfully, **error** is **undefined**, and **data** is the first obtained IP address. Otherwise, **error** is an error object.| **Error codes** @@ -1864,7 +1929,7 @@ Enumerates network types. ## HttpProxy10+ -Defines the global HTTP proxy configuration of the network. +Represents the HTTP proxy configuration. **System capability**: SystemCapability.Communication.NetManager.Core @@ -1872,7 +1937,7 @@ Defines the global HTTP proxy configuration of the network. | ------ | ------ | --- |------------------------- | | host | string | No | Host name of the proxy server.| | port | number | No | Host port.| -| exclusionList | Array | No | Exclusion list of hosts that do not use the proxy server. The length of the combined elements in the list cannot exceed 96 bytes.
For example, the length of **baidu.com,zhihu.com** is 20 bytes.| +| exclusionList | Array | No | List of the names of hosts that do not use a proxy. Host names can be domain names, IP addresses, or wildcards. The detailed matching rules are as follows:
- Domain name matching:
- Exact match: The host name of the proxy server exactly matches any host name in the list.
- Partial match: The host name of the proxy server contains any host name in the list.
For example, if **ample.com** is set in the host name list, **ample.com**, **www.ample.com**, and **ample.com:80** are matched, and **www.example.com** and **ample.com.org** are not matched.
- IP address matching: The host name of the proxy server exactly matches any IP address in the list.
- Both the domain name and IP address are added to the list for matching.
- A single asterisk (*) is the only valid wildcard. If the list contains only wildcards, the wildcards match all host names; that is, the HTTP proxy is disabled. A wildcard can only be added independently. It cannot be added to the list together with other domain names or IP addresses. Otherwise, the wildcard does not take effect.
- Host names are case insensitive.
- Protocol prefixes such as **http** and **https** are ignored during matching.| ## NetSpecifier8+ diff --git a/en/application-dev/reference/apis/js-apis-socket.md b/en/application-dev/reference/apis/js-apis-socket.md index 4cea6beaaec94d89b21a3e59743e54cb3d7b87d8..62bdc0ec13d6df516a3d0b632f9c6fcbd30b342e 100644 --- a/en/application-dev/reference/apis/js-apis-socket.md +++ b/en/application-dev/reference/apis/js-apis-socket.md @@ -472,7 +472,7 @@ Enables listening for message receiving events of the UDPSocket connection. This | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | -| type | string | Yes | Type of the event to subscribe to.
**message**: message receiving event| +| type | string | Yes | Type of the event to subscribe to.
**message**: message receiving event| | callback | Callback\<{message: ArrayBuffer, remoteInfo: [SocketRemoteInfo](#socketremoteinfo)}\> | Yes | Callback used to return the result. | **Example** @@ -506,7 +506,7 @@ Disables listening for message receiving events of the UDPSocket connection. Thi | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | -| type | string | Yes | Type of the event to subscribe to.
**message**: message receiving event| +| type | string | Yes | Type of the event to subscribe to.
**message**: message receiving event| | callback | Callback<{message: ArrayBuffer, remoteInfo: [SocketRemoteInfo](#socketremoteinfo)}> | No | Callback used to return the result. | **Example** @@ -541,7 +541,7 @@ Enables listening for data packet message events or close events of the UDPSocke | Name | Type | Mandatory| Description | | -------- | ---------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of the event to subscribe to.

- **listening**: data packet message event
- **close**: close event| +| type | string | Yes | Type of the event to subscribe to.
- **listening**: data packet message event
- **close**: close event| | callback | Callback\ | Yes | Callback used to return the result. | **Example** @@ -606,7 +606,7 @@ Enables listening for error events of the UDPSocket connection. This API uses an | Name | Type | Mandatory| Description | | -------- | ------------- | ---- | ------------------------------------ | -| type | string | Yes | Type of the event to subscribe to.
**error**: error event| +| type | string | Yes | Type of the event to subscribe to.
**error**: error event| | callback | ErrorCallback | Yes | Callback used to return the result. | **Example** @@ -633,7 +633,7 @@ Disables listening for error events of the UDPSocket connection. This API uses a | Name | Type | Mandatory| Description | | -------- | ------------- | ---- | ------------------------------------ | -| type | string | Yes | Type of the event to subscribe to.
**error**: error event| +| type | string | Yes | Type of the event to subscribe to.
**error**: error event| | callback | ErrorCallback | No | Callback used to return the result. | **Example** @@ -1358,7 +1358,7 @@ Enables listening for message receiving events of the TCPSocket connection. This | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | -| type | string | Yes | Type of the event to subscribe to.
**message**: message receiving event| +| type | string | Yes | Type of the event to subscribe to.
**message**: message receiving event| | callback | Callback<{message: ArrayBuffer, remoteInfo: [SocketRemoteInfo](#socketremoteinfo)}> | Yes | Callback used to return the result. | **Example** @@ -1392,7 +1392,7 @@ Disables listening for message receiving events of the TCPSocket connection. Thi | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | -| type | string | Yes | Type of the event to subscribe to.
**message**: message receiving event| +| type | string | Yes | Type of the event to subscribe to.
**message**: message receiving event| | callback | Callback<{message: ArrayBuffer, remoteInfo: [SocketRemoteInfo](#socketremoteinfo)}> | No | Callback used to return the result. | **Example** @@ -1427,7 +1427,7 @@ Enables listening for connection or close events of the TCPSocket connection. Th | Name | Type | Mandatory| Description | | -------- | ---------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of the event to subscribe to.

- **connect**: connection event
- **close**: close event| +| type | string | Yes | Type of the event to subscribe to.
- **connect**: connection event
- **close**: close event| | callback | Callback\ | Yes | Callback used to return the result. | **Example** @@ -1457,7 +1457,7 @@ Disables listening for connection or close events of the TCPSocket connection. T | Name | Type | Mandatory| Description | | -------- | ---------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of the event to subscribe to.

- **connect**: connection event
- **close**: close event| +| type | string | Yes | Type of the event to subscribe to.
- **connect**: connection event
- **close**: close event| | callback | Callback\ | No | Callback used to return the result. | **Example** @@ -1492,7 +1492,7 @@ Enables listening for error events of the TCPSocket connection. This API uses an | Name | Type | Mandatory| Description | | -------- | ------------- | ---- | ------------------------------------ | -| type | string | Yes | Type of the event to subscribe to.
**error**: error event| +| type | string | Yes | Type of the event to subscribe to.
**error**: error event| | callback | ErrorCallback | Yes | Callback used to return the result. | **Example** @@ -1519,7 +1519,7 @@ Disables listening for error events of the TCPSocket connection. This API uses a | Name | Type | Mandatory| Description | | -------- | ------------- | ---- | ------------------------------------ | -| type | string | Yes | Type of the event to subscribe to.
**error**: error event| +| type | string | Yes | Type of the event to subscribe to.
**error**: error event| | callback | ErrorCallback | No | Callback used to return the result. | **Example** @@ -1572,7 +1572,960 @@ Defines other properties of the TCPSocket connection. | receiveBufferSize | number | No | Size of the receive buffer, in bytes. The default value is **0**. | | sendBufferSize | number | No | Size of the send buffer, in bytes. The default value is **0**. | | reuseAddress | boolean | No | Whether to reuse addresses. The default value is **false**. | -| socketTimeout | number | No | Timeout duration of the TCPSocket connection, in ms. The default value is **0**. | +| socketTimeout | number | No | Timeout duration of the UDPSocket connection, in ms. The default value is **0**. | + +## socket.constructTCPSocketServerInstance10+ + +constructTCPSocketServerInstance(): TCPSocketServer + +Creates a **TCPSocketServer** object. + +**System capability**: SystemCapability.Communication.NetStack + +**Return value** + +| Type | Description | +| :---------------------------------- | :---------------------------- | +| [TCPSocketServer](#tcpsocketserver10) | **TCPSocketServer** object.| + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +``` + +## TCPSocketServer10+ + +Defines a TCPSocketServer connection. Before invoking TCPSocketServer APIs, you need to call [socket.constructTCPSocketServerInstance](#socketconstructtcpsocketserverinstance10) to create a **TCPSocketServer** object. + +### listen10+ + +listen(address: NetAddress, callback: AsyncCallback\): void + +Binds the IP address and port number. The port number can be specified or randomly allocated by the system. The server listens to and accepts TCPSocket connections established over the socket. Multiple threads are used to process client data concurrently. This API uses an asynchronous callback to return the result. + +> **NOTE** +> The server uses this API to perform the bind, listen, and accept operations. + +**Required permissions**: ohos.permission.INTERNET + +**System capability**: SystemCapability.Communication.NetStack + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | --------------------------------------------- | +| address | [NetAddress](#netaddress7) | Yes | Destination address.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | + +**Error codes** + +| ID| Error Message | +| -------- | ------------------------------------------- | +| 401 | Parameter error. | +| 201 | Permission denied. | +| 2300002 | System internal error. | +| 2303109 | Bad file number. | +| 2303111 | Resource temporarily unavailable try again. | +| 2303198 | Address already in use. | +| 2303199 | Cannot assign requested address. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +tcpServer.listen({ address: "192.168.xx.xxx", port: xxxx, family: 1 }, err => { + if (err) { + console.log("listen fail"); + return; + } + console.log("listen success"); +}) +``` + +### listen10+ + +listen(address: NetAddress): Promise\ + +Binds the IP address and port number. The port number can be specified or randomly allocated by the system. The server listens to and accepts TCPSocket connections established over the socket. Multiple threads are used to process client data concurrently. This API uses a promise to return the result. + +> **NOTE** +> The server uses this API to perform the bind, listen, and accept operations. + +**Required permissions**: ohos.permission.INTERNET + +**System capability**: SystemCapability.Communication.NetStack + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------------------------- | ---- | --------------------------------------------- | +| address | [NetAddress](#netaddress7) | Yes | Destination address.| + +**Return value** + +| Type | Description | +| :-------------- | :----------------------------------------------------------- | +| Promise\ | Promise used to return the result. If the operation is successful, no value is returned. If the operation fails, an error message is returned.| + +**Error codes** + +| ID| Error Message | +| -------- | ------------------------------------------- | +| 401 | Parameter error. | +| 201 | Permission denied. | +| 2300002 | System internal error. | +| 2303109 | Bad file number. | +| 2303111 | Resource temporarily unavailable try again. | +| 2303198 | Address already in use. | +| 2303199 | Cannot assign requested address. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +let promise = tcpServer.listen({ address: '192.168.xx.xxx', port: xxxx, family: 1 }); +promise.then(() => { + console.log('listen success'); +}).catch(err => { + console.log('listen fail'); +}); +``` + +### getState10+ + +getState(callback: AsyncCallback\): void + +Obtains the status of the TCPSocketServer connection. This API uses an asynchronous callback to return the result. + +> **NOTE** +> This API can be called only after **listen** is successfully called. + +**Required permissions**: ohos.permission.INTERNET + +**System capability**: SystemCapability.Communication.NetStack + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------------------- | ---- | ---------- | +| callback | AsyncCallback<[SocketStateBase](#socketstatebase7)> | Yes | Callback used to return the result.| + +**Error codes** + +| ID| Error Message | +| -------- | ------------------------------- | +| 401 | Parameter error. | +| 201 | Permission denied. | +| 2300002 | System internal error. | +| 2303188 | Socket operation on non-socket. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +tcpServer.listen({ address: "192.168.xx.xxx", port: xxxx, family: 1 }, err => { + if (err) { + console.log("listen fail"); + return; + } + console.log("listen success"); +}) +tcpServer.getState((err, data) => { + if (err) { + console.log('getState fail'); + return; + } + console.log('getState success:' + JSON.stringify(data)); +}) +``` + +### getState10+ + +getState(): Promise\ + +Obtains the status of the TCPSocketServer connection. This API uses a promise to return the result. + +> **NOTE** +> This API can be called only after **listen** is successfully called. + +**Required permissions**: ohos.permission.INTERNET + +**System capability**: SystemCapability.Communication.NetStack + +**Return value** + +| Type | Description | +| :------------------------------------------- | :----------------------------------------- | +| Promise<[SocketStateBase](#socketstatebase7)> | Promise used to return the result.| + +**Error codes** + +| ID| Error Message | +| -------- | ------------------------------- | +| 201 | Permission denied. | +| 2300002 | System internal error. | +| 2303188 | Socket operation on non-socket. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +let promiseListen = tcpServer.listen({ address: '192.168.xx.xxx', port: xxxx, family: 1 }); +promiseListen.then(() => { + console.log('listen success'); +}).catch(err => { + console.log('listen fail'); +}); +let promise = tcpServer.getState(); +promise.then(() => { + console.log('getState success'); +}).catch(err => { + console.log('getState fail'); +}); +``` + +### setExtraOptions10+ + +setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback\): void + +Sets other properties of the TCPSocketServer connection. This API uses an asynchronous callback to return the result. + +> **NOTE** +> This API can be called only after **listen** is successfully called. + +**Required permissions**: ohos.permission.INTERNET + +**System capability**: SystemCapability.Communication.NetStack + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------- | ---- | ------------------------------------------------------------ | +| options | [TCPExtraOptions](#tcpextraoptions7) | Yes | Other properties of the TCPSocketServer connection.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | + +**Error codes** + +| ID| Error Message | +| -------- | ------------------------------- | +| 401 | Parameter error. | +| 201 | Permission denied. | +| 2300002 | System internal error. | +| 2303188 | Socket operation on non-socket. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +tcpServer.listen({ address: "192.168.xx.xxx", port: xxxx, family: 1 }, err => { + if (err) { + console.log("listen fail"); + return; + } + console.log("listen success"); +}) +tcpServer.setExtraOptions({ + keepAlive: true, + OOBInline: true, + TCPNoDelay: true, + socketLinger: { on: true, linger: 10 }, + receiveBufferSize: 1000, + sendBufferSize: 1000, + reuseAddress: true, + socketTimeout: 3000, +}, err => { + if (err) { + console.log('setExtraOptions fail'); + return; + } + console.log('setExtraOptions success'); +}); +``` + +### setExtraOptions10+ + +setExtraOptions(options: TCPExtraOptions): Promise\ + +Sets other properties of the TCPSocketServer connection. This API uses a promise to return the result. + +> **NOTE** +> This API can be called only after **listen** is successfully called. + +**Required permissions**: ohos.permission.INTERNET + +**System capability**: SystemCapability.Communication.NetStack + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ----------------------------------- | ---- | ------------------------------------------------------------ | +| options | [TCPExtraOptions](#tcpextraoptions7) | Yes | Other properties of the TCPSocketServer connection.| + +**Return value** + +| Type | Description | +| :-------------- | :--------------------------------------------------------- | +| Promise\ | Promise used to return the result. If the operation is successful, no value is returned. If the operation fails, an error message is returned.| + +**Error codes** + +| ID| Error Message | +| -------- | ------------------------------- | +| 401 | Parameter error. | +| 201 | Permission denied. | +| 2300002 | System internal error. | +| 2303188 | Socket operation on non-socket. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +let promiseListen = tcpServer.listen({ address: '192.168.xx.xxx', port: xxxx, family: 1 }); +promiseListen.then(() => { + console.log('listen success'); +}).catch(err => { + console.log('listen fail'); +}); +let promise = tcpServer.setExtraOptions({ + keepAlive: true, + OOBInline: true, + TCPNoDelay: true, + socketLinger: { on: true, linger: 10 }, + receiveBufferSize: 1000, + sendBufferSize: 1000, + reuseAddress: true, + socketTimeout: 3000, +}); +promise.then(() => { + console.log('setExtraOptions success'); +}).catch(err => { + console.log('setExtraOptions fail'); +}); +``` + +### on('connect')10+ + +on(type: 'connect', callback: Callback\): void + +Enables listening for TCPSocketServer connection events. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Communication.NetStack + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------- | ---- | ------------------------------------- | +| type | string | Yes | Type of the event to subscribe to.
**connect**: connection event| +| callback | Callback<[TCPSocketConnection](#tcpsocketconnection10)> | Yes | Callback used to return the result. | + +**Error codes** + +| ID| Error Message | +| -------- | ---------------- | +| 401 | Parameter error. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +tcpServer.on('connect', function(data) { + console.log(JSON.stringify(data)) +}); +``` + +### off('connect')10+ + +off(type: 'connect', callback?: Callback\): void + +Disables listening for TCPSocketServer connection events. This API uses an asynchronous callback to return the result. + +> **NOTE** +> 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 + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------- | ---- | ------------------------------------- | +| type | string | Yes | Type of the event to subscribe to.
**connect**: connection event| +| callback | Callback<[TCPSocketConnection](#tcpsocketconnection10)> | No | Callback used to return the result. | + +**Error codes** + +| ID| Error Message | +| -------- | ---------------- | +| 401 | Parameter error. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +let callback = data => { + console.log('on connect message: ' + JSON.stringify(data)); +} +tcpServer.on('connect', 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. +tcpServer.off('connect', callback); +tcpServer.off('connect'); +``` + +### on('error')10+ + +on(type: 'error', callback: ErrorCallback): void + +Enables listening for error events of the TCPSocketServer connection. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Communication.NetStack + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | ------------------------------------ | +| type | string | Yes | Type of the event to subscribe to.
**error**: error event| +| callback | ErrorCallback | Yes | Callback used to return the result. | + +**Error codes** + +| ID| Error Message | +| -------- | ---------------- | +| 401 | Parameter error. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +tcpServer.on('error', err => { + console.log("on error, err:" + JSON.stringify(err)) +}); +``` + +### off('error')10+ + +off(type: 'error', callback?: ErrorCallback): void + +Disables listening for error events of the TCPSocketServer connection. This API uses an asynchronous callback to return the result. + +> **NOTE** +> 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 + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | ------------------------------------ | +| type | string | Yes | Type of the event to subscribe to.
**error**: error event| +| callback | ErrorCallback | No | Callback used to return the result. | + +**Error codes** + +| ID| Error Message | +| -------- | ---------------- | +| 401 | Parameter error. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +let callback = err => { + console.log("on error, err:" + JSON.stringify(err)); +} +tcpServer.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. +tcpServer.off('error', callback); +tcpServer.off('error'); +``` + +## TCPSocketConnection10+ + +Defines a **TCPSocketConnection** object, that is, the connection between the TCPSocket client and the server. Before invoking TCPSocketConnection APIs, you need to obtain a **TCPSocketConnection** object. + +**System capability**: SystemCapability.Communication.NetStack + +### Attributes + +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ----------------------------------------- | +| clientId | number | Yes | ID of the connection between the client and TCPSocketServer.| + +### send10+ + +send(options: TCPSendOptions, callback: AsyncCallback\): void + +Sends data over a **TCPSocketConnection** object. This API uses an asynchronous callback to return the result. + +> **NOTE** +> This API can be called only after a connection with the client is set up. + +**Required permissions**: ohos.permission.INTERNET + +**System capability**: SystemCapability.Communication.NetStack + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------------- | ---- | ------------------------------------------------------------ | +| options | [TCPSendOptions](#tcpsendoptions7) | Yes | Defines the parameters for sending data over the **TCPSocketConnection** object.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | + +**Error codes** + +| ID| Error Message | +| -------- | ---------------------- | +| 401 | Parameter error. | +| 201 | Permission denied. | +| 2300002 | System internal error. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +tcpServer.on('connect', function(client) { + client.send({data: 'Hello, client!'}, err => { + if (err) { + console.log('send fail'); + return; + } + console.log('send success'); + }); +}); +``` + +### send10+ + +send(options: TCPSendOptions): Promise\ + +Sends data over a **TCPSocketConnection** object. This API uses a promise to return the result. + +> **NOTE** +> This API can be called only after a connection with the client is set up. + +**Required permissions**: ohos.permission.INTERNET + +**System capability**: SystemCapability.Communication.NetStack + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | --------------------------------- | ---- | ------------------------------------------------------------ | +| options | [TCPSendOptions](#tcpsendoptions7) | Yes | Defines the parameters for sending data over the **TCPSocketConnection** object.| + +**Return value** + +| Type | Description | +| :-------------- | :----------------------------------------------------------- | +| Promise\ | Promise used to return the result. If the operation is successful, no value is returned. If the operation fails, an error message is returned.| + +**Error codes** + +| ID| Error Message | +| -------- | ---------------------- | +| 401 | Parameter error. | +| 201 | Permission denied. | +| 2300002 | System internal error. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +tcpServer.on('connect', function(client) { + let promise = client.send({data: 'Hello, client!'}); + promise.then(() => { + console.log('send success'); + }).catch(err => { + console.log('send fail'); + }); +}); +``` + +### close10+ + +close(callback: AsyncCallback\): void + +Closes a **TCPSocketConnection** object. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.INTERNET + +**System capability**: SystemCapability.Communication.NetStack + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ---------- | +| callback | AsyncCallback\ | Yes | Callback used to return the result.| + +**Error codes** + +| ID| Error Message | +| -------- | ---------------------- | +| 401 | Parameter error. | +| 201 | Permission denied. | +| 2300002 | System internal error. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +tcpServer.on('connect', function(client) { + client.close(err => { + if (err) { + console.log('close fail'); + return; + } + console.log('close success'); + }); +}); +``` + +### close10+ + +close(): Promise\ + +Closes a **TCPSocketConnection** object. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.INTERNET + +**System capability**: SystemCapability.Communication.NetStack + +**Return value** + +| Type | Description | +| :-------------- | :------------------------------------------- | +| Promise\ | Promise used to return the result. If the operation is successful, no value is returned. If the operation fails, an error message is returned.| + +**Error codes** + +| ID| Error Message | +| -------- | ---------------------- | +| 201 | Permission denied. | +| 2300002 | System internal error. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +tcpServer.on('connect', function(client) { + let promise = client.close(); + promise.then(() => { + console.log('close success'); + }).catch(err => { + console.log('close fail'); + }); +}); +``` + +### getRemoteAddress10+ + +getRemoteAddress(callback: AsyncCallback\): void + +Obtains the remote address of a socket connection. This API uses an asynchronous callback to return the result. + +> **NOTE** +> This API can be called only after a connection with the client is set up. + +**Required permissions**: ohos.permission.INTERNET + +**System capability**: SystemCapability.Communication.NetStack + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------- | ---- | ---------- | +| callback | AsyncCallback<[NetAddress](#netaddress7)> | Yes | Callback used to return the result.| + +**Error codes** + +| ID| Error Message | +| -------- | ------------------------------- | +| 401 | Parameter error. | +| 201 | Permission denied. | +| 2300002 | System internal error. | +| 2303188 | Socket operation on non-socket. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +tcpServer.on('connect', function(client) { + client.getRemoteAddress((err, data) => { + if (err) { + console.log('getRemoteAddress fail'); + return; + } + console.log('getRemoteAddress success:' + JSON.stringify(data)); + }); +}); +``` + +### getRemoteAddress10+ + +getRemoteAddress(): Promise\ + +Obtains the remote address of a socket connection. This API uses a promise to return the result. + +> **NOTE** +> This API can be called only after a connection with the client is set up. + +**Required permissions**: ohos.permission.INTERNET + +**System capability**: SystemCapability.Communication.NetStack + +**Return value** + +| Type | Description | +| :--------------------------------- | :------------------------------------------ | +| Promise<[NetAddress](#netaddress7)> | Promise used to return the result.| + +**Error codes** + +| ID| Error Message | +| -------- | ------------------------------- | +| 201 | Permission denied. | +| 2300002 | System internal error. | +| 2303188 | Socket operation on non-socket. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +tcpServer.on('connect', function(client) { + let promise = client.getRemoteAddress(); + promise.then(() => { + console.log('getRemoteAddress success'); + }).catch(err => { + console.log('getRemoteAddress fail'); + }); +}); +``` + +### on('message')10+ + +on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void + +Enables listening for **message** events of a **TCPSocketConnection** object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Communication.NetStack + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | +| type | string | Yes | Type of the event to subscribe to.
**message**: message receiving event| +| callback | Callback<{message: ArrayBuffer, remoteInfo: [SocketRemoteInfo](#socketremoteinfo7)}> | Yes | Callback used to return the result.
**message**: received message.
**remoteInfo**: socket connection information. | + +**Error codes** + +| ID| Error Message | +| -------- | ---------------- | +| 401 | Parameter error. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +tcpServer.on('connect', function(client) { + client.on('message', value => { + let messageView = ''; + for (var i = 0; i < value.message.length; i++) { + let messages = value.message[i]; + let message = String.fromCharCode(messages); + messageView += item; + } + console.log('on message message: ' + JSON.stringify(messageView)); + console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo)); + }); +}); +``` + +### off('message')10+ + +off(type: 'message', callback?: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void + +Disables listening for **message** events of a **TCPSocketConnection** object. This API uses an asynchronous callback to return the result. + +> **NOTE** +> 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 + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | +| type | string | Yes | Type of the event to subscribe to.
**message**: message receiving event| +| callback | Callback<{message: ArrayBuffer, remoteInfo: [SocketRemoteInfo](#socketremoteinfo7)}> | No | Callback used to return the result. **message**: received message.
**remoteInfo**: socket connection information. | + +**Error codes** + +| ID| Error Message | +| -------- | ---------------- | +| 401 | Parameter error. | + +**Example** + +```js +let callback = value => { + let messageView = ''; + for (var i = 0; i < value.message.length; i++) { + let messages = value.message[i]; + let message = String.fromCharCode(messages); + messageView += item; + } + console.log('on message message: ' + JSON.stringify(messageView)); + console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo)); +} +let tcpServer = socket.constructTCPSocketServerInstance(); +tcpServer.on('connect', function(client) { + client.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. + client.off('message', callback); + client.off('message'); +}); +``` + +### on('close')10+ + +on(type: 'close', callback: Callback\): void + +Enables listening for **close** events of a **TCPSocketConnection** object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Communication.NetStack + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------- | ---- | ----------------------------------- | +| type | string | Yes | Type of the event to subscribe to.
**close**: close event| +| callback | Callback\ | No | Callback used to return the result. | + +**Error codes** + +| ID| Error Message | +| -------- | ---------------- | +| 401 | Parameter error. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +tcpServer.on('connect', function(client) { + client.on('close', () => { + console.log("on close success") + }); +}); +``` + +### off('close')10+ + +on(type: 'close', callback: Callback\): void + +Disables listening for **close** events of a **TCPSocketConnection** object. This API uses an asynchronous callback to return the result. + +> **NOTE** +> 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 + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------- | ---- | ----------------------------------- | +| type | string | Yes | Type of the event to subscribe to.
**close**: close event| +| callback | Callback\ | No | Callback used to return the result. | + +**Error codes** + +| ID| Error Message | +| -------- | ---------------- | +| 401 | Parameter error. | + +**Example** + +```js +let callback = () => { + console.log("on close success"); +} +let tcpServer = socket.constructTCPSocketServerInstance(); +tcpServer.on('connect', function(client) { + client.on('close', 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. + client.off('close', callback); + client.off('close'); +}); +``` + +### on('error')10+ + +on(type: 'error', callback: ErrorCallback): void + +Enables listening for **error** events of a **TCPSocketConnection** object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Communication.NetStack + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | ------------------------------------ | +| type | string | Yes | Type of the event to subscribe to.
**error**: error event| +| callback | ErrorCallback | Yes | Callback used to return the result. | + +**Error codes** + +| ID| Error Message | +| -------- | ---------------- | +| 401 | Parameter error. | + +**Example** + +```js +let tcpServer = socket.constructTCPSocketServerInstance(); +tcpServer.on('connect', function(client) { + client.on('error', err => { + console.log("on error, err:" + JSON.stringify(err)) + }); +}); +``` + +### off('error')10+ + +off(type: 'error', callback?: ErrorCallback): void + +Disables listening for **error** events of a **TCPSocketConnection** object. This API uses an asynchronous callback to return the result. + +> **NOTE** +> 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 + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | ------------------------------------ | +| type | string | Yes | Type of the event to subscribe to.
**error**: error event| +| callback | ErrorCallback | No | Callback used to return the result. | + +**Error codes** + +| ID| Error Message | +| -------- | ---------------- | +| 401 | Parameter error. | + +**Example** + +```js +let callback = err => { + console.log("on error, err:" + JSON.stringify(err)); +} +let tcpServer = socket.constructTCPSocketServerInstance(); +tcpServer.on('connect', function(client) { + client.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. + client.off('error', callback); + client.off('error'); +}); +``` ## Description of TCP Error Codes @@ -1873,7 +2826,7 @@ promise.then(() => { on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; -Subscribes to **message** events of the TLSSocket connection. This API uses an asynchronous callback to return the result. +Enables listening for **message** events of the TLSSocket connection. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Communication.NetStack @@ -1881,7 +2834,7 @@ Subscribes to **message** events of the TLSSocket connection. This API uses an a | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | -| type | string | Yes | Type of the event to subscribe to.
**message**: message receiving event| +| type | string | Yes | Type of the event to subscribe to.
**message**: message receiving event| | callback | Callback\<{message: ArrayBuffer, remoteInfo: [SocketRemoteInfo](#socketremoteinfo)}\> | Yes | Callback used to return the result.
**message**: received message.
**remoteInfo**: socket connection information.| **Example** @@ -1904,7 +2857,7 @@ tls.on('message', value => { off(type: 'message', callback?: Callback\<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void -Unsubscribes from **message** events of the TLSSocket connection. This API uses an asynchronous callback to return the result. +Disables listening for **message** events of the TLSSocket connection. This API uses an asynchronous callback to return the result. > **NOTE** > 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. @@ -1915,7 +2868,7 @@ Unsubscribes from **message** events of the TLSSocket connection. This API uses | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | -| type | string | Yes | Type of the event to subscribe to.
**message**: message receiving event| +| type | string | Yes | Type of the event to subscribe to.
**message**: message receiving event| | callback | Callback<{message: ArrayBuffer, remoteInfo: [SocketRemoteInfo](#socketremoteinfo)}> | No | Callback used to return the result. **message**: received message.
**remoteInfo**: socket connection information.| **Example** @@ -1948,7 +2901,7 @@ Enables listening for connection or close events of the TLSSocket connection. Th | Name | Type | Mandatory| Description | | -------- | ---------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of the event to subscribe to.

- **connect**: connection event
- **close**: close event| +| type | string | Yes | Type of the event to subscribe to.
- **connect**: connection event
- **close**: close event| | callback | Callback\ | Yes | Callback used to return the result. | **Example** @@ -1978,7 +2931,7 @@ Disables listening for connection or close events of the TLSSocket connection. T | Name | Type | Mandatory| Description | | -------- | ---------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of the event to subscribe to.

- **connect**: connection event
- **close**: close event| +| type | string | Yes | Type of the event to subscribe to.
- **connect**: connection event
- **close**: close event| | callback | Callback\ | No | Callback used to return the result. | **Example** @@ -2012,7 +2965,7 @@ Enables listening for error events of the TLSSocket connection. This API uses an | Name | Type | Mandatory| Description | | -------- | ------------- | ---- | ------------------------------------ | -| type | string | Yes | Type of the event to subscribe to.
**error**: error event| +| type | string | Yes | Type of the event to subscribe to.
**error**: error event| | callback | ErrorCallback | Yes | Callback used to return the result. | **Example** @@ -2039,7 +2992,7 @@ Disables listening for error events of the TLSSocket connection. This API uses a | Name | Type | Mandatory| Description | | -------- | ------------- | ---- | ------------------------------------ | -| type | string | Yes | Type of the event to subscribe to.
**error**: error event| +| type | string | Yes | Type of the event to subscribe to.
**error**: error event| | callback | ErrorCallback | No | Callback used to return the result. | **Example**