提交 124efdb6 编写于 作者: S shawn_he

update docs

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 79dba0f5
......@@ -7,7 +7,7 @@
## Modules to Import
```js
```
import radio from '@ohos.telephony.radio'
```
......@@ -15,7 +15,7 @@ import radio from '@ohos.telephony.radio'
getRadioTech\(slotId: number, callback: AsyncCallback<\{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology\}\>\): void
Obtains the radio access technology (RAT) used by the CS and PS domains. This API uses an asynchronous callback to return the result.
Obtains the radio access technology (RAT) used by the CS and PS domains for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
......@@ -42,7 +42,7 @@ radio.getRadioTech(slotId, (err, data) =>{
getRadioTech\(slotId: number\): Promise<\{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology\}\>
Obtains the RAT used by the CS and PS domains. This API uses a promise to return the result.
Obtains the RAT used by the CS and PS domains for the SIM card in the specified slot. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
......@@ -102,7 +102,7 @@ radio.getNetworkState((err, data) =>{
getNetworkState\(slotId: number, callback: AsyncCallback<NetworkState\>\): void
Obtains the network status. This API uses an asynchronous callback to return the result.
Obtains the network status of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
......@@ -231,7 +231,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------------------------------------- |
| slotId | number | Yes | Card slot ID.<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 an ISO country code, for example, **CN** (China).|
**Example**
......@@ -556,10 +556,350 @@ promise.then(data => {
});
```
## radio.setPrimarySlotId<sup>8+</sup>
setPrimarySlotId(slotId: number, callback: AsyncCallback<void\>): void
Sets the ID of the slot in which the primary card is located. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
**Example**
```js
let slotId = 0;
radio.setPrimarySlotId(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.setPrimarySlotId<sup>8+</sup>
setPrimarySlotId\(slotId: number\): Promise\<void\>
Sets the ID of the slot in which the primary card is located. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| --------------- | ------------------------------- |
| Promise\<void\> | Promise that returns no value. |
**Example**
```js
let slotId = 0;
let promise = radio.setPrimarySlotId(slotId);
promise.then(data => {
console.log(`setPrimarySlotId success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`setPrimarySlotId fail, promise: err->${JSON.stringify(err)}`);
});
```
## radio.getIMEI<sup>8+</sup>
getIMEI(callback: AsyncCallback<string\>): void
Obtains the IMEI of the SIM card in a card slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ------------------------------------------ |
| callback | AsyncCallback\<string\> | Yes | Callback used to return the result. If the IMEI does not exist, an empty string is returned.|
**Example**
```js
radio.getIMEI((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.getIMEI<sup>8+</sup>
getIMEI(slotId: number, callback: AsyncCallback<string\>): void
Obtains the IMEI of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ------------------------------------------ |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| callback | AsyncCallback\<string\> | Yes | Callback used to return the result. If the IMEI does not exist, an empty string is returned.|
**Example**
```js
let slotId = 0;
radio.getIMEI(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.getIMEI<sup>8+</sup>
getIMEI(slotId?: number): Promise<string\>
Obtains the IMEI of the SIM card in a card slot. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | No | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| ----------------- | ------------------------------------------ |
| Promise\<string\> | Promise used to return the result. If the IMEI does not exist, an empty string is returned.|
**Example**
```js
let slotId = 0;
let promise = radio.getIMEI(slotId);
promise.then(data => {
console.log(`getIMEI success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`getIMEI fail, promise: err->${JSON.stringify(err)}`);
});
```
## radio.getMEID<sup>8+</sup>
getMEID(callback: AsyncCallback<string\>): void
Obtains the MEID of the SIM card in a card slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------- |
| callback | AsyncCallback\<string\> | Yes | Callback used to return the result.|
**Example**
```js
radio.getMEID((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.getMEID<sup>8+</sup>
getMEID(slotId: number, callback: AsyncCallback<string\>): void
Obtains the MEID of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<string\> | Yes | Callback used to return the result. |
**Example**
```js
let slotId = 0;
radio.getMEID(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.getMEID<sup>8+</sup>
getMEID(slotId?: number): Promise<string\>
Obtains the MEID of the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | No | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| ----------------- | --------------------------------------- |
| Promise\<string\> | Promise used to return the result.|
**Example**
```js
let slotId = 0;
let promise = radio.getMEID(slotId);
promise.then(data => {
console.log(`getMEID success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`getMEID fail, promise: err->${JSON.stringify(err)}`);
});
```
## radio.getUniqueDeviceId<sup>8+</sup>
getUniqueDeviceId(callback: AsyncCallback<string\>): void
Obtains the unique device ID of the SIM card in a card slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------- |
| callback | AsyncCallback\<string\> | Yes | Callback used to return the result.|
**Example**
```js
radio.getUniqueDeviceId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.getUniqueDeviceId<sup>8+</sup>
getUniqueDeviceId(slotId: number, callback: AsyncCallback<string\>): void
Obtains the unique device ID of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<string\> | Yes | Callback used to return the result. |
**Example**
```js
let slotId = 0;
radio.getUniqueDeviceId(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.getUniqueDeviceId<sup>8+</sup>
getUniqueDeviceId(slotId?: number): Promise<string\>
Obtains the unique device ID of the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | No | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| ----------------- | --------------------------------------------- |
| Promise\<string\> | Promise used to return the result.|
**Example**
```js
let slotId = 0;
let promise = radio.getUniqueDeviceId(slotId);
promise.then(data => {
console.log(`getUniqueDeviceId success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`getUniqueDeviceId fail, promise: err->${JSON.stringify(err)}`);
});
```
## RadioTechnology
Enumerates the RATs.
Enumerates the RAT.
**System capability**: SystemCapability.Telephony.CoreService
......@@ -594,7 +934,7 @@ Defines the signal strength.
## NetworkType
Defines the network type.
Enumerates network types.
**System capability**: SystemCapability.Telephony.CoreService
......@@ -610,7 +950,7 @@ Defines the network type.
## NetworkState
Defines the network registration status.
Defines the network status.
**System capability**: SystemCapability.Telephony.CoreService
......@@ -629,7 +969,7 @@ Defines the network registration status.
## RegState
Defines the network registration status.
Defines the network status.
**System capability**: SystemCapability.Telephony.CoreService
......
......@@ -6,7 +6,7 @@
## Modules to Import
```
```js
import sms from '@ohos.telephony.sms';
```
......@@ -22,13 +22,13 @@ Creates an SMS message instance based on the protocol data unit (PDU) and the sp
| Name | Type | Mandatory| Description |
| ------------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ |
| pdu | Array&lt;number&gt; | Yes | PDU, which is obtained from the received SMS message. |
| pdu | Array&lt;number&gt; | Yes | Protocol data unit, which is obtained from the received SMS message. |
| 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. |
**Example**
```
```js
const specification = '3gpp';
// Display PDUs using numbers in an array, for example, [0x08, 0x91, ...].
const pdu = [0x08, 0x91];
......@@ -50,10 +50,10 @@ Creates an SMS message instance based on the PDU and the specified SMS protocol.
| Name | Type | Mandatory| Description |
| ------------- | ------------------- | ---- | ------------------------------------------------------------ |
| pdu | Array&lt;number&gt; | Yes | PDU, which is obtained from the received SMS message. |
| pdu | Array&lt;number&gt; | Yes | Protocol data unit, which is obtained from the received SMS message. |
| specification | string | Yes | SMS protocol type. <br>- **3gpp**: GSM/UMTS/LTE SMS<br>- **3gpp2**: CDMA SMS|
**Return Value**
**Return value**
| Type | Description |
| -------------------------------------------- | --------------------------------- |
......@@ -61,7 +61,7 @@ Creates an SMS message instance based on the PDU and the specified SMS protocol.
**Example**
```
```js
const specification = '3gpp';
// Display PDUs using numbers in an array, for example, [0x08, 0x91, ...].
const pdu = [0x08, 0x91];
......@@ -87,11 +87,11 @@ Sends an SMS message.
| 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.|
**Example**
```
```js
let sendCallback = function (err, data) {
console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}
......@@ -120,11 +120,11 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result. <br>- **0**: card slot 1<br>- **1**: card slot 2|
**Example**
```
```js
sms.getDefaultSmsSlotId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -139,7 +139,7 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use
**System capability**: SystemCapability.Telephony.SmsMms
**Return Value**
**Return value**
| Type | Description |
| --------------- | ------------------------------------------------------------ |
......@@ -147,7 +147,7 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use
**Example**
```
```js
let promise = sms.getDefaultSmsSlotId();
promise.then(data => {
console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`);
......@@ -156,6 +156,68 @@ promise.then(data => {
});
```
## sms.setDefaultSmsSlotId<sup>7+</sup>
setDefaultSmsSlotId\(slotId: number,callback: AsyncCallback&lt;void&gt;\): void
Sets the default slot of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: Clears the default configuration.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
sms.setDefaultSmsSlotId(0,(err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sms.setDefaultSmsSlotId<sup>7+</sup>
setDefaultSmsSlotId\(slotId: number\): Promise&lt;void&gt;
Sets the default slot of the SIM card used to send SMS messages. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: Clears the default configuration.|
**Return value**
| Type | Description |
| -------------- | ------------------------------- |
| Promise\<void\> | Promise that returns no value. |
**Example**
```js
let promise = sms.setDefaultSmsSlotId(0);
promise.then(data => {
console.log(`setDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`setDefaultSmsSlotId fail, promise: err->${JSON.stringify(err)}`);
});
```
## sms.setSmscAddr<sup>7+</sup>
......@@ -163,23 +225,23 @@ setSmscAddr\(slotId: number, smscAddr: string, callback: AsyncCallback<void\>\):
Sets the short message service center (SMSC) address. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE (a system permission)
**System capability**: SystemCapability.Telephony.SmsMms
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------------------- |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| smscAddr | string | Yes | SMSC address. |
| smscAddr | string | Yes | SMSC address. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```
```js
let slotId = 0;
let smscAddr = '+861xxxxxxxxxx';
sms.setSmscAddr(slotId, smscAddr, (err,data) => {
......@@ -190,24 +252,24 @@ sms.setSmscAddr(slotId, smscAddr, (err,data) => {
## sms.setSmscAddr<sup>7+</sup>
setSmscAddr\(slotId: number, smscAddr: string\): Promise<void\>
setSmscAddr\(slotId: number, smscAddr: string\): Promise\<void\>
Sets the SMSC address. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE (a system permission)
**System capability**: SystemCapability.Telephony.SmsMms
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ----------------------------------------- |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| smscAddr | string | Yes | SMSC address. |
| smscAddr | string | Yes | SMSC address. |
**Return Value**
**Return value**
| Type | Description |
| ------------------- | ------------------------------- |
......@@ -215,7 +277,7 @@ This is a system API and cannot be called by third-party applications.
**Example**
```
```js
let slotId = 0;
let smscAddr = '+861xxxxxxxxxx';
let promise = sms.setSmscAddr(slotId, smscAddr);
......@@ -233,12 +295,12 @@ getSmscAddr\(slotId: number, callback: AsyncCallback<string\>\): void
Obtains the SMSC address. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE (a system permission)
**System capability**: SystemCapability.Telephony.SmsMms
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
......@@ -248,7 +310,7 @@ This is a system API and cannot be called by third-party applications.
**Example**
```
```js
let slotId = 0;
sms.getSmscAddr(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -262,19 +324,19 @@ getSmscAddr\(slotId: number\): Promise<string\>
Obtains the SMSC address. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE (a system permission)
**System capability**: SystemCapability.Telephony.SmsMms
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ----------------------------------------- |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return Value**
**Return value**
| Type | Description |
| --------------------- | --------------------------------------------- |
......@@ -282,7 +344,7 @@ This is a system API and cannot be called by third-party applications.
**Example**
```
```js
let slotId = 0;
let promise = sms.getSmscAddr(slotId);
promise.then(data => {
......@@ -300,13 +362,13 @@ Checks whether the current device can send and receive SMS messages. This API wo
**System capability**: SystemCapability.Telephony.SmsMms
**Return Value**
**Return value**
| Type | Description |
| ------- | ------------------------------------------------------------ |
| boolean | - **true**: The device can send and receive SMS messages.<br>- **false**: The device cannot send or receive SMS messages.|
```
```js
let result = sms.hasSmsCapability();
console.log(`hasSmsCapability: ${JSON.stringify(result)}`);
```
......@@ -319,13 +381,13 @@ Defines an SMS message instance.
| 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 device 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 device returns a response based on the SMSC that sends the SMS message.|
| 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.|
| messageClass | [ShortMessageClass](#shortmessageclass) | SMS message type. |
| messageClass | [ShortMessageClass](#shortmessageclass) | Enumerates SMS message types. |
| pdu | Array&lt;number&gt; | PDU in the SMS message. |
| protocolId | number | ID of the protocol used for sending SMS messages. |
| scAddress | string | Address of the short message service center (SMSC). |
| protocolId | number | Protocol identifier used for delivering the SMS message. |
| scAddress | string | SMSC address. |
| scTimestamp | number | SMSC timestamp. |
| status | number | SMS message status sent by the SMSC in the **SMS-STATUS-REPORT** message.|
| visibleMessageBody | string | SMS message body. |
......@@ -334,7 +396,7 @@ Defines an SMS message instance.
## ShortMessageClass
SMS message type.
Enumerates SMS message types.
**System capability**: SystemCapability.Telephony.SmsMms
......@@ -374,12 +436,12 @@ Provides the callback for the SMS message sending result. It consists of three p
| ---------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| 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. |
| url | string | Yes | URI for storing sent SMS messages. |
| url | string | Yes | URI for storing the sent SMS message. |
## IDeliveryShortMessageCallback
Provides the callback for the SMS message sending result. Return the SMS delivery report.
Provides the callback for the SMS message delivery report.
**System capability**: SystemCapability.Telephony.SmsMms
......@@ -396,7 +458,7 @@ Enumerates SMS message sending results.
| Name | Value | Description |
| ------------------------------------ | ---- | ------------------------------------------------------ |
| 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_SUCCESS | 0 | The SMS message is sent successfully. |
| SEND_SMS_FAILURE_UNKNOWN | 1 | Failed to send the SMS message due to an unknown reason. |
| SEND_SMS_FAILURE_RADIO_OFF | 2 | Failed to send the SMS message because the modem is shut down. |
| SEND_SMS_FAILURE_SERVICE_UNAVAILABLE | 3 | Failed to send the SMS message because the network is unavailable or SMS message sending or receiving is not supported.|
......@@ -6,7 +6,7 @@
## Modules to Import
```
```js
import data from '@ohos.telephony.data';
```
......@@ -14,7 +14,7 @@ import data from '@ohos.telephony.data';
getDefaultCellularDataSlotId(callback: AsyncCallback\<number\>): void
Obtains the default SIM card used for mobile data. This API uses an asynchronous callback to return the result.
Obtains the default slot of the SIM card used for mobile data. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
......@@ -28,7 +28,7 @@ Obtains the default SIM card used for mobile data. This API uses an asynchronous
**Example**
```
```js
data.getDefaultCellularDataSlotId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -38,13 +38,13 @@ data.getDefaultCellularDataSlotId((err, data) => {
getDefaultCellularDataSlotId(): Promise\<number\>
Obtains the default SIM card used for mobile data. This API uses a promise to return the result.
Obtains the default slot of the SIM card used for mobile data. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Telephony.CellularData
**Return Value**
**Return value**
| Type | Description |
| ----------------- | ------------------------------------------------------------ |
......@@ -52,12 +52,74 @@ Obtains the default SIM card used for mobile data. This API uses a promise to re
**Example**
```
```js
let promise = data.getDefaultCellularDataSlotId();
promise.then((data) => {
console.log(`test success, promise: data->${JSON.stringify(data)}`);
console.log(`getDefaultCellularDataSlotId success, promise: data->${JSON.stringify(data)}`);
}).catch((err) => {
console.error(`test fail, promise: err->${JSON.stringify(err)}`);
console.error(`getDefaultCellularDataSlotId fail, promise: err->${JSON.stringify(err)}`);
});
```
## data.setDefaultCellularDataSlotId
setDefaultCellularDataSlotId(slotId: number,callback: AsyncCallback\<void\>): void
Sets the default slot of the SIM card used for mobile data. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CellularData
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: Clears the default configuration.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object. |
**Example**
```js
data.setDefaultCellularDataSlotId(0,(err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## data.setDefaultCellularDataSlotId
setDefaultCellularDataSlotId(slotId: number): Promise\<void\>
Sets the default slot of the SIM card used for mobile data. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CellularData
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: Clears the default configuration.|
**Return value**
| Type | Description |
| -------------- | ------------------------------- |
| Promise<\void\> | Promise that returns no value. |
**Example**
```js
let promise = data.setDefaultCellularDataSlotId(0);
promise.then((data) => {
console.log(`setDefaultCellularDataSlotId success, promise: data->${JSON.stringify(data)}`);
}).catch((err) => {
console.error(`setDefaultCellularDataSlotId fail, promise: err->${JSON.stringify(err)}`);
});
```
......@@ -77,7 +139,7 @@ Obtains the cellular data flow type, which can be uplink or downlink. This API u
**Example**
```
```js
data.getCellularDataFlowType((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -91,7 +153,7 @@ Obtains the cellular data flow type, which can be uplink or downlink. This API u
**System capability**: SystemCapability.Telephony.CellularData
**Return Value**
**Return value**
| Type | Description |
| ---------------------------------------- | ----------------------------------------------- |
......@@ -99,7 +161,7 @@ Obtains the cellular data flow type, which can be uplink or downlink. This API u
**Example**
```
```js
let promise = data.getCellularDataFlowType();
promise.then((data) => {
console.log(`test success, promise: data->${JSON.stringify(data)}`);
......@@ -124,7 +186,7 @@ Obtains the connection status of the packet switched (PS) domain. This API uses
**Example**
```
```js
data.getCellularDataState((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -138,7 +200,7 @@ Obtains the connection status of the PS domain. This API uses a promise to retur
**System capability**: SystemCapability.Telephony.CellularData
**Return Value**
**Return value**
| Type | Description |
| ------------------------------------------------ | ------------------------------------- |
......@@ -146,7 +208,7 @@ Obtains the connection status of the PS domain. This API uses a promise to retur
**Example**
```
```js
let promise = data.getCellularDataState();
promise.then((data) => {
console.log(`test success, promise: data->${JSON.stringify(data)}`);
......@@ -169,11 +231,11 @@ Checks whether the cellular data service is enabled. This API uses an asynchrono
| 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**
```
```js
data.isCellularDataEnabled((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -189,15 +251,15 @@ Checks whether the cellular data service is enabled. This API uses a promise to
**System capability**: SystemCapability.Telephony.CellularData
**Return Value**
**Return value**
| Type | Description |
| ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.<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**
```
```js
let promise = data.isCellularDataEnabled();
promise.then((data) => {
console.log(`test success, promise: data->${JSON.stringify(data)}`);
......@@ -220,12 +282,12 @@ Checks whether roaming is enabled for the cellular data service. This API uses a
| Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | ------------------------------------------------------------ |
| 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.|
| 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.|
**Example**
```
```js
data.isCellularDataRoamingEnabled(0,(err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -245,17 +307,17 @@ Checks whether roaming is enabled for the cellular data service. This API uses a
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------------------- |
| slotId | number | Yes | Card slot ID. <br>**0**: card slot 1<br>**1**: card slot 2|
| slotId | number | Yes | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2|
**Return Value**
**Return value**
| Type | Description |
| ------------------ | ------------------------------------------------------------ |
| 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.|
| 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**
```
```js
let promise = data.isCellularDataRoamingEnabled(0);
promise.then((data) => {
console.log(`test success, promise: data->${JSON.stringify(data)}`);
......@@ -275,7 +337,7 @@ Defines the cellular data flow type.
| DATA_FLOW_TYPE_NONE | 0 | No uplink or downlink data is available. |
| DATA_FLOW_TYPE_DOWN | 1 | Only the downlink data is available. |
| 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_UP_DOWN | 3 | Both the 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
......@@ -286,7 +348,7 @@ Describes the connection status of a cellular data link.
| Name | Value | Description |
| ----------------------- | ---- | -------------------------- |
| DATA_STATE_UNKNOWN | -1 | The status of the cellular data link is unknown. |
| DATA_STATE_UNKNOWN | -1 | The status of the cellular data link is unknown. |
| DATA_STATE_DISCONNECTED | 0 | The cellular data link is disconnected. |
| DATA_STATE_CONNECTING | 1 | The cellular data link is being connected.|
| DATA_STATE_CONNECTED | 2 | The cellular data link is connected. |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册