未验证 提交 5454c765 编写于 作者: O openharmony_ci 提交者: Gitee

!4537 翻译已完成4184

Merge pull request !4537 from shawn_he/4184-a
# Call # Call
>**NOTE** 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**<br>
> >
>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. >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.
...@@ -15,7 +19,7 @@ import call from '@ohos.telephony.call'; ...@@ -15,7 +19,7 @@ import call from '@ohos.telephony.call';
dial\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void dial\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void
Initiates a call. This API uses an asynchronous callback to return the execution result. Initiates a call. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.PLACE\_CALL (a system permission) **Required permission**: ohos.permission.PLACE\_CALL (a system permission)
...@@ -24,7 +28,7 @@ Initiates a call. This API uses an asynchronous callback to return the execution ...@@ -24,7 +28,7 @@ Initiates a call. This API uses an asynchronous callback to return the execution
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ---------------------------- | ---- | ------------------------------------------------- | | ----------- | ---------------------------- | ---- | --------------------------------------- |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br>- **true**: success<br>- **false**: failure| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br>- **true**: success<br>- **false**: failure|
...@@ -41,7 +45,7 @@ call.dial("138xxxxxxxx", (err, data) => { ...@@ -41,7 +45,7 @@ call.dial("138xxxxxxxx", (err, data) => {
dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean\>\): void dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean\>\): void
Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the execution result. Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.PLACE\_CALL (a system permission) **Required permission**: ohos.permission.PLACE\_CALL (a system permission)
...@@ -50,9 +54,9 @@ Initiates a call. You can set call options as needed. This API uses an asynchron ...@@ -50,9 +54,9 @@ Initiates a call. You can set call options as needed. This API uses an asynchron
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ---------------------------- | ---- | ------------------------------------------------- | | ----------- | ---------------------------- | ---- | --------------------------------------- |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| options | DialOptions | Yes | Call options defined in [DialOptions](#dialoptions). | | options | [DialOptions](#dialoptions) | Yes | Call option, which indicates whether the call is a voice call or video call. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br>- **true**: success<br>- **false**: failure| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br>- **true**: success<br>- **false**: failure|
**Example** **Example**
...@@ -70,7 +74,7 @@ call.dial("138xxxxxxxx", { ...@@ -70,7 +74,7 @@ call.dial("138xxxxxxxx", {
dial\(phoneNumber: string, options?: DialOptions\): Promise<boolean\> dial\(phoneNumber: string, options?: DialOptions\): Promise<boolean\>
Initiates a call. You can set call options as needed. This API uses a promise to return the execution result. Initiates a call. You can set call options as needed. This API uses a promise to return the result.
**Required permission**: ohos.permission.PLACE\_CALL (a system permission) **Required permission**: ohos.permission.PLACE\_CALL (a system permission)
...@@ -79,15 +83,15 @@ Initiates a call. You can set call options as needed. This API uses a promise to ...@@ -79,15 +83,15 @@ Initiates a call. You can set call options as needed. This API uses a promise to
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ----------- | ---- | ------------------------------------------- | | ----------- | --------------------------- | ---- | -------------------------------------- |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| options | DialOptions | Yes | Call options defined in [DialOptions](#dialoptions).| | options | [DialOptions](#dialoptions) | Yes | Call option, which indicates whether the call is a voice call or video call.|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ---------------------- | --------------------------------- | | ---------------------- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise used to return the result.| | Promise&lt;boolean&gt; | Promise used to return the result.<br>- **true**: success<br>- **false**: failure|
**Example** **Example**
...@@ -108,8 +112,6 @@ makeCall(phoneNumber: string, callback: AsyncCallback\<void\>): void ...@@ -108,8 +112,6 @@ makeCall(phoneNumber: string, callback: AsyncCallback\<void\>): void
Launches the call screen and displays the dialed number. This API uses an asynchronous callback to return the result. Launches the call screen and displays the dialed number. This API uses an asynchronous callback to return the result.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
**System capability**: SystemCapability.Applications.Contacts **System capability**: SystemCapability.Applications.Contacts
**Parameters** **Parameters**
...@@ -134,8 +136,6 @@ makeCall(phoneNumber: string): Promise\<void\> ...@@ -134,8 +136,6 @@ makeCall(phoneNumber: string): Promise\<void\>
Launches the call screen and displays the dialed number. This API uses a promise to return the result. Launches the call screen and displays the dialed number. This API uses a promise to return the result.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
**System capability**: SystemCapability.Applications.Contacts **System capability**: SystemCapability.Applications.Contacts
**Parameters** **Parameters**
...@@ -144,7 +144,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a ...@@ -144,7 +144,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
| ----------- | ------ | ---- | ---------- | | ----------- | ------ | ---- | ---------- |
| phoneNumber | string | Yes | Phone number.| | phoneNumber | string | Yes | Phone number.|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | --------------------------------- | | ------------------- | --------------------------------- |
...@@ -173,7 +173,7 @@ Checks whether a call is in progress. This API uses an asynchronous callback to ...@@ -173,7 +173,7 @@ Checks whether a call is in progress. This API uses an asynchronous callback to
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br>- **true**: A call is in progress.<br>- **false**: No call is in progress.| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. Callback used to return the result.<br>- **true**: A call is in progress.<br>- **false**: No call is in progress.|
**Example** **Example**
...@@ -192,7 +192,7 @@ Checks whether a call is in progress. This API uses a promise to return the resu ...@@ -192,7 +192,7 @@ Checks whether a call is in progress. This API uses a promise to return the resu
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ---------------------- | --------------------------------------- | | ---------------------- | --------------------------------------- |
...@@ -241,10 +241,10 @@ Obtains the call status. This API uses a promise to return the result. ...@@ -241,10 +241,10 @@ Obtains the call status. This API uses a promise to return the result.
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
**Return Value** **Return value**
| Type | Description | | Type | Description |
| -------------------------------------- | ----------------------------------------- | | -------------------------------------- | --------------------------------------- |
| Promise&lt;[CallState](#callstate)&gt; | Promise used to return the result.| | Promise&lt;[CallState](#callstate)&gt; | Promise used to return the result.|
**Example** **Example**
...@@ -262,11 +262,11 @@ promise.then(data => { ...@@ -262,11 +262,11 @@ promise.then(data => {
hasVoiceCapability(): boolean hasVoiceCapability(): boolean
Checks whether a device supports voice calls. This API works in synchronous mode. Checks whether a device supports voice calls.
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------- | ------------------------------------------------------------ | | ------- | ------------------------------------------------------------ |
...@@ -281,7 +281,7 @@ console.log(`hasVoiceCapability: ${JSON.stringify(result)}`); ...@@ -281,7 +281,7 @@ console.log(`hasVoiceCapability: ${JSON.stringify(result)}`);
isEmergencyPhoneNumber\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void isEmergencyPhoneNumber\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void
Checks whether the call number of the SIM card in the specified slot is an emergency number. This API uses an asynchronous callback to return the result. Checks whether the called number is an emergency number. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
...@@ -290,7 +290,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg ...@@ -290,7 +290,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ---------------------------- | ---- | ------------------------------------------------------------ | | ----------- | ---------------------------- | ---- | ------------------------------------------------------------ |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br>- **true**: The called number is an emergency number.<br>- **false**: The called number is not an emergency number.| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br> - **true**: The called number is an emergency number.<br>- **false**: The called number is not an emergency number.|
**Example** **Example**
...@@ -305,17 +305,17 @@ call.isEmergencyPhoneNumber("138xxxxxxxx", (err, data) => { ...@@ -305,17 +305,17 @@ call.isEmergencyPhoneNumber("138xxxxxxxx", (err, data) => {
isEmergencyPhoneNumber\(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback<boolean\>\): void isEmergencyPhoneNumber\(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback<boolean\>\): void
Checks whether the call number of the SIM card in the specified slot is an emergency number. This API uses an asynchronous callback to return the result. 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 **System capability**: SystemCapability.Telephony.CallManager
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ---------------------------- | ---- | ------------------------------------------------------------ | | ----------- | -------------------------------------------------- | ---- | -------------------------------------------- |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| options | EmergencyNumberOptions | Yes | Emergency number options defined in [EmergencyNumberOptions](#emergencynumberoptions7).| | options | [EmergencyNumberOptions](#emergencynumberoptions7) | Yes | Phone number option. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br>- **true**: The called number is an emergency number.<br>- **false**: The called number is not an emergency number.| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br> - **true**: The called number is an emergency number.<br>- **false**: The called number is not an emergency number.|
**Example** **Example**
...@@ -330,18 +330,18 @@ call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, value) => { ...@@ -330,18 +330,18 @@ call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, value) => {
isEmergencyPhoneNumber\(phoneNumber: string, options?: EmergencyNumberOptions\): Promise<boolean\> isEmergencyPhoneNumber\(phoneNumber: string, options?: EmergencyNumberOptions\): Promise<boolean\>
Checks whether the call number of the SIM card in the specified slot is an emergency number. This API uses a promise to return the result. 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 **System capability**: SystemCapability.Telephony.CallManager
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ---------------------- | ---- | ------------------------------------------------------------ | | ----------- | -------------------------------------------------- | ---- | -------------- |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| options | EmergencyNumberOptions | Yes | Emergency number options defined in [EmergencyNumberOptions](#emergencynumberoptions7).| | options | [EmergencyNumberOptions](#emergencynumberoptions7) | Yes | Phone number option.|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ---------------------- | --------------------------------------------------- | | ---------------------- | --------------------------------------------------- |
...@@ -362,7 +362,9 @@ promise.then(data => { ...@@ -362,7 +362,9 @@ promise.then(data => {
formatPhoneNumber\(phoneNumber: string, callback: AsyncCallback<string\>\): void formatPhoneNumber\(phoneNumber: string, callback: AsyncCallback<string\>\): void
Formats a phone number based on the specified ISO country code. This API uses an asynchronous callback to return the result. 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 **System capability**: SystemCapability.Telephony.CallManager
...@@ -381,22 +383,23 @@ call.formatPhoneNumber("138xxxxxxxx", (err, data) => { ...@@ -381,22 +383,23 @@ call.formatPhoneNumber("138xxxxxxxx", (err, data) => {
}); });
``` ```
## call.formatPhoneNumber<sup>7+</sup> ## call.formatPhoneNumber<sup>7+</sup>
formatPhoneNumber\(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback<string\>\): void formatPhoneNumber\(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback<string\>\): void
Formats a phone number based on specified formatting options. This API uses an asynchronous callback to return the result. 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 **System capability**: SystemCapability.Telephony.CallManager
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | ------------------------------------------------------------ | | ----------- | -------------------------------------------- | ---- | ------------------------------------ |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| options | NumberFormatOptions | Yes | Number formatting options defined in [NumberFormatOptions](#numberformatoptions7).| | options | [NumberFormatOptions](#numberformatoptions7) | Yes | Number formatting option, for example, country code. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -415,16 +418,18 @@ formatPhoneNumber\(phoneNumber: string, options?: NumberFormatOptions\): Promise ...@@ -415,16 +418,18 @@ formatPhoneNumber\(phoneNumber: string, options?: NumberFormatOptions\): Promise
Formats a phone number based on specified formatting options. This API uses a promise to return the result. 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 **System capability**: SystemCapability.Telephony.CallManager
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ------------------- | ---- | ------------------------------------------------------------ | | ----------- | -------------------------------------------- | ---- | ---------------------- |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| options | NumberFormatOptions | Yes | Number formatting options defined in [NumberFormatOptions](#numberformatoptions7).| | options | [NumberFormatOptions](#numberformatoptions7) | Yes | Number formatting option, for example, country code.|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------------------------------- | | --------------------- | ------------------------------------------- |
...@@ -451,8 +456,6 @@ Converts a phone number into the E.164 format. This API uses an asynchronous cal ...@@ -451,8 +456,6 @@ Converts a phone number into the E.164 format. This API uses an asynchronous cal
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. 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 **System capability**: SystemCapability.Telephony.CallManager
**Parameters** **Parameters**
...@@ -493,7 +496,7 @@ All country codes are supported. ...@@ -493,7 +496,7 @@ All country codes are supported.
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| countryCode | string | Yes | Country code, for example, **CN** (China). All country codes are supported.| | countryCode | string | Yes | Country code, for example, **CN** (China). All country codes are supported.|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------------------------------------------------ | | --------------------- | ------------------------------------------------------------ |
...@@ -542,8 +545,8 @@ Provides an option for determining whether a number is an emergency number for t ...@@ -542,8 +545,8 @@ Provides an option for determining whether a number is an emergency number for t
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------ | | ------ | ------ | ---- | ---------------------------------------------- |
| slotId | number | No | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | No | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
## NumberFormatOptions<sup>7+</sup> ## NumberFormatOptions<sup>7+</sup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册