diff --git a/en/application-dev/dfx/Readme-EN.md b/en/application-dev/dfx/Readme-EN.md index 977812697f34817f07a996e3d3f787c985baf840..5a1b6326bae1ecb94ef7fe8d9e4cfe2cdf2c6c56 100644 --- a/en/application-dev/dfx/Readme-EN.md +++ b/en/application-dev/dfx/Readme-EN.md @@ -4,7 +4,9 @@ - [Development of Performance Tracing](hitracemeter-guidelines.md) - [Development of Distributed Call Chain Tracing](hitracechain-guidelines.md) - [HiLog Development (Native)](hilog-guidelines.md) -- [Development of Performance Tracing (Native)](hitracemeter-native-guidelines.md) +- Performance Tracing + - [Development of Performance Tracing (ArkTS)](hitracemeter-guidelines.md) + - [Development of Performance Tracing (Native)](hitracemeter-native-guidelines.md) - Error Management - [Development of Error Manager](errormanager-guidelines.md) - [Development of Application Recovery](apprecovery-guidelines.md) diff --git a/en/application-dev/dfx/hitracemeter-guidelines.md b/en/application-dev/dfx/hitracemeter-guidelines.md index 3244aa9356bbcd3748594061a3752fad8aa3d3f3..a4152acb7303cd672b830d80a3ba48bc54ee8d9c 100644 --- a/en/application-dev/dfx/hitracemeter-guidelines.md +++ b/en/application-dev/dfx/hitracemeter-guidelines.md @@ -1,4 +1,4 @@ -# Development of Performance Tracing +# Development of Performance Tracing (ArkTS) ## Introduction @@ -17,19 +17,19 @@ hiTraceMeter provides APIs for system performance tracing. You can call the APIs ## Constraints -Due to the asynchronous I/O feature of JS, the hiTraceMeter module provides only asynchronous APIs. +- Due to the asynchronous I/O feature of JS, the hiTraceMeter module provides only asynchronous APIs. ## Available APIs -The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference](../reference/apis/js-apis-hitracemeter.md). +The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference]( ../reference/apis/js-apis-hitracemeter.md). **APIs for performance tracing** -| API | Return Value | Description | -| ---------------------------------------------------------------------------- | --------- | ------------ | -| hiTraceMeter.startTrace(name: string, taskId: number) | void | Marks the start of a trace task. If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**. If the trace tasks with the same name are not performed at the same time, the same task ID can be used.| -| hiTraceMeter.finishTrace(name: string, taskId: number) | void | Marks the end of a trace task. The values of **name** and **taskId** must be the same as those of **hiTraceMeter.startTrace**.| -| hiTraceMeter.traceByValue(name: string, value: number) | void | Marks the value changes of a numeric variable in a trace task.| +| API | Return Value | Description | +| ------------------------------------------------------ | ---- | -------------------------------------------------------------------------------------------------------------------- | +| hiTraceMeter.startTrace(name: string, taskId: number) | void | Marks the start of a trace task. If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**. If the trace tasks with the same name are not performed at the same time, the same task ID can be used.| +| hiTraceMeter.finishTrace(name: string, taskId: number) | void | Marks the end of a trace task. The values of **name** and **taskId** must be the same as those of **hiTraceMeter.startTrace**. | +| hiTraceMeter.traceByValue(name: string, value: number) | void | Marks the value changes of a numeric variable in a trace task. | ## How to Develop diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index b19c71404a0273c7813f764a1ef3ef9392ce8891..f7c52787326fe5429c6911e1e9500b48b0e0f615 100644 --- a/en/application-dev/reference/apis/js-apis-call.md +++ b/en/application-dev/reference/apis/js-apis-call.md @@ -1,5146 +1,5420 @@ -# +# @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. | +| 8300005 | Airplane mode is on. | +| 8300006 | Network not in service. | +| 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. | +| 8300005 | Airplane mode is on. | +| 8300006 | Network not in service. | +| 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. | +| 8300005 | Airplane mode is on. | +| 8300006 | Network not in service. | +| 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.kickOutFromConference10+ - +kickOutFromConference\(callId: number, callback: AsyncCallback\\): void - +Removes a specified call from a conference 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 | +| -------- | ------------------------- | ---- | ---------- | +| 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. | + +**Example** + +```js +call.kickOutFromConference(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); +}); +``` + +## call.kickOutFromConference10+ + +kickOutFromConference\(callId: number\): Promise\ + +Removes a specified call from a conference call. 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 | +| ------ | ------ | ---- | -------- | +| 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. | + +**Example** + +```js +call.kickOutFromConference(1).then(() => { + console.log(`kickOutFromConference success.`); +}).catch((err) => { + console.error(`kickOutFromConference 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. | +| 801 | Capability not supported. | +| 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. | +| 801 | Capability not supported. | +| 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. | +| 801 | Capability not supported. | +| 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. | +| 801 | Capability not supported. | +| 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. | +| 801 | Capability not supported. | +| 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. | +| 801 | Capability not supported. | +| 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. | +| 801 | Capability not supported. | +| 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. | +| 801 | Capability not supported. | +| 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.setCallRestrictionPassword10+ + +setCallRestrictionPassword\(slotId: number, oldPassword: string, newPassword: string, callback: AsyncCallback\\): void + +Changes the call barring password. 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| +| oldPassword | string | Yes | Old password for call barring. | +| newPassword | string | Yes | New password for call barring. | +| 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. | +| 801 | Capability not supported. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | + +**Example** + +```js +call.setCallRestrictionPassword(0, "123456", "654321", (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); +}); ``` -## +## call.setCallRestrictionPassword10+ + +setCallRestrictionPassword\(slotId: number, oldPassword: string, newPassword: string\): Promise\ - +Changes the call barring password. 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| +| oldPassword | string | Yes | Old password for call barring. | +| newPassword | string | Yes | New password for call barring. | -| | | | | +**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. | +| 801 | Capability not supported. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | + +**Example** + +```js +call.setCallRestrictionPassword(0, "123456", "654321").then(() => { + console.log(`setCallRestrictionPassword success.`); +}).catch((err) => { + console.error(`setCallRestrictionPassword 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. | +| 801 | Capability not supported. | +| 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. | +| 801 | Capability not supported. | +| 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. | +| 801 | Capability not supported. | +| 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. | +| 801 | Capability not supported. | +| 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. - +**Required permission**: ohos.permission.SET_TELEPHONY_STATE - +**System capability**: SystemCapability.Telephony.CallManager - +**Parameters** -| | | | | +| Name | Type | Mandatory| Description | | -------- | ---------------------------- | ---- | ---------- | -| | | | | -| | | | | +| device | [AudioDevice](#audiodevice10)| 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 | | -------- | -------------------------------------------- | -| | | -| | | -| | | -| | | -| | | -| | | -| | | - - - - - - +| 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 audioDevice={ + deviceType: 1 } - - - +call.setAudioDevice(audioDevice, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); +}); ``` -## +## call.setAudioDevice10+ - +setAudioDevice\(device: AudioDevice): Promise\ - +Sets the audio device for a 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 - +**Parameters** -| | | | | +| Name | Type | Mandatory| Description | | -------- | ---------------------------- | ---- | ---------- | -| | | | | +| device | [AudioDevice](#audiodevice10)| Yes | Audio device.| - +**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 audioDevice={ + deviceType: 1 } - - - - - +call.setAudioDevice(audioDevice).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<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; +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<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; +let state = 1; +call.setVoNRState(slotId, state).then((data) => { + 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((data) => { + 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)}`); } ``` -## +## call.removeMissedIncomingCallNotification10+ + +removeMissedIncomingCallNotification\(callback: AsyncCallback\\): void + +Removes missed call notifications. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE, ohos.permission.READ_CALL_LOG, and ohos.permission.WRITE_CALL_LOG + +**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. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +call.removeMissedIncomingCallNotification((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); +}); +``` + + +## call.removeMissedIncomingCallNotification10+ + +removeMissedIncomingCallNotification\(\): Promise\ + +Removes missed call notifications. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE, ohos.permission.READ_CALL_LOG, and ohos.permission.WRITE_CALL_LOG + +**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 +let promise = call.removeMissedIncomingCallNotification(); +promise.then(data => { + console.log(`removeMissedIncomingCallNotification success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`removeMissedIncomingCallNotification failed, promise: err->${JSON.stringify(err)}`); +}); +``` + + +## 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+ - +Provides an option for determining whether a call is a video 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. | -## +## AudioDevice10+ - +Enumerates audio devices. - +**System API**: This is a system API. - +**System capability**: SystemCapability.Telephony.CallManager -| | | | | +| Name | Type | Mandatory | Description | | --------------------------------- | ------------------------------------- | ---- | ---------------- | -| | | | | -| | | | | +| deviceType 10+ | [AudioDeviceType](#audiodevicetype10) | Yes | Audio device type. | +| address 10+ | string | No | Audio device address. | -## +## 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\](#audiodevice10) | Yes | Audio device list. | +| currentAudioDevice 10+ | [AudioDevice](#audiodevice10) | Yes | Current audio device. | +| 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.| diff --git a/en/application-dev/reference/apis/js-apis-inputdevice.md b/en/application-dev/reference/apis/js-apis-inputdevice.md index d07a232664c8e095c9dd7dbf33f41b571c33f3e4..b69a4f06be062bf9a06e61ee79c0c5d496749148 100644 --- a/en/application-dev/reference/apis/js-apis-inputdevice.md +++ b/en/application-dev/reference/apis/js-apis-inputdevice.md @@ -468,11 +468,13 @@ Sets the keyboard repeat delay. This API uses an asynchronous callback to return **System capability**: SystemCapability.MultimodalInput.Input.InputDevice +**System API**: This is a system API. + **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**.| +| delay | number | Yes | Keyboard repeat delay, in ms. The value range is [300, 1000] and the default value is **500**.| | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** @@ -499,6 +501,8 @@ Sets the keyboard repeat delay. This API uses a promise to return the result. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice +**System API**: This is a system API. + **Parameters** | Name | Type | Mandatory | Description | @@ -523,6 +527,66 @@ try { } ``` +## inputDevice.getKeyboardRepeatDelay10+ + +getKeyboardRepeatDelay(callback: AsyncCallback<number>): void + +Obtains the keyboard repeat delay. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback<number> | Yes | Callback used to return the result.| + +**Example** + +```js +try { + inputDevice.getKeyboardRepeatDelay((error, delay) => { + if (error) { + console.log(`Get keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + return; + } + console.log(`Get keyboard repeat delay success`); + }); +} catch (error) { + console.log(`Get keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputDevice.getKeyboardRepeatDelay10+ + +getKeyboardRepeatDelay(): Promise<number> + +Obtains the keyboard repeat delay. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**System API**: This is a system API. + +**Return value** + +| Parameters | Description | +| --------------------- | ------------------- | +| Promise<number> | Promise used to return the result.| + +**Example** + +```js +try { + inputDevice.getKeyboardRepeatDelay().then(delay => { + console.log(`Get keyboard repeat delay success`); + }); +} catch (error) { + console.log(`Get keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + ## inputDevice.setKeyboardRepeatRate10+ setKeyboardRepeatRate(rate: number, callback: AsyncCallback<void>): void @@ -531,6 +595,8 @@ Sets the keyboard repeat rate. This API uses an asynchronous callback to return **System capability**: SystemCapability.MultimodalInput.Input.InputDevice +**System API**: This is a system API. + **Parameters** | Name | Type | Mandatory| Description | @@ -562,6 +628,8 @@ Sets the keyboard repeat rate. This API uses a promise to return the result. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice +**System API**: This is a system API. + **Parameters** | Name | Type | Mandatory | Description | @@ -586,6 +654,66 @@ try { } ``` +## inputDevice.getKeyboardRepeatRate10+ + +getKeyboardRepeatRate(callback: AsyncCallback<number>): void + +Obtains the keyboard repeat rate. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | ---- | -------------- | +| callback | AsyncCallback<number> | Yes | Callback used to return the result.| + +**Example** + +```js +try { + inputDevice.getKeyboardRepeatRate((error, rate) => { + if (error) { + console.log(`Get keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + return; + } + console.log(`Get keyboard repeat rate success`); + }); +} catch (error) { + console.log(`Get keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputDevice.getKeyboardRepeatRate10+ + +getKeyboardRepeatRate(): Promise<number> + +Obtains the keyboard repeat rate. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**System API**: This is a system API. + +**Return value** + +| Parameters | Description | +| --------------------- | ------------------- | +| Promise<number> | Promise used to return the result.| + +**Example** + +```js +try { + inputDevice.getKeyboardRepeatRate().then(rate => { + console.log(`Get keyboard repeat rate success`); + }); +} catch (error) { + console.log(`Get keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + ## DeviceListener9+ Defines the listener for hot swap events of an input device. diff --git a/en/application-dev/reference/apis/js-apis-mindSporeLite.md b/en/application-dev/reference/apis/js-apis-mindSporeLite.md index dfa2aa0e22c175001ed2598102da9313f7a588b1..6a80afa3976c1ee8c4fdce9e3ffa0e1288fdd62c 100644 --- a/en/application-dev/reference/apis/js-apis-mindSporeLite.md +++ b/en/application-dev/reference/apis/js-apis-mindSporeLite.md @@ -1,8 +1,7 @@ # @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. +The **mindSporeLite** module provides APIs for the MindSpore Lite inference engine to implment model inference. > **NOTE** > diff --git a/en/application-dev/reference/apis/js-apis-observer.md b/en/application-dev/reference/apis/js-apis-observer.md index 81a8b7bc6859f69bb6543e18600fd46296bb818c..1c511921ee8e093eb8cd4a7c4b42d0694fdafe10 100644 --- a/en/application-dev/reference/apis/js-apis-observer.md +++ b/en/application-dev/reference/apis/js-apis-observer.md @@ -849,6 +849,83 @@ observer.off('simStateChange', callback); observer.off('simStateChange'); ``` +## observer.on('iccAccountInfoChange')10+ + +on\(type: 'iccAccountInfoChange', callback: Callback\\): void; + +Registers an observer for account information change events of the SIM card. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes | Account information change event. This field has a fixed value of **iccAccountInfoChange**. | +| callback | Callback\ | 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 | +| -------- | -------------------------------------------- | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +observer.on('iccAccountInfoChange', error => { + console.log("on iccAccountInfoChange, error:" + JSON.stringify(error)); +}); +``` + + +## observer.off('iccAccountInfoChange')10+ + +off\(type: 'iccAccountInfoChange', callback?: Callback\\): void; + +Unregisters the observer for account information change events of the SIM card. 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.Telephony.StateRegistry + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes | Account information change event. This field has a fixed value of **iccAccountInfoChange**. | +| callback | Callback\ | No | 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 | +| -------- | -------------------------------------------- | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let callback = data => { + console.log("on iccAccountInfoChange, data:" + JSON.stringify(data)); +} +observer.on('iccAccountInfoChange', 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. +observer.off('iccAccountInfoChange', callback); +observer.off('iccAccountInfoChange'); +``` + ## LockReason8+ diff --git a/en/application-dev/reference/apis/js-apis-power.md b/en/application-dev/reference/apis/js-apis-power.md index 04967480dfd6469eea02de987f0be83a71f6fc9d..00455b6440d170f5579d0376b3156dab7859ff0f 100644 --- a/en/application-dev/reference/apis/js-apis-power.md +++ b/en/application-dev/reference/apis/js-apis-power.md @@ -147,7 +147,7 @@ try { ## power.suspend9+ -suspend(): void +suspend(isImmediate?: boolean): void Hibernates a device. @@ -155,6 +155,13 @@ Hibernates a device. **System capability:** SystemCapability.PowerManager.PowerManager.Core +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------- | +| isImmediate10+ | boolean | No | Whether to hibernate a device immediately. If this parameter is not specified, the default value **false** is used. The system automatically determines when to enter the hibernation state.
**NOTE**: This parameter is supported since API version 10.| + + **Error codes** For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md). @@ -289,6 +296,39 @@ power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE) }); ``` +## power.isStandby10+ + +isStandby(): boolean + +Checks whether the device is in standby mode. + +**System capability:** SystemCapability.PowerManager.PowerManager.Core + +**Return value** + +| Type | Description | +| ------------------- | -------------------------------------- | +| boolean | The value **true** indicates that the device is in standby mode, and the value **false** indicates the opposite.| + +**Error codes** + +For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md). + +| ID | Error Message | +|---------|---------| +| 4900101 | If connecting to the service failed. | + +**Example** + +```js +try { + var isStandby = power.isStandby(); + console.info('device is in standby: ' + isStandby); +} catch(err) { + console.error('check isStandby failed, err: ' + err); +} +``` + ## power.rebootDevice(deprecated) rebootDevice(reason: string): void diff --git a/en/application-dev/reference/apis/js-apis-shortKey.md b/en/application-dev/reference/apis/js-apis-shortKey.md index 79a8ce26644ead2c634af316ab5e191fc6955442..712d5e10bdb062edb0b8e6d1a36020fb83b73f91 100644 --- a/en/application-dev/reference/apis/js-apis-shortKey.md +++ b/en/application-dev/reference/apis/js-apis-shortKey.md @@ -15,7 +15,7 @@ import shortKey from '@ohos.multimodalInput.shortKey'; ## shortKey.setKeyDownDuration -setKeyDownDuration(businessId: string, delay: number, callback: AsyncCallback<void>): void +setKeyDownDuration(businessKey: string, delay: number, callback: AsyncCallback<void>): void Sets the delay for starting an ability using the shortcut key. This API uses an asynchronous callback to return the result. @@ -25,7 +25,7 @@ Sets the delay for starting an ability using the shortcut key. This API uses an | Name | Type | Mandatory| Description | | ---------- | ------------------- | ---- | ------------------------------------------------------------ | -| businessId | string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.| +| businessKey| string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.| | delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.| | callback | AsyncCallback<void> | Yes | Callback used to return the result. | @@ -49,7 +49,7 @@ try { ## shortKey.setKeyDownDuration -setKeyDownDuration(businessId: string, delay: number): Promise<void> +setKeyDownDuration(businessKey: string, delay: number): Promise<void> Sets the delay for starting an ability using the shortcut key. This API uses a promise to return the result. @@ -59,7 +59,7 @@ Sets the delay for starting an ability using the shortcut key. This API uses a p | Name | Type | Mandatory| Description | | ---------- | ------ | ---- | ------------------------------------------------------------ | -| businessId | string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.| +| businessKey| string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.| | delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.| **Return value** diff --git a/en/application-dev/reference/apis/js-apis-sim.md b/en/application-dev/reference/apis/js-apis-sim.md index 08700a85bd5bab7b6bc8a0e190f5376602eeb462..fb3aa7540b8383f983436c0d713e09346ad6aa3e 100644 --- a/en/application-dev/reference/apis/js-apis-sim.md +++ b/en/application-dev/reference/apis/js-apis-sim.md @@ -615,7 +615,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses an | 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 | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** indicates that the SIM card in the specified slot is installed, and the value **false** indicates the opposite. | **Error codes** @@ -681,13 +681,15 @@ promise.then(data => { }); ``` -## sim.getSimAccountInfo7+ +## sim.getSimAccountInfo10+ getSimAccountInfo\(slotId: number, callback: AsyncCallback\\): void Obtains SIM card account information. This API uses an asynchronous callback to return the result. -**System API**: This is a system API. +>**NOTE** +> +>If you do not have the **GET_TELEPHONY_STATE** permission, the ICCID and number information is empty. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -706,8 +708,6 @@ For details about the following error codes, see [Telephony Error Codes](../../r | 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. | @@ -725,13 +725,15 @@ sim.getSimAccountInfo(0, (err, data) => { ``` -## sim.getSimAccountInfo7+ +## sim.getSimAccountInfo10+ getSimAccountInfo\(slotId: number\): Promise\ Obtains SIM card account information. This API uses a promise to return the result. -**System API**: This is a system API. +>**NOTE** +> +>If you do not have the **GET_TELEPHONY_STATE** permission, the ICCID and number information is empty. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -755,8 +757,6 @@ For details about the following error codes, see [Telephony Error Codes](../../r | 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. | @@ -776,13 +776,15 @@ promise.then(data => { }); ``` -## sim.getActiveSimAccountInfoList8+ +## sim.getActiveSimAccountInfoList10+ getActiveSimAccountInfoList\(callback: AsyncCallback\\>\): void Obtains the account information list of the active SIM card. This API uses an asynchronous callback to return the result. -**System API**: This is a system API. +>**NOTE** +> +>If you do not have the **GET_TELEPHONY_STATE** permission, the ICCID and number information is empty. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -800,8 +802,6 @@ For details about the following error codes, see [Telephony Error Codes](../../r | ID| Error Message | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | @@ -817,13 +817,15 @@ sim.getActiveSimAccountInfoList((err, data) => { ``` -## sim.getActiveSimAccountInfoList8+ +## sim.getActiveSimAccountInfoList10+ getActiveSimAccountInfoList\(\): Promise\\>; Obtains the account information list of the active SIM card. This API uses a promise to return the result. -**System API**: This is a system API. +>**NOTE** +> +>If you do not have the **GET_TELEPHONY_STATE** permission, the ICCID and number information is empty. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -841,8 +843,6 @@ For details about the following error codes, see [Telephony Error Codes](../../r | ID| Error Message | | -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Non-system applications use system APIs. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | | 8300004 | Do not have sim card. | @@ -2250,6 +2250,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r | 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. | @@ -2302,6 +2303,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r | 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. | @@ -3990,6 +3992,80 @@ try { } ``` +## sim.getDefaultVoiceSimId10+ + +getDefaultVoiceSimId\(callback: AsyncCallback\\): void + +Obtains the default slot ID of the SIM card that provides voice services. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------- | ---- | ---------- | +| callback | AsyncCallback<number> | Yes | Callback used to return the result.
The return value is bound to the SIM card and increases from 1.| + +**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. | +| 8300004 | Do not have sim card. | +| 8300999 | Unknown error code. | +| 8301001 | SIM card is not activated. | + +**Example** + +```js +sim.getDefaultVoiceSimId((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## sim.getDefaultVoiceSimId10+ + +getDefaultVoiceSimId\(\): Promise\ + +Obtains the default slot ID of the SIM card that provides voice services. This API uses a promise to return the result. + +**System capability**: SystemCapability.Telephony.CoreService + +**Return value** + +| Type | Description | +| ----------------- | --------------------------------------- | +| Promise\ | Promise used to return the result.
The return value is bound to the SIM card and increases from 1.| + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300004 | Do not have sim card. | +| 8300999 | Unknown error code. | +| 8301001 | SIM card is not activated. | + +**Example** + +```js +let promise = sim.getDefaultVoiceSimId(); +promise.then(data => { + console.log(`getDefaultVoiceSimId success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getDefaultVoiceSimId failed, promise: err->${JSON.stringify(err)}`); +}); +``` + ## SimState Enumerates SIM card states. @@ -4113,7 +4189,7 @@ Defines the personalized lock information. ## IccAccountInfo7+ -Defines the ICC account information. +ICC account information. **System API**: This is a system API. diff --git a/en/application-dev/reference/apis/js-apis-sms.md b/en/application-dev/reference/apis/js-apis-sms.md index b959988ba1c900b0ef4273ec6773a504076c76a6..e428eaa609d028073417c7759d3b0c645e5f80a7 100644 --- a/en/application-dev/reference/apis/js-apis-sms.md +++ b/en/application-dev/reference/apis/js-apis-sms.md @@ -99,12 +99,16 @@ promise.then(data => { }); ``` -## sms.sendMessage +## sms.sendMessage(deprecated) sendMessage\(options: SendMessageOptions\): void Sends an SMS message. +> **NOTE** +> +> This API is supported since API version 8 and deprecated since API version 10. You are advised to use [sendShortMessage](#smssendshortmessage10). + **Required permissions**: ohos.permission.SEND_MESSAGES **System capability**: SystemCapability.Telephony.SmsMms @@ -146,6 +150,114 @@ let options = {slotId, content, destinationHost, serviceCenter, destinationPort, sms.sendMessage(options); ``` +## sms.sendShortMessage10+ + +sendShortMessage\(options: SendMessageOptions, callback: AsyncCallback<void>\): void + +Sends an SMS message. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.SEND_MESSAGES + +**System capability**: SystemCapability.Telephony.SmsMms + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------- | ---- | ---------------------------------------- | +| options | [SendMessageOptions](#sendmessageoptions) | Yes | Options (including the callback) for sending an SMS 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. | +| 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 sendCallback = function (err, data) { + console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +} +let deliveryCallback = function (err, data) { + console.log(`deliveryCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +} +let slotId = 0; +let content ='SMS message content'; +let destinationHost = '+861xxxxxxxxxx'; +let serviceCenter = '+861xxxxxxxxxx'; +let destinationPort = 1000; +let options = {slotId, content, destinationHost, serviceCenter, destinationPort, sendCallback, deliveryCallback}; +sms.sendMessage(options, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); +}); +``` + +## sms.sendShortMessage10+ + +sendShortMessage\(options: SendMessageOptions\): Promise<void> + +Sends an SMS message. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.SEND_MESSAGES + +**System capability**: SystemCapability.Telephony.SmsMms + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------- | ---- | ---------------------------------------- | +| options | [SendMessageOptions](#sendmessageoptions) | Yes | Options (including the callback) for sending an SMS message.| + +**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. | +| 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 sendCallback = function (err, data) { + console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +} +let deliveryCallback = function (err, data) { + console.log(`deliveryCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +} +let slotId = 0; +let content ='SMS message content'; +let destinationHost = '+861xxxxxxxxxx'; +let serviceCenter = '+861xxxxxxxxxx'; +let destinationPort = 1000; +let options = {slotId, content, destinationHost, serviceCenter, destinationPort, sendCallback, deliveryCallback}; +let promise = sms.sendShortMessage(options); +promise.then(() => { + console.log(`sendShortMessage success`); +}).catch(err => { + console.error(`sendShortMessage failed, promise: err->${JSON.stringify(err)}`); +}); + +``` ## sms.getDefaultSmsSlotId7+ @@ -1371,6 +1483,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r | ID| Error Message | | -------- | -------------------------------------------- | +| 202 | Non-system applications use system APIs. | | 401 | Parameter error. | | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | @@ -1415,6 +1528,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r | ID| Error Message | | -------- | -------------------------------------------- | +| 202 | Non-system applications use system APIs. | | 401 | Parameter error. | | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | @@ -1456,6 +1570,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r | ID| Error Message | | -------- | -------------------------------------------- | +| 202 | Non-system applications use system APIs. | | 401 | Parameter error. | | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | @@ -1508,6 +1623,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r | ID| Error Message | | -------- | -------------------------------------------- | +| 202 | Non-system applications use system APIs. | | 401 | Parameter error. | | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | @@ -1534,6 +1650,81 @@ promise.then(data => { }); ``` +## sms.getDefaultSmsSimId10+ + +getDefaultSmsSimId\(callback: AsyncCallback<number>\): void + +Obtains the default ID of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Telephony.SmsMms + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------- | ---- | ---------------------------------------- | +| callback | AsyncCallback<number> | Yes | Callback used to return the result.
The return value is bound to the SIM card and increases from 1.| + +**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. | +| 8300004 | Do not have sim card. | +| 8300999 | Unknown error code. | +| 8301001 | SIM card is not activated. | + +**Example** + +```js +sms.getDefaultSmsSimId((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sms.getDefaultSmsSimId10+ + +getDefaultSmsSimId\(\): Promise<number> + +Obtains the default ID of the SIM card used to send SMS messages. This API uses a promise to return the result. + +**System capability**: SystemCapability.Telephony.SmsMms + +**Return value** + +| Type | Description | +| --------------- | ------------------------------------------------------------ | +| Promise<number> | Promise used to return the result.
The return value is bound to the SIM card and increases from 1.| + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300004 | Do not have sim card. | +| 8300999 | Unknown error code. | +| 8301001 | SIM card is not activated. | + +**Example** + +```js +let promise = sms.getDefaultSmsSimId(); +promise.then(data => { + console.log(`getDefaultSmsSimId success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getDefaultSmsSimId failed, promise: err->${JSON.stringify(err)}`); +}); +``` + ## ShortMessage Defines an SMS message instance. @@ -2026,7 +2217,7 @@ Defines an MMS message delivery index. | messageId | string | Yes | Message ID.| | date | number | Yes | Date. | | to | Array<[MmsAddress](#mmsaddress8)\> | Yes | Destination address.| -| status | number | Yes | Status | +| status | number | Yes | Status. | | version | [MmsVersionType](#mmsversiontype8) | Yes | Version. | ## MmsRespInd8+ @@ -2040,7 +2231,7 @@ Defines an MMS response index. | Name | Type | Mandatory| Description | | ------------- | ---------------------------------- | ---- | -------- | | transactionId | string | Yes | Event ID. | -| status | number | Yes | Status | +| status | number | Yes | Status. | | version | [MmsVersionType](#mmsversiontype8) | Yes | Version. | | reportAllowed | [ReportType](#reporttype8) | No | Report allowed.| diff --git a/en/application-dev/reference/apis/js-apis-socket.md b/en/application-dev/reference/apis/js-apis-socket.md index 62bdc0ec13d6df516a3d0b632f9c6fcbd30b342e..6e89fa67f9e48752ca11967eb4be365554c9cf17 100644 --- a/en/application-dev/reference/apis/js-apis-socket.md +++ b/en/application-dev/reference/apis/js-apis-socket.md @@ -2398,7 +2398,7 @@ Enables listening for **close** events of a **TCPSocketConnection** object. This | 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. | +| callback | Callback\ | Yes | Callback used to return the result. | **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-telephony-data.md b/en/application-dev/reference/apis/js-apis-telephony-data.md index 4b234fb7c765a888a037d1034856225d069e5bb3..27ed2853288b73303f841a2c2c6061fcfe90a191 100644 --- a/en/application-dev/reference/apis/js-apis-telephony-data.md +++ b/en/application-dev/reference/apis/js-apis-telephony-data.md @@ -1,6 +1,6 @@ # @ohos.telephony.data (Cellular Data) -The cellular data module provides basic mobile data management functions. You can obtain and set the default slot of the SIM card used for mobile data, and obtain the uplink and downlink connection status of cellular data services and connection status of the packet switched (PS) domain. Besides, you can check whether cellular data services and data roaming are enabled. +The **data** module provides basic mobile data management functions. You can obtain and set the default slot of the SIM card used for mobile data, and obtain the uplink and downlink connection status of cellular data services and connection status of the packet switched (PS) domain. Besides, you can check whether cellular data services and data roaming are enabled. >**NOTE** > @@ -24,7 +24,7 @@ Obtains the default slot of the SIM card used for mobile data. This API uses an | Name | Type | Mandatory| Description | | -------- | ----------------------- | ---- | ------------------------------------------ | -| callback | AsyncCallback\ | Yes | Callback used to return the result.
**0**: card slot 1
**1**: card slot 2| +| callback | AsyncCallback\ | Yes | Callback used to return the result.
**0**: card slot 1.
**1**: card slot 2.| **Example** @@ -46,7 +46,7 @@ Obtains the default slot of the SIM card used for mobile data. This API uses a p | Type | Description | | ----------------- | ------------------------------------------------------------ | -| Promise\ | Promise used to return the result.
**0**: card slot 1
**1**: card slot 2| +| Promise\ | Promise used to return the result.
**0**: card slot 1.
**1**: card slot 2.| **Example** @@ -71,7 +71,7 @@ Obtains the default SIM card used for mobile data synchronously. | Type | Description | | ------ | -------------------------------------------------- | -| number | Card slot ID.
**0**: card slot 1
**1**: card slot 2| +| number | Card slot ID.
**0**: card slot 1.
**1**: card slot 2.| **Example** @@ -87,7 +87,7 @@ Sets the default slot of the SIM card used for mobile data. This API uses an asy **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -95,7 +95,7 @@ Sets the default slot of the SIM card used for mobile data. This API uses an asy | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ------------------------------------------------------------ | -| slotId | number | Yes | SIM card slot ID.
**0**: card slot 1
**1**: card slot 2
**-1**: Clears the default configuration.| +| slotId | number | Yes | SIM card slot ID.
- **0**: card slot 1.
- **1**: card slot 2.
- **-1**: Clears the default configuration.| | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Error codes** @@ -130,7 +130,7 @@ Sets the default slot of the SIM card used for mobile data. This API uses a prom **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -138,7 +138,7 @@ Sets the default slot of the SIM card used for mobile data. This API uses a prom | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| slotId | number | Yes | SIM card slot ID.
**0**: card slot 1
**1**: card slot 2
**-1**: Clears the default configuration.| +| slotId | number | Yes | SIM card slot ID.
- **0**: card slot 1.
- **1**: card slot 2.
- **-1**: Clears the default configuration.| **Return value** @@ -356,7 +356,7 @@ Checks whether roaming is enabled for the cellular data service. This API uses a | Name | Type | Mandatory| Description | | -------- | ------------------------ | ---- | ------------------------------------------------------------ | -| slotId | number | Yes | Card slot ID.
**0**: card slot 1
**1**: card slot 2 | +| slotId | number | Yes | Card slot ID.
**0**: card slot 1.
**1**: card slot 2. | | callback | AsyncCallback\ | Yes | Callback used to return the result.
**true**: Roaming is enabled for the cellular data service.
**false**: Roaming is disabled for the cellular data service.| **Error codes** @@ -394,7 +394,7 @@ Checks whether roaming is enabled for the cellular data service. This API uses a | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ---------------------------------------- | -| slotId | number | Yes | Card slot ID.
**0**: card slot 1
**1**: card slot 2| +| slotId | number | Yes | Card slot ID.
**0**: card slot 1.
**1**: card slot 2.| **Return value** @@ -434,7 +434,7 @@ Enables the cellular data service. This API uses an asynchronous callback to ret **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -474,7 +474,7 @@ Enables the cellular data service. This API uses a promise to return the result. **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -515,7 +515,7 @@ Disables the cellular data service. This API uses an asynchronous callback to re **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -555,7 +555,7 @@ Disables the cellular data service. This API uses a promise to return the result **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -596,7 +596,7 @@ Enables the cellular data roaming service. This API uses an asynchronous callbac **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -604,7 +604,7 @@ Enables the cellular data roaming service. This API uses an asynchronous callbac | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ---------------------------------------- | -| slotId | number | Yes | Card slot ID.
**0**: card slot 1
**1**: card slot 2| +| slotId | number | Yes | Card slot ID.
**0**: card slot 1.
**1**: card slot 2.| | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Error codes** @@ -637,7 +637,7 @@ Enables the cellular data roaming service. This API uses a promise to return the **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -645,7 +645,7 @@ Enables the cellular data roaming service. This API uses a promise to return the | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ---------------------------------------- | -| slotId | number | Yes | Card slot ID.
**0**: card slot 1
**1**: card slot 2| +| slotId | number | Yes | Card slot ID.
**0**: card slot 1.
**1**: card slot 2.| **Return value** @@ -686,7 +686,7 @@ Disables the cellular data roaming service. This API uses an asynchronous callba **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -694,7 +694,7 @@ Disables the cellular data roaming service. This API uses an asynchronous callba | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ---------------------------------------- | -| slotId | number | Yes | Card slot ID.
**0**: card slot 1
**1**: card slot 2| +| slotId | number | Yes | Card slot ID.
**0**: card slot 1.
**1**: card slot 2.| | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Error codes** @@ -727,7 +727,7 @@ Disables the cellular data roaming service. This API uses a promise to return th **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -735,7 +735,7 @@ Disables the cellular data roaming service. This API uses a promise to return th | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ---------------------------------------- | -| slotId | number | Yes | Card slot ID.
**0**: card slot 1
**1**: card slot 2| +| slotId | number | Yes | Card slot ID.
**0**: card slot 1.
**1**: card slot 2.| **Return value** @@ -768,6 +768,26 @@ promise.then(() => { }); ``` +## data.getDefaultCellularDataSimId10+ + +getDefaultCellularDataSimId(): number + +Obtains the default ID of the SIM card used for mobile data. + +**System capability**: SystemCapability.Telephony.CellularData + +**Return value** + +| Type | Description | +| ------ | -------------------------------------------------- | +| number | Obtains the default ID of the SIM card used for mobile data.
The return value is bound to the SIM card and increases from 1.| + +**Example** + +```js +console.log("Result: "+ data.getDefaultCellularDataSimId()) +``` + ## DataFlowType Defines the cellular data flow type. diff --git a/en/application-dev/reference/native-apis/Readme-EN.md b/en/application-dev/reference/native-apis/Readme-EN.md index 87aeec065c1bc5d206b96b68a1c0e4971aeda87f..fee6bf6d47f2dd9fc3268c8e0384cf0ea0567727 100644 --- a/en/application-dev/reference/native-apis/Readme-EN.md +++ b/en/application-dev/reference/native-apis/Readme-EN.md @@ -29,6 +29,8 @@ - [HuksTypeApi](_huks_type_api.md) - [Init](init.md) - [Memory](memory.md) + - [UsbDdk](_usb_ddk.md) + - [Hitrace](_hitrace.md) - Header Files - [drawing_bitmap.h](drawing__bitmap_8h.md) - [drawing_brush.h](drawing__brush_8h.md) @@ -87,6 +89,9 @@ - [relational_store.h](relational__store_8h.md) - [syscap_ndk.h](syscap__ndk_8h.md) - [purgeable_memory.h](purgeable__memory_8h.md) + - [usb_ddk_api.h](usb__ddk__api_8h.md) + - [usb_ddk_types.h](usb__ddk__types_8h.md) + - [trace.h](trace_8h.md) - Structs - [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) - [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) @@ -132,3 +137,14 @@ - [OH_Rdb_Store](_o_h___rdb___store.md) - [OH_VBucket](_o_h___v_bucket.md) - [OH_VObject](_o_h___v_object.md) + - [UsbConfigDescriptor](_usb_config_descriptor.md) + - [UsbControlRequestSetup](_usb_control_request_setup.md) + - [UsbDdkConfigDescriptor](_usb_ddk_config_descriptor.md) + - [UsbDdkEndpointDescriptor](_usb_ddk_endpoint_descriptor.md) + - [UsbDdkInterface](_usb_ddk_interface.md) + - [UsbDdkInterfaceDescriptor](_usb_ddk_interface_descriptor.md) + - [UsbDeviceDescriptor](_usb_device_descriptor.md) + - [UsbDeviceMemMap](_usb_device_mem_map.md) + - [UsbEndpointDescriptor](_usb_endpoint_descriptor.md) + - [UsbInterfaceDescriptor](_usb_interface_descriptor.md) + - [UsbRequestPipe](_usb_request_pipe.md) diff --git a/en/application-dev/reference/native-apis/_usb_config_descriptor.md b/en/application-dev/reference/native-apis/_usb_config_descriptor.md new file mode 100644 index 0000000000000000000000000000000000000000..2a5e7498f86d2aaaeaff4548cd75bce912d2dcf2 --- /dev/null +++ b/en/application-dev/reference/native-apis/_usb_config_descriptor.md @@ -0,0 +1,130 @@ +# UsbConfigDescriptor + + +## Overview + +Defines standard configuration descriptors, which correspond to **Standard Configuration Descriptor** in the USB protocol. + +**Since** + +10 + +**Related Modules** + +[UsbDdk](_usb_ddk.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [bLength](#blength) | Size of the descriptor, in bytes.| +| [bDescriptorType](#bdescriptortype) | Descriptor type.| +| [wTotalLength](#wtotallength) | Total length of the configuration descriptor, including the configuration, interface, endpoint, and class- or vendor-specific descriptors.| +| [bNumInterfaces](#bnuminterfaces) | Number of interfaces supported by the configuration.| +| [bConfigurationValue](#bconfigurationvalue) | Configuration index, which is used to select the configuration.| +| [iConfiguration](#iconfiguration) | Index of the string descriptor that describes the configuration.| +| [bmAttributes](#bmattributes) | Configuration attributes, including the power mode and remote wakeup.| +| [bMaxPower](#bmaxpower) | Maximum power consumption of the bus-powered USB device, in 2 mA.| + + +## Member Variable Description + + +### bConfigurationValue + + +``` +uint8_t UsbConfigDescriptor::bConfigurationValue +``` + +**Description** + +Configuration index, which is used to select the configuration. + + +### bDescriptorType + + +``` +uint8_t UsbConfigDescriptor::bDescriptorType +``` + +**Description** + +Descriptor type. + + +### bLength + + +``` +uint8_t UsbConfigDescriptor::bLength +``` + +**Description** + +Size of the descriptor, in bytes. + + +### bmAttributes + + +``` +uint8_t UsbConfigDescriptor::bmAttributes +``` + +**Description** + +Configuration attributes, including the power mode and remote wakeup. + + +### bMaxPower + + +``` +uint8_t UsbConfigDescriptor::bMaxPower +``` + +**Description** + +Maximum power consumption of the bus-powered USB device, in 2 mA. + + +### bNumInterfaces + + +``` +uint8_t UsbConfigDescriptor::bNumInterfaces +``` + +**Description** + +Number of interfaces supported by the configuration. + + +### iConfiguration + + +``` +uint8_t UsbConfigDescriptor::iConfiguration +``` + +**Description** + +Index of the string descriptor that describes the configuration. + + +### wTotalLength + + +``` +uint16_t UsbConfigDescriptor::wTotalLength +``` + +**Description** + +Total length of the configuration descriptor, including the configuration, interface, endpoint, and class- or vendor-specific descriptors. diff --git a/en/application-dev/reference/native-apis/_usb_control_request_setup.md b/en/application-dev/reference/native-apis/_usb_control_request_setup.md new file mode 100644 index 0000000000000000000000000000000000000000..84277932fa8f813b3127b2f416595ded5449a4a4 --- /dev/null +++ b/en/application-dev/reference/native-apis/_usb_control_request_setup.md @@ -0,0 +1,91 @@ +# UsbControlRequestSetup + + +## Overview + +Defines the setup data for control transfer, which corresponds to Setup Data in the USB protocol. + +**Since** + +10 + +**Related Modules** + +[UsbDdk](_usb_ddk.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [bmRequestType](#bmrequesttype) | Request type.| +| [bRequest](#brequest) | Specific request.| +| [wValue](#wvalue) | Value corresponding to **wValue** in the USB protocol. Its meaning varies according to the request.| +| [wIndex](#windex) | Index corresponding to **wIndex** in the USB protocol. It is usually used to transfer the index or offset. Its meaning varies according to the request. | +| [wLength](#wlength) | Data length corresponding to **wLength** in the USB protocol. If data is transferred, this field indicates the number of transferred bytes.| + + +## Member Variable Description + + +### wIndex + + +``` +uint16_t UsbControlRequestSetup::wIndex +``` + +**Description** + +Index corresponding to **wIndex** in the USB protocol. It is usually used to transfer the index or offset. Its meaning varies according to the request. + + +### wLength + + +``` +uint16_t UsbControlRequestSetup::wLength +``` + +**Description** + +Data length corresponding to **wLength** in the USB protocol. If data is transferred, this field indicates the number of transferred bytes. + + +### bRequest + + +``` +uint8_t UsbControlRequestSetup::bRequest +``` + +**Description** + +Specific request. + + +### bmRequestType + + +``` +uint8_t UsbControlRequestSetup::bmRequestType +``` + +**Description** + +Request type. + + +### wValue + + +``` +uint16_t UsbControlRequestSetup::wValue +``` + +**Description** + +Value corresponding to **wValue** in the USB protocol. Its meaning varies according to the request. diff --git a/en/application-dev/reference/native-apis/_usb_ddk.md b/en/application-dev/reference/native-apis/_usb_ddk.md new file mode 100644 index 0000000000000000000000000000000000000000..1fa6721f4cc8acc4e7db23e38384ff3579c5a840 --- /dev/null +++ b/en/application-dev/reference/native-apis/_usb_ddk.md @@ -0,0 +1,472 @@ +# UsbDdk + + +## Overview + +Provides USB DDK APIs to open and close USB interfaces, perform non-isochronous and isochronous data transfer over USB pipes, and implement control transfer and interrupt transfer, etc. + +\@syscap SystemCapability.Driver.USB.Extension + +**Since** + +10 + + +## Summary + + +### File + +| Name| Description| +| -------- | -------- | +| [usb_ddk_api.h](usb__ddk__api_8h.md) | Declares the USB DDK APIs used by the USB host to access USB devices.
File to include: <usb/usb_ddk_api.h>| +| [usb_ddk_types.h](usb__ddk__types_8h.md) | Provides the enumerated variables, structures, and macros used in USB DDK APIs.
File to include: <usb/usb_ddk_types.h> | + + +### Structs + +| Name| Description| +| -------- | -------- | +| [UsbControlRequestSetup](_usb_control_request_setup.md) | Setup data for control transfer. It corresponds to **Setup Data** in the USB protocol.| +| [UsbDeviceDescriptor](_usb_device_descriptor.md) | Standard device descriptor, corresponding to **Standard Device Descriptor** in the USB protocol.| +| [UsbConfigDescriptor](_usb_config_descriptor.md) | Standard configuration descriptor, corresponding to **Standard Configuration Descriptor** in the USB protocol.| +| [UsbInterfaceDescriptor](_usb_interface_descriptor.md) | Standard interface descriptor, corresponding to **Standard Interface Descriptor** in the USB protocol.| +| [UsbEndpointDescriptor](_usb_endpoint_descriptor.md) | Standard endpoint descriptor, corresponding to **Standard Endpoint Descriptor** in the USB protocol.| +| [UsbDdkEndpointDescriptor](_usb_ddk_endpoint_descriptor.md) | Endpoint descriptor.| +| [UsbDdkInterfaceDescriptor](_usb_ddk_interface_descriptor.md) | Interface descriptor.| +| [UsbDdkInterface](_usb_ddk_interface.md) | USB DDK interface, which is a collection of alternate settings for a particular USB interface.| +| [UsbDdkConfigDescriptor](_usb_ddk_config_descriptor.md) | Configuration descriptor.| +| [UsbRequestPipe](_usb_request_pipe.md) | Request pipe.| +| [UsbDeviceMemMap](_usb_device_mem_map.md) | Device memory map created by calling [OH_Usb_CreateDeviceMemMap()](#oh_usb_createdevicememmap). A buffer using the device memory map can provide better performance.| + + +### Types + +| Name| Description| +| -------- | -------- | +| [UsbDdkEndpointDescriptor](#usbddkendpointdescriptor) | Endpoint descriptor.| +| [UsbDdkInterfaceDescriptor](#usbddkinterfacedescriptor) | Interface descriptor.| +| [UsbDdkInterface](#usbddkinterface) | USB DDK interface, which is a collection of alternate settings for a particular USB interface.| +| [UsbDdkConfigDescriptor](#usbddkconfigdescriptor) | Configuration descriptor.| +| [UsbDeviceMemMap](#usbdevicememmap) | Device memory map created by calling [OH_Usb_CreateDeviceMemMap()](#oh_usb_createdevicememmap). A buffer using the device memory map can provide better performance.| + + +### Enums + +| Name| Description| +| -------- | -------- | +| [UsbDdkErrCode](#usbddkerrcode) {
USB_DDK_SUCCESS = 0, USB_DDK_FAILED = -1, USB_DDK_INVALID_PARAMETER = -2, USB_DDK_MEMORY_ERROR = -3,
USB_DDK_INVALID_OPERATION = -4, USB_DDK_NULL_PTR = -5, USB_DDK_DEVICE_BUSY = -6, USB_DDK_TIMEOUT = -7
} | USB DDK error code definitions.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_Usb_Init](#oh_usb_init) (void) | Initializes the DDK.| +| [OH_Usb_Release](#oh_usb_release) (void) | Releases the DDK.| +| [OH_Usb_GetDeviceDescriptor](#oh_usb_getdevicedescriptor) (uint64_t deviceId, struct [UsbDeviceDescriptor](_usb_device_descriptor.md) \*desc) | Obtains the device descriptor.| +| [OH_Usb_GetConfigDescriptor](#oh_usb_getconfigdescriptor) (uint64_t deviceId, uint8_t configIndex, struct [UsbDdkConfigDescriptor](_usb_ddk_config_descriptor.md) \*\*const config) | Obtains the configuration descriptor. To avoid memory leakage, use **OH_Usb_FreeConfigDescriptor** to release a descriptor after use.| +| [OH_Usb_FreeConfigDescriptor](#oh_usb_freeconfigdescriptor) (const struct [UsbDdkConfigDescriptor](_usb_ddk_config_descriptor.md) \*const config) | Releases the configuration descriptor. To avoid memory leakage, release a descriptor after use.| +| [OH_Usb_ClaimInterface](#oh_usb_claiminterface) (uint64_t deviceId, uint8_t interfaceIndex, uint64_t \*[interfaceHandle](usb__ddk__types_8h.md#interfacehandle)) | Declares a USB interface.| +| [OH_Usb_ReleaseInterface](#oh_usb_releaseinterface) (uint64_t [interfaceHandle](usb__ddk__types_8h.md#interfacehandle)) | Releases a USB interface.| +| [OH_Usb_SelectInterfaceSetting](#oh_usb_selectinterfacesetting) (uint64_t [interfaceHandle](usb__ddk__types_8h.md#interfacehandle), uint8_t settingIndex) | Activates the alternate setting of a USB interface.| +| [OH_Usb_GetCurrentInterfaceSetting](#oh_usb_getcurrentinterfacesetting) (uint64_t [interfaceHandle](usb__ddk__types_8h.md#interfacehandle), uint8_t \*settingIndex) | Obtains the activated alternate setting of a USB interface.| +| [OH_Usb_SendControlReadRequest](#oh_usb_sendcontrolreadrequest) (uint64_t [interfaceHandle](usb__ddk__types_8h.md#interfacehandle), const struct [UsbControlRequestSetup](_usb_control_request_setup.md) \*setup, uint32_t [timeout](usb__ddk__types_8h.md#timeout), uint8_t \*data, uint32_t \*dataLen) | Sends a control read transfer request. This API works in a synchronous manner.| +| [OH_Usb_SendControlWriteRequest](#oh_usb_sendcontrolwriterequest) (uint64_t [interfaceHandle](usb__ddk__types_8h.md#interfacehandle), const struct [UsbControlRequestSetup](_usb_control_request_setup.md) \*setup, uint32_t [timeout](usb__ddk__types_8h.md#timeout), const uint8_t \*data, uint32_t dataLen) | Sends a control write transfer request. This API works in a synchronous manner.| +| [OH_Usb_SendPipeRequest](#oh_usb_sendpiperequest) (const struct [UsbRequestPipe](_usb_request_pipe.md) \*pipe, [UsbDeviceMemMap](_usb_device_mem_map.md) \*devMmap) | Sends a pipe request. This API works in a synchronous manner. It applies to interrupt transfer and bulk transfer.| +| [OH_Usb_CreateDeviceMemMap](#oh_usb_createdevicememmap) (uint64_t deviceId, size_t size, [UsbDeviceMemMap](_usb_device_mem_map.md) \*\*devMmap) | Creates a buffer. To avoid memory leakage, use [OH_Usb_DestroyDeviceMemMap()](#oh_usb_destroydevicememmap) to destroy a buffer after use.| +| [OH_Usb_DestroyDeviceMemMap](#oh_usb_destroydevicememmap) ([UsbDeviceMemMap](_usb_device_mem_map.md) \*devMmap) | Destroys a buffer. To avoid resource leakage, destroy a buffer in time after use.| + + +## Type Description + + +### UsbDdkConfigDescriptor + + +``` +typedef struct UsbDdkConfigDescriptor UsbDdkConfigDescriptor +``` + +**Description** + +Configuration descriptor. + + +### UsbDdkEndpointDescriptor + + +``` +typedef struct UsbDdkEndpointDescriptor UsbDdkEndpointDescriptor +``` + +**Description** + +Endpoint descriptor. + + +### UsbDdkInterface + + +``` +typedef struct UsbDdkInterface UsbDdkInterface +``` + +**Description** + +USB DDK interface, which is a collection of alternate settings for a particular USB interface. + + +### UsbDdkInterfaceDescriptor + + +``` +typedef struct UsbDdkInterfaceDescriptor UsbDdkInterfaceDescriptor +``` + +**Description** + +Interface descriptor. + + +### UsbDeviceMemMap + + +``` +typedef struct UsbDeviceMemMap UsbDeviceMemMap +``` + +**Description** + +Device memory map created by calling [OH_Usb_CreateDeviceMemMap()](#oh_usb_createdevicememmap). A buffer using the device memory map can provide better performance. + + +## Enum Description + + +### UsbDdkErrCode + + +``` +enum UsbDdkErrCode +``` + +**Description** + +USB DDK error code definitions. + +| Value| Description| +| -------- | -------- | +| USB_DDK_SUCCESS | Operation successful.| +| USB_DDK_FAILED | Operation failed.| +| USB_DDK_INVALID_PARAMETER | Invalid parameter.| +| USB_DDK_MEMORY_ERROR | Memory-related error, for example, insufficient memory, memory data copy failure, or memory application failure.| +| USB_DDK_INVALID_OPERATION | Invalid operation.| +| USB_DDK_NULL_PTR | Null pointer.| +| USB_DDK_DEVICE_BUSY | Device busy.| +| USB_DDK_TIMEOUT | Transfer timed out.| + + +## Function Description + + +### OH_Usb_ClaimInterface() + + +``` +int32_t OH_Usb_ClaimInterface (uint64_t deviceId, uint8_t interfaceIndex, uint64_t * interfaceHandle ) +``` + +**Description** + +Declares a USB interface. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| deviceId | Device ID.| +| interfaceIndex | Interface index, which corresponds to [bInterfaceNumber](_usb_interface_descriptor.md#binterfacenumber) in the USB protocol.| +| interfaceHandle | Interface operation handle. After the interface is claimed successfully, a value will be assigned to this parameter.| + +**Returns** + +**0** if the operation is successful; a negative value otherwise. + + +### OH_Usb_CreateDeviceMemMap() + + +``` +int32_t OH_Usb_CreateDeviceMemMap (uint64_t deviceId, size_t size, UsbDeviceMemMap ** devMmap ) +``` + +**Description** + +Creates a buffer. To avoid memory leakage, use [OH_Usb_DestroyDeviceMemMap()](#oh_usb_destroydevicememmap) to destroy a buffer after use. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| deviceId | Device ID.| +| size | Buffer size.| +| devMmap | Data memory map, through which the created buffer is returned to the caller.| + +**Returns** + +**0** if the operation is successful; a negative value otherwise. + + +### OH_Usb_DestroyDeviceMemMap() + + +``` +void OH_Usb_DestroyDeviceMemMap (UsbDeviceMemMap * devMmap) +``` + +**Description** + +Destroys a buffer. To avoid resource leakage, destroy a buffer in time after use. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| devMmap | Destroys the buffer created by [OH_Usb_CreateDeviceMemMap()](#oh_usb_createdevicememmap).| + + +### OH_Usb_FreeConfigDescriptor() + + +``` +void OH_Usb_FreeConfigDescriptor (const struct UsbDdkConfigDescriptor *const config) +``` + +**Description** + +Releases the configuration descriptor. To avoid memory leakage, use **OH_Usb_FreeConfigDescriptor** to release a descriptor after use. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| config | Configuration descriptor obtained by calling [OH_Usb_GetConfigDescriptor()](#oh_usb_getconfigdescriptor).| + + +### OH_Usb_GetConfigDescriptor() + + +``` +int32_t OH_Usb_GetConfigDescriptor (uint64_t deviceId, uint8_t configIndex, struct UsbDdkConfigDescriptor **const config ) +``` + +**Description** + +Obtains the configuration descriptor. To avoid memory leakage, use **OH_Usb_FreeConfigDescriptor** to release a descriptor after use. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| deviceId | Device ID.| +| configIndex | Configuration ID, which corresponds to [bConfigurationValue](_usb_config_descriptor.md#bconfigurationvalue) in the USB protocol.| +| config | Configuration descriptor, which includes the standard configuration descriptor defined in the USB protocol and the associated interface descriptor and endpoint descriptor.| + +**Returns** + +**0** if the operation is successful; a negative value otherwise. + + +### OH_Usb_GetCurrentInterfaceSetting() + + +``` +int32_t OH_Usb_GetCurrentInterfaceSetting (uint64_t interfaceHandle, uint8_t * settingIndex ) +``` + +**Description** + +Obtains the activated alternate setting of a USB interface. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| interfaceHandle | Interface operation handle.| +| settingIndex | Index of the alternate setting, which corresponds to [bAlternateSetting](_usb_interface_descriptor.md#balternatesetting) in the USB protocol.| + +**Returns** + +**0** if the operation is successful; a negative value otherwise. + + +### OH_Usb_GetDeviceDescriptor() + + +``` +int32_t OH_Usb_GetDeviceDescriptor (uint64_t deviceId, struct UsbDeviceDescriptor * desc ) +``` + +**Description** + +Obtains the device descriptor. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| deviceId | Device ID.| +| desc | Device descriptor. For details, see [UsbDeviceDescriptor](_usb_device_descriptor.md).| + +**Returns** + +**0** if the operation is successful; a negative value otherwise. + + +### OH_Usb_Init() + + +``` +int32_t OH_Usb_Init (void ) +``` + +**Description** + +Initializes the DDK. + +**Returns** + +**0** if the operation is successful; a negative value otherwise. + + +### OH_Usb_Release() + + +``` +void OH_Usb_Release (void ) +``` + +**Description** + +Releases the DDK. + + +### OH_Usb_ReleaseInterface() + + +``` +int32_t OH_Usb_ReleaseInterface (uint64_t interfaceHandle) +``` + +**Description** + +Releases a USB interface. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| interfaceHandle | Interface operation handle.| + +**Returns** + +**0** if the operation is successful; a negative value otherwise. + + +### OH_Usb_SelectInterfaceSetting() + + +``` +int32_t OH_Usb_SelectInterfaceSetting (uint64_t interfaceHandle, uint8_t settingIndex ) +``` + +**Description** + +Activates the alternate setting of a USB interface. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| interfaceHandle | Interface operation handle.| +| settingIndex | Index of the alternate setting, which corresponds to [bAlternateSetting](_usb_interface_descriptor.md#balternatesetting) in the USB protocol.| + +**Returns** + +**0** if the operation is successful; a negative value otherwise. + + +### OH_Usb_SendControlReadRequest() + + +``` +int32_t OH_Usb_SendControlReadRequest (uint64_t interfaceHandle, const struct UsbControlRequestSetup * setup, uint32_t timeout, uint8_t * data, uint32_t * dataLen ) +``` + +**Description** + +Sends a control read transfer request. This API works in a synchronous manner. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| interfaceHandle | Interface operation handle.| +| setup | Request parameters. For details, see [UsbControlRequestSetup](_usb_control_request_setup.md).| +| timeout | Timeout duration, in milliseconds.| +| data | Data to be transferred.| +| dataLen | Data length. The return value indicates the length of the actually read data.| + +**Returns** + +**0** if the operation is successful; a negative value otherwise. + + +### OH_Usb_SendControlWriteRequest() + + +``` +int32_t OH_Usb_SendControlWriteRequest (uint64_t interfaceHandle, const struct UsbControlRequestSetup * setup, uint32_t timeout, const uint8_t * data, uint32_t dataLen ) +``` + +**Description** + +Sends a control write transfer request. This API works in a synchronous manner. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| interfaceHandle | Interface operation handle.| +| setup | Request parameters. For details, see [UsbControlRequestSetup](_usb_control_request_setup.md).| +| timeout | Timeout duration, in milliseconds.| +| data | Data to be transferred.| +| dataLen | Data length.| + +**Returns** + +**0** if the operation is successful; a negative value otherwise. + + +### OH_Usb_SendPipeRequest() + + +``` +int32_t OH_Usb_SendPipeRequest (const struct UsbRequestPipe * pipe, UsbDeviceMemMap * devMmap ) +``` + +**Description** + +Sends a pipe request. This API works in a synchronous manner. It applies to interrupt transfer and bulk transfer. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| pipe | Pipe used to transfer data.| +| devMmap | Device memory map, which can be obtained by calling [OH_Usb_CreateDeviceMemMap()](#oh_usb_createdevicememmap).| + +**Returns** + +**0** if the operation is successful; a negative value otherwise. diff --git a/en/application-dev/reference/native-apis/_usb_ddk_config_descriptor.md b/en/application-dev/reference/native-apis/_usb_ddk_config_descriptor.md new file mode 100644 index 0000000000000000000000000000000000000000..bfaecd425c45b53eef5dd8968bf16372024230a2 --- /dev/null +++ b/en/application-dev/reference/native-apis/_usb_ddk_config_descriptor.md @@ -0,0 +1,78 @@ +# UsbDdkConfigDescriptor + + +## Overview + +Defines configuration descriptors. + +**Since** + +10 + +**Related Modules** + +[UsbDdk](_usb_ddk.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [configDescriptor](#configdescriptor) | Standard configuration descriptor.| +| [interface](#interface) | Interfaces contained in the configuration.| +| [extra](#extra) | Unresolved descriptor, including class- or vendor-specific descriptors.| +| [extraLength](#extralength) | Length of the unresolved descriptor.| + + +## Member Variable Description + + +### configDescriptor + + +``` +struct UsbConfigDescriptor UsbDdkConfigDescriptor::configDescriptor +``` + +**Description** + +Standard configuration descriptor. + + +### extra + + +``` +uint8_t* UsbDdkConfigDescriptor::extra +``` + +**Description** + +Unresolved descriptor, including class- or vendor-specific descriptors. + + +### extraLength + + +``` +uint32_t UsbDdkConfigDescriptor::extraLength +``` + +**Description** + +Length of the unresolved descriptor. + + +### interface + + +``` +struct UsbDdkInterface* UsbDdkConfigDescriptor::interface +``` + +**Description** + +Interfaces contained in the configuration. diff --git a/en/application-dev/reference/native-apis/_usb_ddk_endpoint_descriptor.md b/en/application-dev/reference/native-apis/_usb_ddk_endpoint_descriptor.md new file mode 100644 index 0000000000000000000000000000000000000000..243b7c06e4b2b9a45176695963beecadfc863ce3 --- /dev/null +++ b/en/application-dev/reference/native-apis/_usb_ddk_endpoint_descriptor.md @@ -0,0 +1,65 @@ +# UsbDdkEndpointDescriptor + + +## Overview + +Defines endpoint descriptors. + +**Since** + +10 + +**Related Modules** + +[UsbDdk](_usb_ddk.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [endpointDescriptor](#endpointdescriptor) | Standard endpoint descriptor.| +| [extra](#extra) | Unresolved descriptor, including class- or vendor-specific descriptors.| +| [extraLength](#extralength) | Length of the unresolved descriptor.| + + +## Member Variable Description + + +### endpointDescriptor + + +``` +struct UsbEndpointDescriptor UsbDdkEndpointDescriptor::endpointDescriptor +``` + +**Description** + +Standard endpoint descriptor. + + +### extra + + +``` +uint8_t* UsbDdkEndpointDescriptor::extra +``` + +**Description** + +Unresolved descriptor, including class- or vendor-specific descriptors. + + +### extraLength + + +``` +uint32_t UsbDdkEndpointDescriptor::extraLength +``` + +**Description** + +Length of the unresolved descriptor. diff --git a/en/application-dev/reference/native-apis/_usb_ddk_interface.md b/en/application-dev/reference/native-apis/_usb_ddk_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..be24c7a9d80eb52d12c74ae1a27b4d3985db0bac --- /dev/null +++ b/en/application-dev/reference/native-apis/_usb_ddk_interface.md @@ -0,0 +1,52 @@ +# UsbDdkInterface + + +## Overview + +Defines a USB DDK interface, which is a collection of alternate settings for a particular USB interface. + +**Since** + +10 + +**Related Modules** + +[UsbDdk](_usb_ddk.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [numAltsetting](#numaltsetting) | Number of alternate settings of the interface.| +| [altsetting](#altsetting) | Alternate setting of the interface.| + + +## Member Variable Description + + +### altsetting + + +``` +struct UsbDdkInterfaceDescriptor* UsbDdkInterface::altsetting +``` + +**Description** + +Alternate setting of the interface. + + +### numAltsetting + + +``` +uint8_t UsbDdkInterface::numAltsetting +``` + +**Description** + +Number of alternate settings of the interface. diff --git a/en/application-dev/reference/native-apis/_usb_ddk_interface_descriptor.md b/en/application-dev/reference/native-apis/_usb_ddk_interface_descriptor.md new file mode 100644 index 0000000000000000000000000000000000000000..c3ecc8992d41adbb133e22430ec6b06c4a6dcd84 --- /dev/null +++ b/en/application-dev/reference/native-apis/_usb_ddk_interface_descriptor.md @@ -0,0 +1,78 @@ +# UsbDdkInterfaceDescriptor + + +## Overview + +Defines interface descriptors. + +**Since** + +10 + +**Related Modules** + +[UsbDdk](_usb_ddk.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [interfaceDescriptor](#interfacedescriptor) | Standard interface descriptor.| +| [endPoint](#endpoint) | Endpoint descriptor contained in the interface.| +| [extra](#extra) | Unresolved descriptor, including class- or vendor-specific descriptors.| +| [extraLength](#extralength) | Length of the unresolved descriptor.| + + +## Member Variable Description + + +### endPoint + + +``` +struct UsbDdkEndpointDescriptor* UsbDdkInterfaceDescriptor::endPoint +``` + +**Description** + +Endpoint descriptor contained in the interface. + + +### extra + + +``` +uint8_t* UsbDdkInterfaceDescriptor::extra +``` + +**Description** + +Unresolved descriptor, including class- or vendor-specific descriptors. + + +### extraLength + + +``` +uint32_t UsbDdkInterfaceDescriptor::extraLength +``` + +**Description** + +Length of the unresolved descriptor. + + +### interfaceDescriptor + + +``` +struct UsbInterfaceDescriptor UsbDdkInterfaceDescriptor::interfaceDescriptor +``` + +**Description** + +Standard interface descriptor. diff --git a/en/application-dev/reference/native-apis/_usb_device_descriptor.md b/en/application-dev/reference/native-apis/_usb_device_descriptor.md new file mode 100644 index 0000000000000000000000000000000000000000..a998d2a7fd180e2a2c9f9acd88133134d727c826 --- /dev/null +++ b/en/application-dev/reference/native-apis/_usb_device_descriptor.md @@ -0,0 +1,208 @@ +# UsbDeviceDescriptor + + +## Overview + +Defines standard device descriptors, which correspond to **Standard Device Descriptor** in the USB protocol. + +**Since** + +10 + +**Related Modules** + +[UsbDdk](_usb_ddk.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [bLength](#blength) | Size of the descriptor, in bytes.| +| [bDescriptorType](#bdescriptortype) | Descriptor type.| +| [bcdUSB](#bcdusb) | USB protocol release number.| +| [bDeviceClass](#bdeviceclass) | Interface class code allocated by the USB-IF.| +| [bDeviceSubClass](#bdevicesubclass) | Device subclass code allocated by USB-IF. The value is limited by that of bDeviceClass.| +| [bDeviceProtocol](#bdeviceprotocol) | Protocol code allocated by USB-IF. The value is limited by that of [bDeviceClass](#bdeviceclass) and [bDeviceSubClass](#bdevicesubclass).| +| [bMaxPacketSize0](#bmaxpacketsize0) | Maximum packet size of endpoint 0. Only values 8, 16, 32, and 64 are valid.| +| [idVendor](#idvendor) | Vendor ID allocated by USB-IF.| +| [idProduct](#idproduct) | Product ID allocated by the vendor.| +| [bcdDevice](#bcddevice) | Device release number.| +| [iManufacturer](#imanufacturer) | Index of the string descriptor that describes the vendor.| +| [iProduct](#iproduct) | Index of the string descriptor that describes the product.| +| [iSerialNumber](#iserialnumber) | Index of the string descriptor that describes the device SN.| +| [bNumConfigurations](#bnumconfigurations) | Configuration quantity.| + + +## Member Variable Description + + +### bcdDevice + + +``` +uint16_t UsbDeviceDescriptor::bcdDevice +``` + +**Description** + +Device release number. + + +### bcdUSB + + +``` +uint16_t UsbDeviceDescriptor::bcdUSB +``` + +**Description** + +USB protocol release number. + + +### bDescriptorType + + +``` +uint8_t UsbDeviceDescriptor::bDescriptorType +``` + +**Description** + +Descriptor type. + + +### bDeviceClass + + +``` +uint8_t UsbDeviceDescriptor::bDeviceClass +``` + +**Description** + +Interface class code allocated by the USB-IF. + + +### bDeviceProtocol + + +``` +uint8_t UsbDeviceDescriptor::bDeviceProtocol +``` + +**Description** + +Protocol code allocated by USB-IF. The value is limited by that of [bDeviceClass](#bdeviceclass) and [bDeviceSubClass](#bdevicesubclass). + + +### bDeviceSubClass + + +``` +uint8_t UsbDeviceDescriptor::bDeviceSubClass +``` + +**Description** + +Device subclass code allocated by USB-IF. The value is limited by that of bDeviceClass. + + +### bLength + + +``` +uint8_t UsbDeviceDescriptor::bLength +``` + +**Description** + +Size of the descriptor, in bytes. + + +### bMaxPacketSize0 + + +``` +uint8_t UsbDeviceDescriptor::bMaxPacketSize0 +``` + +**Description** + +Maximum packet size of endpoint 0. Only values 8, 16, 32, and 64 are valid. + + +### bNumConfigurations + + +``` +uint8_t UsbDeviceDescriptor::bNumConfigurations +``` + +**Description** + +Configuration quantity. + + +### idProduct + + +``` +uint16_t UsbDeviceDescriptor::idProduct +``` + +**Description** + +Product ID allocated by the vendor. + + +### idVendor + + +``` +uint16_t UsbDeviceDescriptor::idVendor +``` + +**Description** + +Vendor ID allocated by USB-IF. + + +### iManufacturer + + +``` +uint8_t UsbDeviceDescriptor::iManufacturer +``` + +**Description** + +Index of the string descriptor that describes the vendor. + + +### iProduct + + +``` +uint8_t UsbDeviceDescriptor::iProduct +``` + +**Description** + +Index of the string descriptor that describes the product. + + +### iSerialNumber + + +``` +uint8_t UsbDeviceDescriptor::iSerialNumber +``` + +**Description** + +Index of the string descriptor that describes the device SN. diff --git a/en/application-dev/reference/native-apis/_usb_device_mem_map.md b/en/application-dev/reference/native-apis/_usb_device_mem_map.md new file mode 100644 index 0000000000000000000000000000000000000000..1b26f2631efe02cedfc4281b86bda8a09fac8c22 --- /dev/null +++ b/en/application-dev/reference/native-apis/_usb_device_mem_map.md @@ -0,0 +1,91 @@ +# UsbDeviceMemMap + + +## Overview + +Device memory map created by calling [OH_Usb_CreateDeviceMemMap()](_usb_ddk.md#oh_usb_createdevicememmap). A buffer using the device memory map can provide better performance. + +**Since** + +10 + +**Related Modules** + +[UsbDdk](_usb_ddk.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [address](#address) | Buffer address.| +| [size](#size) | Buffer size.| +| [offset](#offset) | Offset of the used buffer. The default value is 0, indicating that there is no offset and the buffer starts from the specified address.| +| [bufferLength](#bufferlength) | Length of the used buffer. By default, the value is equal to the size, indicating that the entire buffer is used.| +| [transferedLength](#transferedlength) | Length of the transferred data.| + + +## Member Variable Description + + +### address + + +``` +uint8_t* const UsbDeviceMemMap::address +``` + +**Description** + + Buffer address. + + +### bufferLength + + +``` +uint32_t UsbDeviceMemMap::bufferLength +``` + +**Description** + +Length of the used buffer. By default, the value is equal to the size, indicating that the entire buffer is used. + + +### offset + + +``` +uint32_t UsbDeviceMemMap::offset +``` + +**Description** + +Offset of the used buffer. The default value is 0, indicating that there is no offset and the buffer starts from the specified address. + + +### size + + +``` +const size_t UsbDeviceMemMap::size +``` + +**Description** + +Buffer size. + + +### transferedLength + + +``` +uint32_t UsbDeviceMemMap::transferedLength +``` + +**Description** + +Length of the transferred data. diff --git a/en/application-dev/reference/native-apis/_usb_endpoint_descriptor.md b/en/application-dev/reference/native-apis/_usb_endpoint_descriptor.md new file mode 100644 index 0000000000000000000000000000000000000000..30171e2038fe3b7539dd7582a157670055f51071 --- /dev/null +++ b/en/application-dev/reference/native-apis/_usb_endpoint_descriptor.md @@ -0,0 +1,130 @@ +# UsbEndpointDescriptor + + +## Overview + +Defines standard endpoint descriptors, which correspond to **Standard Endpoint Descriptor** in the USB protocol. + +**Since** + +10 + +**Related Modules** + +[UsbDdk](_usb_ddk.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [bLength](#blength) | Size of the descriptor, in bytes.| +| [bDescriptorType](#bdescriptortype) | Descriptor type.| +| [bEndpointAddress](#bendpointaddress) | Endpoint address, including the endpoint number and endpoint direction.| +| [bmAttributes](#bmattributes) | Endpoint attributes, including the transfer type, synchronization type, and usage type.| +| [wMaxPacketSize](#wmaxpacketsize) | Maximum packet size supported by an endpoint.| +| [bInterval](#binterval) | Interval for polling endpoints for data transfer.| +| [bRefresh](#brefresh) | Refresh rate for audio devices.| +| [bSynchAddress](#bsynchaddress) | Endpoint synchronization address for audio devices.| + + +## Member Variable Description + + +### bDescriptorType + + +``` +uint8_t UsbEndpointDescriptor::bDescriptorType +``` + +**Description** + +Descriptor type. + + +### bEndpointAddress + + +``` +uint8_t UsbEndpointDescriptor::bEndpointAddress +``` + +**Description** + +Endpoint address, including the endpoint number and endpoint direction. + + +### bInterval + + +``` +uint8_t UsbEndpointDescriptor::bInterval +``` + +**Description** + +Interval for polling endpoints for data transfer. + + +### bLength + + +``` +uint8_t UsbEndpointDescriptor::bLength +``` + +**Description** + +Size of the descriptor, in bytes. + + +### bmAttributes + + +``` +uint8_t UsbEndpointDescriptor::bmAttributes +``` + +**Description** + +Endpoint attributes, including the transfer type, synchronization type, and usage type. + + +### bRefresh + + +``` +uint8_t UsbEndpointDescriptor::bRefresh +``` + +**Description** + +Refresh rate for audio devices. + + +### bSynchAddress + + +``` +uint8_t UsbEndpointDescriptor::bSynchAddress +``` + +**Description** + +Endpoint synchronization address for audio devices. + + +### wMaxPacketSize + + +``` +uint16_t UsbEndpointDescriptor::wMaxPacketSize +``` + +**Description** + +Maximum packet size supported by an endpoint. diff --git a/en/application-dev/reference/native-apis/_usb_interface_descriptor.md b/en/application-dev/reference/native-apis/_usb_interface_descriptor.md new file mode 100644 index 0000000000000000000000000000000000000000..d960dba070b233f9b2fd0df0c3927a4e674bf08a --- /dev/null +++ b/en/application-dev/reference/native-apis/_usb_interface_descriptor.md @@ -0,0 +1,143 @@ +# UsbInterfaceDescriptor + + +## Overview + +Defines standard interface descriptors, which correspond to **Standard Interface Descriptor** in the USB protocol. + +**Since** + +10 + +**Related Modules** + +[UsbDdk](_usb_ddk.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [bLength](#blength) | Size of the descriptor, in bytes.| +| [bDescriptorType](#bdescriptortype) | Descriptor type.| +| [bInterfaceNumber](#binterfacenumber) | Interface ID.| +| [bAlternateSetting](#balternatesetting) | Value used to select the alternate setting of the interface.| +| [bNumEndpoints](#bnumendpoints) | Number of endpoints (excluding endpoint 0) used by the interface.| +| [bInterfaceClass](#binterfaceclass) | Interface class code allocated by the USB-IF.| +| [bInterfaceSubClass](#binterfacesubclass) | Device subclass code allocated by USB-IF. The value is limited by that of [bInterfaceClass](#binterfaceclass).| +| [bInterfaceProtocol](#binterfaceprotocol) | Protocol code allocated by USB-IF. The value is limited by that of [bInterfaceClass](#binterfaceclass) and [bInterfaceSubClass](#binterfacesubclass).| +| [iInterface](#iinterface) | Index of the string descriptor that describes the interface.| + + +## Member Variable Description + + +### bAlternateSetting + + +``` +uint8_t UsbInterfaceDescriptor::bAlternateSetting +``` + +**Description** + +Value used to select the alternate setting of the interface. + + +### bDescriptorType + + +``` +uint8_t UsbInterfaceDescriptor::bDescriptorType +``` + +**Description** + +Descriptor type. + + +### bInterfaceClass + + +``` +uint8_t UsbInterfaceDescriptor::bInterfaceClass +``` + +**Description** + +Interface class code allocated by the USB-IF. + + +### bInterfaceNumber + + +``` +uint8_t UsbInterfaceDescriptor::bInterfaceNumber +``` + +**Description** + +Interface ID. + + +### bInterfaceProtocol + + +``` +uint8_t UsbInterfaceDescriptor::bInterfaceProtocol +``` + +**Description** + +Protocol code allocated by USB-IF. The value is limited by that of [bInterfaceClass](#binterfaceclass) and [bInterfaceSubClass](#binterfacesubclass). + + +### bInterfaceSubClass + + +``` +uint8_t UsbInterfaceDescriptor::bInterfaceSubClass +``` + +**Description** + +Device subclass code allocated by USB-IF. The value is limited by that of [bInterfaceClass](#binterfaceclass). + + +### bLength + + +``` +uint8_t UsbInterfaceDescriptor::bLength +``` + +**Description** + +Size of the descriptor, in bytes. + + +### bNumEndpoints + + +``` +uint8_t UsbInterfaceDescriptor::bNumEndpoints +``` + +**Description** + +Number of endpoints (excluding endpoint 0) used by the interface. + + +### iInterface + + +``` +uint8_t UsbInterfaceDescriptor::iInterface +``` + +**Description** + +Index of the string descriptor that describes the interface. diff --git a/en/application-dev/reference/native-apis/_usb_request_pipe.md b/en/application-dev/reference/native-apis/_usb_request_pipe.md new file mode 100644 index 0000000000000000000000000000000000000000..636e9d2c3c7cdc7f8eee7b3e00c40692974df80c --- /dev/null +++ b/en/application-dev/reference/native-apis/_usb_request_pipe.md @@ -0,0 +1,65 @@ +# UsbRequestPipe + + +## Overview + +Defines a request pipe. + +**Since** + +10 + +**Related Modules** + +[UsbDdk](_usb_ddk.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [interfaceHandle](#interfacehandle) | Interface operation handle.| +| [endpoint](#endpoint) | Endpoint address.| +| [timeout](#timeout) | Timeout duration, in milliseconds.| + + +## Member Variable Description + + +### endpoint + + +``` +uint8_t UsbRequestPipe::endpoint +``` + +**Description** + +Endpoint address. + + +### interfaceHandle + + +``` +uint64_t UsbRequestPipe::interfaceHandle +``` + +**Description** + +Interface operation handle. + + +### timeout + + +``` +uint32_t UsbRequestPipe::timeout +``` + +**Description** + +Timeout duration, in milliseconds. diff --git a/en/application-dev/reference/native-apis/usb__ddk__api_8h.md b/en/application-dev/reference/native-apis/usb__ddk__api_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..65e6e9ae039ef08ec18cf49141acc19f9eaa048f --- /dev/null +++ b/en/application-dev/reference/native-apis/usb__ddk__api_8h.md @@ -0,0 +1,37 @@ +# usb_ddk_api.h + + +## Overview + +Declares the USB DDK APIs used by the USB host to access USB devices. + +**Since** + +10 + +**Related Modules** + +[UsbDdk](_usb_ddk.md) + + +## Summary + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_Usb_Init](_usb_ddk.md#oh_usb_init) (void) | Initializes the DDK.| +| [OH_Usb_Release](_usb_ddk.md#oh_usb_release) (void) | Releases the DDK.| +| [OH_Usb_GetDeviceDescriptor](_usb_ddk.md#oh_usb_getdevicedescriptor) (uint64_t deviceId, struct [UsbDeviceDescriptor](_usb_device_descriptor.md) \*desc) | Obtains the device descriptor.| +| [OH_Usb_GetConfigDescriptor](_usb_ddk.md#oh_usb_getconfigdescriptor) (uint64_t deviceId, uint8_t configIndex, struct [UsbDdkConfigDescriptor](_usb_ddk_config_descriptor.md) \*\*const config) | Obtains the configuration descriptor. To avoid memory leakage, use [OH_Usb_FreeConfigDescriptor()](_usb_ddk.md#oh_usb_freeconfigdescriptor) to release a descriptor after use.| +| [OH_Usb_FreeConfigDescriptor](_usb_ddk.md#oh_usb_freeconfigdescriptor) (const struct [UsbDdkConfigDescriptor](_usb_ddk_config_descriptor.md) \*const config) | Releases the configuration descriptor. To avoid memory leakage, release a descriptor after use.| +| [OH_Usb_ClaimInterface](_usb_ddk.md#oh_usb_claiminterface) (uint64_t deviceId, uint8_t interfaceIndex, uint64_t \*[interfaceHandle](usb__ddk__types_8h.md#interfacehandle)) | Declares a USB interface.| +| [OH_Usb_ReleaseInterface](_usb_ddk.md#oh_usb_releaseinterface) (uint64_t [interfaceHandle](usb__ddk__types_8h.md#interfacehandle)) | Releases a USB interface.| +| [OH_Usb_SelectInterfaceSetting](_usb_ddk.md#oh_usb_selectinterfacesetting) (uint64_t [interfaceHandle](usb__ddk__types_8h.md#interfacehandle), uint8_t settingIndex) | Activates the alternate setting of a USB interface.| +| [OH_Usb_GetCurrentInterfaceSetting](_usb_ddk.md#oh_usb_getcurrentinterfacesetting) (uint64_t [interfaceHandle](usb__ddk__types_8h.md#interfacehandle), uint8_t \*settingIndex) | Obtains the activated alternate setting of a USB interface.| +| [OH_Usb_SendControlReadRequest](_usb_ddk.md#oh_usb_sendcontrolreadrequest) (uint64_t [interfaceHandle](usb__ddk__types_8h.md#interfacehandle), const struct [UsbControlRequestSetup](_usb_control_request_setup.md) \*setup, uint32_t [timeout](usb__ddk__types_8h.md#timeout), uint8_t \*data, uint32_t \*dataLen) | Sends a control read transfer request. This API works in a synchronous manner.| +| [OH_Usb_SendControlWriteRequest](_usb_ddk.md#oh_usb_sendcontrolwriterequest) (uint64_t [interfaceHandle](usb__ddk__types_8h.md#interfacehandle), const struct [UsbControlRequestSetup](_usb_control_request_setup.md) \*setup, uint32_t [timeout](usb__ddk__types_8h.md#timeout), const uint8_t \*data, uint32_t dataLen) | Sends a control write transfer request. This API works in a synchronous manner.| +| [OH_Usb_SendPipeRequest](_usb_ddk.md#oh_usb_sendpiperequest) (const struct [UsbRequestPipe](_usb_request_pipe.md) \*pipe, [UsbDeviceMemMap](_usb_device_mem_map.md) \*devMmap) | Sends a pipe request. This API works in a synchronous manner. It applies to interrupt transfer and bulk transfer.| +| [OH_Usb_CreateDeviceMemMap](_usb_ddk.md#oh_usb_createdevicememmap) (uint64_t deviceId, size_t size, [UsbDeviceMemMap](_usb_device_mem_map.md) \*\*devMmap) | Creates a buffer. To avoid memory leakage, use [OH_Usb_DestroyDeviceMemMap()](_usb_ddk.md#oh_usb_destroydevicememmap) to destroy a buffer after use.| +| [OH_Usb_DestroyDeviceMemMap](_usb_ddk.md#oh_usb_destroydevicememmap) ([UsbDeviceMemMap](_usb_device_mem_map.md) \*devMmap) | Destroys a buffer. To avoid resource leakage, destroy a buffer in time after use.| diff --git a/en/application-dev/reference/native-apis/usb__ddk__types_8h.md b/en/application-dev/reference/native-apis/usb__ddk__types_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..94e43e22e6e65267f7c8e7f08a6789372ffa9dcf --- /dev/null +++ b/en/application-dev/reference/native-apis/usb__ddk__types_8h.md @@ -0,0 +1,594 @@ +# usb_ddk_types.h + + +## Overview + +Provides the enumerated variables, structures, and macros used in USB DDK APIs. + +**Since** + +10 + +**Related Modules** + +[UsbDdk](_usb_ddk.md) + + +## Summary + + +### Structs + +| Name| Description| +| -------- | -------- | +| [UsbControlRequestSetup](_usb_control_request_setup.md) | Setup data for control transfer, corresponding to **Setup Data** in the USB protocol.| +| [UsbDeviceDescriptor](_usb_device_descriptor.md) | Standard device descriptor, corresponding to **Standard Device Descriptor** in the USB protocol.| +| [UsbConfigDescriptor](_usb_config_descriptor.md) | Standard configuration descriptor, corresponding to **Standard Configuration Descriptor** in the USB protocol.| +| [UsbInterfaceDescriptor](_usb_interface_descriptor.md) | Standard interface descriptor, corresponding to **Standard Interface Descriptor** in the USB protocol.| +| [UsbEndpointDescriptor](_usb_endpoint_descriptor.md) | Standard endpoint descriptor, corresponding to **Standard Endpoint Descriptor** in the USB protocol.| +| [UsbDdkEndpointDescriptor](_usb_ddk_endpoint_descriptor.md) | Endpoint descriptor.| +| [UsbDdkInterfaceDescriptor](_usb_ddk_interface_descriptor.md) | Interface descriptor.| +| [UsbDdkInterface](_usb_ddk_interface.md) | USB DDK interface, which is a collection of alternate settings for a particular USB interface.| +| [UsbDdkConfigDescriptor](_usb_ddk_config_descriptor.md) | Configuration descriptor.| +| [UsbRequestPipe](_usb_request_pipe.md) | Request pipe.| +| [UsbDeviceMemMap](_usb_device_mem_map.md) | Device memory map created by calling [OH_Usb_CreateDeviceMemMap()](_usb_ddk.md#oh_usb_createdevicememmap). A buffer using the device memory map can provide better performance.| + + +### Types + +| Name| Description| +| -------- | -------- | +| [UsbDdkEndpointDescriptor](_usb_ddk.md#usbddkendpointdescriptor) | Endpoint descriptor.| +| [UsbDdkInterfaceDescriptor](_usb_ddk.md#usbddkinterfacedescriptor) | Interface descriptor.| +| [UsbDdkInterface](_usb_ddk.md#usbddkinterface) | USB interface.| +| [UsbDdkConfigDescriptor](_usb_ddk.md#usbddkconfigdescriptor) | Configuration descriptor.| +| [UsbDeviceMemMap](_usb_ddk.md#usbdevicememmap) | Device memory map created by calling [OH_Usb_CreateDeviceMemMap()](_usb_ddk.md#oh_usb_createdevicememmap). A buffer using the device memory map can provide better performance.| + + +### Enums + +| Name| Description| +| -------- | -------- | +| [UsbDdkErrCode](_usb_ddk.md#usbddkerrcode) {
USB_DDK_SUCCESS = 0, USB_DDK_FAILED = -1, USB_DDK_INVALID_PARAMETER = -2, USB_DDK_MEMORY_ERROR = -3,
USB_DDK_INVALID_OPERATION = -4, USB_DDK_NULL_PTR = -5, USB_DDK_DEVICE_BUSY = -6, USB_DDK_TIMEOUT = -7
} | USB DDK error code definition.| + + +### Variables + +| Name| Description| +| -------- | -------- | +| [bmRequestType](#bmrequesttype) | Request type.| +| [bRequest](#brequest) | Specific request.| +| [wValue](#wvalue) | Value corresponding to **wValue** in the USB protocol. Its meaning varies according to the request.| +| [wIndex](#windex) | Index corresponding to **wIndex** in the USB protocol. It is usually used to transfer the index or offset. Its meaning varies according to the request. | +| [wLength](#wlength) | Data length corresponding to **wLength** in the USB protocol. If data is transferred, this field indicates the number of transferred bytes.| +| [bLength](#blength) | Size of the descriptor, in bytes.| +| [bDescriptorType](#bdescriptortype) | Descriptor type.| +| [bcdUSB](#bcdusb) | USB protocol release number.| +| [bDeviceClass](#bdeviceclass) | Interface class code allocated by the USB-IF.| +| [bDeviceSubClass](#bdevicesubclass) | Device subclass code allocated by USB-IF. The value is limited by that of bDeviceClass.| +| [bDeviceProtocol](#bdeviceprotocol) | Protocol code allocated by USB-IF. The value is limited by that of [bDeviceClass](#bdeviceclass) and [bDeviceSubClass](#bdevicesubclass).| +| [bMaxPacketSize0](#bmaxpacketsize0) | Maximum packet size of endpoint 0. Only values 8, 16, 32, and 64 are valid.| +| [idVendor](#idvendor) | Vendor ID allocated by USB-IF.| +| [idProduct](#idproduct) | Product ID allocated by the vendor.| +| [bcdDevice](#bcddevice) | Device release number.| +| [iManufacturer](#imanufacturer) | Index of the string descriptor that describes the vendor.| +| [iProduct](#iproduct) | Index of the string descriptor that describes the product.| +| [iSerialNumber](#iserialnumber) | Index of the string descriptor that describes the device SN.| +| [bNumConfigurations](#bnumconfigurations) | Configuration quantity.| +| [wTotalLength](#wtotallength) | Total length of the configuration descriptor, including the configuration, interface, endpoint, and class- or vendor-specific descriptors.| +| [bNumInterfaces](#bnuminterfaces) | Number of interfaces supported by the configuration.| +| [bConfigurationValue](#bconfigurationvalue) | Configuration index, which is used to select the configuration.| +| [iConfiguration](#iconfiguration) | Index of the string descriptor that describes the configuration.| +| [bmAttributes](#bmattributes) | Configuration attributes, including the power mode and remote wakeup.| +| [bMaxPower](#bmaxpower) | Maximum power consumption of the bus-powered USB device, in 2 mA.| +| [bInterfaceNumber](#binterfacenumber) | Interface ID.| +| [bAlternateSetting](#balternatesetting) | Value used to select the alternate setting of the interface.| +| [bNumEndpoints](#bnumendpoints) | Number of endpoints (excluding endpoint 0) used by the interface.| +| [bInterfaceClass](#binterfaceclass) | Interface class code allocated by the USB-IF.| +| [bInterfaceSubClass](#binterfacesubclass) | Device subclass code allocated by USB-IF. The value is limited by that of [bInterfaceClass](#binterfaceclass).| +| [bInterfaceProtocol](#binterfaceprotocol) | Protocol code allocated by USB-IF. The value is limited by that of [bInterfaceClass](#binterfaceclass) and [bInterfaceSubClass](#binterfacesubclass).| +| [iInterface](#iinterface) | Index of the string descriptor that describes the interface.| +| [bEndpointAddress](#bendpointaddress) | Endpoint address, including the endpoint number and endpoint direction.| +| [bmAttributes](#bmattributes) | Endpoint attributes, including the transfer type, synchronization type, and usage type.| +| [wMaxPacketSize](#wmaxpacketsize) | Maximum packet size supported by an endpoint.| +| [bInterval](#binterval) | Interval for polling endpoints for data transfer.| +| [bRefresh](#brefresh) | Refresh rate for audio devices.| +| [bSynchAddress](#bsynchaddress) | Endpoint synchronization address for audio devices.| +| [interfaceHandle](#interfacehandle) | Interface operation handle.| +| [endpoint](#endpoint) | Endpoint address.| +| [timeout](#timeout) | Timeout duration, in milliseconds.| + + +## Variable Description + + +### bAlternateSetting + + +``` +uint8_t bAlternateSetting +``` + +**Description** + +Value used to select the alternate setting of the interface. + + +### bcdDevice + + +``` +uint16_t bcdDevice +``` + +**Description** + +Device release number. + + +### bcdUSB + + +``` +uint16_t bcdUSB +``` + +**Description** + +USB protocol release number. + + +### bConfigurationValue + + +``` +uint8_t bConfigurationValue +``` + +**Description** + +Configuration index, which is used to select the configuration. + + +### bDescriptorType + + +``` +uint8_t bDescriptorType +``` + +**Description** + +Descriptor type. + + +### bDeviceClass + + +``` +uint8_t bDeviceClass +``` + +**Description** + +Interface class code allocated by the USB-IF. + + +### bDeviceProtocol + + +``` +uint8_t bDeviceProtocol +``` + +**Description** + +Protocol code allocated by USB-IF. The value is limited by that of [bDeviceClass](#bdeviceclass) and [bDeviceSubClass](#bdevicesubclass). + + +### bDeviceSubClass + + +``` +uint8_t bDeviceSubClass +``` + +**Description** + +Device subclass code allocated by USB-IF. The value is limited by that of bDeviceClass. + + +### bEndpointAddress + + +``` +uint8_t bEndpointAddress +``` + +**Description** + +Endpoint address, including the endpoint number and endpoint direction. + + +### bmAttributes + + +``` +uint8_t bmAttributes +``` + +**Description** + +Endpoint attributes, including the transfer type, synchronization type, and usage type. + + +### bInterfaceClass + + +``` +uint8_t bInterfaceClass +``` + +**Description** + +Interface class code allocated by the USB-IF. + + +### bInterfaceNumber + + +``` +uint8_t bInterfaceNumber +``` + +**Description** + +Interface ID. + + +### bInterfaceProtocol + + +``` +uint8_t bInterfaceProtocol +``` + +**Description** + +Protocol code allocated by USB-IF. The value is limited by that of [bInterfaceClass](#binterfaceclass) and [bInterfaceSubClass](#binterfacesubclass). + + +### bInterfaceSubClass + + +``` +uint8_t bInterfaceSubClass +``` + +**Description** + +Device subclass code allocated by USB-IF. The value is limited by that of [bInterfaceClass](#binterfaceclass). + + +### bInterval + + +``` +uint8_t bInterval +``` + +**Description** + +Interval for polling endpoints for data transfer. + + +### bLength + + +``` +uint8_t bLength +``` + +**Description** + +Size of the descriptor, in bytes. + + +### bmAttributes + + +``` +uint8_t bmAttributes +``` + +**Description** + +Configuration attributes, including the power mode and remote wakeup. + + +### bMaxPacketSize0 + + +``` +uint8_t bMaxPacketSize0 +``` + +**Description** + +Maximum packet size of endpoint 0. Only values 8, 16, 32, and 64 are valid. + + +### bMaxPower + + +``` +uint8_t bMaxPower +``` + +**Description** + +Maximum power consumption of the bus-powered USB device, in 2 mA. + + +### bNumConfigurations + + +``` +uint8_t bNumConfigurations +``` + +**Description** + +Configuration quantity. + + +### bNumEndpoints + + +``` +uint8_t bNumEndpoints +``` + +**Description** + +Number of endpoints (excluding endpoint 0) used by the interface. + + +### bNumInterfaces + + +``` +uint8_t bNumInterfaces +``` + +**Description** + +Number of interfaces supported by the configuration. + + +### bRefresh + + +``` +uint8_t bRefresh +``` + +**Description** + +Refresh rate for audio devices. + + +### bSynchAddress + + +``` +uint8_t bSynchAddress +``` + +**Description** + +Endpoint synchronization address for audio devices. + + +### endpoint + + +``` +uint8_t endpoint +``` + +**Description** + +Endpoint address. + + +### iConfiguration + + +``` +uint8_t iConfiguration +``` + +**Description** + +Index of the string descriptor that describes the configuration. + + +### idProduct + + +``` +uint16_t idProduct +``` + +**Description** + +Product ID allocated by the vendor. + + +### idVendor + + +``` +uint16_t idVendor +``` + +**Description** + +Vendor ID allocated by USB-IF. + + +### iInterface + + +``` +uint8_t iInterface +``` + +**Description** + +Index of the string descriptor that describes the interface. + + +### iManufacturer + + +``` +uint8_t iManufacturer +``` + +**Description** + +Index of the string descriptor that describes the vendor. + + +### wIndex + + +``` +uint16_t wIndex +``` + +**Description** + +Index corresponding to **wIndex** in the USB protocol. It is usually used to transfer the index or offset. Its meaning varies according to the request. + + +### interfaceHandle + + +``` +uint64_t interfaceHandle +``` + +**Description** + +Interface operation handle. + + +### iProduct + + +``` +uint8_t iProduct +``` + +**Description** + +Index of the string descriptor that describes the product. + + +### iSerialNumber + + +``` +uint8_t iSerialNumber +``` + +**Description** + +Index of the string descriptor that describes the device SN. + + +### wLength + + +``` +uint16_t wLength +``` + +**Description** + +Data length corresponding to **wLength** in the USB protocol. If data is transferred, this field indicates the number of transferred bytes. + + +### bRequest + + +``` +uint8_t bRequest +``` + +**Description** + +Specific request. + + +### bmRequestType + + +``` +uint8_t bmRequestType +``` + +**Description** + +Request type. + + +### timeout + + +``` +uint32_t timeout +``` + +**Description** + +Timeout duration, in milliseconds. + + +### wValue + + +``` +uint16_t wValue +``` + +**Description** + +Value corresponding to **wValue** in the USB protocol. Its meaning varies according to the request. + + +### wMaxPacketSize + + +``` +uint16_t wMaxPacketSize +``` + +**Description** + +Maximum packet size supported by an endpoint. + + +### wTotalLength + + +``` +uint16_t wTotalLength +``` + +**Description** + +Total length of the configuration descriptor, including the configuration, interface, endpoint, and class- or vendor-specific descriptors.