提交 5fde327e 编写于 作者: S shawn_he

update docs

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 79282e42
...@@ -45,8 +45,13 @@ ...@@ -45,8 +45,13 @@
- [SMS](js-apis-sms.md) - [SMS](js-apis-sms.md)
- [SIM Management](js-apis-sim.md) - [SIM Management](js-apis-sim.md)
- [Radio](js-apis-radio.md) - [Radio](js-apis-radio.md)
- [observer](js-apis-observer.md) - [Observer](js-apis-observer.md)
- [Cellular Data](js-apis-telephony-data.md) - [Cellular Data](js-apis-telephony-data.md)
- Network Management
- [Network Connection Management](js-apis-net-connection.md)
- [Socket Connection](js-apis-socket.md)
- [WebSocket Connection](js-apis-webSocket.md)
- [Data Request](js-apis-http.md)
- Network and Connectivity - Network and Connectivity
- [WLAN](js-apis-wifi.md) - [WLAN](js-apis-wifi.md)
- [Bluetooth](js-apis-bluetooth.md) - [Bluetooth](js-apis-bluetooth.md)
......
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
import call from '@ohos.telephony.call'; import call from '@ohos.telephony.call';
``` ```
## call.dial<a name=call.dial-callback1></a> ## call.dial
dial\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void dial\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void
Initiates a call. This function uses an asynchronous callback to return the execution result. Initiates a call. This API uses an asynchronous callback to return the execution result.
**Required permission**: ohos.permission.PLACE\_CALL (a system permission) **Required permission**: ohos.permission.PLACE\_CALL (a system permission)
...@@ -23,7 +23,7 @@ Initiates a call. This function uses an asynchronous callback to return the exec ...@@ -23,7 +23,7 @@ Initiates a call. This function uses an asynchronous callback to return the exec
**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|
...@@ -37,11 +37,11 @@ call.dial("138xxxxxxxx", (err, data) => { ...@@ -37,11 +37,11 @@ call.dial("138xxxxxxxx", (err, data) => {
``` ```
## call.dial<a name=call.dial-callback2></a> ## call.dial
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 function 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 execution result.
**Required permission**: ohos.permission.PLACE\_CALL (a system permission) **Required permission**: ohos.permission.PLACE\_CALL (a system permission)
...@@ -49,10 +49,10 @@ Initiates a call. You can set call options as needed. This function uses an asyn ...@@ -49,10 +49,10 @@ Initiates a call. You can set call options as needed. This function uses an asyn
**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. For details, see [DialOptions](#DialOptions). | | options | DialOptions | Yes | Call options defined in [DialOptions](#dialoptions). |
| 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**
...@@ -66,11 +66,11 @@ call.dial("138xxxxxxxx", { ...@@ -66,11 +66,11 @@ call.dial("138xxxxxxxx", {
``` ```
## call.dial<a name=call.dial-promise></a> ## call.dial
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 function 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 execution result.
**Required permission**: ohos.permission.PLACE\_CALL (a system permission) **Required permission**: ohos.permission.PLACE\_CALL (a system permission)
...@@ -78,10 +78,10 @@ Initiates a call. You can set call options as needed. This function uses a promi ...@@ -78,10 +78,10 @@ Initiates a call. You can set call options as needed. This function uses a promi
**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. For details, see [DialOptions](#DialOptions).| | options | DialOptions | Yes | Call options defined in [DialOptions](#dialoptions).|
**Return Value** **Return Value**
...@@ -102,17 +102,19 @@ promise.then(data => { ...@@ -102,17 +102,19 @@ promise.then(data => {
}); });
``` ```
## call.makeCall<sup>7+</sup><a name=call.makeCall-callback></a> ## call.makeCall<sup>7+</sup>
makeCall(phoneNumber: string, callback: AsyncCallback<void>): void makeCall(phoneNumber: string, callback: AsyncCallback\<void\>): void
Launches the call screen and displays the dialed number. This method 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.
**System capability**: SystemCapability.Telephony.CallManager 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
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ------------------------- | ---- | ------------------------------------------ | | ----------- | ------------------------- | ---- | ------------------------------------------ |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
...@@ -126,17 +128,19 @@ call.makeCall("138xxxxxxxx", err => { ...@@ -126,17 +128,19 @@ call.makeCall("138xxxxxxxx", err => {
``` ```
## call.makeCall<sup>7+</sup><a name=call.makeCall-promise></a> ## call.makeCall<sup>7+</sup>
makeCall(phoneNumber: string): Promise<void> makeCall(phoneNumber: string): Promise\<void\>
Launches the call screen and displays the dialed number. This method 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.
**System capability**: SystemCapability.Telephony.CallManager 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
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ---------- | | ----------- | ------ | ---- | ---------- |
| phoneNumber | string | Yes | Phone number.| | phoneNumber | string | Yes | Phone number.|
...@@ -157,17 +161,17 @@ promise.then(() => { ...@@ -157,17 +161,17 @@ promise.then(() => {
}); });
``` ```
## call.hasCall<a name=call.hasCall-callback></a> ## call.hasCall
hasCall\(callback: AsyncCallback<boolean\>\): void hasCall\(callback: AsyncCallback<boolean\>\): void
Checks whether a call is in progress. This function uses an asynchronous callback to return the result. Checks whether a call is in progress. 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 |
| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
| 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.<br>- **true**: A call is in progress.<br>- **false**: No call is in progress.|
...@@ -180,11 +184,11 @@ call.hasCall((err, data) => { ...@@ -180,11 +184,11 @@ call.hasCall((err, data) => {
``` ```
## call.hasCall<a name=call.hasCall-promise></a> ## call.hasCall
hasCall\(\): Promise<boolean\> hasCall\(\): Promise<boolean\>
Checks whether a call is in progress. This function uses a promise to return the result. Checks whether a call is in progress. This API uses a promise to return the result.
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
...@@ -206,19 +210,19 @@ promise.then(data => { ...@@ -206,19 +210,19 @@ promise.then(data => {
``` ```
## call.getCallState<a name=call.getCallState-callback></a> ## call.getCallState
getCallState\(callback: AsyncCallback<CallState\>\): void getCallState\(callback: AsyncCallback<CallState\>\): void
Obtains the call status. This function uses an asynchronous callback to return the result. Obtains the call status. 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 |
| -------- | -------------------------------------------- | ---- | ------------------------------------ | | -------- | -------------------------------------------- | ---- | ------------------------------------ |
| callback | AsyncCallback&lt;[CallState](#CallState)&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;[CallState](#callstate)&gt; | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -229,11 +233,11 @@ call.getCallState((err, data) => { ...@@ -229,11 +233,11 @@ call.getCallState((err, data) => {
``` ```
## call.getCallState<a name="call.getCallState-promise"></a> ## call.getCallState
getCallState\(\): Promise<CallState\> getCallState\(\): Promise<CallState\>
Obtains the call status. This function uses a promise to return the result. Obtains the call status. This API uses a promise to return the result.
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
...@@ -241,7 +245,7 @@ Obtains the call status. This function uses a promise to return the result. ...@@ -241,7 +245,7 @@ Obtains the call status. This function uses a promise to return the result.
| 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**
...@@ -254,11 +258,11 @@ promise.then(data => { ...@@ -254,11 +258,11 @@ promise.then(data => {
}); });
``` ```
## call.hasVoiceCapability<sup>7+</sup><a name=call.hasVoiceCapability></a> ## call.hasVoiceCapability<sup>7+</sup>
hasVoiceCapability(): boolean hasVoiceCapability(): boolean
Checks whether a device supports voice calls. This function works in synchronous mode. Checks whether a device supports voice calls. This API works in synchronous mode.
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
...@@ -273,17 +277,17 @@ let result = call.hasVoiceCapability(); ...@@ -273,17 +277,17 @@ let result = call.hasVoiceCapability();
console.log(`hasVoiceCapability: ${JSON.stringify(result)}`); console.log(`hasVoiceCapability: ${JSON.stringify(result)}`);
``` ```
## call.isEmergencyPhoneNumber<sup>7+</sup><a name=call.isEmergencyPhoneNumber-callback1></a> ## call.isEmergencyPhoneNumber<sup>7+</sup>
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 function uses an asynchronous callback to return the result. 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.
**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. |
| 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.|
...@@ -297,20 +301,20 @@ call.isEmergencyPhoneNumber("138xxxxxxxx", (err, data) => { ...@@ -297,20 +301,20 @@ call.isEmergencyPhoneNumber("138xxxxxxxx", (err, data) => {
``` ```
## call.isEmergencyPhoneNumber<sup>7+</sup><a name=call.isEmergencyPhoneNumber-callback2></a> ## call.isEmergencyPhoneNumber<sup>7+</sup>
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 function uses an asynchronous callback to return the result. 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.
**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](#EmergencyNumberOptions).| | options | EmergencyNumberOptions | Yes | Emergency number options defined in [EmergencyNumberOptions](#emergencynumberoptions7).|
| 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**
...@@ -322,20 +326,20 @@ call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, value) => { ...@@ -322,20 +326,20 @@ call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, value) => {
``` ```
## call.isEmergencyPhoneNumber<sup>7+</sup><a name=call.isEmergencyPhoneNumber-promise></a> ## call.isEmergencyPhoneNumber<sup>7+</sup>
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 function uses a promise to return the result. 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.
**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](#EmergencyNumberOptions).| | options | EmergencyNumberOptions | Yes | Emergency number options defined in [EmergencyNumberOptions](#emergencynumberoptions7).|
**Return Value** **Return Value**
...@@ -354,17 +358,17 @@ promise.then(data => { ...@@ -354,17 +358,17 @@ promise.then(data => {
}); });
``` ```
## call.formatPhoneNumber<sup>7+</sup><a name=call.formatPhoneNumber-callback1></a> ## call.formatPhoneNumber<sup>7+</sup>
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 function uses an asynchronous callback to return the result. Formats a phone number based on the specified ISO country code. 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. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result.|
...@@ -378,20 +382,20 @@ call.formatPhoneNumber("138xxxxxxxx", (err, data) => { ...@@ -378,20 +382,20 @@ call.formatPhoneNumber("138xxxxxxxx", (err, data) => {
``` ```
## call.formatPhoneNumber<sup>7+</sup><a name=call.formatPhoneNumber-callback2></a> ## 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 function 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.
**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](#NumberFormatOptions).| | options | NumberFormatOptions | Yes | Number formatting options defined in [NumberFormatOptions](#numberformatoptions7).|
| 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**
...@@ -405,20 +409,20 @@ call.formatPhoneNumber("138xxxxxxxx",{ ...@@ -405,20 +409,20 @@ call.formatPhoneNumber("138xxxxxxxx",{
``` ```
## call.formatPhoneNumber<sup>7+</sup><a name=call.formatPhoneNumber-promise></a> ## call.formatPhoneNumber<sup>7+</sup>
formatPhoneNumber\(phoneNumber: string, options?: NumberFormatOptions\): Promise<string\> formatPhoneNumber\(phoneNumber: string, options?: NumberFormatOptions\): Promise<string\>
Formats a phone number based on specified formatting options. This function 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.
**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](#NumberFormatOptions).| | options | NumberFormatOptions | Yes | Number formatting options defined in [NumberFormatOptions](#numberformatoptions7).|
**Return Value** **Return Value**
...@@ -439,11 +443,11 @@ promise.then(data => { ...@@ -439,11 +443,11 @@ promise.then(data => {
}); });
``` ```
## call.formatPhoneNumberToE164<sup>7+</sup><a name=call.formatPhoneNumberToE164-callback></a> ## call.formatPhoneNumberToE164<sup>7+</sup>
formatPhoneNumberToE164\(phoneNumber: string, countryCode: string, callback: AsyncCallback<string\>\): void formatPhoneNumberToE164\(phoneNumber: string, countryCode: string, callback: AsyncCallback<string\>\): void
Converts a phone number into the E.164 format. This function uses an asynchronous callback to return the result. 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. 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.
...@@ -453,7 +457,7 @@ All country codes are supported. ...@@ -453,7 +457,7 @@ All country codes are supported.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | ----------------------------------------------------- | | ----------- | --------------------------- | ---- | ----------------------------------------------------- |
| 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. |
...@@ -470,11 +474,11 @@ call.formatPhoneNumberToE164("138xxxxxxxx",{ ...@@ -470,11 +474,11 @@ call.formatPhoneNumberToE164("138xxxxxxxx",{
``` ```
## call.formatPhoneNumberToE164<sup>7+</sup><a name=call.formatPhoneNumberToE164-promise></a> ## call.formatPhoneNumberToE164<sup>7+</sup>
formatPhoneNumberToE164\(phoneNumber: string, countryCode: string\): Promise<string\> formatPhoneNumberToE164\(phoneNumber: string, countryCode: string\): Promise<string\>
Converts a phone number into the E.164 format. This function uses a promise to return the result. 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. 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.
...@@ -484,7 +488,7 @@ All country codes are supported. ...@@ -484,7 +488,7 @@ All country codes are supported.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ---------------------------------------- | | ----------- | ------ | ---- | ---------------------------------------- |
| 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.|
...@@ -508,43 +512,45 @@ promise.then(data => { ...@@ -508,43 +512,45 @@ promise.then(data => {
}); });
``` ```
## DialOptions<a name=DialOptions></a> ## DialOptions
Provides an option for determining whether a call is a video call. Provides an option for determining whether a call is a video call.
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
| Parameter | Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------- | ---- | ------------------------------------------------------------ | | ------ | ------- | ---- | ------------------------------------------------------------ |
| extras | boolean | No | Indication of a video call. <br>- **true**: video call<br>- **false** (default): voice call| | extras | boolean | No | Indication of a video call. <br>- **true**: video call<br>- **false** (default): voice call|
## CallState<a name=CallState></a> ## CallState
Enumerates call states. Enumerates call states.
| Variable | Value | Description | **System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| ------------------ | ---- | ------------------------------------------------------------ | | ------------------ | ---- | ------------------------------------------------------------ |
| CALL_STATE_UNKNOWN | -1 | The call status fails to be obtained and is unknown.<br>**System capability**: SystemCapability.Telephony.CallManager| | CALL_STATE_UNKNOWN | -1 | The call status fails to be obtained and is unknown. |
| CALL_STATE_IDLE | 0 | No call is in progress.<br>**System capability**: SystemCapability.Telephony.CallManager| | CALL_STATE_IDLE | 0 | No call is in progress. |
| CALL_STATE_RINGING | 1 | The call is in the ringing or waiting state.<br>**System capability**: SystemCapability.Telephony.CallManager| | 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.<br>**System capability**: SystemCapability.Telephony.CallManager| | CALL_STATE_OFFHOOK | 2 | At least one call is in dialing, active, or on hold, and no new incoming call is ringing or waiting.|
## EmergencyNumberOptions<sup>7+</sup><a name=EmergencyNumberOptions></a> ## EmergencyNumberOptions<sup>7+</sup>
Provides an option for determining whether a number is an emergency number for the SIM card in the specified slot. 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 **System capability**: SystemCapability.Telephony.CallManager
| Parameter | 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><a name=NumberFormatOptions></a> ## NumberFormatOptions<sup>7+</sup>
Provides an option for number formatting. Provides an option for number formatting.
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
| Parameter | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ---------------------------------------------------------- | | ----------- | ------ | ---- | ---------------------------------------------------------- |
| countryCode | string | No | Country code, for example, **CN** (China). All country codes are supported. The default value is **CN**.| | countryCode | string | No | Country code, for example, **CN** (China). All country codes are supported. The default value is **CN**.|
...@@ -137,25 +137,25 @@ Initiates an HTTP request containing specified options to a given URL. This API ...@@ -137,25 +137,25 @@ Initiates an HTTP request containing specified options to a given URL. This API
``` ```
httpRequest.request("EXAMPLE_URL", httpRequest.request("EXAMPLE_URL",
{ {
method: 'GET', method: 'GET',
header: { header: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
readTimeout: 60000, readTimeout: 60000,
connectTimeout: 60000 connectTimeout: 60000
},(err, data) => { }, (err, data) => {
if (!err) { if (!err) {
console.info('Result:' + data.result); console.info('Result:' + data.result);
console.info('code:' + data.responseCode); console.info('code:' + data.responseCode);
console.info('header:' + data.header); console.info('header:' + data.header);
console.info('cookies:' + data.cookies); // 8+ console.info('cookies:' + data.cookies); // 8+
console.info('header['Content-Type']:' + data.header['Content-Type']); console.info('header.Content-Type:' + data.header['Content-Type']);
console.info('header['Status-Line']:' + data.header['Status-Line']); console.info('header.Status-Line:' + data.header['Status-Line']);
console.info('header.Date:' + data.header.Date); console.info('header.Date:' + data.header.Date);
console.info('header.Server:' + data.header.Server); console.info('header.Server:' + data.header.Server);
} else { } else {
console.info('error:' + err.data); console.info('error:' + err.data);
} }
}); });
``` ```
...@@ -188,24 +188,24 @@ Initiates an HTTP request to a given URL. This API uses a promise to return the ...@@ -188,24 +188,24 @@ Initiates an HTTP request to a given URL. This API uses a promise to return the
``` ```
let promise = httpRequest.request("EXAMPLE_URL", { let promise = httpRequest.request("EXAMPLE_URL", {
method: "GET", method: "GET",
connectTimeout: 60000, connectTimeout: 60000,
readTimeout: 60000, readTimeout: 60000,
header: { header: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
}); });
promise.then((value) => { promise.then((value) => {
console.info('Result:' + value.result); console.info('Result:' + value.result);
console.info('code:' + value.responseCode); console.info('code:' + value.responseCode);
console.info('header:' + value.header); console.info('header:' + value.header);
console.info('cookies:' + value.cookies); // 8+ console.info('cookies:' + value.cookies); // 8+
console.info('header['Content-Type']:' + value.header['Content-Type']); console.info('header.Content-Type:' + value.header['Content-Type']);
console.info('header['Status-Line']:' + value.header['Status-Line']); console.info('header.Status-Line:' + value.header['Status-Line']);
console.info('header.Date:' + value.header.Date); console.info('header.Date:' + value.header.Date);
console.info('header.Server:' + value.header.Server); console.info('header.Server:' + value.header.Server);
}).catch((err) => { }).catch((err) => {
console.error(`errCode:${err.code}, errMessage:${err.data}`); console.error(`errCode:${err.code}, errMessage:${err.data}`);
}); });
``` ```
...@@ -246,9 +246,9 @@ Registers an observer for HTTP Response Header events. ...@@ -246,9 +246,9 @@ Registers an observer for HTTP Response Header events.
``` ```
httpRequest.on('headerReceive', (err, data) => { httpRequest.on('headerReceive', (err, data) => {
if (!err) { if (!err) {
console.info('header: ' + data.header); console.info('header: ' + data.header);
} else { } else {
console.info('error:' + err.data); console.info('error:' + err.data);
} }
}); });
``` ```
...@@ -280,9 +280,9 @@ Unregisters the observer for HTTP Response Header events. ...@@ -280,9 +280,9 @@ Unregisters the observer for HTTP Response Header events.
``` ```
httpRequest.on('headerReceive', (err, data) => { httpRequest.on('headerReceive', (err, data) => {
if (!err) { if (!err) {
console.info('header: ' + data.header); console.info('header: ' + data.header);
} else { } else {
console.info('error:' + err.data); console.info('error:' + err.data);
} }
}); });
httpRequest.off('headerReceive'); httpRequest.off('headerReceive');
......
# Network Connection Management # Network Connection Management
> **NOTE**<br/> > **NOTE**
> >
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -17,7 +17,7 @@ getDefaultNet(callback: AsyncCallback\<NetHandle>): void ...@@ -17,7 +17,7 @@ getDefaultNet(callback: AsyncCallback\<NetHandle>): void
Obtains the default active data network. This API uses an asynchronous callback to return the result. Obtains the default active data network. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -42,11 +42,11 @@ getDefaultNet(): Promise\<NetHandle> ...@@ -42,11 +42,11 @@ getDefaultNet(): Promise\<NetHandle>
Obtains the default active data network. This API uses a promise to return the result. Obtains the default active data network. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
**Return value** **Return Value**
| Type | Description | | Type | Description |
| --------------------------------- | ------------------------------------- | | --------------------------------- | ------------------------------------- |
...@@ -91,7 +91,7 @@ Checks whether the default data network is activated. This API uses a promise to ...@@ -91,7 +91,7 @@ Checks whether the default data network is activated. This API uses a promise to
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
**Return value** **Return Value**
| Type | Description | | Type | Description |
| ----------------- | ----------------------------------------------- | | ----------------- | ----------------------------------------------- |
...@@ -111,7 +111,7 @@ getAllNets(callback: AsyncCallback&lt;Array&lt;NetHandle&gt;&gt;): void ...@@ -111,7 +111,7 @@ getAllNets(callback: AsyncCallback&lt;Array&lt;NetHandle&gt;&gt;): void
Obtains the list of all active data networks. This API uses an asynchronous callback to return the result. Obtains the list of all active data networks. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -136,11 +136,11 @@ getAllNets(): Promise&lt;Array&lt;NetHandle&gt;&gt; ...@@ -136,11 +136,11 @@ getAllNets(): Promise&lt;Array&lt;NetHandle&gt;&gt;
Obtains the list of all active data networks. This API uses a promise to return the result. Obtains the list of all active data networks. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
**Return value** **Return Value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;[NetHandle](#nethandle)&gt;&gt; | Promise used to return the result.| | Promise&lt;Array&lt;[NetHandle](#nethandle)&gt;&gt; | Promise used to return the result.|
...@@ -157,9 +157,9 @@ connection.getAllNets().then(function (nets) { ...@@ -157,9 +157,9 @@ connection.getAllNets().then(function (nets) {
getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\<ConnectionProperties>): void getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\<ConnectionProperties>): void
Obtains connection properties of the network corresponding to the **netHandle**. This API uses an asynchronous callback to return the result. Obtains connection properties of the network corresponding to given network handle. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -185,9 +185,9 @@ connection.getDefaultNet().then(function (netHandle) { ...@@ -185,9 +185,9 @@ connection.getDefaultNet().then(function (netHandle) {
getConnectionProperties(netHandle: NetHandle): Promise\<ConnectionProperties> getConnectionProperties(netHandle: NetHandle): Promise\<ConnectionProperties>
Obtains connection properties of the network corresponding to the **netHandle**. This API uses a promise to return the result. Obtains connection properties of the network corresponding to **netHandle**. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -197,7 +197,7 @@ Obtains connection properties of the network corresponding to the **netHandle**. ...@@ -197,7 +197,7 @@ Obtains connection properties of the network corresponding to the **netHandle**.
| --------- | ----------------------- | ---- | ---------------- | | --------- | ----------------------- | ---- | ---------------- |
| netHandle | [NetHandle](#nethandle) | Yes | Network handle.| | netHandle | [NetHandle](#nethandle) | Yes | Network handle.|
**Return value** **Return Value**
| Type | Description | | Type | Description |
| ------------------------------------------------------- | --------------------------------- | | ------------------------------------------------------- | --------------------------------- |
...@@ -217,9 +217,9 @@ connection.getDefaultNet().then(function (netHandle) { ...@@ -217,9 +217,9 @@ connection.getDefaultNet().then(function (netHandle) {
getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback\<NetCapabilities>): void getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback\<NetCapabilities>): void
Obtains capability information of the network corresponding to the **netHandle**. This API uses an asynchronous callback to return the result. Obtains capability information of the network corresponding to **netHandle**. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -245,9 +245,9 @@ connection.getDefaultNet().then(function (netHandle) { ...@@ -245,9 +245,9 @@ connection.getDefaultNet().then(function (netHandle) {
getNetCapabilities(netHandle: NetHandle): Promise\<NetCapabilities> getNetCapabilities(netHandle: NetHandle): Promise\<NetCapabilities>
Obtains capability information of the network corresponding to the **netHandle**. This API uses a promise to return the result. Obtains capability information of the network corresponding to **netHandle**. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -257,7 +257,7 @@ Obtains capability information of the network corresponding to the **netHandle** ...@@ -257,7 +257,7 @@ Obtains capability information of the network corresponding to the **netHandle**
| --------- | ----------------------- | ---- | ---------------- | | --------- | ----------------------- | ---- | ---------------- |
| netHandle | [NetHandle](#nethandle) | Yes | Network handle.| | netHandle | [NetHandle](#nethandle) | Yes | Network handle.|
**Return value** **Return Value**
| Type | Description | | Type | Description |
| --------------------------------------------- | --------------------------------- | | --------------------------------------------- | --------------------------------- |
...@@ -279,7 +279,7 @@ reportNetConnected(netHandle: NetHandle, callback: AsyncCallback&lt;void&gt;): v ...@@ -279,7 +279,7 @@ reportNetConnected(netHandle: NetHandle, callback: AsyncCallback&lt;void&gt;): v
Reports connection of the data network. This API uses an asynchronous callback to return the result. Reports connection of the data network. This API uses an asynchronous callback to return the result.
**Required permissions** : ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET ** Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -306,7 +306,7 @@ reportNetConnected(netHandle: NetHandle): Promise&lt;void&gt; ...@@ -306,7 +306,7 @@ reportNetConnected(netHandle: NetHandle): Promise&lt;void&gt;
Reports connection of the data network. This API uses a promise to return the result. Reports connection of the data network. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET ** Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -315,7 +315,7 @@ Reports connection of the data network. This API uses a promise to return the re ...@@ -315,7 +315,7 @@ Reports connection of the data network. This API uses a promise to return the re
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).|
**Return value** **Return Value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
...@@ -337,7 +337,7 @@ reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback&lt;void&gt;) ...@@ -337,7 +337,7 @@ reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback&lt;void&gt;)
Reports disconnection of the data network. This API uses an asynchronous callback to return the result. Reports disconnection of the data network. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET ** Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -364,7 +364,7 @@ reportNetDisconnected(netHandle: NetHandle): Promise&lt;void&gt; ...@@ -364,7 +364,7 @@ reportNetDisconnected(netHandle: NetHandle): Promise&lt;void&gt;
Reports disconnection of the data network. This API uses a promise to return the result. Reports disconnection of the data network. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET ** Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -373,7 +373,7 @@ Reports disconnection of the data network. This API uses a promise to return the ...@@ -373,7 +373,7 @@ Reports disconnection of the data network. This API uses a promise to return the
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).|
**Return value** **Return Value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
...@@ -394,7 +394,7 @@ getAddressesByName(host: string, callback: AsyncCallback\<Array\<NetAddress>>): ...@@ -394,7 +394,7 @@ getAddressesByName(host: string, callback: AsyncCallback\<Array\<NetAddress>>):
Resolves the host name by using the default network to obtain all IP addresses. This API uses an asynchronous callback to return the result. Resolves the host name by using the default network to obtain all IP addresses. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -402,7 +402,7 @@ Resolves the host name by using the default network to obtain all IP addresses. ...@@ -402,7 +402,7 @@ Resolves the host name by using the default network to obtain all IP addresses.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------- | ---- | ------------------ | | -------- | ------------------------------------------------- | ---- | ------------------ |
| host | string | Yes | Host name to resolve.| | host | string | Yes | Host name to be resolved.|
| callback | AsyncCallback\<Array\<[NetAddress](#netaddress)>> | Yes | Callback used to return the result. | | callback | AsyncCallback\<Array\<[NetAddress](#netaddress)>> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -421,7 +421,7 @@ getAddressesByName(host: string): Promise\<Array\<NetAddress>> ...@@ -421,7 +421,7 @@ getAddressesByName(host: string): Promise\<Array\<NetAddress>>
Resolves the host name by using the default network to obtain all IP addresses. This API uses a promise to return the result. Resolves the host name by using the default network to obtain all IP addresses. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -429,13 +429,13 @@ Resolves the host name by using the default network to obtain all IP addresses. ...@@ -429,13 +429,13 @@ Resolves the host name by using the default network to obtain all IP addresses.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ | | ------ | ------ | ---- | ------------------ |
| host | string | Yes | Host name to resolve.| | host | string | Yes | Host name to be resolved.|
**Return value** **Return Value**
| Type | Description | | Type | Description |
| ------------------------------------------- | ----------------------------- | | ------------------------------------------- | ----------------------------- |
| Promise\<Array\<[NetAddress](#netaddress)>> | Promise used to return the IP addresses obtained.| | Promise\<Array\<[NetAddress](#netaddress)>> | Promise used to return the result.|
**Example** **Example**
...@@ -461,7 +461,7 @@ Obtains the handle of the network specified by **netSpecifier**. ...@@ -461,7 +461,7 @@ Obtains the handle of the network specified by **netSpecifier**.
| netSpecifier | [NetSpecifier](#netspecifier) | No | Network specifier. If this parameter is not set, the default network is used. | | netSpecifier | [NetSpecifier](#netspecifier) | No | Network specifier. If this parameter is not set, the default network is used. |
| timeout | number | No | Timeout interval for obtaining the network specified by **netSpecifier**. This parameter is valid only when **netSpecifier** is set.| | timeout | number | No | Timeout interval for obtaining the network specified by **netSpecifier**. This parameter is valid only when **netSpecifier** is set.|
**Return value** **Return Value**
| Type | Description | | Type | Description |
| ------------------------------- | -------------------- | | ------------------------------- | -------------------- |
...@@ -520,7 +520,7 @@ Registers a listener for **netCapabilitiesChange** events. ...@@ -520,7 +520,7 @@ Registers a listener for **netCapabilitiesChange** events.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The value is fixed to **netCapabilitiesChange**.<br>**netCapabilitiesChange**: event indicating that the network capabilities have changed.| | type | string | Yes | Event type. The value is fixed to **netCapabilitiesChange**.<br>**netCapabilitiesChange**: event indicating that he network capabilities have changed.|
| callback | Callback<{ netHandle: [NetHandle](#nethandle), netCap: [NetCapabilities](#netcapabilities) }> | Yes | Callback used to return the result. | | callback | Callback<{ netHandle: [NetHandle](#nethandle), netCap: [NetCapabilities](#netcapabilities) }> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -630,7 +630,7 @@ register(callback: AsyncCallback\<void>): void ...@@ -630,7 +630,7 @@ register(callback: AsyncCallback\<void>): void
Registers a listener for network status changes. Registers a listener for network status changes.
**Required permissions**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -674,15 +674,15 @@ netConnection.unregister(function (error) { ...@@ -674,15 +674,15 @@ netConnection.unregister(function (error) {
Defines the handle of the data network. Defines the handle of the data network.
Before invoking **NetHandle** APIs, call **getNetHandle** to obtain a **NetHandle** object. Before invoking NetHandle APIs, call **getNetHandle** to obtain a **NetHandle** object.
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
### Attributes ### Parameters
| Name| Type | Description | | Name| Type | Description |
| ------ | ------ | ------------------------- | | ------ | ------ | ------------------------- |
| netId | number | Network ID. The value must be greater than or equal to **100**.| | netId | number | Network ID. The value must be greater than or equal to 100.|
### bindSocket ### bindSocket
...@@ -731,7 +731,7 @@ Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses ...@@ -731,7 +731,7 @@ Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| socketParam | TCPSocket \| UDPSocket | Yes | **TCPSocket** or **UDPSocket** object.| | socketParam | TCPSocket \| UDPSocket | Yes | **TCPSocket** or **UDPSocket** object.|
**Return value** **Return Value**
| Type | Description | | Type | Description |
| ------------------- | --------------------------- | | ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
...@@ -767,7 +767,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre ...@@ -767,7 +767,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------- | ---- | ------------------ | | -------- | ------------------------------------------------- | ---- | ------------------ |
| host | string | Yes | Host name to resolve.| | host | string | Yes | Host name to be resolved.|
| callback | AsyncCallback\<Array\<[NetAddress](#netaddress)>> | Yes | Callback used to return the result. | | callback | AsyncCallback\<Array\<[NetAddress](#netaddress)>> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -794,9 +794,9 @@ Resolves the host name by using the corresponding network to obtain all IP addre ...@@ -794,9 +794,9 @@ Resolves the host name by using the corresponding network to obtain all IP addre
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ | | ------ | ------ | ---- | ------------------ |
| host | string | Yes | Host name to resolve.| | host | string | Yes | Host name to be resolved.|
**Return value** **Return Value**
| Type | Description | | Type | Description |
| ------------------------------------------- | ----------------------------- | | ------------------------------------------- | ----------------------------- |
...@@ -825,7 +825,7 @@ Resolves the host name by using the corresponding network to obtain the first IP ...@@ -825,7 +825,7 @@ Resolves the host name by using the corresponding network to obtain the first IP
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | ------------------ | | -------- | ----------------------------------------- | ---- | ------------------ |
| host | string | Yes | Host name to resolve.| | host | string | Yes | Host name to be resolved.|
| callback | AsyncCallback\<[NetAddress](#netaddress)> | Yes | Callback used to return the result. | | callback | AsyncCallback\<[NetAddress](#netaddress)> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -852,9 +852,9 @@ Resolves the host name by using the corresponding network to obtain the first IP ...@@ -852,9 +852,9 @@ Resolves the host name by using the corresponding network to obtain the first IP
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ | | ------ | ------ | ---- | ------------------ |
| host | string | Yes | Host name to resolve.| | host | string | Yes | Host name to be resolved.|
**Return value** **Return Value**
| Type | Description | | Type | Description |
| ----------------------------------- | ------------------------------- | | ----------------------------------- | ------------------------------- |
...@@ -901,7 +901,7 @@ Defines the network capability. ...@@ -901,7 +901,7 @@ Defines the network capability.
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
| Name | Value α | Description | | Name | Value | Description |
| ------------------------ | ---- | ---------------------- | | ------------------------ | ---- | ---------------------- |
| NET_CAPABILITY_MMS | 0 | The network can connect to the carrier's Multimedia Messaging Service Center (MMSC) to send and receive multimedia messages.| | NET_CAPABILITY_MMS | 0 | The network can connect to the carrier's Multimedia Messaging Service Center (MMSC) to send and receive multimedia messages.|
| NET_CAPABILITY_NOT_METERED | 11 | The network traffic is not metered.| | NET_CAPABILITY_NOT_METERED | 11 | The network traffic is not metered.|
...@@ -915,7 +915,7 @@ Defines the network type. ...@@ -915,7 +915,7 @@ Defines the network type.
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
| Name | Value α | Description | | Name | Value | Description |
| --------------- | ---- | ----------- | | --------------- | ---- | ----------- |
| BEARER_CELLULAR | 0 | Cellular network | | BEARER_CELLULAR | 0 | Cellular network |
| BEARER_WIFI | 1 | Wi-Fi network| | BEARER_WIFI | 1 | Wi-Fi network|
...@@ -938,7 +938,7 @@ Defines the network connection properties. ...@@ -938,7 +938,7 @@ Defines the network connection properties.
## LinkAddress ## LinkAddress
Defines network link information. Network link information.
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -949,7 +949,7 @@ Defines network link information. ...@@ -949,7 +949,7 @@ Defines network link information.
## RouteInfo ## RouteInfo
Defines network route information. Network route information.
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -971,4 +971,4 @@ Defines the network address. ...@@ -971,4 +971,4 @@ Defines the network address.
| ------- | ------ | ------------------------------ | | ------- | ------ | ------------------------------ |
| address | string | Network address. | | address | string | Network address. |
| family | number | Address family identifier. The value is **1** for IPv4 and **2** for IPv6. The default value is **1**.| | family | number | Address family identifier. The value is **1** for IPv4 and **2** for IPv6. The default value is **1**.|
| port | number | Port number. The value range is 0 to 65535. | | port | number | Port number. The value ranges from **0** to **65535**. |
...@@ -600,13 +600,13 @@ Defines the network type. ...@@ -600,13 +600,13 @@ Defines the network type.
| Name | Value | Description | | Name | Value | Description |
| -------------------- | ---- | ------------------------------------------------------------ | | -------------------- | ---- | ------------------------------------------------------------ |
| NETWORK_TYPE_UNKNOWN | 0 | Unknown network | | NETWORK_TYPE_UNKNOWN | 0 | Unknown network. |
| NETWORK_TYPE_GSM | 1 | GSM network | | NETWORK_TYPE_GSM | 1 | GSM network. |
| NETWORK_TYPE_CDMA | 2 | CDMA network | | NETWORK_TYPE_CDMA | 2 | CDMA network. |
| NETWORK_TYPE_WCDMA | 3 | WCDMA network | | NETWORK_TYPE_WCDMA | 3 | WCDMA network. |
| NETWORK_TYPE_TDSCDMA | 4 | TD-SCDMA network| | NETWORK_TYPE_TDSCDMA | 4 | TD-SCDMA network.|
| NETWORK_TYPE_LTE | 5 | LTE network | | NETWORK_TYPE_LTE | 5 | LTE network. |
| NETWORK_TYPE_NR | 6 | 5G NR network | | NETWORK_TYPE_NR | 6 | 5G NR network. |
## NetworkState ## NetworkState
......
...@@ -15,7 +15,7 @@ import sim from '@ohos.telephony.sim'; ...@@ -15,7 +15,7 @@ import sim from '@ohos.telephony.sim';
isSimActive\(slotId: number, callback: AsyncCallback<boolean\>\): void isSimActive\(slotId: number, callback: AsyncCallback<boolean\>\): void
Checks whether the SIM card in the specified slot is activated. This function uses an asynchronous callback to return the result. Checks whether the SIM card in the specified slot is activated. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
...@@ -23,7 +23,7 @@ Checks whether the SIM card in the specified slot is activated. This function us ...@@ -23,7 +23,7 @@ Checks whether the SIM card in the specified slot is activated. This function us
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------------------------- | | -------- | --------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -39,7 +39,7 @@ sim.isSimActive(0, (err, data) => { ...@@ -39,7 +39,7 @@ sim.isSimActive(0, (err, data) => {
isSimActive\(slotId: number\): Promise<boolean\> isSimActive\(slotId: number\): Promise<boolean\>
Checks whether the SIM card in the specified slot is activated. This function uses a promise to return the result. Checks whether the SIM card in the specified slot is activated. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
...@@ -47,9 +47,9 @@ Checks whether the SIM card in the specified slot is activated. This function us ...@@ -47,9 +47,9 @@ Checks whether the SIM card in the specified slot is activated. This function us
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- | | ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------------------------------- | | --------------------- | ---------------------------------- |
...@@ -71,7 +71,7 @@ promise.then(data => { ...@@ -71,7 +71,7 @@ promise.then(data => {
getDefaultVoiceSlotId\(callback: AsyncCallback<number\>\): void getDefaultVoiceSlotId\(callback: AsyncCallback<number\>\): void
Obtains the default slot ID of the SIM card that provides voice services. This function uses an asynchronous callback to return the result. Obtains the default slot ID of the SIM card that provides voice services. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
...@@ -94,11 +94,11 @@ sim.getDefaultVoiceSlotId((err, data) => { ...@@ -94,11 +94,11 @@ sim.getDefaultVoiceSlotId((err, data) => {
getDefaultVoiceSlotId\(\): Promise<number\> getDefaultVoiceSlotId\(\): Promise<number\>
Obtains the default slot ID of the SIM card that provides voice services. This function uses a promise to return the result. Obtains the default slot ID of the SIM card that provides voice services. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ----------------- | --------------------------------------- | | ----------------- | --------------------------------------- |
...@@ -119,7 +119,7 @@ promise.then(data => { ...@@ -119,7 +119,7 @@ promise.then(data => {
hasOperatorPrivileges(slotId: number, callback: AsyncCallback\<boolean\>): void hasOperatorPrivileges(slotId: number, callback: AsyncCallback\<boolean\>): void
Checks whether the application (caller) has been granted the operator permission. This function uses an asynchronous callback to return the result. Checks whether the application (caller) has been granted the operator permission. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
...@@ -127,7 +127,7 @@ Checks whether the application (caller) has been granted the operator permission ...@@ -127,7 +127,7 @@ Checks whether the application (caller) has been granted the operator permission
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | ---------------------------------------- | | -------- | ------------------------ | ---- | ---------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -140,9 +140,9 @@ sim.hasOperatorPrivileges(0, (err, data) => { ...@@ -140,9 +140,9 @@ sim.hasOperatorPrivileges(0, (err, data) => {
## sim.hasOperatorPrivileges<sup>7+</sup> ## sim.hasOperatorPrivileges<sup>7+</sup>
hasOperatorPrivileges(slotId: number): Promise<boolean> hasOperatorPrivileges(slotId: number): Promise<boolean\>
Checks whether the application (caller) has been granted the operator permission. This function uses a promise to return the result. Checks whether the application (caller) has been granted the operator permission. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
...@@ -150,9 +150,9 @@ Checks whether the application (caller) has been granted the operator permission ...@@ -150,9 +150,9 @@ Checks whether the application (caller) has been granted the operator permission
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------------------- | | ------ | ------ | ---- | ---------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| :----------------- | :---------------------------------------------------------- | | :----------------- | :---------------------------------------------------------- |
...@@ -173,7 +173,7 @@ promise.then(data => { ...@@ -173,7 +173,7 @@ promise.then(data => {
getISOCountryCodeForSim\(slotId: number, callback: AsyncCallback<string\>\): void getISOCountryCodeForSim\(slotId: number, callback: AsyncCallback<string\>\): void
Obtains the ISO country code of the SIM card in the specified slot. This function uses an asynchronous callback to return the result. Obtains the ISO country code of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
...@@ -181,7 +181,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This functio ...@@ -181,7 +181,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This functio
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------------------------------------- | | -------- | ----------------------- | ---- | ---------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2 | | slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| callback | AsyncCallback\<string\> | Yes | Callback used to return the result, which is a country code, for example, **CN** (China).| | callback | AsyncCallback\<string\> | Yes | Callback used to return the result, which is a country code, for example, **CN** (China).|
**Example** **Example**
...@@ -197,7 +197,7 @@ sim.getISOCountryCodeForSim(0, (err, data) => { ...@@ -197,7 +197,7 @@ sim.getISOCountryCodeForSim(0, (err, data) => {
getISOCountryCodeForSim\(slotId: number\): Promise<string\> getISOCountryCodeForSim\(slotId: number\): Promise<string\>
Obtains the ISO country code of the SIM card in the specified slot. This function uses a promise to return the result. Obtains the ISO country code of the SIM card in the specified slot. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
...@@ -205,9 +205,9 @@ Obtains the ISO country code of the SIM card in the specified slot. This functio ...@@ -205,9 +205,9 @@ Obtains the ISO country code of the SIM card in the specified slot. This functio
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- | | ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ----------------- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ |
...@@ -229,7 +229,7 @@ promise.then(data => { ...@@ -229,7 +229,7 @@ promise.then(data => {
getSimOperatorNumeric\(slotId: number, callback: AsyncCallback<string\>\): void getSimOperatorNumeric\(slotId: number, callback: AsyncCallback<string\>\): void
Obtains the public land mobile network (PLMN) ID of the SIM card in the specified slot. This function uses an asynchronous callback to return the result. Obtains the public land mobile network (PLMN) ID of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
...@@ -237,7 +237,7 @@ Obtains the public land mobile network (PLMN) ID of the SIM card in the specifie ...@@ -237,7 +237,7 @@ Obtains the public land mobile network (PLMN) ID of the SIM card in the specifie
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- | | -------- | ----------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<string\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<string\> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -253,7 +253,7 @@ sim.getSimOperatorNumeric(0, (err, data) => { ...@@ -253,7 +253,7 @@ sim.getSimOperatorNumeric(0, (err, data) => {
getSimOperatorNumeric\(slotId: number\): Promise<string\> getSimOperatorNumeric\(slotId: number\): Promise<string\>
Obtains the PLMN ID of the SIM card in the specified slot. This function uses a promise to return the result. Obtains the PLMN ID of the SIM card in the specified slot. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
...@@ -261,9 +261,9 @@ Obtains the PLMN ID of the SIM card in the specified slot. This function uses a ...@@ -261,9 +261,9 @@ Obtains the PLMN ID of the SIM card in the specified slot. This function uses a
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- | | ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ----------------- | ------------------------------------------------ | | ----------------- | ------------------------------------------------ |
...@@ -285,7 +285,7 @@ promise.then(data => { ...@@ -285,7 +285,7 @@ promise.then(data => {
getSimSpn\(slotId: number, callback: AsyncCallback<string\>\): void getSimSpn\(slotId: number, callback: AsyncCallback<string\>\): void
Obtains the service provider name (SPN) of the SIM card in the specified slot. This function uses an asynchronous callback to return the result. Obtains the service provider name (SPN) of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
...@@ -293,7 +293,7 @@ Obtains the service provider name (SPN) of the SIM card in the specified slot. T ...@@ -293,7 +293,7 @@ Obtains the service provider name (SPN) of the SIM card in the specified slot. T
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- | | -------- | ----------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<string\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<string\> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -309,7 +309,7 @@ sim.getSimSpn(0, (err, data) => { ...@@ -309,7 +309,7 @@ sim.getSimSpn(0, (err, data) => {
getSimSpn\(slotId: number\): Promise<string\> getSimSpn\(slotId: number\): Promise<string\>
Obtains the SPN of the SIM card in the specified slot. This function uses a promise to return the result. Obtains the SPN of the SIM card in the specified slot. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
...@@ -317,9 +317,9 @@ Obtains the SPN of the SIM card in the specified slot. This function uses a prom ...@@ -317,9 +317,9 @@ Obtains the SPN of the SIM card in the specified slot. This function uses a prom
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- | | ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ----------------- | ----------------------------------------- | | ----------------- | ----------------------------------------- |
...@@ -341,7 +341,7 @@ promise.then(data => { ...@@ -341,7 +341,7 @@ promise.then(data => {
getSimState\(slotId: number, callback: AsyncCallback<SimState\>\): void getSimState\(slotId: number, callback: AsyncCallback<SimState\>\): void
Obtains the status of the SIM card in the specified slot. This function uses an asynchronous callback to return the result. Obtains the status of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
...@@ -349,7 +349,7 @@ Obtains the status of the SIM card in the specified slot. This function uses an ...@@ -349,7 +349,7 @@ Obtains the status of the SIM card in the specified slot. This function uses an
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | -------------------------------------- | | -------- | -------------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<[SimState](#simState)\> | Yes | Callback used to return the result. For details, see [SimState](#simState). | | callback | AsyncCallback\<[SimState](#simState)\> | Yes | Callback used to return the result. For details, see [SimState](#simState). |
**Example** **Example**
...@@ -365,7 +365,7 @@ sim.getSimState(0, (err, data) => { ...@@ -365,7 +365,7 @@ sim.getSimState(0, (err, data) => {
getSimState\(slotId: number\): Promise<SimState\> getSimState\(slotId: number\): Promise<SimState\>
Obtains the status of the SIM card in the specified slot. This function uses a promise to return the result. Obtains the status of the SIM card in the specified slot. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
...@@ -373,9 +373,9 @@ Obtains the status of the SIM card in the specified slot. This function uses a p ...@@ -373,9 +373,9 @@ Obtains the status of the SIM card in the specified slot. This function uses a p
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- | | ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| -------------------------------- | ------------------------------------------ | | -------------------------------- | ------------------------------------------ |
...@@ -396,7 +396,7 @@ promise.then(data => { ...@@ -396,7 +396,7 @@ promise.then(data => {
getCardType\(slotId: number, callback: AsyncCallback<CardType\>\): void getCardType\(slotId: number, callback: AsyncCallback<CardType\>\): void
Obtains the type of the SIM card in the specified slot. This function uses an asynchronous callback to return the result. Obtains the type of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
...@@ -404,7 +404,7 @@ Obtains the type of the SIM card in the specified slot. This function uses an as ...@@ -404,7 +404,7 @@ Obtains the type of the SIM card in the specified slot. This function uses an as
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- | | -------- | ----------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<[CardType](#cardtype7)\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<[CardType](#cardtype7)\> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -420,7 +420,7 @@ sim.getCardType(0, (err, data) => { ...@@ -420,7 +420,7 @@ sim.getCardType(0, (err, data) => {
getCardType\(slotId: number\): Promise<CardType\> getCardType\(slotId: number\): Promise<CardType\>
Obtains the type of the SIM card in the specified slot. This function uses a promise to return the result. Obtains the type of the SIM card in the specified slot. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
...@@ -428,9 +428,9 @@ Obtains the type of the SIM card in the specified slot. This function uses a pro ...@@ -428,9 +428,9 @@ Obtains the type of the SIM card in the specified slot. This function uses a pro
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- | | ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ----------------- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ |
...@@ -452,7 +452,7 @@ promise.then(data => { ...@@ -452,7 +452,7 @@ promise.then(data => {
hasSimCard\(slotId: number, callback: AsyncCallback<boolean\>\): void hasSimCard\(slotId: number, callback: AsyncCallback<boolean\>\): void
Checks whether the SIM card in the specified slot is installed. This function uses an asynchronous callback to return the result. Checks whether the SIM card in the specified slot is installed. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
...@@ -460,7 +460,7 @@ Checks whether the SIM card in the specified slot is installed. This function us ...@@ -460,7 +460,7 @@ Checks whether the SIM card in the specified slot is installed. This function us
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------------------------- | | -------- | --------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -476,7 +476,7 @@ sim.hasSimCard(0, (err, data) => { ...@@ -476,7 +476,7 @@ sim.hasSimCard(0, (err, data) => {
hasSimCard\(slotId: number\): Promise<boolean\> hasSimCard\(slotId: number\): Promise<boolean\>
Checks whether the SIM card in the specified slot is installed. This function uses a promise to return the result. Checks whether the SIM card in the specified slot is installed. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
...@@ -484,9 +484,9 @@ Checks whether the SIM card in the specified slot is installed. This function us ...@@ -484,9 +484,9 @@ Checks whether the SIM card in the specified slot is installed. This function us
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- | | ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------------------------------- | | --------------------- | ---------------------------------- |
...@@ -512,7 +512,7 @@ Obtains the number of card slots. ...@@ -512,7 +512,7 @@ Obtains the number of card slots.
**System capability**: SystemCapability.Communication.CoreService **System capability**: SystemCapability.Communication.CoreService
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ----------------- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ |
...@@ -557,4 +557,4 @@ Enumerates card types. ...@@ -557,4 +557,4 @@ Enumerates card types.
|CU_DUAL_MODE_CARD | 42 | China Unicom dual-mode card| |CU_DUAL_MODE_CARD | 42 | China Unicom dual-mode card|
|DUAL_MODE_TELECOM_LTE_CARD | 43 | China Telecom dual-mode LTE card| |DUAL_MODE_TELECOM_LTE_CARD | 43 | China Telecom dual-mode LTE card|
|DUAL_MODE_UG_CARD | 50 | Dual-mode card (UMTS+GSM)| |DUAL_MODE_UG_CARD | 50 | Dual-mode card (UMTS+GSM)|
|SINGLE_MODE_ISIM_CARD | 60 | Single-card (ISIM)| |SINGLE_MODE_ISIM_CARD<sup>8+</sup> | 60 | Single-card (ISIM)|
...@@ -10,11 +10,11 @@ ...@@ -10,11 +10,11 @@
import sms from '@ohos.telephony.sms'; import sms from '@ohos.telephony.sms';
``` ```
## sms.createMessage<a name=sms.createMessage-callback></a> ## sms.createMessage
createMessage\(pdu: Array<number\>, specification: string, callback: AsyncCallback<ShortMessage\>\): void createMessage\(pdu: Array<number\>, specification: string, callback: AsyncCallback<ShortMessage\>\): void
Creates an SMS message instance based on the protocol data unit (PDU) and the specified SMS protocol. This function uses an asynchronous callback to return the result. Creates an SMS message instance based on the protocol data unit (PDU) and the specified SMS protocol. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
...@@ -24,7 +24,7 @@ Creates an SMS message instance based on the protocol data unit (PDU) and the sp ...@@ -24,7 +24,7 @@ Creates an SMS message instance based on the protocol data unit (PDU) and the sp
| ------------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ | | ------------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ |
| pdu | Array&lt;number&gt; | Yes | PDU, which is obtained from the received SMS message. | | pdu | Array&lt;number&gt; | Yes | PDU, which is obtained from the received SMS message. |
| specification | string | Yes | SMS protocol type. <br>- **3gpp**: GSM/UMTS/LTE SMS<br>- **3gpp2**: CDMA SMS| | specification | string | Yes | SMS protocol type. <br>- **3gpp**: GSM/UMTS/LTE SMS<br>- **3gpp2**: CDMA SMS|
| callback | AsyncCallback&lt;[ShortMessage](#ShortMessage)&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;[ShortMessage](#shortmessage)&gt; | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -38,11 +38,11 @@ sms.createMessage(pdu, specification, (err, data) => { ...@@ -38,11 +38,11 @@ sms.createMessage(pdu, specification, (err, data) => {
``` ```
## sms.createMessage<a name=sms.createMessage-promise></a> ## sms.createMessage
createMessage\(pdu: Array<number\>, specification: string\): Promise<ShortMessage\> createMessage\(pdu: Array<number\>, specification: string\): Promise<ShortMessage\>
Creates an SMS message instance based on the PDU and the specified SMS protocol. This function uses a promise to return the result. Creates an SMS message instance based on the PDU and the specified SMS protocol. This API uses a promise to return the result.
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
...@@ -57,7 +57,7 @@ Creates an SMS message instance based on the PDU and the specified SMS protocol. ...@@ -57,7 +57,7 @@ Creates an SMS message instance based on the PDU and the specified SMS protocol.
| Type | Description | | Type | Description |
| -------------------------------------------- | --------------------------------- | | -------------------------------------------- | --------------------------------- |
| Promise&lt;[ShortMessage](#ShortMessage)&gt; | Promise used to return the result.| | Promise&lt;[ShortMessage](#shortmessage)&gt; | Promise used to return the result.|
**Example** **Example**
...@@ -87,7 +87,7 @@ Sends an SMS message. ...@@ -87,7 +87,7 @@ Sends an SMS message.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [SendMessageOptions](#SendMessageOptions) | Yes | Options (including the callback) for sending an SMS message. For details, see [SendMessageOptions](#SendMessageOptions).| | options | [SendMessageOptions](#sendmessageoptions) | Yes | Options (including the callback) for sending an SMS message. For details, see [SendMessageOptions](#sendmessageoptions).|
**Example** **Example**
...@@ -108,11 +108,11 @@ sms.sendMessage(options); ...@@ -108,11 +108,11 @@ sms.sendMessage(options);
``` ```
## sms.getDefaultSmsSlotId<sup>7+</sup><a name=sms.getDefaultSmsSlotId-callback></a> ## sms.getDefaultSmsSlotId<sup>7+</sup>
getDefaultSmsSlotId\(callback: AsyncCallback<number\>\): void getDefaultSmsSlotId\(callback: AsyncCallback<number\>\): void
Obtains the default slot of the SIM card used to send SMS messages. This function uses an asynchronous callback to return the result. Obtains the default slot of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
...@@ -131,11 +131,11 @@ sms.getDefaultSmsSlotId((err, data) => { ...@@ -131,11 +131,11 @@ sms.getDefaultSmsSlotId((err, data) => {
``` ```
## sms.getDefaultSmsSlotId<sup>7+</sup><a name=sms.getDefaultSmsSlotId-promise></a> ## sms.getDefaultSmsSlotId<sup>7+</sup>
getDefaultSmsSlotId\(\): Promise<number\> getDefaultSmsSlotId\(\): Promise<number\>
Obtains the default slot of the SIM card used to send SMS messages. This function uses a promise to return the result. Obtains the default slot of the SIM card used to send SMS messages. This API uses a promise to return the result.
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
...@@ -157,16 +157,18 @@ promise.then(data => { ...@@ -157,16 +157,18 @@ promise.then(data => {
``` ```
## sms.setSmscAddr<sup>7+</sup><a name=sms.setSmscAddr-callback></a> ## sms.setSmscAddr<sup>7+</sup>
setSmscAddr\(slotId: number, smscAddr: string, callback: AsyncCallback<void\>\): void setSmscAddr\(slotId: number, smscAddr: string, callback: AsyncCallback<void\>\): void
Sets the short message service center (SMSC) address. This function uses an asynchronous callback to return the result. Sets the short message service center (SMSC) address. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE (a system permission) **Required permission**: ohos.permission.SET_TELEPHONY_STATE (a system permission)
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -186,16 +188,18 @@ sms.setSmscAddr(slotId, smscAddr, (err,data) => { ...@@ -186,16 +188,18 @@ sms.setSmscAddr(slotId, smscAddr, (err,data) => {
``` ```
## sms.setSmscAddr<sup>7+</sup><a name=sms.setSmscAddr-promise></a> ## sms.setSmscAddr<sup>7+</sup>
setSmscAddr\(slotId: number, smscAddr: string\): Promise<void\> setSmscAddr\(slotId: number, smscAddr: string\): Promise<void\>
Sets the SMSC address. This function uses a promise to return the result. Sets the SMSC address. This API uses a promise to return the result.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE (a system permission) **Required permission**: ohos.permission.SET_TELEPHONY_STATE (a system permission)
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -223,17 +227,17 @@ promise.then(data => { ...@@ -223,17 +227,17 @@ promise.then(data => {
``` ```
## sms.getSmscAddr<sup>7+</sup><a name=sms.getSmscAddr-callback></a> ## sms.getSmscAddr<sup>7+</sup>
getSmscAddr\(slotId: number, callback: AsyncCallback<string\>\): void getSmscAddr\(slotId: number, callback: AsyncCallback<string\>\): void
Obtains the SMSC address. This function uses an asynchronous callback to return the result. Obtains the SMSC address. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE (a system permission) **Required permission**: ohos.permission.GET_TELEPHONY_STATE (a system permission)
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
**Note:** This is a system API and it is used only for system applications. This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
...@@ -252,17 +256,17 @@ sms.getSmscAddr(slotId, (err, data) => { ...@@ -252,17 +256,17 @@ sms.getSmscAddr(slotId, (err, data) => {
``` ```
## sms.getSmscAddr<sup>7+</sup><a name=sms.getSmscAddr-promise></a> ## sms.getSmscAddr<sup>7+</sup>
getSmscAddr\(slotId: number\): Promise<string\> getSmscAddr\(slotId: number\): Promise<string\>
Obtains the SMSC address. This function uses a promise to return the result. Obtains the SMSC address. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE (a system permission) **Required permission**: ohos.permission.GET_TELEPHONY_STATE (a system permission)
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
**Note:** This is a system API and it is used only for system applications. This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
...@@ -288,11 +292,11 @@ promise.then(data => { ...@@ -288,11 +292,11 @@ promise.then(data => {
}); });
``` ```
## sms.hasSmsCapability<sup>7+</sup><a name=sms.hasSmsCapability></a> ## sms.hasSmsCapability<sup>7+</sup>
hasSmsCapability(): boolean hasSmsCapability(): boolean
Checks whether the current device can send and receive SMS messages. This function works in synchronous mode. Checks whether the current device can send and receive SMS messages. This API works in synchronous mode.
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
...@@ -307,18 +311,18 @@ let result = sms.hasSmsCapability(); ...@@ -307,18 +311,18 @@ let result = sms.hasSmsCapability();
console.log(`hasSmsCapability: ${JSON.stringify(result)}`); console.log(`hasSmsCapability: ${JSON.stringify(result)}`);
``` ```
## ShortMessage<a name=ShortMessage></a> ## ShortMessage
Defines an SMS message instance. Defines an SMS message instance.
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
| Variable | Type | Description | | Name | Type | Description |
| ------------------------ | --------------------------------------- | ------------------------------------------------------------ | | ------------------------ | --------------------------------------- | ------------------------------------------------------------ |
| hasReplyPath | boolean | Whether the received SMS contains **TP-Reply-Path**. The default value is **false**.<br>**TP-Reply-Path**: the path in which the mobile phone can reply to the SMS message through the originating SMSC.| | hasReplyPath | boolean | Whether the received SMS contains **TP-Reply-Path**. The default value is **false**.<br>**TP-Reply-Path**: the path in which the mobile phone can reply to the SMS message through the originating SMSC.|
| isReplaceMessage | boolean | Whether the received SMS message is a **replace short message**. The default value is **false**.<br>For details, see section 9.2.3.9 in **3GPP TS 23.040**.| | isReplaceMessage | boolean | Whether the received SMS message is a **replace short message**. The default value is **false**.<br>For details, see section 9.2.3.9 in **3GPP TS 23.040**.|
| isSmsStatusReportMessage | boolean | Whether the received SMS message is an SMS delivery status report. The default value is **false**.<br>**SMS-Status-Report**: a message sent from the SMSC to the mobile station to show the SMS message delivery status.| | isSmsStatusReportMessage | boolean | Whether the received SMS message is an SMS delivery status report. The default value is **false**.<br>**SMS-Status-Report**: a message sent from the SMSC to the mobile station to show the SMS message delivery status.|
| messageClass | [ShortMessageClass](#ShortMessageClass) | SMS message type. | | messageClass | [ShortMessageClass](#shortmessageclass) | SMS message type. |
| pdu | Array&lt;number&gt; | PDU in the SMS message. | | pdu | Array&lt;number&gt; | PDU in the SMS message. |
| protocolId | number | ID of the protocol used for sending SMS messages. | | protocolId | number | ID of the protocol used for sending SMS messages. |
| scAddress | string | Address of the short message service center (SMSC). | | scAddress | string | Address of the short message service center (SMSC). |
...@@ -328,69 +332,69 @@ Defines an SMS message instance. ...@@ -328,69 +332,69 @@ Defines an SMS message instance.
| visibleRawAddress | string | Sender address. | | visibleRawAddress | string | Sender address. |
## ShortMessageClass<a name=ShortMessageClass></a> ## ShortMessageClass
Enumerates SMS message types. SMS message type.
| Variable | Value | Description | **System capability**: SystemCapability.Telephony.SmsMms
| ---------------- | ---- | ------------------------------------------------------------ |
| UNKNOWN | 0 | Unknown type.<br>**System capability**: SystemCapability.Telephony.SmsMms|
| INSTANT_MESSAGE | 1 | Instant message, which is displayed immediately after being received.<br>**System capability**: SystemCapability.Telephony.SmsMms|
| OPTIONAL_MESSAGE | 2 | Message stored in the device or SIM card.<br>**System capability**: SystemCapability.Telephony.SmsMms|
| SIM_MESSAGE | 3 | Message containing SIM card information, which is to be stored in the SIM card.<br>**System capability**: SystemCapability.Telephony.SmsMms|
| FORWARD_MESSAGE | 4 | Message to be forwarded to another device.<br>**System capability**: SystemCapability.Telephony.SmsMms|
| Name | Value | Description |
| ---------------- | ---- | ---------------------------------------- |
| UNKNOWN | 0 | Unknown type. |
| INSTANT_MESSAGE | 1 | Instant message, which is displayed immediately after being received. |
| OPTIONAL_MESSAGE | 2 | Message stored in the device or SIM card. |
| SIM_MESSAGE | 3 | Message containing SIM card information, which is to be stored in the SIM card.|
| FORWARD_MESSAGE | 4 | Message to be forwarded to another device. |
## SendMessageOptions<a name=SendMessageOptions></a>
Provides the options (including callbacks) for sending an SMS message. ## SendMessageOptions
For example, you can specify the SMS message type by the optional parameter **content**. Provides the options (including callbacks) for sending an SMS message. For example, you can specify the SMS message type by the optional parameter **content**.
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
| Parameter | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | Slot ID of the SIM card used for sending SMS messages. <br>- **0**: card slot 1<br>- **1**: card slot 2 | | slotId | number | Yes | Slot ID of the SIM card used for sending SMS messages. <br>- **0**: card slot 1<br>- **1**: card slot 2 |
| destinationHost | string | Yes | Destination address of the SMS message. | | destinationHost | string | Yes | Destination address of the SMS message. |
| content | string \| Array&lt;number&gt; | Yes | SMS message type. If the content is composed of character strings, the SMS message is a text message. If the content is composed of byte arrays, the SMS message is a data message.| | content | string \| Array&lt;number&gt; | Yes | SMS message type. If the content is composed of character strings, the SMS message is a text message. If the content is composed of byte arrays, the SMS message is a data message.|
| serviceCenter | string | No | SMSC address. By default, the SMSC address in the SIM card is used. | | serviceCenter | string | No | SMSC address. By default, the SMSC address in the SIM card is used. |
| destinationPort | number | No | Destination port of the SMS message. This field is mandatory only for a data message. Otherwise, it is optional. | | destinationPort | number | No | Destination port of the SMS message. This field is mandatory only for a data message. Otherwise, it is optional. |
| sendCallback | AsyncCallback&lt;[ISendShortMessageCallback](#ISendShortMessageCallback)&gt; | No | Callback used to return the SMS message sending result. For details, see [ISendShortMessageCallback](#ISendShortMessageCallback).| | sendCallback | AsyncCallback&lt;[ISendShortMessageCallback](#isendshortmessagecallback)&gt; | No | Callback used to return the SMS message sending result. For details, see [ISendShortMessageCallback](#isendshortmessagecallback).|
| deliveryCallback | AsyncCallback&lt;[IDeliveryShortMessageCallback](#IDeliveryShortMessageCallback)&gt; | No | Callback used to return the SMS message delivery report. For details, see [IDeliveryShortMessageCallback](#IDeliveryShortMessageCallback).| | deliveryCallback | AsyncCallback&lt;[IDeliveryShortMessageCallback](#ideliveryshortmessagecallback)&gt; | No | Callback used to return the SMS message delivery report. For details, see [IDeliveryShortMessageCallback](#ideliveryshortmessagecallback).|
## ISendShortMessageCallback<a name=ISendShortMessageCallback></a> ## ISendShortMessageCallback
Provides the callback for the SMS message sending result. It consists of three parts: SMS message sending result, URI for storing the sent SMS message, and whether the SMS message is the last part of a long SMS message. Provides the callback for the SMS message sending result. It consists of three parts: SMS message sending result, URI for storing the sent SMS message, and whether the SMS message is the last part of a long SMS message.
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
| Parameter | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------------- | ---- | ------------------------------------------------------------ | | ---------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| isLastPart | boolean | No | Whether this SMS message is the last part of a long SMS message. The value **true** indicates that this SMS message is the last part of a long SMS message, and value **false** indicates the opposite. The default value is **false**.| | isLastPart | boolean | No | Whether this SMS message is the last part of a long SMS message. The value **true** indicates that this SMS message is the last part of a long SMS message, and value **false** indicates the opposite. The default value is **false**.|
| result | [SendSmsResult](#SendSmsResult) | Yes | SMS message sending result. | | result | [SendSmsResult](#sendsmsresult) | Yes | SMS message sending result. |
| url | string | Yes | URI for storing sent SMS messages. | | url | string | Yes | URI for storing sent SMS messages. |
## IDeliveryShortMessageCallback<a name=IDeliveryShortMessageCallback></a> ## IDeliveryShortMessageCallback
Provides the callback for the SMS message sending result. Return the SMS delivery report. Provides the callback for the SMS message sending result. Return the SMS delivery report.
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
| Parameter| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------------------- | ---- | -------------- | | ------ | ------------------- | ---- | -------------- |
| pdu | Array&lt;number&gt; | Yes | SMS message delivery report.| | pdu | Array&lt;number&gt; | Yes | SMS message delivery report.|
## SendSmsResult<a name=SendSmsResult></a> ## SendSmsResult
Enumerates SMS message sending results. SMS message sending result.
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
| Parameter | Value | Description | | Name | Value | Description |
| ------------------------------------ | ---- | ------------------------------------------------------ | | ------------------------------------ | ---- | ------------------------------------------------------ |
| SEND_SMS_SUCCESS | 0 | SMS message sent successfully. | | SEND_SMS_SUCCESS | 0 | SMS message sent successfully. |
| SEND_SMS_FAILURE_UNKNOWN | 1 | Failed to send the SMS message due to unknown reasons. | | SEND_SMS_FAILURE_UNKNOWN | 1 | Failed to send the SMS message due to unknown reasons. |
......
# Socket # Socket Connection
>![](public_sys-resources/icon-note.gif) **NOTE:** >![](public_sys-resources/icon-note.gif) **NOTE:**
> >
......
...@@ -10,11 +10,11 @@ ...@@ -10,11 +10,11 @@
import data from '@ohos.telephony.data'; import data from '@ohos.telephony.data';
``` ```
## data.getDefaultCellularDataSlotId<a name=data.getDefaultCellularDataSlotId-callback></a> ## data.getDefaultCellularDataSlotId
getDefaultCellularDataSlotId(callback: AsyncCallback\<number\>): void getDefaultCellularDataSlotId(callback: AsyncCallback\<number\>): void
Obtains the default SIM card used for mobile data. This function uses an asynchronous callback to return the result. Obtains the default SIM card used for mobile data. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
...@@ -22,9 +22,9 @@ Obtains the default SIM card used for mobile data. This function uses an asynchr ...@@ -22,9 +22,9 @@ Obtains the default SIM card used for mobile data. This function uses an asynchr
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ------------------------------------------ | | -------- | ----------------------- | ---- | ------------------------------------------ |
| callback | AsyncCallback\<number\> | Yes| Callback used to return the result. <br /> **0**: slot 1 <br/>**1**: slot 2| | callback | AsyncCallback\<number\> | Yes | Callback used to return the result.<br>**0**: card slot 1<br>**1**: card slot 2|
**Example** **Example**
...@@ -34,21 +34,21 @@ data.getDefaultCellularDataSlotId((err, data) => { ...@@ -34,21 +34,21 @@ data.getDefaultCellularDataSlotId((err, data) => {
}); });
``` ```
## data.getDefaultCellularDataSlotId<a name=data.getDefaultCellularDataSlotId-promise></a> ## data.getDefaultCellularDataSlotId
getDefaultCellularDataSlotId(): Promise\<number\> getDefaultCellularDataSlotId(): Promise\<number\>
Obtains the default SIM card used for mobile data. This function uses a promise to return the result. Obtains the default SIM card used for mobile data. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
**Return value** **Return Value**
| Type| Description| | Type | Description |
| ----------------- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result, wherein: <br />**0**: slot 1 <br/>**1**: slot 2| | Promise\<number\> | Promise used to return the result.<br>**0**: card slot 1<br>**1**: card slot 2|
**Example** **Example**
...@@ -61,19 +61,19 @@ promise.then((data) => { ...@@ -61,19 +61,19 @@ promise.then((data) => {
}); });
``` ```
## data.getCellularDataFlowType<a name=data.getCellularDataFlowType-callback></a> ## data.getCellularDataFlowType
getCellularDataFlowType(callback: AsyncCallback\<DataFlowType\>): void getCellularDataFlowType(callback: AsyncCallback\<DataFlowType\>): void
Obtains the cellular data flow type, which can be uplink or downlink. This function uses an asynchronous callback to return the result. Obtains the cellular data flow type, which can be uplink or downlink. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------- | ---- | ---------- | | -------- | ---------------------------------------------- | ---- | ---------- |
| callback | AsyncCallback\<[DataFlowType](#DataFlowType)\> | Yes| Callback used to return the result.| | callback | AsyncCallback\<[DataFlowType](#dataflowtype)\> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -83,19 +83,19 @@ data.getCellularDataFlowType((err, data) => { ...@@ -83,19 +83,19 @@ data.getCellularDataFlowType((err, data) => {
}); });
``` ```
## data.getCellularDataFlowType<a name=data.getCellularDataFlowType-promise></a> ## data.getCellularDataFlowType
getCellularDataFlowType(): Promise\<DataFlowType\> getCellularDataFlowType(): Promise\<DataFlowType\>
Obtains the cellular data flow type, which can be uplink or downlink. This function uses a promise to return the result. Obtains the cellular data flow type, which can be uplink or downlink. This API uses a promise to return the result.
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
**Return value** **Return Value**
| Type| Description| | Type | Description |
| ---------------------------------------- | ----------------------------------------------- | | ---------------------------------------- | ----------------------------------------------- |
| Promise\<[DataFlowType](#DataFlowType)\> | Promise used to return the result. | | Promise\<[DataFlowType](#dataflowtype)\> | Promise used to return the result. |
**Example** **Example**
...@@ -108,19 +108,19 @@ promise.then((data) => { ...@@ -108,19 +108,19 @@ promise.then((data) => {
}); });
``` ```
## data.getCellularDataState<a name=data.getCellularDataState-callback></a> ## data.getCellularDataState
getCellularDataState(callback: AsyncCallback\<DataConnectState\>): void getCellularDataState(callback: AsyncCallback\<DataConnectState\>): void
Obtains the connection status of the packet switched (PS) domain. This function uses an asynchronous callback to return the result. Obtains the connection status of the packet switched (PS) domain. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------ | ---- | ---------- | | -------- | ------------------------------------------------------ | ---- | ---------- |
| callback | AsyncCallback\<[DataConnectState](#DataConnectState)\> | Yes| Callback used to return the result.| | callback | AsyncCallback\<[DataConnectState](#dataconnectstate)\> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -130,19 +130,19 @@ data.getCellularDataState((err, data) => { ...@@ -130,19 +130,19 @@ data.getCellularDataState((err, data) => {
}); });
``` ```
## data.getCellularDataState<a name=data.getCellularDataState-promise></a> ## data.getCellularDataState
getCellularDataState(): Promise\<DataConnectState\> getCellularDataState(): Promise\<DataConnectState\>
Obtains the connection status of the PS domain. This function uses a promise to return the result. Obtains the connection status of the PS domain. This API uses a promise to return the result.
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
**Return value** **Return Value**
| Type| Description| | Type | Description |
| ------------------------------------------------ | ------------------------------------- | | ------------------------------------------------ | ------------------------------------- |
| Promise\<[DataConnectState](#DataConnectState)\> | Promise used to return the result.| | Promise\<[DataConnectState](#dataconnectstate)\> | Promise used to return the result.|
**Example** **Example**
...@@ -155,11 +155,11 @@ promise.then((data) => { ...@@ -155,11 +155,11 @@ promise.then((data) => {
}); });
``` ```
## data.isCellularDataEnabled<a name=data.isCellularDataEnabled-callback></a> ## data.isCellularDataEnabled
isCellularDataEnabled(callback: AsyncCallback\<boolean\>): void isCellularDataEnabled(callback: AsyncCallback\<boolean\>): void
Checks whether the cellular data service is enabled. This function uses an asynchronous callback to return the result. Checks whether the cellular data service is enabled. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
...@@ -167,9 +167,9 @@ Checks whether the cellular data service is enabled. This function uses an async ...@@ -167,9 +167,9 @@ Checks whether the cellular data service is enabled. This function uses an async
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback\<boolean\> | Yes| Callback used to return the result. <br />**true**: The cellular data service is enabled. <br />**false**: The cellular data service is disabled.| | callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.<br>**true**: The cellular data service is enabled.<br>**false**: The cellular data service is disabled.|
**Example** **Example**
...@@ -179,21 +179,21 @@ data.isCellularDataEnabled((err, data) => { ...@@ -179,21 +179,21 @@ data.isCellularDataEnabled((err, data) => {
}); });
``` ```
## data.isCellularDataEnabled<a name=data.isCellularDataEnabled-promise></a> ## data.isCellularDataEnabled
isCellularDataEnabled(): Promise\<boolean\> isCellularDataEnabled(): Promise\<boolean\>
Checks whether the cellular data service is enabled. This function uses a promise to return the result. Checks whether the cellular data service is enabled. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
**Return value** **Return Value**
| Type| Description| | Type | Description |
| ------------------ | ------------------------------------------------------------ | | ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result, wherein: <br />**true**: The cellular data service is enabled. <br />**false**: The cellular data service is disabled.| | Promise\<boolean\> | Promise used to return the result.<br>**true**: The cellular data service is enabled.<br>**false**: The cellular data service is disabled.|
**Example** **Example**
...@@ -206,11 +206,11 @@ promise.then((data) => { ...@@ -206,11 +206,11 @@ promise.then((data) => {
}); });
``` ```
## data.isCellularDataRoamingEnabled<a name=data.isCellularDataRoamingEnabled-callback></a> ## data.isCellularDataRoamingEnabled
isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback\<boolean\>): void isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback\<boolean\>): void
Checks whether roaming is enabled for the cellular data service. This function uses an asynchronous callback to return the result. Checks whether roaming is enabled for the cellular data service. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
...@@ -218,10 +218,10 @@ Checks whether roaming is enabled for the cellular data service. This function u ...@@ -218,10 +218,10 @@ Checks whether roaming is enabled for the cellular data service. This function u
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------ | ---- | ------------------------------------------------------------ |
| slotId | number | Yes| Card slot ID. The options are as follows: <br />**0**: slot 1 <br />**1**: slot 2| | slotId | number | Yes | Card slot ID. <br>**0**: card slot 1<br>**1**: card slot 2 |
| callback | AsyncCallback\<boolean\> | Yes| Callback used to return the result. <br />**true**: Roaming is enabled for the cellular data service. <br />**false**: Roaming is disabled for the cellular data service.| | callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.<br>**true**: Roaming is enabled for the cellular data service.<br>**false**: Roaming is disabled for the cellular data service.|
**Example** **Example**
...@@ -231,11 +231,11 @@ data.isCellularDataRoamingEnabled(0,(err, data) => { ...@@ -231,11 +231,11 @@ data.isCellularDataRoamingEnabled(0,(err, data) => {
}); });
``` ```
## data.isCellularDataRoamingEnabled<a name=data.isCellularDataRoamingEnabled-promise></a> ## data.isCellularDataRoamingEnabled
isCellularDataRoamingEnabled(slotId: number): Promise\<boolean\> isCellularDataRoamingEnabled(slotId: number): Promise\<boolean\>
Checks whether roaming is enabled for the cellular data service. This method uses a promise to return the result. Checks whether roaming is enabled for the cellular data service. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
...@@ -243,15 +243,15 @@ Checks whether roaming is enabled for the cellular data service. This method use ...@@ -243,15 +243,15 @@ Checks whether roaming is enabled for the cellular data service. This method use
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------------------- | | ------ | ------ | ---- | ---------------------------------------- |
| slotId | number | Yes| Card slot ID. The options are as follows: <br />**0**: slot 1 <br/>**1**: slot 2| | slotId | number | Yes | Card slot ID. <br>**0**: card slot 1<br>**1**: card slot 2|
**Return value** **Return Value**
| Type| Description| | Type | Description |
| ------------------ | ------------------------------------------------------------ | | ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result, wherein: <br />**true**: Roaming is enabled for the cellular data service. <br />**false**: Roaming is disabled for the cellular data service.| | Promise\<boolean\> | Promise used to return the result.<br>**true**: Roaming is enabled for the cellular data service.<br>**false**: Roaming is disabled for the cellular data service.|
**Example** **Example**
...@@ -264,26 +264,30 @@ promise.then((data) => { ...@@ -264,26 +264,30 @@ promise.then((data) => {
}); });
``` ```
## DataFlowType<a name=DataFlowType></a> ## DataFlowType
Defines the cellular data flow type. Defines the cellular data flow type.
| Name| Value| Description| **System capability**: SystemCapability.Telephony.CellularData
| ------ | ---------------------- | ------------------------------------------------------------ |
| 0 | DATA_FLOW_TYPE_NONE | No uplink or downlink data is available. <br />**System capability**: SystemCapability.Telephony.CellularData| | Name | Value | Description |
| 1 | DATA_FLOW_TYPE_DOWN | Only the downlink data is available. <br />**System capability**: SystemCapability.Telephony.CellularData| | ---------------------- | ---- | ------------------------------------------ |
| 2 | DATA_FLOW_TYPE_UP | Only the uplink data is available. <br />**System capability**: SystemCapability.Telephony.CellularData| | DATA_FLOW_TYPE_NONE | 0 | No uplink or downlink data is available. |
| 3 | DATA_FLOW_TYPE_UP_DOWN | Both uplink data and downlink data are available. <br />**System capability**: SystemCapability.Telephony.CellularData| | DATA_FLOW_TYPE_DOWN | 1 | Only the downlink data is available. |
| 4 | DATA_FLOW_TYPE_DORMANT | No uplink or downlink data is available because the lower-layer link is in the dormant state. <br />**System capability**: SystemCapability.Telephony.CellularData| | DATA_FLOW_TYPE_UP | 2 | Only the uplink data is available. |
| DATA_FLOW_TYPE_UP_DOWN | 3 | Both uplink data and downlink data are available. |
| DATA_FLOW_TYPE_DORMANT | 4 | No uplink or downlink data is available because the lower-layer link is in the dormant state.|
## DataConnectState<a name=DataConnectState></a> ## DataConnectState
Describes the connection status of a cellular data link. Describes the connection status of a cellular data link.
**System capability**: SystemCapability.Telephony.CellularData
| Name| Value| Description| | Name | Value | Description |
| ------ | ----------------------- | ------------------------------------------------------------ | | ----------------------- | ---- | -------------------------- |
| -1 | DATA_STATE_UNKNOWN| The status of the cellular data link is unknown. <br />**System capability**: SystemCapability.Telephony.CellularData| | DATA_STATE_UNKNOWN | -1 | The status of the cellular data link is unknown. |
| 0 | DATA_STATE_DISCONNECTED | The cellular data link is disconnected. <br />**System capability**: SystemCapability.Telephony.CellularData| | DATA_STATE_DISCONNECTED | 0 | The cellular data link is disconnected. |
| 1 | DATA_STATE_CONNECTING | The cellular data link is being connected. <br />**System capability**: SystemCapability.Telephony.CellularData| | DATA_STATE_CONNECTING | 1 | The cellular data link is being connected.|
| 2 | DATA_STATE_CONNECTED | The cellular data link is connected. <br />**System capability**: SystemCapability.Telephony.CellularData| | DATA_STATE_CONNECTED | 2 | The cellular data link is connected. |
| 3 | DATA_STATE_SUSPENDED | The cellular data link is suspended. <br />**System capability**: SystemCapability.Telephony.CellularData| | DATA_STATE_SUSPENDED | 3 | The cellular data link is suspended. |
# WebSocket # WebSocket Connection
>![](public_sys-resources/icon-note.gif) **NOTE:** >![](public_sys-resources/icon-note.gif) **NOTE:**
>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. >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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册