diff --git a/en/application-dev/reference/apis/js-apis-radio.md b/en/application-dev/reference/apis/js-apis-radio.md index 86d29eebedf8fb206589a7770a92362a79873c69..b8cbdcc23c001aa24aebe7dfaae2ca06a0fae706 100644 --- a/en/application-dev/reference/apis/js-apis-radio.md +++ b/en/application-dev/reference/apis/js-apis-radio.md @@ -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\): 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.
- **0**: card slot 1
- **1**: card slot 2 | -| callback | AsyncCallback\ | Yes | Callback used to return the result. which is a country code, for example, **CN** (China).| +| callback | AsyncCallback\ | 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.setPrimarySlotId8+ + +setPrimarySlotId(slotId: number, callback: AsyncCallback): 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.
- **0**: card slot 1
- **1**: card slot 2| +| callback | AsyncCallback\ | 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.setPrimarySlotId8+ + +setPrimarySlotId\(slotId: number\): Promise\ + +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.
- **0**: card slot 1
- **1**: card slot 2| + +**Return value** + +| Type | Description | +| --------------- | ------------------------------- | +| Promise\ | 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.getIMEI8+ + +getIMEI(callback: AsyncCallback): 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\ | 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.getIMEI8+ + +getIMEI(slotId: number, callback: AsyncCallback): 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.
- **0**: card slot 1
- **1**: card slot 2 | +| callback | AsyncCallback\ | 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.getIMEI8+ + +getIMEI(slotId?: number): Promise + +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.
- **0**: card slot 1
- **1**: card slot 2| + +**Return value** + +| Type | Description | +| ----------------- | ------------------------------------------ | +| Promise\ | 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.getMEID8+ + +getMEID(callback: AsyncCallback): 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\ | 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.getMEID8+ + +getMEID(slotId: number, callback: AsyncCallback): 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.
- **0**: card slot 1
- **1**: card slot 2| +| callback | AsyncCallback\ | 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.getMEID8+ + +getMEID(slotId?: number): Promise + +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.
- **0**: card slot 1
- **1**: card slot 2| + +**Return value** + +| Type | Description | +| ----------------- | --------------------------------------- | +| Promise\ | 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.getUniqueDeviceId8+ + +getUniqueDeviceId(callback: AsyncCallback): 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\ | 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.getUniqueDeviceId8+ + +getUniqueDeviceId(slotId: number, callback: AsyncCallback): 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.
- **0**: card slot 1
- **1**: card slot 2| +| callback | AsyncCallback\ | 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.getUniqueDeviceId8+ + +getUniqueDeviceId(slotId?: number): Promise + +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.
- **0**: card slot 1
- **1**: card slot 2| + +**Return value** + +| Type | Description | +| ----------------- | --------------------------------------------- | +| Promise\ | 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 diff --git a/en/application-dev/reference/apis/js-apis-sim.md b/en/application-dev/reference/apis/js-apis-sim.md index 3344e47d14f8d615b1f81e75f92251dc4e8c8287..acad2c7f0223074ef134389ddeac17b8f8d47455 100644 --- a/en/application-dev/reference/apis/js-apis-sim.md +++ b/en/application-dev/reference/apis/js-apis-sim.md @@ -17,13 +17,13 @@ isSimActive\(slotId: number, callback: AsyncCallback\): void 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.Telephony.CoreService **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID. The options are as follows:
- **0**: card slot 1
- **1**: card slot 2| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. | **Example** @@ -41,13 +41,13 @@ isSimActive\(slotId: number\): Promise 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.Telephony.CoreService **Parameters** | Name| Type | Mandatory| Description | | ------ | ------ | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID. The options are as follows:
- **0**: card slot 1
- **1**: card slot 2| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| **Return value** @@ -73,7 +73,7 @@ getDefaultVoiceSlotId\(callback: AsyncCallback\): void Obtains the default slot ID of the SIM card that provides voice services. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Communication.CoreService +**System capability**: SystemCapability.Telephony.CoreService **Parameters** @@ -96,7 +96,7 @@ getDefaultVoiceSlotId\(\): Promise Obtains the default slot ID of the SIM card that provides voice services. This API uses a promise to return the result. -**System capability**: SystemCapability.Communication.CoreService +**System capability**: SystemCapability.Telephony.CoreService **Return value** @@ -121,13 +121,13 @@ hasOperatorPrivileges(slotId: number, callback: AsyncCallback\): void 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.Telephony.CoreService **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------ | ---- | ---------------------------------------- | -| slotId | number | Yes | Card slot ID. The options are as follows:
- **0**: card slot 1
- **1**: card slot 2| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -144,13 +144,13 @@ hasOperatorPrivileges(slotId: number): Promise 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.Telephony.CoreService **Parameters** | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ---------------------------------------- | -| slotId | number | Yes | Card slot ID. The options are as follows:
- **0**: card slot 1
- **1**: card slot 2| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| **Return value** @@ -175,14 +175,14 @@ getISOCountryCodeForSim\(slotId: number, callback: AsyncCallback\): voi 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.Telephony.CoreService **Parameters** | Name | Type | Mandatory| Description | | -------- | ----------------------- | ---- | ---------------------------------------- | -| slotId | number | Yes | Card slot ID. The options are as follows:
- **0**: card slot 1
- **1**: card slot 2 | -| callback | AsyncCallback\ | Yes | Callback used to return the result, which is a country code, for example, **CN** (China).| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| callback | AsyncCallback\ | Yes | Callback used to return the result, which is an ISO country code, for example, **CN** (China).| **Example** @@ -199,19 +199,19 @@ getISOCountryCodeForSim\(slotId: number\): Promise 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.Telephony.CoreService **Parameters** | Name| Type | Mandatory| Description | | ------ | ------ | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID. The options are as follows:
- **0**: card slot 1
- **1**: card slot 2| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| **Return value** | Type | Description | | ----------------- | ------------------------------------------------------------ | -| Promise\ | Promise used to return the result, which is a country code, for example, **CN** (China).| +| Promise\ | Promise used to return the result, which is an ISO country code, for example, **CN** (China).| **Example** @@ -231,13 +231,13 @@ getSimOperatorNumeric\(slotId: number, callback: AsyncCallback\): void 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.Telephony.CoreService **Parameters** | Name | Type | Mandatory| Description | | -------- | ----------------------- | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID. The options are as follows:
- **0**: card slot 1
- **1**: card slot 2| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -255,13 +255,13 @@ getSimOperatorNumeric\(slotId: number\): Promise 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.Telephony.CoreService **Parameters** | Name| Type | Mandatory| Description | | ------ | ------ | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID. The options are as follows:
- **0**: card slot 1
- **1**: card slot 2| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| **Return value** @@ -287,13 +287,13 @@ getSimSpn\(slotId: number, callback: AsyncCallback\): void 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.Telephony.CoreService **Parameters** | Name | Type | Mandatory| Description | | -------- | ----------------------- | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID. The options are as follows:
- **0**: card slot 1
- **1**: card slot 2| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -311,13 +311,13 @@ getSimSpn\(slotId: number\): Promise 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.Telephony.CoreService **Parameters** | Name| Type | Mandatory| Description | | ------ | ------ | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID. The options are as follows:
- **0**: card slot 1
- **1**: card slot 2| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| **Return value** @@ -343,13 +343,13 @@ getSimState\(slotId: number, callback: AsyncCallback\): void 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.Telephony.CoreService **Parameters** | Name | Type | Mandatory| Description | | -------- | -------------------------------------- | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID. The options are as follows:
- **0**: card slot 1
- **1**: card slot 2| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| | callback | AsyncCallback\<[SimState](#simstate)\> | Yes | Callback used to return the result. For details, see [SimState](#simstate). | **Example** @@ -367,13 +367,13 @@ getSimState\(slotId: number\): Promise 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.Telephony.CoreService **Parameters** | Name| Type | Mandatory| Description | | ------ | ------ | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID. The options are as follows:
- **0**: card slot 1
- **1**: card slot 2| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| **Return value** @@ -398,13 +398,13 @@ getCardType\(slotId: number, callback: AsyncCallback\): void 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.Telephony.CoreService **Parameters** | Name | Type | Mandatory| Description | | -------- | ----------------------- | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID. The options are as follows:
- **0**: card slot 1
- **1**: card slot 2| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| | callback | AsyncCallback\<[CardType](#cardtype7)\> | Yes | Callback used to return the result. | **Example** @@ -422,13 +422,13 @@ getCardType\(slotId: number\): Promise 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.Telephony.CoreService **Parameters** | Name| Type | Mandatory| Description | | ------ | ------ | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID. The options are as follows:
- **0**: card slot 1
- **1**: card slot 2| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| **Return value** @@ -454,18 +454,18 @@ hasSimCard\(slotId: number, callback: AsyncCallback\): void 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.Telephony.CoreService **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID. The options are as follows:
- **0**: card slot 1
- **1**: card slot 2| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. | **Example** -```js +```jsjs sim.hasSimCard(0, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -478,13 +478,13 @@ hasSimCard\(slotId: number\): Promise 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.Telephony.CoreService **Parameters** | Name| Type | Mandatory| Description | | ------ | ------ | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID. The options are as follows:
- **0**: card slot 1
- **1**: card slot 2| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| **Return value** @@ -503,58 +503,1271 @@ promise.then(data => { }); ``` +## sim.getSimAccountInfo7+ -## sim.getMaxSimCount7+ +getSimAccountInfo(slotId: number, callback: AsyncCallback): void -getMaxSimCount\(\): number +Obtains account information of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -Obtains the number of card slots. +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.
- **0**: card slot 1
- **1**: card slot 2| +| callback | AsyncCallback\<[IccAccountInfo](#IccAccountInfo7)\> | Yes | Callback used to return the result. For details, see [IccAccountInfo](#IccAccountInfo7).| + +**Example** + +```js +sim.getSimAccountInfo(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.getSimAccountInfo7+ + +getSimAccountInfo(slotId: number): Promise + +Obtains account information of the SIM card in the specified slot. This API uses a promise to return the result. + +This is a system API. -**System capability**: SystemCapability.Communication.CoreService +**Required permission**: ohos.permission.GET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| **Return value** -| Type | Description | -| ----------------- | ------------------------------------------------------------ | -| number | Number of card slots.| +| Type | Description | +| -------------------------------------------- | ------------------------------------------ | +| Promise<[IccAccountInfo](#IccAccountInfo7)\> | Promise used to return the result.| **Example** ```js -console.log("Result: "+ sim.getMaxSimCount()) +let promise = sim.getSimAccountInfo(0); +promise.then(data => { + console.log(`getSimAccountInfo success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getSimAccountInfo fail, promise: err->${JSON.stringify(err)}`); +}); ``` +## sim.getActiveSimAccountInfoList8+ -## SimState +getActiveSimAccountInfoList(callback: AsyncCallback>): void -Enumerates SIM card states. +Obtains the account information list of the active SIM card. 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 -| Name | Value | Description | -| --------------------- | ---- | ---------------------------------------------------------- | -| SIM_STATE_UNKNOWN | 0 | The SIM card is in **unknown** state; that is, the SIM card status cannot be obtained. | -| SIM_STATE_NOT_PRESENT | 1 | The SIM card is in **not present** state; that is, no SIM card is inserted into the slot. | -| SIM_STATE_LOCKED | 2 | The SIM card is in **locked** state; that is, the SIM card is locked by the personal identification number (PIN), PIN unblocking key (PUK), or network. | -| SIM_STATE_NOT_READY | 3 | The SIM card is in **not ready** state; that is, the SIM card is present but cannot work properly. | -| SIM_STATE_READY | 4 | The SIM card is in **ready** state; that is, the SIM card is present and is working properly. | -| SIM_STATE_LOADED | 5 | The SIM card is in **loaded** state; that is, the SIM card is present and all its files have been loaded.| +**Parameters** -## CardType7+ +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------------------------- | ---- | ---------- | +| callback | AsyncCallback\\> | Yes | Callback used to return the result.| -Enumerates card types. +**Example** + +```js +sim.getActiveSimAccountInfoList(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.getActiveSimAccountInfoList8+ + +getActiveSimAccountInfoList(): Promise>; + +Obtains the account information list of the active SIM card. 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 -| Name| Value| Description| -| ----- | ----- | ----- | -|UNKNOWN_CARD | -1 | Unknown| -|SINGLE_MODE_SIM_CARD | 10 | Single-card (SIM)| -|SINGLE_MODE_USIM_CARD | 20 | Single-card (USIM)| -|SINGLE_MODE_RUIM_CARD | 30 | Single-card (RUIM)| -|DUAL_MODE_CG_CARD | 40 | Dual-card (CDMA+GSM)| -|CT_NATIONAL_ROAMING_CARD | 41 | China Telecom internal roaming 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_UG_CARD | 50 | Dual-mode card (UMTS+GSM)| -|SINGLE_MODE_ISIM_CARD8+ | 60 | Single-card (ISIM)| +**Return value** + +| Type | Description | +| ---------------------------------------------------- | ---------------------------------------------- | +| Promise\> | Promise used to return the result.| + +**Example** + +```js +let promise = sim.getActiveSimAccountInfoList(); +promise.then(data => { + console.log(`getActiveSimAccountInfoList success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getActiveSimAccountInfoList fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.setDefaultVoiceSlotId7+ + +setDefaultVoiceSlotId(slotId: number, callback: AsyncCallback): void + +Sets the default slot ID of the SIM card that provides voice services. 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 | SIM card slot ID.
- **0**: card slot 1
- **1**: card slot 2
- **-1**: Clears the default configuration.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example** + +```js +sim.setDefaultVoiceSlotId(0,(err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.setDefaultVoiceSlotId7+ + +setDefaultVoiceSlotId(slotId: number): Promise\ + +Sets the default slot ID of the SIM card that provides voice services. 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 | SIM card slot ID.
- **0**: card slot 1
- **1**: card slot 2
- **-1**: Clears the default configuration.| + +**Return value** + +| Type | Description | +| -------------- | ------------------------------- | +| Promise\ | Promise that returns no value. | + +**Example** + +```js +let promise = sim.setDefaultVoiceSlotId(0); +promise.then(data => { + console.log(`setDefaultVoiceSlotId success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`setDefaultVoiceSlotId fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.**setShowName**8+ + +setShowName\(slotId: number, name: string,callback: AsyncCallback\): void + +Sets a display name for 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| name | string | Yes | SIM card name. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example** + +```js +const name='China Mobile'; +sim.setShowName(0, name,(err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## sim.**setShowName**8+ + +setShowName\(slotId: number, name: string\): Promise\ + +Sets a display name for 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| name | string | Yes | SIM card name. | + +**Return value** + +| Type | Description | +| -------------- | ------------------------------- | +| Promise\ | Promise that returns no value. | + +**Example** + +```js +const name='China Mobile'; +let promise = sim.setShowName(0,name); +promise.then(data => { + console.log(`setShowName success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`setShowName fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.**getShowName**8+ + +getShowName(slotId: number, callback: AsyncCallback): void + +Obtains the name 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.
- **0**: card slot 1
- **1**: card slot 2| +| callback | AsyncCallback<string> | Yes | Callback used to return the result. | + +**Example** + +```js +sim.getShowName(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.**getShowName**8+ + +getShowName(slotId: number): Promise + +Obtains the name 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 | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| + +**Return value** + +| Type | Description | +| --------------------- | -------------------------------------- | +| Promise<string> | Promise used to return the result.| + +**Example** + +```js +let promise = sim.getShowName(0); +promise.then(data => { + console.log(`getShowName success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getShowName fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.**setShowNumber**8+ + +setShowNumber\(slotId: number, number: string,callback: AsyncCallback\): void + +Sets a display number for 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| number | string | Yes | SIM card number. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example** + +```js +let number='+861xxxxxxxxxx'; +sim.setShowNumber(0, number,(err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.**setShowNumber**8+ + +setShowNumber\(slotId: number,number: string\): Promise\ + +Sets a display number for 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| number | string | Yes | SIM card number. | + +**Return value** + +| Type | Description | +| -------------- | ------------------------------- | +| Promise\ | Promise that returns no value. | + +**Example** + +```js +let number='+861xxxxxxxxxx'; +let promise = sim.setShowNumber(0,number); +promise.then(data => { + console.log(`setShowNumber success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`setShowNumber fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.**getShowNumber**8+ + +getShowNumber(slotId: number,callback: AsyncCallback): void + +Obtains the display number 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.
- **0**: card slot 1
- **1**: card slot 2| +| callback | AsyncCallback<string> | Yes | Callback used to return the result. | + +**Example** + +```js +sim.getShowNumber(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.**getShowNumber**8+ + +getShowNumber(slotId: number): Promise + +Obtains the display number 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 | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| + +**Return value** + +| Type | Description | +| --------------------- | --------------------------------- | +| Promise<string> | Promise used to return the result.| + +**Example** + +```js +let promise = sim.getShowNumber(0); +promise.then(data => { + console.log(`getShowNumber success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getShowNumber fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.**activateSim**8+ + +activateSim(slotId: number, callback: AsyncCallback): void + +Activates 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example** + +```js +sim.activateSim(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.**activateSim**8+ + +activateSim(slotId: number): Promise\ + +Activates 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| + +**Return value** + +| Type | Description | +| -------------- | ------------------------------- | +| Promise\ | Promise that returns no value. | + +**Example** + +```js +let promise = sim.activateSim(0); +promise.then(data => { + console.log(`activateSim success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`activateSim fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.**deactivateSim**8+ + +deactivateSim(slotId: number, callback: AsyncCallback): void + +Deactivates 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example** + +```js +sim.deactivateSim(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.**deactivateSim**8+ + +deactivateSim(slotId: number): Promise\ + +Deactivates 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| + +**Return value** + +| Type | Description | +| -------------- | ------------------------------- | +| Promise\ | Promise that returns no value. | + +**Example** + +```js +let promise = sim.deactivateSim(0); +promise.then(data => { + console.log(`deactivateSim success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`deactivateSim fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.setLockState7+ + +setLockState(slotId: number, options: LockInfo, callback: AsyncCallback): void + +Sets the lock status 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| callback | AsyncCallback\<[LockStatusResponse](#LockStatusResponse7)\> | Yes | Callback used to return the result. | +| options | [LockInfo](#LockInfo8) | Yes | Lock information.
- **lockType**: [LockType](#LockType8)
- **password**: string
- **state**: [LockState](#LockState8) | + +**Example** + +```js +LockInfo.lockType = 1; +LockInfo.password = "1234"; +LockInfo.state = 0; +sim.setLockState(0, LockInfo, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.setLockState7+ + +setLockState(slotId: number, options: LockInfo): Promise + +Sets the lock status 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ---------------------- | ---- | ------------------------------------------------------------ | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| options | [LockInfo](#LockInfo8) | Yes | Lock information.
- **lockType**: [LockType](#LockType8)
**password**: string
**state**: [LockState](#LockState8) | + +**Return value** + +| Type | Description | +| ---------------------------------------------------- | -------------------------------------------- | +| Promise<[LockStatusResponse](#LockStatusResponse7)\> | Promise used to return the result.| + +**Example** + +```js +LockInfo.lockType = 1; +LockInfo.password = "1234"; +LockInfo.state = 0; +let promise = sim.setLockState(0, LockInfo); +promise.then(data => { + console.log(`setLockState success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`setLockState fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.getLockState8+ + +getLockState(slotId: number, lockType: LockType, callback: AsyncCallback): void + +Obtains the lock status of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. + +This is a system API. + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------- | ---- | --------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| callback | AsyncCallback\<[LockState](#LockState8)\> | Yes | Callback used to return the result. | +| options | [LockType](#LockType8) | Yes | Lock type.
- **1**: PIN lock
- **2**: PIN2 lock| + +**Example** + +```js +sim.getLockState(0, 1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.getLockState8+ + +getLockState(slotId: number, lockType: LockType): Promise + +Obtains the lock status of the SIM card in the specified slot. This API uses a promise to return the result. + +This is a system API. + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ---------------------- | ---- | --------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| options | [LockType](#LockType8) | Yes | Lock type.
- **1**: PIN lock
- **2**: PIN2 lock| + +**Return value** + +| Type | Description | +| ---------------------------------- | -------------------------------------------- | +| Promise<[LockState](#LockState8)\> | Promise used to return the result.| + +**Example** + +```js +let promise = sim.getLockState(0, 1); +promise.then(data => { + console.log(`getLockState success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getLockState fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.alterPin7+ + +alterPin(slotId: number, newPin: string, oldPin: string, callback: AsyncCallback): void + +Changes the PIN. 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.
- **0**: card slot 1
- **1**: card slot 2| +| callback | AsyncCallback\<[LockStatusResponse](#LockStatusResponse7)\> | Yes | Callback used to return the result. | +| newPin | string | Yes | New PIN. | +| oldPin | string | Yes | Old PIN. | + +**Example** + +```js +sim.alterPin(0, "1234", "0000"(err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.alterPin7+ + +alterPin(slotId: number, newPin: string, oldPin: string): Promise; + +Changes the PIN. 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.
- **0**: card slot 1
- **1**: card slot 2| +| newPin | string | Yes | New PIN. | +| oldPin | string | Yes | Old PIN. | + +**Return value** + +| Type | Description | +| ---------------------------------------------------- | --------------------------------------------- | +| Promise<[LockStatusResponse](#LockStatusResponse7)\> | Promise used to return the result.| + +**Example** + +```js +let promise = sim.alterPin(0, "1234", "0000"); +promise.then(data => { + console.log(`alterPin success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`alterPin fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.alterPin28+ + +alterPin2(slotId: number, newPin2: string, oldPin2: string, callback: AsyncCallback): void + +Changes PIN 2. 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.
- **0**: card slot 1
- **1**: card slot 2| +| callback | AsyncCallback\<[LockStatusResponse](#LockStatusResponse7)\> | Yes | Callback used to return the result. | +| newPin2 | string | Yes | New PIN. | +| oldPin2 | string | Yes | Old PIN. | + +**Example** + +```js +sim.alterPin2(0, "1234", "0000", (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.alterPin28+ + +alterPin2(slotId: number, newPin2: string, oldPin2: string): Promise + +Changes PIN 2. 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.
- **0**: card slot 1
- **1**: card slot 2| +| newPin2 | string | Yes | New PIN. | +| oldPin2 | string | Yes | Old PIN. | + +**Return value** + +| Type | Description | +| ---------------------------------------------------- | --------------------------------------------- | +| Promise<[LockStatusResponse](#LockStatusResponse7)\> | Promise used to return the result.| + +**Example** + +```js +let promise = sim.alterPin2(0, "1234","0000"); +promise.then(data => { + console.log(`alterPin2 success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`alterPin2 fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.**unlockPin**7+ + +unlockPin(slotId: number,pin: string ,callback: AsyncCallback): void + +Unlocks the PIN 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| pin | string | Yes | PIN of the SIM card. | +| callback | AsyncCallback<[LockStatusResponse](#LockStatusResponse7)> | Yes | Callback used to return the result. | + +**Example** + +```js +let pin='1234'; +sim.unlockPin(0, pin,(err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.**unlockPin**7+ + +unlockPin(slotId: number,pin: string): Promise<LockStatusResponse\> + +Unlocks the PIN 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| pin | string | Yes | PIN of the SIM card. | + +**Return value** + +| Type | Description | +| ---------------------------------------------------- | -------------------------------------------------- | +| Promise\<[LockStatusResponse](#LockStatusResponse)\> | Promise used to return the result.| + +**Example** + +```js +let pin='1234'; +let promise = sim.unlockPin(0,pin); +promise.then(data => { + console.log(`unlockPin success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`unlockPin fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.**unlockPuk**7+ + +unlockPuk(slotId: number,newPin: string,puk: string ,callback: AsyncCallback): void + +Unlocks the PUK 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| newPin | string | Yes | New PIN. | +| puk | string | Yes | PUK of the SIM card. | +| callback | AsyncCallback<[LockStatusResponse](#LockStatusResponse7)> | Yes | Callback used to return the result. | + +**Example** + +```js +let puk='1xxxxxxx'; +let newPin='1235'; +sim.unlockPuk(0, newPin,puk,(err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.**unlockPuk**7+ + +unlockPuk(slotId: number,newPin: string,puk: string): Promise<LockStatusResponse\> + +Unlocks the PUK 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| newPin | string | Yes | New PIN. | +| puk | string | Yes | PUK of the SIM card. | + +**Return value** + +| Type | Description | +| ---------------------------------------------------- | -------------------------------------------------- | +| Promise\<[LockStatusResponse](#LockStatusResponse)\> | Promise used to return the result.| + +**Example** + +```js +let puk='1xxxxxxx'; +let newPin='1235'; +let promise = sim.unlockPuk(0,newPin,puk); +promise.then(data => { + console.log(`unlockPuk success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`unlockPuk fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.**unlockPin**28+ + +****unlockPin2****(slotId: number,pin2: string ,callback: AsyncCallback): void + +Unlocks PIN 2 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| pin2 | string | Yes | PIN of the SIM card. | +| callback | AsyncCallback<[LockStatusResponse](#LockStatusResponse7)> | Yes | Callback used to return the result. | + +**Example** + +```js +let pin2='1234'; +sim.unlockPin2(0, pin2,(err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.**unlockPin**28+ + +unlockPin2(slotId: number,pin2: string): Promise<LockStatusResponse\> + +Unlocks PIN 2 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| pin2 | string | Yes | PIN of the SIM card. | + +**Return value** + +| Type | Description | +| ----------------------------------------------------- | -------------------------------------------------- | +| Promise\<[LockStatusResponse](#LockStatusResponse7)\> | Promise used to return the result.| + +**Example** + +```js +let pin2='1234'; +let promise = sim.unlockPin2(0,pin2); +promise.then(data => { + console.log(`unlockPin2 success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`unlockPin2 fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.**unlockPuk**28+ + +unlockPuk2(slotId: number,newPin2: string,puk2: string ,callback: AsyncCallback): void + +Unlocks PUK 2 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| newPin2 | string | Yes | New PIN. | +| puk2 | string | Yes | PUK of the SIM card. | +| callback | AsyncCallback<[LockStatusResponse](#LockStatusResponse7)> | Yes | Callback used to return the result. | + +**Example** + +```js +let puk2='1xxxxxxx'; +let newPin2='1235'; +sim.unlockPuk2(0, newPin2,puk2,(err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.**unlockPuk2**8+ + +unlockPuk2slotId: number,newPin2: string,puk2: string): Promise<LockStatusResponse\> + +Unlocks PUK 2 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.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| newPin2 | string | Yes | New PIN. | +| puk2 | string | Yes | PUK of the SIM card. | + +**Return value** + +| Type | Description | +| ---------------------------------------------------- | -------------------------------------------------- | +| Promise\<[LockStatusResponse](#LockStatusResponse)\> | Promise used to return the result.| + +**Example** + +```js +let puk2='1xxxxxxx'; +let newPin2='1235'; +let promise = sim.unlockPuk2(0,newPin2,puk2); +promise.then(data => { + console.log(`unlockPuk2 success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`unlockPuk2 fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.getMaxSimCount7+ + +getMaxSimCount\(\): number + +Obtains the number of card slots. + +**System capability**: SystemCapability.Telephony.CoreService + +**Return value** + +| Type | Description | +| ----------------- | ------------------------------------------------------------ | +| number | Number of card slots.| + +**Example** + +```js +console.log("Result: "+ sim.getMaxSimCount()) +``` + + +## SimState + +Enumerates SIM card states. + +**System capability**: SystemCapability.Telephony.CoreService + +| Name | Value | Description | +| --------------------- | ---- | ---------------------------------------------------------- | +| SIM_STATE_UNKNOWN | 0 | The SIM card is in **unknown** state; that is, the SIM card status cannot be obtained. | +| SIM_STATE_NOT_PRESENT | 1 | The SIM card is in **not present** state; that is, no SIM card is inserted into the card slot. | +| SIM_STATE_LOCKED | 2 | The SIM card is in **locked** state; that is, the SIM card is locked by the personal identification number (PIN), PIN unblocking key (PUK), or network. | +| SIM_STATE_NOT_READY | 3 | The SIM card is in **not ready** state; that is, the SIM card has been installed but cannot work properly. | +| SIM_STATE_READY | 4 | The SIM card is in **ready** state; that is, the SIM card has been installed and is working properly. | +| SIM_STATE_LOADED | 5 | The SIM card is in **loaded** state; that is, the SIM card is present and all its files have been loaded.| + +## CardType7+ + +Enumerates card types. + +**System capability**: SystemCapability.Telephony.CoreService + +| Name| Value| Description| +| ----- | ----- | ----- | +|UNKNOWN_CARD | -1 | Unknown| +|SINGLE_MODE_SIM_CARD | 10 | Single-card (SIM)| +|SINGLE_MODE_USIM_CARD | 20 | Single-card (USIM)| +|SINGLE_MODE_RUIM_CARD | 30 | Single-card (RUIM)| +|DUAL_MODE_CG_CARD | 40 | Dual-card (CDMA+GSM)| +|CT_NATIONAL_ROAMING_CARD | 41 | China Telecom internal roaming 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_UG_CARD | 50 | Dual-mode card (UMTS+GSM)| +|SINGLE_MODE_ISIM_CARD8+ | 60 | Single-card (ISIM)| + +## LockType8+ + +Enumerates lock types. + +This is a system API. + +**System capability**: SystemCapability.Telephony.CoreService + +| Name | Value | Description | +| -------- | ---- | ----------- | +| PIN_LOCK | 1 | SIM card password lock| +| FDN_LOCK | 2 | Fixed dialing lock | + +## LockState8+ + +Enumerates lock states. + +This is a system API. + +**System capability**: SystemCapability.Telephony.CoreService + +| Name | Value | Description | +| -------- | ---- | ---------- | +| LOCK_OFF | 0 | The lock is off.| +| LOCK_ON | 1 | The lock is on.| + +## **PersoLockType**8+ + +Enumerates personalized lock types. + +This is a system API. + +**System capability**: SystemCapability.Telephony.CoreService + +| Name | Value | Description | +| ------------ | ---- | ----------------------------------------------- | +| PN_PIN_LOCK | 0 | Personalized network PIN lock. For details, see *3GPP TS 22.022 [33]*. | +| PN_PUK_LOCK | 1 | Personalized network PUK lock. | +| PU_PIN_LOCK | 2 | Personalized network subset PIN lock. For details, see *3GPP TS 22.022 [33]*. | +| PU_PUK_LOCK | 3 | Personalized network subset PUK lock. | +| PP_PIN_LOCK | 4 | Personalized service provider PIN lock. For details, see *3GPP TS 22.022 [33]*.| +| PP_PUK_LOCK | 5 | Personalized service provider PUK lock. | +| PC_PIN_LOCK | 6 | Personalized corporate PIN lock. For details, see *3GPP TS 22.022 [33]*. | +| PC_PUK_LOCK | 7 | Personalized corporate PUK lock. | +| SIM_PIN_LOCK | 8 | Personalized SIM card PIN lock. For details, see *3GPP TS 22.022 [33]*. | +| SIM_PUK_LOCK | 9 | Personalized SIM card PUK lock. | + +## **LockStatusResponse**7+ + +Defines the lock status response. + +This is a system API. + +**System capability**: SystemCapability.Telephony.CoreService + +| Name | Type | Description | +| --------------- | ------ | ------------------ | +| result | number | Operation result. | +| remain?: number | number | Remaining attempts (can be null).| + +## **LockInfo**8+ + +Defines the personalized lock status response. + +This is a system API. + +**System capability**: SystemCapability.Telephony.CoreService + +| Name | Type | Description | +| -------- | --------- | ------ | +| lockType | LockType | Lock type.| +| password | string | Password. | +| state | LockState | Lock state.| + +## **PersoLockInfo**8+ + +Defines the personalized lock information. + +This is a system API. + +**System capability**: SystemCapability.Telephony.CoreService + +| Name | Type | Description | +| -------- | ------------- | ------------ | +| lockType | PersoLockType | Personalized lock type.| +| password | string | Password. | + +## **IccAccountInfo**7+ + +Defines the ICC account information. + +This is a system API. + +**System capability**: SystemCapability.Telephony.CoreService + +| Name | Type | Description | +| ---------- | ------- | ---------------- | +| simId | number | SIM card ID. | +| slotIndex | number | Card slot ID. | +| isEsim | boolean | Whether the SIM card is an eSim card.| +| isActive | boolean | Whether the card is activated. | +| iccId | string | ICCID number. | +| showName | string | SIM card display name. | +| showNumber | string | SIM card display number. | diff --git a/en/application-dev/reference/apis/js-apis-sms.md b/en/application-dev/reference/apis/js-apis-sms.md index a264817ec018ad6a7fe22888ea0f7a3c5f223fcf..11fdf806794469274ea30ee3b4797b42f9041965 100644 --- a/en/application-dev/reference/apis/js-apis-sms.md +++ b/en/application-dev/reference/apis/js-apis-sms.md @@ -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<number> | Yes | PDU, which is obtained from the received SMS message. | +| pdu | Array<number> | Yes | Protocol data unit, which is obtained from the received SMS message. | | specification | string | Yes | SMS protocol type.
- **3gpp**: GSM/UMTS/LTE SMS
- **3gpp2**: CDMA SMS| | callback | AsyncCallback<[ShortMessage](#shortmessage)> | 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<number> | Yes | PDU, which is obtained from the received SMS message. | +| pdu | Array<number> | Yes | Protocol data unit, which is obtained from the received SMS message. | | specification | string | Yes | SMS protocol type.
- **3gpp**: GSM/UMTS/LTE SMS
- **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<number> | Yes | Callback used to return the result.
- **0**: card slot 1
- **1**: card slot 2| +| callback | AsyncCallback<number> | Yes | Callback used to return the result.
- **0**: card slot 1
- **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.setDefaultSmsSlotId7+ + +setDefaultSmsSlotId\(slotId: number,callback: AsyncCallback<void>\): 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.
- **0**: card slot 1
- **1**: card slot 2
- **-1**: Clears the default configuration.| +| callback | AsyncCallback<void> | 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.setDefaultSmsSlotId7+ + +setDefaultSmsSlotId\(slotId: number\): Promise<void> + +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.
- **0**: card slot 1
- **1**: card slot 2
- **-1**: Clears the default configuration.| + +**Return value** + +| Type | Description | +| -------------- | ------------------------------- | +| Promise\ | 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.setSmscAddr7+ @@ -163,23 +225,23 @@ setSmscAddr\(slotId: number, smscAddr: string, callback: AsyncCallback\): 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.
- **0**: card slot 1
- **1**: card slot 2| -| smscAddr | string | Yes | SMSC address. | +| smscAddr | string | Yes | SMSC address. | | callback | AsyncCallback<void> | 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.setSmscAddr7+ -setSmscAddr\(slotId: number, smscAddr: string\): Promise +setSmscAddr\(slotId: number, smscAddr: string\): Promise\ 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.
- **0**: card slot 1
- **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\): 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 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.
- **0**: card slot 1
- **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.
- **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**.
**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**.
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**.
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**.
**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<number> | 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.| diff --git a/en/application-dev/reference/apis/js-apis-telephony-data.md b/en/application-dev/reference/apis/js-apis-telephony-data.md index b6bdef1d34b9f544e1380d3d4a9a7cd7d1d293b7..309e32bdae7af66c7ca14802f734ccca0ccdbb99 100644 --- a/en/application-dev/reference/apis/js-apis-telephony-data.md +++ b/en/application-dev/reference/apis/js-apis-telephony-data.md @@ -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\): 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\ -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 + +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.
- **0**: card slot 1
- **1**: card slot 2
- **-1**: Clears the default configuration.| +| callback | AsyncCallback\ | 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\ + +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.
- **0**: card slot 1
- **1**: card slot 2
- **-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\ | Yes | Callback used to return the result.
**true**: The cellular data service is enabled.
**false**: The cellular data service is disabled.| +| callback | AsyncCallback\ | Yes | Callback used to return the result.
- **true**: The cellular data service is enabled.
- **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\ | Promise used to return the result.
**true**: The cellular data service is enabled.
**false**: The cellular data service is disabled.| +| Promise\ | Promise used to return the result.
- **true**: The cellular data service is enabled.
- **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.
**0**: card slot 1
**1**: card slot 2 | -| callback | AsyncCallback\ | Yes | Callback used to return the result.
**true**: Roaming is enabled for the cellular data service.
**false**: Roaming is disabled for the cellular data service.| +| slotId | number | Yes | Card slot ID.
**0**: card slot 1
**1**: card slot 2 | +| callback | AsyncCallback\ | Yes | Callback used to return the result.
- **true**: Roaming is enabled for the cellular data service.
- **false**: Roaming is disabled for the cellular data service.| **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.
**0**: card slot 1
**1**: card slot 2| +| slotId | number | Yes | Card slot ID.
**0**: card slot 1
**1**: card slot 2| -**Return Value** +**Return value** | Type | Description | | ------------------ | ------------------------------------------------------------ | -| Promise\ | Promise used to return the result.
**true**: Roaming is enabled for the cellular data service.
**false**: Roaming is disabled for the cellular data service.| +| Promise\ | Promise used to return the result.
- **true**: Roaming is enabled for the cellular data service.
- **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. |