js-apis-sim.md 167.5 KB
Newer Older
S
shawn_he 已提交
1
# @ohos.telephony.sim (SIM Management)
S
shawn_he 已提交
2

S
shawn_he 已提交
3
The **sim** module provides basic SIM card management functions. You can obtain the name, number, ISO country code, home PLMN number, service provider name, SIM card status, type, installation status, activation status, and lock status of the SIM card in the specified slot. Besides, you can set the name, number, and lock status of the SIM card, activate or deactivate the SIM card, and change the PIN or unlock the PIN or PUK of the SIM card.
S
shawn_he 已提交
4

S
shawn_he 已提交
5
>**NOTE**
S
shawn_he 已提交
6
>
Z
zengyawen 已提交
7
>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
S
shawn_he 已提交
8
>
S
shawn_he 已提交
9 10 11

## Modules to Import

S
shawn_he 已提交
12
```js
S
shawn_he 已提交
13 14 15
import sim from '@ohos.telephony.sim';
```

S
shawn_he 已提交
16
## sim.isSimActive<sup>7+</sup>
S
shawn_he 已提交
17

S
shawn_he 已提交
18
isSimActive\(slotId: number, callback: AsyncCallback\<boolean\>\): void
S
shawn_he 已提交
19

S
shawn_he 已提交
20
Checks whether the SIM card in the specified slot is activated. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
21

S
shawn_he 已提交
22
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
23

S
shawn_he 已提交
24
**Parameters**
S
shawn_he 已提交
25

S
shawn_he 已提交
26
| Name  | Type                       | Mandatory| Description                                  |
S
shawn_he 已提交
27
| -------- | --------------------------- | ---- | -------------------------------------- |
S
shawn_he 已提交
28
| slotId   | number                      | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
29
| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result.                            |
S
shawn_he 已提交
30

S
shawn_he 已提交
31
**Example**
S
shawn_he 已提交
32

S
shawn_he 已提交
33
```js
S
shawn_he 已提交
34
sim.isSimActive(0, (err, data) => {
S
shawn_he 已提交
35 36 37
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
38 39


S
shawn_he 已提交
40
## sim.isSimActive<sup>7+</sup>
S
shawn_he 已提交
41

S
shawn_he 已提交
42
isSimActive\(slotId: number\): Promise\<boolean\>
S
shawn_he 已提交
43

S
shawn_he 已提交
44
Checks whether the SIM card in the specified slot is activated. This API uses a promise to return the result.
S
shawn_he 已提交
45

S
shawn_he 已提交
46
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
47

S
shawn_he 已提交
48
**Parameters**
S
shawn_he 已提交
49

S
shawn_he 已提交
50
| Name| Type  | Mandatory| Description                                  |
S
shawn_he 已提交
51
| ------ | ------ | ---- | -------------------------------------- |
S
shawn_he 已提交
52
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
53

S
shawn_he 已提交
54
**Return value**
S
shawn_he 已提交
55

S
shawn_he 已提交
56
| Type                 | Description                              |
S
shawn_he 已提交
57
| --------------------- | ---------------------------------- |
S
shawn_he 已提交
58
| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** indicates that the SIM card in the specified slot is activated, and the value **false** indicates the opposite.|
S
shawn_he 已提交
59

S
shawn_he 已提交
60
**Example**
S
shawn_he 已提交
61

S
shawn_he 已提交
62
```js
S
shawn_he 已提交
63
let promise = sim.isSimActive(0);
S
shawn_he 已提交
64
promise.then(data => {
S
shawn_he 已提交
65
    console.log(`isSimActive success, promise: data->${JSON.stringify(data)}`);
S
shawn_he 已提交
66
}).catch(err => {
S
shawn_he 已提交
67
    console.log(`isSimActive failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
68 69
});
```
S
shawn_he 已提交
70

S
shawn_he 已提交
71 72

## sim.getDefaultVoiceSlotId<sup>7+</sup>
S
shawn_he 已提交
73

S
shawn_he 已提交
74
getDefaultVoiceSlotId\(callback: AsyncCallback\<number\>\): void
S
shawn_he 已提交
75

S
shawn_he 已提交
76
Obtains the default slot ID of the SIM card that provides voice services. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
77

S
shawn_he 已提交
78
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
79

S
shawn_he 已提交
80
**Parameters**
S
shawn_he 已提交
81

S
shawn_he 已提交
82
| Name  | Type                       | Mandatory| Description      |
S
shawn_he 已提交
83
| -------- | --------------------------- | ---- | ---------- |
S
shawn_he 已提交
84
| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the result.|
S
shawn_he 已提交
85

S
shawn_he 已提交
86
**Example**
S
shawn_he 已提交
87

S
shawn_he 已提交
88
```js
S
shawn_he 已提交
89 90 91 92
sim.getDefaultVoiceSlotId((err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
93 94


S
shawn_he 已提交
95
## sim.getDefaultVoiceSlotId<sup>7+</sup>
S
shawn_he 已提交
96

S
shawn_he 已提交
97
getDefaultVoiceSlotId\(\): Promise\<number\>
S
shawn_he 已提交
98

S
shawn_he 已提交
99
Obtains the default slot ID of the SIM card that provides voice services. This API uses a promise to return the result.
S
shawn_he 已提交
100

S
shawn_he 已提交
101
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
102

S
shawn_he 已提交
103
**Return value**
S
shawn_he 已提交
104 105

| Type             | Description                                   |
S
shawn_he 已提交
106 107
| ----------------- | --------------------------------------- |
| Promise\<number\> | Promise used to return the result.|
S
shawn_he 已提交
108

S
shawn_he 已提交
109
**Example**
S
shawn_he 已提交
110

S
shawn_he 已提交
111
```js
S
shawn_he 已提交
112 113 114 115
let promise = sim.getDefaultVoiceSlotId();
promise.then(data => {
    console.log(`getDefaultVoiceSlotId success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
116
    console.log(`getDefaultVoiceSlotId failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
117 118
});
```
S
shawn_he 已提交
119

S
shawn_he 已提交
120 121
## sim.hasOperatorPrivileges<sup>7+</sup>

S
shawn_he 已提交
122
hasOperatorPrivileges\(slotId: number, callback: AsyncCallback\<boolean\>\): void
S
shawn_he 已提交
123

S
shawn_he 已提交
124
Checks whether the application (caller) has been granted the operator permission. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
125

S
shawn_he 已提交
126
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
127 128 129 130 131

**Parameters**

| Name  | Type                    | Mandatory| Description                                    |
| -------- | ------------------------ | ---- | ---------------------------------------- |
S
shawn_he 已提交
132
| slotId   | number                   | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
133 134
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.                              |

S
shawn_he 已提交
135 136
**Error codes**

S
shawn_he 已提交
137 138
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
139 140 141 142 143 144 145 146
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
147 148
**Example**

S
shawn_he 已提交
149
```js
S
shawn_he 已提交
150 151 152 153 154 155 156
sim.hasOperatorPrivileges(0, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```

## sim.hasOperatorPrivileges<sup>7+</sup>

S
shawn_he 已提交
157
hasOperatorPrivileges\(slotId: number\): Promise\<boolean\>
S
shawn_he 已提交
158

S
shawn_he 已提交
159
Checks whether the application (caller) has been granted the operator permission. This API uses a promise to return the result.
S
shawn_he 已提交
160

S
shawn_he 已提交
161
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
162 163 164 165 166

**Parameters**

| Name| Type  | Mandatory| Description                                    |
| ------ | ------ | ---- | ---------------------------------------- |
S
shawn_he 已提交
167
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
168

S
shawn_he 已提交
169
**Return value**
S
shawn_he 已提交
170 171 172

| Type              | Description                                                       |
| :----------------- | :---------------------------------------------------------- |
S
shawn_he 已提交
173
| Promise\<boolean\> | Promise used to return the result. The value **true** indicates that the application (caller) has been granted the carrier permission, and the value **false** indicates the opposite.|
S
shawn_he 已提交
174

S
shawn_he 已提交
175 176
**Error codes**

S
shawn_he 已提交
177 178
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
179 180 181 182 183 184 185 186
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
187 188
**Example**

S
shawn_he 已提交
189
```js
S
shawn_he 已提交
190 191 192 193
let promise = sim.hasOperatorPrivileges(0);
promise.then(data => {
    console.log(`hasOperatorPrivileges success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
194
    console.log(`hasOperatorPrivileges failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
195 196 197 198
});
```

## sim.getISOCountryCodeForSim
S
shawn_he 已提交
199

S
shawn_he 已提交
200
getISOCountryCodeForSim\(slotId: number, callback: AsyncCallback\<string\>\): void
S
shawn_he 已提交
201

S
shawn_he 已提交
202
Obtains the ISO country code of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
203

S
shawn_he 已提交
204
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
205

S
shawn_he 已提交
206
**Parameters**
S
shawn_he 已提交
207

S
shawn_he 已提交
208
| Name  | Type                   | Mandatory| Description                                    |
S
shawn_he 已提交
209
| -------- | ----------------------- | ---- | ---------------------------------------- |
S
shawn_he 已提交
210
| slotId   | number                  | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2  |
S
shawn_he 已提交
211 212 213 214
| callback | AsyncCallback\<string\> | Yes  | Callback used to return the result, which is an ISO country code, for example, **CN** (China).|

**Error codes**

S
shawn_he 已提交
215 216
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
217 218 219 220 221 222 223 224
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
S
shawn_he 已提交
225

S
shawn_he 已提交
226
**Example**
S
shawn_he 已提交
227

S
shawn_he 已提交
228
```js
S
shawn_he 已提交
229 230 231 232
sim.getISOCountryCodeForSim(0, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
233 234


S
shawn_he 已提交
235
## sim.getISOCountryCodeForSim
S
shawn_he 已提交
236

S
shawn_he 已提交
237
getISOCountryCodeForSim\(slotId: number\): Promise\<string\>
S
shawn_he 已提交
238

S
shawn_he 已提交
239
Obtains the ISO country code of the SIM card in the specified slot. This API uses a promise to return the result.
S
shawn_he 已提交
240

S
shawn_he 已提交
241
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
242

S
shawn_he 已提交
243
**Parameters**
S
shawn_he 已提交
244

S
shawn_he 已提交
245
| Name| Type  | Mandatory| Description                                  |
S
shawn_he 已提交
246
| ------ | ------ | ---- | -------------------------------------- |
S
shawn_he 已提交
247
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
248

S
shawn_he 已提交
249
**Return value**
S
shawn_he 已提交
250

S
shawn_he 已提交
251
| Type             | Description                                                        |
S
shawn_he 已提交
252
| ----------------- | ------------------------------------------------------------ |
S
shawn_he 已提交
253
| Promise\<string\> | Promise used to return the result, which is an ISO country code, for example, **CN** (China).|
S
shawn_he 已提交
254

S
shawn_he 已提交
255 256
**Error codes**

S
shawn_he 已提交
257 258
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
259 260 261 262 263 264 265 266 267
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
268
**Example**
S
shawn_he 已提交
269

S
shawn_he 已提交
270
```js
S
shawn_he 已提交
271 272 273 274
let promise = sim.getISOCountryCodeForSim(0);
promise.then(data => {
    console.log(`getISOCountryCodeForSim success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
275
    console.log(`getISOCountryCodeForSim failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
276 277
});
```
S
shawn_he 已提交
278 279


S
shawn_he 已提交
280
## sim.getSimOperatorNumeric
S
shawn_he 已提交
281

S
shawn_he 已提交
282
getSimOperatorNumeric\(slotId: number, callback: AsyncCallback\<string\>\): void
S
shawn_he 已提交
283

S
shawn_he 已提交
284
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.
S
shawn_he 已提交
285

S
shawn_he 已提交
286
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
287

S
shawn_he 已提交
288
**Parameters**
S
shawn_he 已提交
289

S
shawn_he 已提交
290
| Name  | Type                   | Mandatory| Description                                  |
S
shawn_he 已提交
291
| -------- | ----------------------- | ---- | -------------------------------------- |
S
shawn_he 已提交
292
| slotId   | number                  | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
293
| callback | AsyncCallback\<string\> | Yes  | Callback used to return the result.                            |
S
shawn_he 已提交
294

S
shawn_he 已提交
295 296
**Error codes**

S
shawn_he 已提交
297 298
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
299 300 301 302 303 304 305 306 307
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
308
**Example**
S
shawn_he 已提交
309

S
shawn_he 已提交
310
```js
S
shawn_he 已提交
311 312 313 314
sim.getSimOperatorNumeric(0, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
315 316


S
shawn_he 已提交
317
## sim.getSimOperatorNumeric
S
shawn_he 已提交
318

S
shawn_he 已提交
319
getSimOperatorNumeric\(slotId: number\): Promise\<string\>
S
shawn_he 已提交
320

S
shawn_he 已提交
321
Obtains the PLMN ID of the SIM card in the specified slot. This API uses a promise to return the result.
S
shawn_he 已提交
322

S
shawn_he 已提交
323
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
324

S
shawn_he 已提交
325
**Parameters**
S
shawn_he 已提交
326

S
shawn_he 已提交
327
| Name| Type  | Mandatory| Description                                  |
S
shawn_he 已提交
328
| ------ | ------ | ---- | -------------------------------------- |
S
shawn_he 已提交
329
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
330

S
shawn_he 已提交
331
**Return value**
S
shawn_he 已提交
332

S
shawn_he 已提交
333
| Type             | Description                                            |
S
shawn_he 已提交
334 335
| ----------------- | ------------------------------------------------ |
| Promise\<string\> | Promise used to return the result.|
S
shawn_he 已提交
336

S
shawn_he 已提交
337 338
**Error codes**

S
shawn_he 已提交
339 340
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
341 342 343 344 345 346 347 348 349
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
350
**Example**
S
shawn_he 已提交
351

S
shawn_he 已提交
352
```js
S
shawn_he 已提交
353 354 355 356
let promise = sim.getSimOperatorNumeric(0);
promise.then(data => {
    console.log(`getSimOperatorNumeric success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
357
    console.log(`getSimOperatorNumeric failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
358 359
});
```
S
shawn_he 已提交
360 361


S
shawn_he 已提交
362
## sim.getSimSpn
S
shawn_he 已提交
363

S
shawn_he 已提交
364
getSimSpn\(slotId: number, callback: AsyncCallback\<string\>\): void
S
shawn_he 已提交
365

S
shawn_he 已提交
366
Obtains the service provider name (SPN) of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
367

S
shawn_he 已提交
368
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
369

S
shawn_he 已提交
370
**Parameters**
S
shawn_he 已提交
371

S
shawn_he 已提交
372
| Name  | Type                   | Mandatory| Description                                  |
S
shawn_he 已提交
373
| -------- | ----------------------- | ---- | -------------------------------------- |
S
shawn_he 已提交
374
| slotId   | number                  | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
375
| callback | AsyncCallback\<string\> | Yes  | Callback used to return the result.                            |
S
shawn_he 已提交
376

S
shawn_he 已提交
377 378
**Error codes**

S
shawn_he 已提交
379 380
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
381 382 383 384 385 386 387 388 389
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
390
**Example**
S
shawn_he 已提交
391

S
shawn_he 已提交
392
```js
S
shawn_he 已提交
393 394 395 396
sim.getSimSpn(0, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
397 398


S
shawn_he 已提交
399
## sim.getSimSpn
S
shawn_he 已提交
400

S
shawn_he 已提交
401
getSimSpn\(slotId: number\): Promise\<string\>
S
shawn_he 已提交
402

S
shawn_he 已提交
403
Obtains the SPN of the SIM card in the specified slot. This API uses a promise to return the result.
S
shawn_he 已提交
404

S
shawn_he 已提交
405
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
406

S
shawn_he 已提交
407
**Parameters**
S
shawn_he 已提交
408

S
shawn_he 已提交
409
| Name| Type  | Mandatory| Description                                  |
S
shawn_he 已提交
410
| ------ | ------ | ---- | -------------------------------------- |
S
shawn_he 已提交
411
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
412

S
shawn_he 已提交
413
**Return value**
S
shawn_he 已提交
414

S
shawn_he 已提交
415
| Type             | Description                                     |
S
shawn_he 已提交
416 417
| ----------------- | ----------------------------------------- |
| Promise\<string\> | Promise used to return the result.|
S
shawn_he 已提交
418

S
shawn_he 已提交
419 420
**Error codes**

S
shawn_he 已提交
421 422
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
423 424 425 426 427 428 429 430 431
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
432
**Example**
S
shawn_he 已提交
433

S
shawn_he 已提交
434
```js
S
shawn_he 已提交
435 436 437 438
let promise = sim.getSimSpn(0);
promise.then(data => {
    console.log(`getSimSpn success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
439
    console.log(`getSimSpn failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
440 441
});
```
S
shawn_he 已提交
442 443


S
shawn_he 已提交
444
## sim.getSimState
S
shawn_he 已提交
445

S
shawn_he 已提交
446
getSimState\(slotId: number, callback: AsyncCallback\<SimState\>\): void
S
shawn_he 已提交
447

S
shawn_he 已提交
448
Obtains the state of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
449

S
shawn_he 已提交
450
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
451

S
shawn_he 已提交
452
**Parameters**
S
shawn_he 已提交
453

S
shawn_he 已提交
454
| Name  | Type                                  | Mandatory| Description                                  |
S
shawn_he 已提交
455
| -------- | -------------------------------------- | ---- | -------------------------------------- |
S
shawn_he 已提交
456
| slotId   | number                                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
457
| callback | AsyncCallback\<[SimState](#simstate)\> | Yes  | Callback used to return the result. For details, see [SimState](#simstate). |
S
shawn_he 已提交
458

S
shawn_he 已提交
459 460
**Error codes**

S
shawn_he 已提交
461 462
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
463 464 465 466 467 468 469 470
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
471
**Example**
S
shawn_he 已提交
472

S
shawn_he 已提交
473
```js
S
shawn_he 已提交
474 475 476 477
sim.getSimState(0, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
478 479


S
shawn_he 已提交
480
## sim.getSimState
S
shawn_he 已提交
481

S
shawn_he 已提交
482
getSimState\(slotId: number\): Promise\<SimState\>
S
shawn_he 已提交
483

S
shawn_he 已提交
484
Obtains the state of the SIM card in the specified slot. This API uses a promise to return the result.
S
shawn_he 已提交
485

S
shawn_he 已提交
486
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
487

S
shawn_he 已提交
488
**Parameters**
S
shawn_he 已提交
489

S
shawn_he 已提交
490
| Name| Type  | Mandatory| Description                                  |
S
shawn_he 已提交
491
| ------ | ------ | ---- | -------------------------------------- |
S
shawn_he 已提交
492
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
493

S
shawn_he 已提交
494
**Return value**
S
shawn_he 已提交
495

S
shawn_he 已提交
496
| Type                            | Description                                      |
S
shawn_he 已提交
497
| -------------------------------- | ------------------------------------------ |
S
shawn_he 已提交
498
| Promise\<[SimState](#simstate)\> | Promise used to return the result.|
S
shawn_he 已提交
499

S
shawn_he 已提交
500 501
**Error codes**

S
shawn_he 已提交
502 503
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
504 505 506 507 508 509 510 511
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
512
**Example**
S
shawn_he 已提交
513

S
shawn_he 已提交
514
```js
S
shawn_he 已提交
515 516 517 518
let promise = sim.getSimState(0);
promise.then(data => {
    console.log(`getSimState success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
519
    console.log(`getSimState failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
520 521
});
```
S
shawn_he 已提交
522

S
shawn_he 已提交
523
## sim.getCardType<sup>7+</sup>
S
shawn_he 已提交
524

S
shawn_he 已提交
525
getCardType\(slotId: number, callback: AsyncCallback\<CardType\>\): void
S
shawn_he 已提交
526

S
shawn_he 已提交
527
Obtains the type of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
528

S
shawn_he 已提交
529
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
530

S
shawn_he 已提交
531
**Parameters**
S
shawn_he 已提交
532

S
shawn_he 已提交
533
| Name  | Type                   | Mandatory| Description                                  |
S
shawn_he 已提交
534
| -------- | ----------------------- | ---- | -------------------------------------- |
S
shawn_he 已提交
535
| slotId   | number                  | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
536
| callback | AsyncCallback\<[CardType](#cardtype7)\> | Yes  | Callback used to return the result.                            |
S
shawn_he 已提交
537

S
shawn_he 已提交
538 539
**Error codes**

S
shawn_he 已提交
540 541
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
542 543 544 545 546 547 548 549 550
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
551
**Example**
S
shawn_he 已提交
552

S
shawn_he 已提交
553
```js
S
shawn_he 已提交
554
sim.getCardType(0, (err, data) => {
S
shawn_he 已提交
555 556 557
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
558 559


S
shawn_he 已提交
560
## sim.getCardType<sup>7+</sup>
S
shawn_he 已提交
561

S
shawn_he 已提交
562
getCardType\(slotId: number\): Promise\<CardType\>
S
shawn_he 已提交
563

S
shawn_he 已提交
564
Obtains the type of the SIM card in the specified slot. This API uses a promise to return the result.
S
shawn_he 已提交
565

S
shawn_he 已提交
566
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
567

S
shawn_he 已提交
568
**Parameters**
S
shawn_he 已提交
569

S
shawn_he 已提交
570
| Name| Type  | Mandatory| Description                                  |
S
shawn_he 已提交
571
| ------ | ------ | ---- | -------------------------------------- |
S
shawn_he 已提交
572
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
573

S
shawn_he 已提交
574
**Return value**
S
shawn_he 已提交
575

S
shawn_he 已提交
576
| Type             | Description                                                        |
S
shawn_he 已提交
577
| ----------------- | ------------------------------------------------------------ |
S
shawn_he 已提交
578
| Promise\<[CardType](#cardtype7)\> | Promise used to return the result.|
S
shawn_he 已提交
579

S
shawn_he 已提交
580 581
**Error codes**

S
shawn_he 已提交
582 583
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
584 585 586 587 588 589 590 591 592
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
593
**Example**
S
shawn_he 已提交
594

S
shawn_he 已提交
595
```js
S
shawn_he 已提交
596
let promise = sim.getCardType(0);
S
shawn_he 已提交
597
promise.then(data => {
S
shawn_he 已提交
598
    console.log(`getCardType success, promise: data->${JSON.stringify(data)}`);
S
shawn_he 已提交
599
}).catch(err => {
S
shawn_he 已提交
600
    console.log(`getCardType failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
601 602
});
```
S
shawn_he 已提交
603 604


S
shawn_he 已提交
605 606
## sim.hasSimCard<sup>7+</sup>

S
shawn_he 已提交
607
hasSimCard\(slotId: number, callback: AsyncCallback\<boolean\>\): void
S
shawn_he 已提交
608

S
shawn_he 已提交
609
Checks whether the SIM card in the specified slot is installed. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
610

S
shawn_he 已提交
611
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
612 613 614 615 616

**Parameters**

| Name  | Type                       | Mandatory| Description                                  |
| -------- | --------------------------- | ---- | -------------------------------------- |
S
shawn_he 已提交
617
| slotId   | number                      | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
618 619
| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result.                            |

S
shawn_he 已提交
620 621
**Error codes**

S
shawn_he 已提交
622 623
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
624 625 626 627 628 629 630 631
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
632 633
**Example**

S
shawn_he 已提交
634
```js
S
shawn_he 已提交
635 636 637 638 639 640 641 642
sim.hasSimCard(0, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sim.hasSimCard<sup>7+</sup>

S
shawn_he 已提交
643
hasSimCard\(slotId: number\): Promise\<boolean\>
S
shawn_he 已提交
644

S
shawn_he 已提交
645
Checks whether the SIM card in the specified slot is installed. This API uses a promise to return the result.
S
shawn_he 已提交
646

S
shawn_he 已提交
647
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
648 649 650 651 652

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
S
shawn_he 已提交
653
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
654

S
shawn_he 已提交
655
**Return value**
S
shawn_he 已提交
656 657 658 659 660

| Type                 | Description                              |
| --------------------- | ---------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** indicates that the SIM card in the specified slot is installed, and the value **false** indicates the opposite.|

S
shawn_he 已提交
661 662
**Error codes**

S
shawn_he 已提交
663 664
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
665 666 667 668 669 670 671 672
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
673 674
**Example**

S
shawn_he 已提交
675
```js
S
shawn_he 已提交
676 677 678 679
let promise = sim.hasSimCard(0);
promise.then(data => {
    console.log(`hasSimCard success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
680
    console.log(`hasSimCard failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
681 682 683
});
```

S
shawn_he 已提交
684
## sim.getSimAccountInfo<sup>7+</sup>
S
shawn_he 已提交
685

S
shawn_he 已提交
686
getSimAccountInfo\(slotId: number, callback: AsyncCallback\<IccAccountInfo\>\): void
S
shawn_he 已提交
687

S
shawn_he 已提交
688
Obtains SIM card account information. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
689

S
shawn_he 已提交
690
**System API**: This is a system API.
S
shawn_he 已提交
691 692 693 694 695 696 697 698 699 700

**Required permission**: ohos.permission.GET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                                               | Mandatory| Description                                  |
| -------- | --------------------------------------------------- | ---- | -------------------------------------- |
| slotId   | number                                              | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
701
| callback | AsyncCallback\<[IccAccountInfo](#iccaccountinfo7)\> | Yes  | Callback used to return the result.                            |
S
shawn_he 已提交
702

S
shawn_he 已提交
703 704
**Error codes**

S
shawn_he 已提交
705 706
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
707 708 709
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
710
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
711 712 713 714 715 716 717 718
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
719 720 721 722 723 724 725 726 727 728 729
**Example**

```js
sim.getSimAccountInfo(0, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sim.getSimAccountInfo<sup>7+</sup>

S
shawn_he 已提交
730
getSimAccountInfo\(slotId: number\): Promise\<IccAccountInfo\>
S
shawn_he 已提交
731

S
shawn_he 已提交
732
Obtains SIM card account information. This API uses a promise to return the result.
S
shawn_he 已提交
733

S
shawn_he 已提交
734
**System API**: This is a system API.
S
shawn_he 已提交
735

S
shawn_he 已提交
736 737 738 739 740 741 742 743 744
**Required permission**: ohos.permission.GET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
745

S
shawn_he 已提交
746
**Return value**
S
shawn_he 已提交
747

S
shawn_he 已提交
748 749
| Type                                        | Description                                      |
| -------------------------------------------- | ------------------------------------------ |
S
shawn_he 已提交
750
| Promise<[IccAccountInfo](#iccaccountinfo7)\> | Promise used to return the result.|
S
shawn_he 已提交
751

S
shawn_he 已提交
752 753
**Error codes**

S
shawn_he 已提交
754 755
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
756 757 758
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
759
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
760 761 762 763 764 765 766 767
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
768 769
**Example**

S
shawn_he 已提交
770
```js
S
shawn_he 已提交
771 772 773 774
let promise = sim.getSimAccountInfo(0);
promise.then(data => {
    console.log(`getSimAccountInfo success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
775
    console.log(`getSimAccountInfo failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
776
});
S
shawn_he 已提交
777 778
```

S
shawn_he 已提交
779
## sim.getActiveSimAccountInfoList<sup>8+</sup>
S
shawn_he 已提交
780

S
shawn_he 已提交
781
getActiveSimAccountInfoList\(callback: AsyncCallback\<Array\<IccAccountInfo\>\>\): void
S
shawn_he 已提交
782

S
shawn_he 已提交
783 784
Obtains the account information list of the active SIM card. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
785
**System API**: This is a system API.
S
shawn_he 已提交
786 787

**Required permission**: ohos.permission.GET_TELEPHONY_STATE
S
shawn_he 已提交
788

S
shawn_he 已提交
789 790
**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
791
**Parameters**
S
shawn_he 已提交
792

S
shawn_he 已提交
793 794
| Name  | Type                                                       | Mandatory| Description      |
| -------- | ----------------------------------------------------------- | ---- | ---------- |
S
shawn_he 已提交
795
| callback | AsyncCallback\<Array<[IccAccountInfo](#iccaccountinfo7)\>\> | Yes  | Callback used to return the result.|
S
shawn_he 已提交
796

S
shawn_he 已提交
797 798
**Error codes**

S
shawn_he 已提交
799 800
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
801 802 803
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
804
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
805 806 807 808 809 810
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
811 812 813
**Example**

```js
S
shawn_he 已提交
814
sim.getActiveSimAccountInfoList((err, data) => {
S
shawn_he 已提交
815 816 817 818 819 820 821
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sim.getActiveSimAccountInfoList<sup>8+</sup>

S
shawn_he 已提交
822
getActiveSimAccountInfoList\(\): Promise\<Array\<IccAccountInfo\>\>;
S
shawn_he 已提交
823 824 825

Obtains the account information list of the active SIM card. This API uses a promise to return the result.

S
shawn_he 已提交
826
**System API**: This is a system API.
S
shawn_he 已提交
827 828

**Required permission**: ohos.permission.GET_TELEPHONY_STATE
S
shawn_he 已提交
829 830 831

**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
832 833 834 835
**Return value**

| Type                                                | Description                                          |
| ---------------------------------------------------- | ---------------------------------------------- |
S
shawn_he 已提交
836
| Promise<Array<[IccAccountInfo](#iccaccountinfo7)\>\> | Promise used to return the result.|
S
shawn_he 已提交
837

S
shawn_he 已提交
838 839
**Error codes**

S
shawn_he 已提交
840 841
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
842 843 844
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
845
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
846 847 848 849 850
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
851 852 853 854 855 856 857
**Example**

```js
let promise = sim.getActiveSimAccountInfoList();
promise.then(data => {
    console.log(`getActiveSimAccountInfoList success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
858
    console.log(`getActiveSimAccountInfoList failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
859 860 861 862 863
});
```

## sim.setDefaultVoiceSlotId<sup>7+</sup>

S
shawn_he 已提交
864
setDefaultVoiceSlotId\(slotId: number, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
865 866 867

Sets the default slot ID of the SIM card that provides voice services. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
868
**System API**: This is a system API.
S
shawn_he 已提交
869 870 871 872 873 874 875 876 877 878 879 880

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                     | Mandatory| Description                                                        |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| slotId   | number                    | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: Clears the default configuration.|
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                                  |

S
shawn_he 已提交
881 882
**Error codes**

S
shawn_he 已提交
883 884
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
885 886 887
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
888
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
889 890 891 892 893 894 895 896
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301001  | SIM card is not activated.                   |

S
shawn_he 已提交
897 898 899
**Example**

```js
S
shawn_he 已提交
900 901
sim.setDefaultVoiceSlotId(0, (err) => {
    console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
902 903 904 905 906 907
});
```


## sim.setDefaultVoiceSlotId<sup>7+</sup>

S
shawn_he 已提交
908
setDefaultVoiceSlotId\(slotId: number\): Promise\<void\>
S
shawn_he 已提交
909 910 911

Sets the default slot ID of the SIM card that provides voice services. This API uses a promise to return the result.

S
shawn_he 已提交
912
**System API**: This is a system API.
S
shawn_he 已提交
913 914 915 916 917 918 919 920 921 922 923 924 925

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                                        |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| slotId | number | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: Clears the default configuration.|

**Return value**

S
shawn_he 已提交
926 927 928
| Type           | Description                           |
| --------------- | ------------------------------- |
| Promise\<void\> | Promise used to return the result.|
S
shawn_he 已提交
929

S
shawn_he 已提交
930 931
**Error codes**

S
shawn_he 已提交
932 933
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
934 935 936
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
937
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
938 939 940 941 942 943 944 945
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301001  | SIM card is not activated.                   |

S
shawn_he 已提交
946 947 948 949
**Example**

```js
let promise = sim.setDefaultVoiceSlotId(0);
S
shawn_he 已提交
950 951 952
promise.then(() => {
    console.log(`setDefaultVoiceSlotId success.`);
}).catch((err) => {
S
shawn_he 已提交
953
    console.log(`setDefaultVoiceSlotId failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
954 955 956
});
```

S
shawn_he 已提交
957
## sim.setShowName<sup>8+</sup>
S
shawn_he 已提交
958

S
shawn_he 已提交
959
setShowName\(slotId: number, name: string, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
960 961 962

Sets a display name for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
963
**System API**: This is a system API.
S
shawn_he 已提交
964 965 966 967 968 969 970 971 972 973 974 975 976

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                     | Mandatory| Description                                  |
| -------- | ------------------------- | ---- | -------------------------------------- |
| slotId   | number                    | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| name     | string                    | Yes  | SIM card name.                             |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                            |

S
shawn_he 已提交
977 978
**Error codes**

S
shawn_he 已提交
979 980
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
981 982 983
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
984
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
985 986 987 988 989 990 991
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
992 993 994
**Example**

```js
S
shawn_he 已提交
995
let name = "ShowName";
S
shawn_he 已提交
996 997
sim.setShowName(0, name, (err) => {
    console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
998 999 1000
});
```

S
shawn_he 已提交
1001
## sim.setShowName<sup>8+</sup>
S
shawn_he 已提交
1002 1003 1004 1005 1006

setShowName\(slotId: number, name: string\): Promise\<void\>

Sets a display name for the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
1007
**System API**: This is a system API.
S
shawn_he 已提交
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| name   | string | Yes  | SIM card name.                             |

**Return value**

S
shawn_he 已提交
1022 1023 1024
| Type           | Description                           |
| --------------- | ------------------------------- |
| Promise\<void\> | Promise used to return the result.|
S
shawn_he 已提交
1025

S
shawn_he 已提交
1026 1027
**Error codes**

S
shawn_he 已提交
1028 1029
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1030 1031 1032
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1033
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1034 1035 1036 1037 1038 1039 1040
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1041 1042 1043
**Example**

```js
S
shawn_he 已提交
1044
let name = "ShowName";
S
shawn_he 已提交
1045
let promise = sim.setShowName(0, name);
S
shawn_he 已提交
1046 1047 1048
promise.then(() => {
    console.log(`setShowName success.`);
}).catch((err) => {
S
shawn_he 已提交
1049
    console.log(`setShowName failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1050 1051 1052
});
```

S
shawn_he 已提交
1053
## sim.getShowName<sup>8+</sup>
S
shawn_he 已提交
1054

S
shawn_he 已提交
1055
getShowName\(slotId: number, callback: AsyncCallback\<string\>\): void
S
shawn_he 已提交
1056 1057 1058

Obtains the name of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
1059
**System API**: This is a system API.
S
shawn_he 已提交
1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071

**Required permission**: ohos.permission.GET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                       | Mandatory| Description                                  |
| -------- | --------------------------- | ---- | -------------------------------------- |
| slotId   | number                      | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the result.                            |

S
shawn_he 已提交
1072 1073
**Error codes**

S
shawn_he 已提交
1074 1075
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1076 1077 1078
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1079
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1080 1081 1082 1083 1084 1085 1086
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1087 1088 1089 1090 1091 1092 1093 1094 1095
**Example**

```js
sim.getShowName(0, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


S
shawn_he 已提交
1096
## sim.getShowName<sup>8+</sup>
S
shawn_he 已提交
1097

S
shawn_he 已提交
1098
getShowName\(slotId: number\): Promise\<string\>
S
shawn_he 已提交
1099 1100 1101

Obtains the name of the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
1102
**System API**: This is a system API.
S
shawn_he 已提交
1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119

**Required permission**: ohos.permission.GET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|

**Return value**

| Type                 | Description                                  |
| --------------------- | -------------------------------------- |
| Promise&lt;string&gt; | Promise used to return the result.|

S
shawn_he 已提交
1120 1121
**Error codes**

S
shawn_he 已提交
1122 1123
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1124 1125 1126
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1127
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1128 1129 1130 1131 1132 1133 1134
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1135 1136 1137 1138 1139 1140 1141
**Example**

```js
let promise = sim.getShowName(0);
promise.then(data => {
    console.log(`getShowName success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1142
    console.log(`getShowName failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1143 1144 1145
});
```

S
shawn_he 已提交
1146
## sim.setShowNumber<sup>8+</sup>
S
shawn_he 已提交
1147

S
shawn_he 已提交
1148
setShowNumber\(slotId: number, number: string, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
1149 1150 1151

Sets a display number for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
1152
**System API**: This is a system API.
S
shawn_he 已提交
1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                     | Mandatory| Description                                  |
| -------- | ------------------------- | ---- | -------------------------------------- |
| slotId   | number                    | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| number   | string                    | Yes  | SIM card number.                             |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                            |

S
shawn_he 已提交
1166 1167
**Error codes**

S
shawn_he 已提交
1168 1169
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1170 1171 1172
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1173
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1174 1175 1176 1177 1178 1179 1180
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1181 1182 1183
**Example**

```js
S
shawn_he 已提交
1184
let number = '+861xxxxxxxxxx';
S
shawn_he 已提交
1185 1186
sim.setShowNumber(0, number, (err) => {
    console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1187 1188 1189 1190
});
```


S
shawn_he 已提交
1191
## sim.setShowNumber<sup>8+</sup>
S
shawn_he 已提交
1192

S
shawn_he 已提交
1193
setShowNumber\(slotId: number, number: string\): Promise\<void\>
S
shawn_he 已提交
1194 1195 1196

Sets a display number for the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
1197
**System API**: This is a system API.
S
shawn_he 已提交
1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| number | string | Yes  | SIM card number.                             |

**Return value**

| Type          | Description                           |
| -------------- | ------------------------------- |
S
shawn_he 已提交
1214
| Promise<void\> | Promise used to return the result.|
S
shawn_he 已提交
1215

S
shawn_he 已提交
1216 1217
**Error codes**

S
shawn_he 已提交
1218 1219
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1220 1221 1222
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1223
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1224 1225 1226 1227 1228 1229 1230
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1231 1232 1233
**Example**

```js
S
shawn_he 已提交
1234 1235
let number = '+861xxxxxxxxxx';
let promise = sim.setShowNumber(0, number);
S
shawn_he 已提交
1236 1237 1238
promise.then(() => {
    console.log(`setShowNumber success.`);
}).catch((err) => {
S
shawn_he 已提交
1239
    console.log(`setShowNumber failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1240 1241 1242
});
```

S
shawn_he 已提交
1243
## sim.getShowNumber<sup>8+</sup>
S
shawn_he 已提交
1244

S
shawn_he 已提交
1245
getShowNumber\(slotId: number, callback: AsyncCallback\<string\>): void
S
shawn_he 已提交
1246 1247 1248

Obtains the display number of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
1249
**System API**: This is a system API.
S
shawn_he 已提交
1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261

**Required permission**: ohos.permission.GET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                       | Mandatory| Description                                  |
| -------- | --------------------------- | ---- | -------------------------------------- |
| slotId   | number                      | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the result.                            |

S
shawn_he 已提交
1262 1263
**Error codes**

S
shawn_he 已提交
1264 1265
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1266 1267 1268
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1269
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1270 1271 1272 1273 1274 1275 1276
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1277 1278 1279 1280 1281 1282 1283 1284 1285
**Example**

```js
sim.getShowNumber(0, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


S
shawn_he 已提交
1286
## sim.getShowNumber<sup>8+</sup>
S
shawn_he 已提交
1287

S
shawn_he 已提交
1288
getShowNumber\(slotId: number\): Promise\<string\>
S
shawn_he 已提交
1289 1290 1291

Obtains the display number of the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
1292
**System API**: This is a system API.
S
shawn_he 已提交
1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309

**Required permission**: ohos.permission.GET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|

**Return value**

| Type                 | Description                             |
| --------------------- | --------------------------------- |
| Promise&lt;string&gt; | Promise used to return the result.|

S
shawn_he 已提交
1310 1311
**Error codes**

S
shawn_he 已提交
1312 1313
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1314 1315 1316
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1317
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1318 1319 1320 1321 1322 1323 1324
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1325 1326 1327 1328 1329 1330 1331
**Example**

```js
let promise = sim.getShowNumber(0);
promise.then(data => {
    console.log(`getShowNumber success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1332
    console.log(`getShowNumber failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1333 1334 1335
});
```

S
shawn_he 已提交
1336
## sim.activateSim<sup>8+</sup>
S
shawn_he 已提交
1337

S
shawn_he 已提交
1338
activateSim\(slotId: number, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
1339

S
shawn_he 已提交
1340
Activates a SIM card in a specified card slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
1341

S
shawn_he 已提交
1342
**System API**: This is a system API.
S
shawn_he 已提交
1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                     | Mandatory| Description                                  |
| -------- | ------------------------- | ---- | -------------------------------------- |
| slotId   | number                    | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                            |

S
shawn_he 已提交
1355 1356
**Error codes**

S
shawn_he 已提交
1357 1358
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1359 1360 1361
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1362
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1363 1364 1365 1366 1367 1368 1369
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1370 1371 1372
**Example**

```js
S
shawn_he 已提交
1373 1374
sim.activateSim(0, (err) => {
    console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1375 1376 1377 1378
});
```


S
shawn_he 已提交
1379
## sim.activateSim<sup>8+</sup>
S
shawn_he 已提交
1380

S
shawn_he 已提交
1381
activateSim\(slotId: number\): Promise\<void\>
S
shawn_he 已提交
1382 1383 1384

Activates the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
1385
**System API**: This is a system API.
S
shawn_he 已提交
1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|

**Return value**

S
shawn_he 已提交
1399 1400 1401
| Type           | Description                           |
| --------------- | ------------------------------- |
| Promise\<void\> | Promise used to return the result.|
S
shawn_he 已提交
1402

S
shawn_he 已提交
1403 1404
**Error codes**

S
shawn_he 已提交
1405 1406
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1407 1408 1409
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1410
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1411 1412 1413 1414 1415 1416 1417
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1418 1419 1420 1421
**Example**

```js
let promise = sim.activateSim(0);
S
shawn_he 已提交
1422 1423 1424
promise.then(() => {
    console.log(`activateSim success.`);
}).catch((err) => {
S
shawn_he 已提交
1425
    console.log(`activateSim failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1426 1427 1428
});
```

S
shawn_he 已提交
1429
## sim.deactivateSim<sup>8+</sup>
S
shawn_he 已提交
1430

S
shawn_he 已提交
1431
deactivateSim\(slotId: number, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
1432

S
shawn_he 已提交
1433
Disables the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
1434

S
shawn_he 已提交
1435
**System API**: This is a system API.
S
shawn_he 已提交
1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                     | Mandatory| Description                                  |
| -------- | ------------------------- | ---- | -------------------------------------- |
| slotId   | number                    | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                            |

S
shawn_he 已提交
1448 1449
**Error codes**

S
shawn_he 已提交
1450 1451
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1452 1453 1454
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1455
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1456 1457 1458 1459 1460 1461 1462
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1463 1464 1465
**Example**

```js
S
shawn_he 已提交
1466 1467
sim.deactivateSim(0, (err) => {
    console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1468 1469 1470 1471
});
```


S
shawn_he 已提交
1472
## sim.deactivateSim<sup>8+</sup>
S
shawn_he 已提交
1473

S
shawn_he 已提交
1474
deactivateSim\(slotId: number\): Promise\<void\>
S
shawn_he 已提交
1475

S
shawn_he 已提交
1476
Disables the SIM card in the specified slot. This API uses a promise to return the result.
S
shawn_he 已提交
1477

S
shawn_he 已提交
1478
**System API**: This is a system API.
S
shawn_he 已提交
1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|

**Return value**

S
shawn_he 已提交
1492 1493
| Type           | Description                           |
| --------------- | ------------------------------- |
S
shawn_he 已提交
1494
| Promise\<void\> | Promise used to return the result.|
S
shawn_he 已提交
1495

S
shawn_he 已提交
1496 1497
**Error codes**

S
shawn_he 已提交
1498 1499
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1500 1501 1502
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1503
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1504 1505 1506 1507 1508 1509 1510
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
1511 1512 1513 1514
**Example**

```js
let promise = sim.deactivateSim(0);
S
shawn_he 已提交
1515 1516 1517
promise.then(() => {
    console.log(`deactivateSim success.`);
}).catch((err) => {
S
shawn_he 已提交
1518
    console.log(`deactivateSim failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1519 1520 1521 1522 1523
});
```

## sim.setLockState<sup>7+</sup>

S
shawn_he 已提交
1524
setLockState\(slotId: number, options: LockInfo, callback: AsyncCallback\<LockStatusResponse\>\): void
S
shawn_he 已提交
1525 1526 1527

Sets the lock status of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
1528
**System API**: This is a system API.
S
shawn_he 已提交
1529 1530 1531 1532 1533 1534 1535 1536 1537 1538

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                                                       | Mandatory| Description                                                        |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| slotId   | number                                                      | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                      |
S
shawn_he 已提交
1539
| callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | Yes  | Callback used to return the result.                                                  |
S
shawn_he 已提交
1540 1541 1542 1543
| options  | [LockInfo](#lockinfo8)                                      | Yes  | Lock information.<br>- lockType: [LockType](#locktype8)<br>- password: string<br>- state: [LockState](#lockstate8) |

**Error codes**

S
shawn_he 已提交
1544 1545
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1546 1547 1548
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1549
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1550 1551 1552 1553 1554 1555 1556
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |
S
shawn_he 已提交
1557 1558 1559 1560

**Example**

```js
S
shawn_he 已提交
1561
let lockInfo = {
S
shawn_he 已提交
1562
    lockType: sim.LockType.PIN_LOCK,
S
shawn_he 已提交
1563
    password: "1234",
S
shawn_he 已提交
1564
    state: sim.LockState.LOCK_OFF
S
shawn_he 已提交
1565 1566
};
sim.setLockState(0, lockInfo, (err, data) => {
S
shawn_he 已提交
1567 1568 1569 1570 1571 1572 1573
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sim.setLockState<sup>7+</sup>

S
shawn_he 已提交
1574
setLockState\(slotId: number, options: LockInfo\): Promise\<LockStatusResponse\>
S
shawn_he 已提交
1575 1576 1577

Sets the lock status of the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
1578
**System API**: This is a system API.
S
shawn_he 已提交
1579 1580 1581 1582 1583 1584 1585 1586 1587 1588

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name | Type                  | Mandatory| Description                                                        |
| ------- | ---------------------- | ---- | ------------------------------------------------------------ |
| slotId  | number                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                      |
S
shawn_he 已提交
1589
| options | [LockInfo](#lockinfo8) | Yes  | Lock information.<br>- lockType: [LockType](#locktype8)<br>- password: string<br>- state: [LockState](#lockstate8) |
S
shawn_he 已提交
1590 1591 1592 1593 1594

**Return value**

| Type                                                | Description                                        |
| ---------------------------------------------------- | -------------------------------------------- |
S
shawn_he 已提交
1595
| Promise<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
S
shawn_he 已提交
1596

S
shawn_he 已提交
1597 1598
**Error codes**

S
shawn_he 已提交
1599 1600
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1601 1602 1603
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1604
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1605 1606 1607 1608 1609 1610 1611 1612
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
1613 1614 1615
**Example**

```js
S
shawn_he 已提交
1616
let lockInfo = {
S
shawn_he 已提交
1617
    lockType: sim.LockType.PIN_LOCK,
S
shawn_he 已提交
1618
    password: "1234",
S
shawn_he 已提交
1619
    state: sim.LockState.LOCK_OFF
S
shawn_he 已提交
1620 1621
};
let promise = sim.setLockState(0, lockInfo);
S
shawn_he 已提交
1622 1623 1624
promise.then(data => {
    console.log(`setLockState success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1625
    console.log(`setLockState failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1626 1627 1628 1629 1630
});
```

## sim.getLockState<sup>8+</sup>

S
shawn_he 已提交
1631
getLockState\(slotId: number, lockType: LockType, callback: AsyncCallback\<LockState\>\): void
S
shawn_he 已提交
1632 1633 1634

Obtains the lock status of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
1635
**System API**: This is a system API.
S
shawn_he 已提交
1636

S
shawn_he 已提交
1637 1638
**Required permission**: ohos.permission.GET_TELEPHONY_STATE

S
shawn_he 已提交
1639 1640 1641 1642 1643 1644 1645
**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                                     | Mandatory| Description                                   |
| -------- | ----------------------------------------- | ---- | --------------------------------------- |
| slotId   | number                                    | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
S
shawn_he 已提交
1646 1647
| callback | AsyncCallback\<[LockState](#lockstate8)\> | Yes  | Callback used to return the result.                             |
| options  | [LockType](#locktype8)                    | Yes  | Lock type.<br>- **1**: PIN lock<br>- **2**: PIN 2 lock|
S
shawn_he 已提交
1648

S
shawn_he 已提交
1649 1650
**Error codes**

S
shawn_he 已提交
1651 1652
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1653 1654 1655
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1656
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1657 1658 1659 1660 1661 1662 1663 1664
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675
**Example**

```js
sim.getLockState(0, 1, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sim.getLockState<sup>8+</sup>

S
shawn_he 已提交
1676
getLockState\(slotId: number, lockType: LockType\): Promise\<LockState\>
S
shawn_he 已提交
1677 1678 1679

Obtains the lock status of the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
1680
**System API**: This is a system API.
S
shawn_he 已提交
1681

S
shawn_he 已提交
1682 1683
**Required permission**: ohos.permission.GET_TELEPHONY_STATE

S
shawn_he 已提交
1684 1685 1686 1687 1688 1689 1690
**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name | Type                  | Mandatory| Description                                   |
| ------- | ---------------------- | ---- | --------------------------------------- |
| slotId  | number                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
S
shawn_he 已提交
1691
| options | [LockType](#locktype8) | Yes  | Lock type.<br>- **1**: PIN lock<br>- **2**: PIN 2 lock|
S
shawn_he 已提交
1692 1693 1694 1695 1696

**Return value**

| Type                              | Description                                        |
| ---------------------------------- | -------------------------------------------- |
S
shawn_he 已提交
1697
| Promise<[LockState](#lockstate8)\> | Promise used to return the result.|
S
shawn_he 已提交
1698

S
shawn_he 已提交
1699 1700
**Error codes**

S
shawn_he 已提交
1701 1702
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1703 1704 1705
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1706
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1707 1708 1709 1710 1711 1712 1713 1714
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
1715 1716 1717 1718 1719 1720 1721
**Example**

```js
let promise = sim.getLockState(0, 1);
promise.then(data => {
    console.log(`getLockState success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1722
    console.log(`getLockState failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1723 1724 1725 1726 1727
});
```

## sim.alterPin<sup>7+</sup>

S
shawn_he 已提交
1728
alterPin\(slotId: number, newPin: string, oldPin: string, callback: AsyncCallback\<LockStatusResponse\>\): void
S
shawn_he 已提交
1729

S
shawn_he 已提交
1730
Changes the PIN of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
1731

S
shawn_he 已提交
1732
**System API**: This is a system API.
S
shawn_he 已提交
1733 1734 1735 1736 1737 1738 1739 1740 1741 1742

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                                                       | Mandatory| Description                                  |
| -------- | ----------------------------------------------------------- | ---- | -------------------------------------- |
| slotId   | number                                                      | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
1743
| callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | Yes  | Callback used to return the result.                            |
S
shawn_he 已提交
1744 1745 1746
| newPin   | string                                                      | Yes  | New PIN.                              |
| oldPin   | string                                                      | Yes  | Old PIN.                              |

S
shawn_he 已提交
1747 1748
**Error codes**

S
shawn_he 已提交
1749 1750
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1751 1752 1753
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1754
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1755 1756 1757 1758 1759 1760 1761 1762
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
1763 1764 1765
**Example**

```js
S
shawn_he 已提交
1766
sim.alterPin(0, "1234", "0000", (err, data) => {
S
shawn_he 已提交
1767 1768 1769 1770 1771 1772 1773
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sim.alterPin<sup>7+</sup>

S
shawn_he 已提交
1774
alterPin\(slotId: number, newPin: string, oldPin: string\): Promise\<LockStatusResponse\>;
S
shawn_he 已提交
1775

S
shawn_he 已提交
1776
Changes the PIN of the SIM card in the specified slot. This API uses a promise to return the result.
S
shawn_he 已提交
1777

S
shawn_he 已提交
1778
**System API**: This is a system API.
S
shawn_he 已提交
1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| newPin | string | Yes  | New PIN.                              |
| oldPin | string | Yes  | Old PIN.                              |

**Return value**

| Type                                                | Description                                         |
| ---------------------------------------------------- | --------------------------------------------- |
S
shawn_he 已提交
1796
| Promise<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
S
shawn_he 已提交
1797

S
shawn_he 已提交
1798 1799
**Error codes**

S
shawn_he 已提交
1800 1801
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1802 1803 1804
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1805
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1806 1807 1808 1809 1810 1811 1812 1813
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
1814 1815 1816 1817 1818 1819 1820
**Example**

```js
let promise = sim.alterPin(0, "1234", "0000");
promise.then(data => {
    console.log(`alterPin success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1821
    console.log(`alterPin failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1822 1823 1824 1825 1826
});
```

## sim.alterPin2<sup>8+</sup>

S
shawn_he 已提交
1827
alterPin2\(slotId: number, newPin2: string, oldPin2: string, callback: AsyncCallback\<LockStatusResponse\>\): void
S
shawn_he 已提交
1828

S
shawn_he 已提交
1829
Changes PIN 2 of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
1830

S
shawn_he 已提交
1831
**System API**: This is a system API.
S
shawn_he 已提交
1832 1833 1834 1835 1836 1837 1838 1839 1840 1841

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                                                       | Mandatory| Description                                  |
| -------- | ----------------------------------------------------------- | ---- | -------------------------------------- |
| slotId   | number                                                      | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
1842
| callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | Yes  | Callback used to return the result.                            |
S
shawn_he 已提交
1843 1844 1845
| newPin2  | string                                                      | Yes  | New PIN.                              |
| oldPin2  | string                                                      | Yes  | Old PIN.                              |

S
shawn_he 已提交
1846 1847
**Error codes**

S
shawn_he 已提交
1848 1849
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1850 1851 1852
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1853
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1854 1855 1856 1857 1858 1859 1860 1861
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872
**Example**

```js
sim.alterPin2(0, "1234", "0000", (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sim.alterPin2<sup>8+</sup>

S
shawn_he 已提交
1873
alterPin2\(slotId: number, newPin2: string, oldPin2: string\): Promise\<LockStatusResponse\>
S
shawn_he 已提交
1874

S
shawn_he 已提交
1875
Changes PIN 2 of the SIM card in the specified slot. This API uses a promise to return the result.
S
shawn_he 已提交
1876

S
shawn_he 已提交
1877
**System API**: This is a system API.
S
shawn_he 已提交
1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name | Type  | Mandatory| Description                                  |
| ------- | ------ | ---- | -------------------------------------- |
| slotId  | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| newPin2 | string | Yes  | New PIN.                              |
| oldPin2 | string | Yes  | Old PIN.                              |

**Return value**

| Type                                                | Description                                         |
| ---------------------------------------------------- | --------------------------------------------- |
S
shawn_he 已提交
1895
| Promise<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
S
shawn_he 已提交
1896

S
shawn_he 已提交
1897 1898
**Error codes**

S
shawn_he 已提交
1899 1900
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1901 1902 1903
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1904
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1905 1906 1907 1908 1909 1910 1911 1912
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
1913 1914 1915
**Example**

```js
S
shawn_he 已提交
1916
let promise = sim.alterPin2(0, "1234", "0000");
S
shawn_he 已提交
1917 1918 1919
promise.then(data => {
    console.log(`alterPin2 success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
1920
    console.log(`alterPin2 failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
1921 1922 1923
});
```

S
shawn_he 已提交
1924
## sim.unlockPin<sup>7+</sup>
S
shawn_he 已提交
1925

S
shawn_he 已提交
1926
unlockPin\(slotId: number, pin: string, callback: AsyncCallback\<LockStatusResponse\>\): void
S
shawn_he 已提交
1927

S
shawn_he 已提交
1928
Unlocks the PIN of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
1929

S
shawn_he 已提交
1930
**System API**: This is a system API.
S
shawn_he 已提交
1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                                                        | Mandatory| Description                                  |
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
| slotId   | number                                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| pin      | string                                                       | Yes  | PIN of the SIM card.                           |
S
shawn_he 已提交
1942
| callback | AsyncCallback&lt;[LockStatusResponse](#lockstatusresponse7)> | Yes  | Callback used to return the result.                            |
S
shawn_he 已提交
1943

S
shawn_he 已提交
1944 1945
**Error codes**

S
shawn_he 已提交
1946 1947
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1948 1949 1950
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
1951
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
1952 1953 1954 1955 1956 1957 1958 1959
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
1960 1961 1962
**Example**

```js
S
shawn_he 已提交
1963 1964
let pin = '1234';
sim.unlockPin(0, pin, (err, data) => {
S
shawn_he 已提交
1965 1966 1967 1968 1969
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


S
shawn_he 已提交
1970
## sim.unlockPin<sup>7+</sup>
S
shawn_he 已提交
1971

S
shawn_he 已提交
1972
unlockPin\(slotId: number, pin: string\): Promise\<LockStatusResponse\>
S
shawn_he 已提交
1973 1974 1975

Unlocks the PIN of the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
1976
**System API**: This is a system API.
S
shawn_he 已提交
1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| pin    | string | Yes  | PIN of the SIM card.                           |

**Return value**

| Type                                                | Description                                              |
| ---------------------------------------------------- | -------------------------------------------------- |
S
shawn_he 已提交
1993
| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
S
shawn_he 已提交
1994

S
shawn_he 已提交
1995 1996
**Error codes**

S
shawn_he 已提交
1997 1998
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
1999 2000 2001
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2002
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2003 2004 2005 2006 2007 2008 2009 2010
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
2011 2012 2013
**Example**

```js
S
shawn_he 已提交
2014 2015
let pin = '1234';
let promise = sim.unlockPin(0, pin);
S
shawn_he 已提交
2016 2017 2018
promise.then(data => {
    console.log(`unlockPin success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
2019
    console.log(`unlockPin failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
2020 2021 2022
});
```

S
shawn_he 已提交
2023
## sim.unlockPuk<sup>7+</sup>
S
shawn_he 已提交
2024

S
shawn_he 已提交
2025
unlockPuk\(slotId: number, newPin: string, puk: string, callback: AsyncCallback\<LockStatusResponse\>\): void
S
shawn_he 已提交
2026 2027 2028

Unlocks the PUK of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
2029
**System API**: This is a system API.
S
shawn_he 已提交
2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                                                        | Mandatory| Description                                  |
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
| slotId   | number                                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| newPin   | string                                                       | Yes  | New PIN.                       |
| puk      | string                                                       | Yes  | PUK of the SIM card.                   |
S
shawn_he 已提交
2042
| callback | AsyncCallback&lt;[LockStatusResponse](#lockstatusresponse7)&gt; | Yes  | Callback used to return the result.                            |
S
shawn_he 已提交
2043

S
shawn_he 已提交
2044 2045
**Error codes**

S
shawn_he 已提交
2046 2047
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2048 2049 2050
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2051
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2052 2053 2054 2055 2056 2057 2058 2059
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
2060 2061 2062
**Example**

```js
S
shawn_he 已提交
2063 2064 2065
let puk = '1xxxxxxx';
let newPin = '1235';
sim.unlockPuk(0, newPin, puk, (err, data) => {
S
shawn_he 已提交
2066 2067 2068 2069 2070
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


S
shawn_he 已提交
2071
## sim.unlockPuk<sup>7+</sup>
S
shawn_he 已提交
2072

S
shawn_he 已提交
2073
unlockPuk\(slotId: number, newPin: string, puk: string\): Promise\<LockStatusResponse\>
S
shawn_he 已提交
2074 2075 2076

Unlocks the PUK of the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
2077
**System API**: This is a system API.
S
shawn_he 已提交
2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| newPin | string | Yes  | New PIN.                       |
| puk    | string | Yes  | PUK of the SIM card.                   |

**Return value**

| Type                                                | Description                                              |
| ---------------------------------------------------- | -------------------------------------------------- |
S
shawn_he 已提交
2095
| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
S
shawn_he 已提交
2096

S
shawn_he 已提交
2097 2098
**Error codes**

S
shawn_he 已提交
2099 2100
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2101 2102 2103
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2104
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2105 2106 2107 2108 2109 2110 2111 2112
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
2113 2114 2115
**Example**

```js
S
shawn_he 已提交
2116 2117 2118
let puk = '1xxxxxxx';
let newPin = '1235';
let promise = sim.unlockPuk(0, newPin, puk);
S
shawn_he 已提交
2119 2120 2121
promise.then(data => {
    console.log(`unlockPuk success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
2122
    console.log(`unlockPuk failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
2123 2124 2125
});
```

S
shawn_he 已提交
2126
## sim.unlockPin2<sup>8+</sup>
S
shawn_he 已提交
2127

S
shawn_he 已提交
2128
unlockPin2\(slotId: number, pin2: string, callback: AsyncCallback\<LockStatusResponse\>\): void
S
shawn_he 已提交
2129

S
shawn_he 已提交
2130
Unlocks the PIN of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
2131

S
shawn_he 已提交
2132
**System API**: This is a system API.
S
shawn_he 已提交
2133 2134 2135 2136 2137 2138 2139 2140 2141 2142

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                                                        | Mandatory| Description                                  |
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
| slotId   | number                                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
2143
| pin2     | string                                                       | Yes  | PIN of the SIM card.                           |
S
shawn_he 已提交
2144
| callback | AsyncCallback&lt;[LockStatusResponse](#lockstatusresponse7)&gt; | Yes  | Callback used to return the result.                            |
S
shawn_he 已提交
2145

S
shawn_he 已提交
2146 2147
**Error codes**

S
shawn_he 已提交
2148 2149
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2150 2151 2152
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2153
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2154 2155 2156 2157 2158 2159 2160 2161
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
2162 2163 2164
**Example**

```js
S
shawn_he 已提交
2165 2166
let pin2 = '1234';
sim.unlockPin2(0, pin2, (err, data) => {
S
shawn_he 已提交
2167 2168 2169 2170 2171
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


S
shawn_he 已提交
2172
## sim.unlockPin2<sup>8+</sup>
S
shawn_he 已提交
2173

S
shawn_he 已提交
2174
unlockPin2\(slotId: number, pin2: string\): Promise\<LockStatusResponse\>
S
shawn_he 已提交
2175

S
shawn_he 已提交
2176
Unlocks the PIN of the SIM card in the specified slot. This API uses a promise to return the result.
S
shawn_he 已提交
2177

S
shawn_he 已提交
2178
**System API**: This is a system API.
S
shawn_he 已提交
2179 2180 2181 2182 2183 2184 2185 2186 2187 2188

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
2189
| pin2   | string | Yes  | PIN of the SIM card.                           |
S
shawn_he 已提交
2190 2191 2192 2193 2194

**Return value**

| Type                                                 | Description                                              |
| ----------------------------------------------------- | -------------------------------------------------- |
S
shawn_he 已提交
2195
| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
S
shawn_he 已提交
2196

S
shawn_he 已提交
2197 2198
**Error codes**

S
shawn_he 已提交
2199 2200
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2201 2202 2203
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2204
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2205 2206 2207 2208 2209 2210 2211 2212
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
2213 2214 2215 2216
**Example**

```js
let pin2='1234';
S
shawn_he 已提交
2217
let promise = sim.unlockPin2(0, pin2);
S
shawn_he 已提交
2218 2219 2220
promise.then(data => {
    console.log(`unlockPin2 success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
2221
    console.log(`unlockPin2 failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
2222 2223 2224
});
```

S
shawn_he 已提交
2225
## sim.unlockPuk2<sup>8+</sup>
S
shawn_he 已提交
2226

S
shawn_he 已提交
2227
unlockPuk2\(slotId: number, newPin2: string, puk2: string, callback: AsyncCallback\<LockStatusResponse\>\): void
S
shawn_he 已提交
2228

S
shawn_he 已提交
2229
Unlocks the PUK of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
2230

S
shawn_he 已提交
2231
**System API**: This is a system API.
S
shawn_he 已提交
2232 2233 2234 2235 2236 2237 2238 2239 2240 2241

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                                                        | Mandatory| Description                                  |
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
| slotId   | number                                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
2242
| newPin2  | string                                                       | Yes  | New PIN 2.                       |
S
shawn_he 已提交
2243
| puk2     | string                                                       | Yes  | PUK of the SIM card.                   |
S
shawn_he 已提交
2244
| callback | AsyncCallback&lt;[LockStatusResponse](#lockstatusresponse7)&gt; | Yes  | Callback used to return the result.                            |
S
shawn_he 已提交
2245

S
shawn_he 已提交
2246 2247
**Error codes**

S
shawn_he 已提交
2248 2249
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
2261 2262 2263
**Example**

```js
S
shawn_he 已提交
2264 2265 2266
let puk2 = '1xxxxxxx';
let newPin2 = '1235';
sim.unlockPuk2(0, newPin2, puk2, (err, data) => {
S
shawn_he 已提交
2267 2268 2269 2270 2271
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


S
shawn_he 已提交
2272
## sim.unlockPuk2<sup>8+</sup>
S
shawn_he 已提交
2273

S
shawn_he 已提交
2274
unlockPuk2\(slotId: number, newPin2: string, puk2: string\): Promise\<LockStatusResponse\>
S
shawn_he 已提交
2275

S
shawn_he 已提交
2276
Unlocks the PUK of the SIM card in the specified slot. This API uses a promise to return the result.
S
shawn_he 已提交
2277

S
shawn_he 已提交
2278
**System API**: This is a system API.
S
shawn_he 已提交
2279 2280 2281 2282 2283 2284 2285 2286 2287 2288

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name | Type  | Mandatory| Description                                  |
| ------- | ------ | ---- | -------------------------------------- |
| slotId  | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
2289
| newPin2 | string | Yes  | New PIN 2.                       |
S
shawn_he 已提交
2290
| puk2    | string | Yes  | PUK of the SIM card.                   |
S
shawn_he 已提交
2291 2292 2293 2294 2295

**Return value**

| Type                                                | Description                                              |
| ---------------------------------------------------- | -------------------------------------------------- |
S
shawn_he 已提交
2296
| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
S
shawn_he 已提交
2297

S
shawn_he 已提交
2298 2299
**Error codes**

S
shawn_he 已提交
2300 2301
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
2313 2314 2315
**Example**

```js
S
shawn_he 已提交
2316 2317 2318
let puk2 = '1xxxxxxx';
let newPin2 = '1235';
let promise = sim.unlockPuk2(0, newPin2, puk2);
S
shawn_he 已提交
2319 2320 2321
promise.then(data => {
    console.log(`unlockPuk2 success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
2322
    console.log(`unlockPuk2 failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345
});
```

## sim.getMaxSimCount<sup>7+</sup>

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())
```

S
shawn_he 已提交
2346
## sim.getSimIccId<sup>7+</sup>
S
shawn_he 已提交
2347

S
shawn_he 已提交
2348
getSimIccId\(slotId: number, callback: AsyncCallback\<string\>\): void
S
shawn_he 已提交
2349

S
shawn_he 已提交
2350
Obtains the ICCID of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
2351

S
shawn_he 已提交
2352
**System API**: This is a system API.
S
shawn_he 已提交
2353 2354

**Required permission**: ohos.permission.GET_TELEPHONY_STATE
S
shawn_he 已提交
2355 2356 2357

**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
2358
**Parameters**
S
shawn_he 已提交
2359

S
shawn_he 已提交
2360 2361 2362 2363 2364
| Name  | Type                  | Mandatory| Description                                  |
| -------- | ---------------------- | ---- | -------------------------------------- |
| slotId   | number                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback<string\> | Yes  | Callback used to return the result.                            |

S
shawn_he 已提交
2365 2366
**Error codes**

S
shawn_he 已提交
2367 2368
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2369 2370 2371
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2372
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2373 2374 2375 2376 2377 2378 2379
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390
**Example**

```js
sim.getSimIccId(0, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sim.getSimIccId<sup>7+</sup>

S
shawn_he 已提交
2391
getSimIccId\(slotId: number\): Promise\<string\>
S
shawn_he 已提交
2392 2393

Obtains the ICCID of the SIM card in the specified slot. This API uses a promise to return the result.
S
shawn_he 已提交
2394

S
shawn_he 已提交
2395
**System API**: This is a system API.
S
shawn_he 已提交
2396 2397

**Required permission**: ohos.permission.GET_TELEPHONY_STATE
S
shawn_he 已提交
2398 2399 2400

**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
2401
**Parameters**
S
shawn_he 已提交
2402

S
shawn_he 已提交
2403 2404 2405
| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
2406

S
shawn_he 已提交
2407 2408 2409 2410 2411 2412
**Return value**

| Type            | Description                                       |
| ---------------- | ------------------------------------------- |
| Promise<string\> | Promise used to return the result.|

S
shawn_he 已提交
2413 2414
**Error codes**

S
shawn_he 已提交
2415 2416
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2417 2418 2419
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2420
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2421 2422 2423 2424 2425 2426 2427
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
2428 2429 2430 2431 2432 2433 2434
**Example**

```js
let promise = sim.getSimIccId(0);
promise.then(data => {
    console.log(`getSimIccId success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
2435
    console.log(`getSimIccId failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
2436 2437 2438 2439 2440
});
```

## sim.getVoiceMailIdentifier<sup>8+</sup>

S
shawn_he 已提交
2441
getVoiceMailIdentifier\(slotId: number, callback: AsyncCallback\<string\>\): void
S
shawn_he 已提交
2442 2443

Obtains the voice mailbox alpha identifier of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
2444

S
shawn_he 已提交
2445
**System API**: This is a system API.
S
shawn_he 已提交
2446

S
shawn_he 已提交
2447 2448
**Required permission**: ohos.permission.GET_TELEPHONY_STATE

S
shawn_he 已提交
2449 2450
**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
2451
**Parameters**
S
shawn_he 已提交
2452

S
shawn_he 已提交
2453 2454 2455 2456 2457
| Name  | Type                  | Mandatory| Description                                  |
| -------- | ---------------------- | ---- | -------------------------------------- |
| slotId   | number                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback<string\> | Yes  | Callback used to return the result.                            |

S
shawn_he 已提交
2458 2459
**Error codes**

S
shawn_he 已提交
2460 2461
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2462 2463 2464
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2465
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2466 2467 2468 2469 2470 2471 2472
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
2473 2474 2475 2476 2477 2478 2479
**Example**

```js
sim.getVoiceMailIdentifier(0, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
2480

S
shawn_he 已提交
2481 2482 2483

## sim.getVoiceMailIdentifier<sup>8+</sup>

S
shawn_he 已提交
2484
getVoiceMailIdentifier\(slotId: number\): Promise\<string\>
S
shawn_he 已提交
2485 2486

Obtains the voice mailbox alpha identifier of the SIM card in the specified slot. This API uses a promise to return the result.
S
shawn_he 已提交
2487

S
shawn_he 已提交
2488
**System API**: This is a system API.
S
shawn_he 已提交
2489

S
shawn_he 已提交
2490 2491
**Required permission**: ohos.permission.GET_TELEPHONY_STATE

S
shawn_he 已提交
2492 2493
**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
2494 2495 2496 2497 2498
**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
2499

S
shawn_he 已提交
2500
**Return value**
S
shawn_he 已提交
2501

S
shawn_he 已提交
2502 2503 2504 2505
| Type            | Description                                             |
| ---------------- | ------------------------------------------------- |
| Promise<string\> | Promise used to return the result.|

S
shawn_he 已提交
2506 2507
**Error codes**

S
shawn_he 已提交
2508 2509
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2510 2511 2512
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2513
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2514 2515 2516 2517 2518 2519 2520
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
2521 2522 2523 2524 2525 2526 2527
**Example**

```js
let promise = sim.getVoiceMailIdentifier(0);
promise.then(data => {
    console.log(`getVoiceMailIdentifier success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
2528
    console.log(`getVoiceMailIdentifier failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
2529 2530 2531 2532 2533
});
```

## sim.getVoiceMailNumber<sup>8+</sup>

S
shawn_he 已提交
2534
getVoiceMailNumber\(slotId: number, callback: AsyncCallback\<string\>): void
S
shawn_he 已提交
2535 2536

Obtains the voice mailbox number of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
2537

S
shawn_he 已提交
2538
**System API**: This is a system API.
S
shawn_he 已提交
2539

S
shawn_he 已提交
2540 2541
**Required permission**: ohos.permission.GET_TELEPHONY_STATE

S
shawn_he 已提交
2542 2543
**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
2544
**Parameters**
S
shawn_he 已提交
2545

S
shawn_he 已提交
2546 2547 2548 2549
| Name  | Type                  | Mandatory| Description                                  |
| -------- | ---------------------- | ---- | -------------------------------------- |
| slotId   | number                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback<string\> | Yes  | Callback used to return the result.                            |
S
shawn_he 已提交
2550

S
shawn_he 已提交
2551 2552
**Error codes**

S
shawn_he 已提交
2553 2554
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2555 2556 2557
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2558
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2559 2560 2561 2562 2563 2564 2565
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576
**Example**

```js
sim.getVoiceMailNumber(0, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sim.getVoiceMailNumber<sup>8+</sup>

S
shawn_he 已提交
2577
getVoiceMailNumber\(slotId: number\): Promise\<string\>
S
shawn_he 已提交
2578 2579

Obtains the voice mailbox number of the SIM card in the specified slot. This API uses a promise to return the result.
S
shawn_he 已提交
2580

S
shawn_he 已提交
2581
**System API**: This is a system API.
S
shawn_he 已提交
2582

S
shawn_he 已提交
2583 2584
**Required permission**: ohos.permission.GET_TELEPHONY_STATE

S
shawn_he 已提交
2585 2586
**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598
**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|

**Return value**

| Type            | Description                                            |
| ---------------- | ------------------------------------------------ |
| Promise<string\> | Promise used to return the result.|

S
shawn_he 已提交
2599 2600
**Error codes**

S
shawn_he 已提交
2601 2602
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2603 2604 2605
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2606
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2607 2608 2609 2610 2611 2612 2613
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
2614 2615 2616 2617 2618 2619 2620
**Example**

```js
let promise = sim.getVoiceMailNumber(0);
promise.then(data => {
    console.log(`getVoiceMailNumber success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
2621
    console.log(`getVoiceMailNumber failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
2622 2623 2624
});
```

S
shawn_he 已提交
2625

S
shawn_he 已提交
2626
## sim.setVoiceMailInfo<sup>8+</sup>
S
shawn_he 已提交
2627

S
shawn_he 已提交
2628
setVoiceMailInfo\(slotId: number, mailName: string, mailNumber: string, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
2629

S
shawn_he 已提交
2630
Sets voice mailbox information for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
2631

S
shawn_he 已提交
2632
**System API**: This is a system API.
S
shawn_he 已提交
2633

S
shawn_he 已提交
2634 2635
**Required permission**: ohos.permission.SET_TELEPHONY_STATE

S
shawn_he 已提交
2636 2637
**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
2638
**Parameters**
S
shawn_he 已提交
2639

S
shawn_he 已提交
2640 2641 2642 2643 2644 2645
| Name    | Type                | Mandatory| Description                                  |
| ---------- | -------------------- | ---- | -------------------------------------- |
| slotId     | number               | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| mailName   | string               | Yes  | Voice mailbox name.                              |
| mailNumber | string               | Yes  | Voice mailbox number.                              |
| callback   | AsyncCallback<void\> | Yes  | Callback used to return the result.                            |
S
shawn_he 已提交
2646

S
shawn_he 已提交
2647 2648
**Error codes**

S
shawn_he 已提交
2649 2650
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2651 2652 2653
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2654
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2655 2656 2657 2658 2659 2660 2661 2662
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
2663 2664 2665
**Example**

```js
S
shawn_he 已提交
2666 2667
sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com", (err) => {
    console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
2668 2669 2670 2671 2672 2673
});
```


## sim.setVoiceMailInfo<sup>8+</sup>

S
shawn_he 已提交
2674
setVoiceMailInfo\(slotId: number, mailName: string, mailNumber: string\): Promise\<void\>
S
shawn_he 已提交
2675 2676

Sets voice mailbox information for the SIM card in the specified slot. This API uses a promise to return the result.
S
shawn_he 已提交
2677

S
shawn_he 已提交
2678
**System API**: This is a system API.
S
shawn_he 已提交
2679

S
shawn_he 已提交
2680 2681
**Required permission**: ohos.permission.SET_TELEPHONY_STATE

S
shawn_he 已提交
2682 2683
**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
2684
**Parameters**
S
shawn_he 已提交
2685

S
shawn_he 已提交
2686 2687 2688 2689 2690
| Name    | Type  | Mandatory| Description                                  |
| ---------- | ------ | ---- | -------------------------------------- |
| slotId     | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| mailName   | string | Yes  | Voice mailbox name.                              |
| mailNumber | string | Yes  | Voice mailbox number.                              |
S
shawn_he 已提交
2691

S
shawn_he 已提交
2692 2693 2694 2695 2696 2697
**Return value**

| Type          | Description                   |
| -------------- | ----------------------- |
| Promise<void\> | Promise used to return the result.|

S
shawn_he 已提交
2698 2699
**Error codes**

S
shawn_he 已提交
2700 2701
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2702 2703 2704
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2705
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2706 2707 2708 2709 2710 2711 2712 2713
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
2714 2715 2716 2717
**Example**

```js
let promise = sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com");
S
shawn_he 已提交
2718 2719 2720
promise.then(() => {
    console.log(`setVoiceMailInfo success.`);
}).catch((err) => {
S
shawn_he 已提交
2721
    console.log(`setVoiceMailInfo failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
2722 2723 2724 2725 2726
});
```

## sim.getSimTelephoneNumber<sup>8+</sup>

S
shawn_he 已提交
2727
getSimTelephoneNumber\(slotId: number, callback: AsyncCallback\<string\>\): void
S
shawn_he 已提交
2728

S
shawn_he 已提交
2729
Obtains the MSISDN of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
2730

S
shawn_he 已提交
2731
**System API**: This is a system API.
S
shawn_he 已提交
2732

S
shawn_he 已提交
2733 2734
**Required permission**: ohos.permission.GET_TELEPHONY_STATE

S
shawn_he 已提交
2735 2736
**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
2737 2738 2739 2740 2741 2742 2743
**Parameters**

| Name  | Type                  | Mandatory| Description                                  |
| -------- | ---------------------- | ---- | -------------------------------------- |
| slotId   | number                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback<string\> | Yes  | Callback used to return the result.                            |

S
shawn_he 已提交
2744 2745
**Error codes**

S
shawn_he 已提交
2746 2747
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2748 2749 2750
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2751
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2752 2753 2754 2755 2756 2757 2758
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769
**Example**

```js
sim.getSimTelephoneNumber(0, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sim.getSimTelephoneNumber<sup>8+</sup>

S
shawn_he 已提交
2770
getSimTelephoneNumber\(slotId: number\): Promise\<string\>
S
shawn_he 已提交
2771 2772 2773

Obtains the MSISDN of the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
2774
**System API**: This is a system API.
S
shawn_he 已提交
2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791

**Required permission**: ohos.permission.GET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|

**Return value**

| Type            | Description                                        |
| ---------------- | -------------------------------------------- |
| Promise<string\> | Promise used to return the result.|

S
shawn_he 已提交
2792 2793
**Error codes**

S
shawn_he 已提交
2794 2795
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2796 2797 2798
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2799
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2800 2801 2802 2803 2804 2805 2806
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
2807 2808 2809 2810 2811 2812 2813
**Example**

```js
let promise = sim.getSimTelephoneNumber(0);
promise.then(data => {
    console.log(`getSimTelephoneNumber success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
2814
    console.log(`getSimTelephoneNumber failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
2815 2816 2817 2818 2819
});
```

## sim.getSimGid1<sup>7+</sup>

S
shawn_he 已提交
2820
getSimGid1\(slotId: number, callback: AsyncCallback\<string\>\): void
S
shawn_he 已提交
2821 2822 2823

Obtains the group identifier level 1 (GID1) of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
2824
**System API**: This is a system API.
S
shawn_he 已提交
2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836

**Required permission**: ohos.permission.GET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                   | Mandatory| Description                                  |
| -------- | ----------------------- | ---- | -------------------------------------- |
| slotId   | number                  | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<string\> | Yes  | Callback used to return the result.                            |

S
shawn_he 已提交
2837 2838
**Error codes**

S
shawn_he 已提交
2839 2840
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2841 2842 2843
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2844
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2845 2846 2847 2848 2849 2850 2851
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862
**Example**

```js
sim.getSimGid1(0, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sim.getSimGid1<sup>7+</sup>

S
shawn_he 已提交
2863
getSimGid1\(slotId: number\): Promise\<string\>
S
shawn_he 已提交
2864 2865 2866

Obtains the GID1 of the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
2867
**System API**: This is a system API.
S
shawn_he 已提交
2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884

**Required permission**: ohos.permission.GET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|

**Return value**

| Type            | Description                                             |
| ---------------- | ------------------------------------------------- |
| Promise<string\> | Promise used to return the result.|

S
shawn_he 已提交
2885 2886
**Error codes**

S
shawn_he 已提交
2887 2888
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2889 2890 2891
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2892
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2893 2894 2895 2896 2897 2898 2899
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
2900 2901 2902 2903 2904 2905 2906
**Example**

```js
let promise = sim.getSimGid1(0);
promise.then(data => {
    console.log(`getSimGid1 success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
2907
    console.log(`getSimGid1 failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
2908 2909 2910 2911 2912
});
```

## sim.getIMSI

S
shawn_he 已提交
2913
getIMSI\(slotId: number, callback: AsyncCallback\<string\>\): void
S
shawn_he 已提交
2914 2915 2916

Obtains the international mobile subscriber identity (IMSI) of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
2917
**System API**: This is a system API.
S
shawn_he 已提交
2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929

**Required permission**: ohos.permission.GET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                   | Mandatory| Description                                  |
| -------- | ----------------------- | ---- | -------------------------------------- |
| slotId   | number                  | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<string\> | Yes  | Callback used to return the result.                            |

S
shawn_he 已提交
2930 2931
**Error codes**

S
shawn_he 已提交
2932 2933
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2934 2935 2936
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2937
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2938 2939 2940 2941 2942 2943 2944
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955
**Example**

```js
sim.getIMSI(0, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sim.getIMSI

S
shawn_he 已提交
2956
getIMSI\(slotId: number\): Promise\<string\>
S
shawn_he 已提交
2957 2958 2959

Obtains the IMSI of the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
2960
**System API**: This is a system API.
S
shawn_he 已提交
2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977

**Required permission**: ohos.permission.GET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|

**Return value**

| Type            | Description                                       |
| ---------------- | ------------------------------------------- |
| Promise<string\> | Promise used to return the result.|

S
shawn_he 已提交
2978 2979
**Error codes**

S
shawn_he 已提交
2980 2981
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
2982 2983 2984
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
2985
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
2986 2987 2988 2989 2990 2991 2992
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
2993 2994 2995 2996 2997 2998 2999
**Example**

```js
let promise = sim.getIMSI(0);
promise.then(data => {
    console.log(`getIMSI success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
3000
    console.log(`getIMSI failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
3001 3002 3003 3004 3005
});
```

## sim.getOperatorConfigs<sup>8+</sup>

S
shawn_he 已提交
3006
getOperatorConfigs\(slotId: number, callback: AsyncCallback\<Array\<OperatorConfig\>\>\): void
S
shawn_he 已提交
3007 3008 3009

Obtains the carrier configuration of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
3010
**System API**: This is a system API.
S
shawn_he 已提交
3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022

**Required permission**: ohos.permission.GET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                                                     | Mandatory| Description                                  |
| -------- | --------------------------------------------------------- | ---- | -------------------------------------- |
| slotId   | number                                                    | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback<Array<[OperatorConfig](#operatorconfig8)\>> | Yes  | Callback used to return the result.                            |

S
shawn_he 已提交
3023 3024
**Error codes**

S
shawn_he 已提交
3025 3026
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3027 3028 3029
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
3030
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
3031 3032 3033 3034 3035 3036
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047
**Example**

```js
sim.getOperatorConfigs(0, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sim.getOperatorConfigs<sup>8+</sup>

S
shawn_he 已提交
3048
getOperatorConfigs\(slotId: number\): Promise\<Array\<OperatorConfig\>\>
S
shawn_he 已提交
3049 3050 3051

Obtains the carrier configuration of the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
3052
**System API**: This is a system API.
S
shawn_he 已提交
3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069

**Required permission**: ohos.permission.GET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|

**Return value**

| Type                                               | Description                         |
| --------------------------------------------------- | ----------------------------- |
| Promise<Array<[OperatorConfig](#operatorconfig8)\>> | Promise used to return the result.|

S
shawn_he 已提交
3070 3071
**Error codes**

S
shawn_he 已提交
3072 3073
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3074 3075 3076
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
3077
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
3078 3079 3080 3081 3082 3083
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
3084 3085 3086 3087 3088 3089 3090
**Example**

```js
let promise = sim.getOperatorConfigs(0);
promise.then(data => {
    console.log(`getOperatorConfigs success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
3091
    console.log(`getOperatorConfigs failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
3092 3093 3094 3095 3096
});
```

## sim.queryIccDiallingNumbers<sup>8+</sup>

S
shawn_he 已提交
3097
queryIccDiallingNumbers\(slotId: number, type: ContactType, callback: AsyncCallback\<Array\<DiallingNumbersInfo\>\>\): void
S
shawn_he 已提交
3098 3099 3100

Queries contact numbers of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
3101
**System API**: This is a system API.
S
shawn_he 已提交
3102 3103 3104 3105 3106 3107 3108 3109 3110 3111

**Permission required**: ohos.permission.READ_CONTACTS

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                                                        | Mandatory| Description                                                      |
| -------- | ------------------------------------------------------------ | ---- | ---------------------------------------------------------- |
| slotId   | number                                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                    |
S
shawn_he 已提交
3112 3113 3114 3115 3116
| type     | [ContactType](#contacttype8)                                 | Yes  | Contact type.<br>- **1**: GENERAL_CONTACT<br>- **2**: FIXED_DIALING|
| callback | AsyncCallback<Array<[DiallingNumbersInfo](#diallingnumbersinfo8)\>> | Yes  | Callback used to return the result.                                         |

**Error codes**

S
shawn_he 已提交
3117 3118
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3119 3120 3121
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
3122
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
3123 3124 3125 3126 3127 3128 3129
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |
S
shawn_he 已提交
3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141

**Example**

```js
sim.queryIccDiallingNumbers(0, 1, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sim.queryIccDiallingNumbers<sup>8+</sup>

S
shawn_he 已提交
3142
queryIccDiallingNumbers\(slotId: number, type: ContactType\): Promise\<Array\<DiallingNumbersInfo\>\>
S
shawn_he 已提交
3143 3144 3145

Queries contact numbers of the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
3146
**System API**: This is a system API.
S
shawn_he 已提交
3147 3148 3149 3150 3151 3152 3153 3154 3155 3156

**Permission required**: ohos.permission.READ_CONTACTS

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type       | Mandatory| Description                                                      |
| ------ | ----------- | ---- | ---------------------------------------------------------- |
| slotId | number      | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                    |
S
shawn_he 已提交
3157
| type   | [ContactType](#contacttype8)  | Yes  | Contact type.<br>- **1**: GENERAL_CONTACT<br>- **2**: FIXED_DIALING|
S
shawn_he 已提交
3158 3159 3160 3161 3162

**Return value**

| Type                                                        | Description                          |
| ------------------------------------------------------------ | ------------------------------ |
S
shawn_he 已提交
3163 3164 3165 3166
| Promise<Array<[DiallingNumbersInfo](#diallingnumbersinfo8)\>> | Promise used to return the result.|

**Error codes**

S
shawn_he 已提交
3167 3168
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3169 3170 3171
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
3172
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
3173 3174 3175 3176 3177 3178 3179
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |
S
shawn_he 已提交
3180 3181 3182 3183 3184 3185 3186 3187

**Example**

```js
let promise = sim.queryIccDiallingNumbers(0, 1);
promise.then(data => {
    console.log(`queryIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
3188
    console.log(`queryIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
3189 3190 3191 3192 3193
});
```

## sim.addIccDiallingNumbers<sup>8+</sup>

S
shawn_he 已提交
3194
addIccDiallingNumbers\(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
3195 3196 3197

Adds contact numbers for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
3198
**System API**: This is a system API.
S
shawn_he 已提交
3199 3200 3201 3202 3203 3204 3205 3206 3207 3208

**Permission required**: ohos.permission.WRITE_CONTACTS

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name         | Type                                        | Mandatory| Description                                                      |
| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
| slotId          | number                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                    |
S
shawn_he 已提交
3209
| type            | [ContactType](#contacttype8)                 | Yes  | Contact type.<br>- **1**: GENERAL_CONTACT<br>- **2**: FIXED_DIALING |
S
shawn_he 已提交
3210 3211 3212
| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes  | Contact number information.                                              |
| callback        | AsyncCallback<void\>                         | Yes  | Callback used to return the result.                                                  |

S
shawn_he 已提交
3213 3214
**Error codes**

S
shawn_he 已提交
3215 3216
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3217 3218 3219
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
3220
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
3221 3222 3223 3224 3225 3226 3227 3228
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
3229 3230 3231 3232
**Example**

```js
let diallingNumbersInof = {
S
shawn_he 已提交
3233 3234 3235
    alphaTag: "alpha",
    number: "138xxxxxxxx",
    pin2: "1234"
S
shawn_he 已提交
3236
};
S
shawn_he 已提交
3237 3238
sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err) => {
    console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
3239 3240 3241 3242 3243 3244
});
```


## sim.addIccDiallingNumbers<sup>8+</sup>

S
shawn_he 已提交
3245
addIccDiallingNumbers\(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo\): Promise\<void\>
S
shawn_he 已提交
3246 3247 3248

Adds contact numbers for the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
3249
**System API**: This is a system API.
S
shawn_he 已提交
3250 3251 3252 3253 3254 3255 3256 3257 3258 3259

**Permission required**: ohos.permission.WRITE_CONTACTS

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name         | Type                                        | Mandatory| Description                                                      |
| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
| slotId          | number                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                    |
S
shawn_he 已提交
3260
| type            | [ContactType](#contacttype8)                 | Yes  | Contact type.<br>- **1**: GENERAL_CONTACT<br>- **2**: FIXED_DIALING |
S
shawn_he 已提交
3261 3262 3263 3264 3265 3266
| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes  | Contact number information.                                              |

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
S
shawn_he 已提交
3267 3268 3269 3270
| Promise<void\> | Promise used to return the result.|

**Error codes**

S
shawn_he 已提交
3271 3272
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3273 3274 3275
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
3276
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
3277 3278 3279 3280 3281 3282 3283
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |
S
shawn_he 已提交
3284 3285 3286 3287 3288

**Example**

```js
let diallingNumbersInof = {
S
shawn_he 已提交
3289
    alphaTag: "alpha",
S
shawn_he 已提交
3290
    number: "138xxxxxxxx"
S
shawn_he 已提交
3291
};
S
shawn_he 已提交
3292
let promise = sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof);
S
shawn_he 已提交
3293 3294 3295
promise.then(() => {
    console.log(`addIccDiallingNumbers success.`);
}).catch((err) => {
S
shawn_he 已提交
3296
    console.log(`addIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
3297 3298 3299 3300 3301
});
```

## sim.delIccDiallingNumbers<sup>8+</sup>

S
shawn_he 已提交
3302
delIccDiallingNumbers\(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
3303 3304 3305

Deletes contact numbers from the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
3306
**System API**: This is a system API.
S
shawn_he 已提交
3307 3308 3309 3310 3311 3312 3313 3314 3315 3316

**Permission required**: ohos.permission.WRITE_CONTACTS

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name         | Type                                        | Mandatory| Description                                                      |
| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
| slotId          | number                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                    |
S
shawn_he 已提交
3317
| type            | [ContactType](#contacttype8)                 | Yes  | Contact type.<br>- **1**: GENERAL_CONTACT<br>- **2**: FIXED_DIALING |
S
shawn_he 已提交
3318 3319 3320
| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes  | Contact number information.                                              |
| callback        | AsyncCallback<void\>                         | Yes  | Callback used to return the result.                                                  |

S
shawn_he 已提交
3321 3322
**Error codes**

S
shawn_he 已提交
3323 3324
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3325 3326 3327
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
3328
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
3329 3330 3331 3332 3333 3334 3335 3336
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
3337 3338 3339 3340
**Example**

```js
let diallingNumbersInof = {
S
shawn_he 已提交
3341
    alphaTag: "alpha",
S
shawn_he 已提交
3342 3343 3344
    number: "138xxxxxxxx",
    recordNumber: 123,
    pin2: "1234"
S
shawn_he 已提交
3345
};
S
shawn_he 已提交
3346 3347
sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err) => {
    console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
3348 3349 3350 3351 3352 3353
});
```


## sim.delIccDiallingNumbers<sup>8+</sup>

S
shawn_he 已提交
3354
delIccDiallingNumbers\(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo\): Promise\<void\>
S
shawn_he 已提交
3355 3356 3357

Deletes contact numbers from the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
3358
**System API**: This is a system API.
S
shawn_he 已提交
3359 3360 3361 3362 3363 3364 3365 3366 3367 3368

**Permission required**: ohos.permission.WRITE_CONTACTS

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name         | Type                                        | Mandatory| Description                                                      |
| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
| slotId          | number                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                    |
S
shawn_he 已提交
3369
| type            | [ContactType](#contacttype8)                 | Yes  | Contact type.<br>- **1**: GENERAL_CONTACT<br>- **2**: FIXED_DIALING |
S
shawn_he 已提交
3370 3371 3372 3373 3374 3375
| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes  | Contact number information.                                              |

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
S
shawn_he 已提交
3376 3377 3378 3379
| Promise<void\> | Promise used to return the result.|

**Error codes**

S
shawn_he 已提交
3380 3381
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3382 3383 3384
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
3385
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
3386 3387 3388 3389 3390 3391 3392
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |
S
shawn_he 已提交
3393 3394 3395 3396 3397

**Example**

```js
let diallingNumbersInof = {
S
shawn_he 已提交
3398
    alphaTag: "alpha",
S
shawn_he 已提交
3399
    number: "138xxxxxxxx"
S
shawn_he 已提交
3400
};
S
shawn_he 已提交
3401
let promise = sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof);
S
shawn_he 已提交
3402 3403 3404
promise.then(() => {
    console.log(`delIccDiallingNumbers success.`);
}).catch((err) => {
S
shawn_he 已提交
3405
    console.log(`delIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
3406 3407 3408 3409 3410
});
```

## sim.updateIccDiallingNumbers<sup>8+</sup>

S
shawn_he 已提交
3411
updateIccDiallingNumbers\(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
3412 3413 3414

Updates contact numbers for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
3415
**System API**: This is a system API.
S
shawn_he 已提交
3416 3417 3418 3419 3420 3421 3422 3423 3424 3425

**Permission required**: ohos.permission.WRITE_CONTACTS

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name         | Type                                        | Mandatory| Description                                                      |
| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
| slotId          | number                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                    |
S
shawn_he 已提交
3426
| type            | [ContactType](#contacttype8)                 | Yes  | Contact type.<br>- **1**: GENERAL_CONTACT<br>- **2**: FIXED_DIALING |
S
shawn_he 已提交
3427 3428 3429
| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes  | Contact number information.                                              |
| callback        | AsyncCallback<void\>                         | Yes  | Callback used to return the result.                                                  |

S
shawn_he 已提交
3430 3431
**Error codes**

S
shawn_he 已提交
3432 3433
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3434 3435 3436
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
3437
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
3438 3439 3440 3441 3442 3443 3444 3445
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
3446 3447 3448 3449
**Example**

```js
let diallingNumbersInof = {
S
shawn_he 已提交
3450
    alphaTag: "alpha",
S
shawn_he 已提交
3451 3452 3453
    number: "138xxxxxxxx",
    recordNumber: 123,
    pin2: "1234"
S
shawn_he 已提交
3454
};
S
shawn_he 已提交
3455 3456
sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err) => {
    console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
3457 3458 3459 3460 3461 3462
});
```


## sim.updateIccDiallingNumbers<sup>8+</sup>

S
shawn_he 已提交
3463
updateIccDiallingNumbers\(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo\): Promise\<void\>
S
shawn_he 已提交
3464 3465 3466

Updates contact numbers for the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
3467
**System API**: This is a system API.
S
shawn_he 已提交
3468 3469 3470 3471 3472 3473 3474 3475 3476 3477

**Permission required**: ohos.permission.WRITE_CONTACTS

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name         | Type                                        | Mandatory| Description                                                      |
| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
| slotId          | number                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                    |
S
shawn_he 已提交
3478
| type            | [ContactType](#contacttype8)                 | Yes  | Contact type.<br>- **1**: GENERAL_CONTACT<br>- **2**: FIXED_DIALING |
S
shawn_he 已提交
3479 3480 3481 3482 3483 3484 3485 3486
| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes  | Contact number information.                                              |

**Return value**

| Type          | Description                         |
| -------------- | ----------------------------- |
| Promise<void\> | Promise used to return the result.|

S
shawn_he 已提交
3487 3488
**Error codes**

S
shawn_he 已提交
3489 3490
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3491 3492 3493
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
3494
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
3495 3496 3497 3498 3499 3500 3501 3502
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
3503 3504 3505 3506
**Example**

```js
let diallingNumbersInof = {
S
shawn_he 已提交
3507 3508
    alphaTag: "alpha",
    number: "138xxxxxxxx",
S
shawn_he 已提交
3509
    recordNumber: 123
S
shawn_he 已提交
3510
};
S
shawn_he 已提交
3511
let promise = sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof);
S
shawn_he 已提交
3512 3513 3514
promise.then(() => {
    console.log(`updateIccDiallingNumbers success.`);
}).catch((err) => {
S
shawn_he 已提交
3515
    console.log(`updateIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
3516 3517 3518 3519 3520
});
```

## sim.sendEnvelopeCmd<sup>8+</sup>

S
shawn_he 已提交
3521
sendEnvelopeCmd\(slotId: number, cmd: string, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
3522 3523 3524

Sends an envelope command to the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
3525
**System API**: This is a system API.
S
shawn_he 已提交
3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                | Mandatory| Description                                  |
| -------- | -------------------- | ---- | -------------------------------------- |
| slotId   | number               | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| cmd      | string               | Yes  | Envelope command.                                  |
S
shawn_he 已提交
3537 3538 3539 3540
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.                                    |

**Error codes**

S
shawn_he 已提交
3541 3542
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3543 3544 3545
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
3546
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
3547 3548 3549 3550 3551 3552
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
S
shawn_he 已提交
3553 3554 3555 3556

**Example**

```js
S
shawn_he 已提交
3557 3558
sim.sendEnvelopeCmd(0, "ls", (err) => {
    console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
3559 3560 3561 3562 3563 3564
});
```


## sim.sendEnvelopeCmd<sup>8+</sup>

S
shawn_he 已提交
3565
sendEnvelopeCmd\(slotId: number, cmd: string\): Promise\<void\>
S
shawn_he 已提交
3566 3567 3568

Sends an envelope command to the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
3569
**System API**: This is a system API.
S
shawn_he 已提交
3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| cmd    | string | Yes  | Envelope command.                                  |

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|

S
shawn_he 已提交
3588 3589
**Error codes**

S
shawn_he 已提交
3590 3591
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3592 3593 3594
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
3595
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
3596 3597 3598 3599 3600 3601 3602
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
3603 3604 3605 3606
**Example**

```js
let promise = sim.sendEnvelopeCmd(0, "ls");
S
shawn_he 已提交
3607 3608 3609
promise.then(() => {
    console.log(`sendEnvelopeCmd success.`);
}).catch((err) => {
S
shawn_he 已提交
3610
    console.log(`sendEnvelopeCmd failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
3611 3612 3613 3614 3615
});
```

## sim.sendTerminalResponseCmd<sup>8+</sup>

S
shawn_he 已提交
3616
sendTerminalResponseCmd\(slotId: number, cmd: string, callback: AsyncCallback\<void\>\): void
S
shawn_he 已提交
3617 3618 3619

Sends a terminal response command to the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
3620
**System API**: This is a system API.
S
shawn_he 已提交
3621 3622 3623 3624 3625 3626 3627 3628 3629 3630

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                | Mandatory| Description                                  |
| -------- | -------------------- | ---- | -------------------------------------- |
| slotId   | number               | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
3631
| cmd      | string               | Yes  | Envelope command.                                  |
S
shawn_he 已提交
3632 3633
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.                            |

S
shawn_he 已提交
3634 3635
**Error codes**

S
shawn_he 已提交
3636 3637
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3638 3639 3640
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
3641
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
3642 3643 3644 3645 3646 3647 3648
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
3649 3650 3651
**Example**

```js
S
shawn_he 已提交
3652 3653
sim.sendTerminalResponseCmd(0, "ls", (err) => {
    console.log(`callback: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
3654 3655 3656 3657 3658 3659
});
```


## sim.sendTerminalResponseCmd<sup>8+</sup>

S
shawn_he 已提交
3660
sendTerminalResponseCmd\(slotId: number, cmd: string\): Promise\<void\>
S
shawn_he 已提交
3661 3662 3663

Sends a terminal response command to the SIM card in the specified slot. This API uses a promise to return the result.

S
shawn_he 已提交
3664
**System API**: This is a system API.
S
shawn_he 已提交
3665 3666 3667 3668 3669 3670 3671 3672 3673 3674

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
3675
| cmd    | string | Yes  | Envelope command.                                  |
S
shawn_he 已提交
3676 3677 3678 3679 3680 3681 3682

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|

S
shawn_he 已提交
3683 3684
**Error codes**

S
shawn_he 已提交
3685 3686
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3687 3688 3689
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
3690
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
3691 3692 3693 3694 3695 3696 3697
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
3698 3699 3700 3701
**Example**

```js
let promise = sim.sendTerminalResponseCmd(0, "ls");
S
shawn_he 已提交
3702 3703 3704
promise.then(() => {
    console.log(`sendTerminalResponseCmd success.`);
}).catch((err) => {
S
shawn_he 已提交
3705
    console.log(`sendTerminalResponseCmd failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
3706 3707 3708
});
```

S
shawn_he 已提交
3709

S
shawn_he 已提交
3710 3711
## sim.unlockSimLock<sup>8+</sup>

S
shawn_he 已提交
3712
unlockSimLock\(slotId: number, lockInfo: PersoLockInfo, callback: AsyncCallback\<LockStatusResponse\>\): void
S
shawn_he 已提交
3713

S
shawn_he 已提交
3714
Unlocks the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
3715

S
shawn_he 已提交
3716
**System API**: This is a system API.
S
shawn_he 已提交
3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                                                      | Mandatory| Description                                  |
| -------- | ---------------------------------------------------------- | ---- | -------------------------------------- |
| slotId   | number                                                     | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| lockInfo | [PersoLockInfo](#persolockinfo8)                           | Yes  | Personalized lock information.                        |
| callback | AsyncCallback<[LockStatusResponse](#lockstatusresponse7)\> | Yes  | Callback used to return the result.                              |

S
shawn_he 已提交
3730 3731
**Error codes**

S
shawn_he 已提交
3732 3733
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3734 3735 3736
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
3737
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
3738 3739 3740 3741 3742 3743 3744 3745
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
3746 3747 3748 3749
**Example**

```js
let persoLockInfo = {
S
shawn_he 已提交
3750 3751
    lockType: sim.PersoLockType.PN_PIN_LOCK,
    password: "1234"
S
shawn_he 已提交
3752 3753 3754 3755 3756 3757 3758 3759 3760
};
sim.unlockSimLock(0, persoLockInfo, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## sim.unlockSimLock<sup>8+</sup>

S
shawn_he 已提交
3761
unlockSimLock\(slotId: number, lockInfo: PersoLockInfo\): Promise\<LockStatusResponse\>
S
shawn_he 已提交
3762

S
shawn_he 已提交
3763
Unlocks the SIM card in the specified slot. This API uses a promise to return the result.
S
shawn_he 已提交
3764

S
shawn_he 已提交
3765
**System API**: This is a system API.
S
shawn_he 已提交
3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783

**Required permission**: ohos.permission.SET_TELEPHONY_STATE

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                            | Mandatory| Description                                  |
| -------- | -------------------------------- | ---- | -------------------------------------- |
| slotId   | number                           | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| lockInfo | [PersoLockInfo](#persolockinfo8) | Yes  | Personalized lock information.                        |

**Return value**

| Type                                                | Description                     |
| ---------------------------------------------------- | ------------------------- |
| Promise<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|

S
shawn_he 已提交
3784 3785
**Error codes**

S
shawn_he 已提交
3786 3787
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3788 3789 3790
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 201      | Permission denied.                           |
S
shawn_he 已提交
3791
| 202      | Non-system applications use system APIs.     |
S
shawn_he 已提交
3792 3793 3794 3795 3796 3797 3798 3799
| 401      | Parameter error.                             |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300004  | Do not have sim card.                        |
| 8300999  | Unknown error code.                          |
| 8301002  | SIM card operation error.                    |

S
shawn_he 已提交
3800 3801 3802 3803
**Example**

```js
let persoLockInfo = {
S
shawn_he 已提交
3804 3805
    lockType: sim.PersoLockType.PN_PIN_LOCK,
    password: "1234"
S
shawn_he 已提交
3806 3807 3808 3809 3810
};
let promise = sim.unlockSimLock(0, persoLockInfo);
promise.then(data => {
    console.log(`unlockSimLock success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
S
shawn_he 已提交
3811
    console.log(`unlockSimLock failed, promise: err->${JSON.stringify(err)}`);
S
shawn_he 已提交
3812 3813 3814 3815 3816
});
```

## sim.getOpKey<sup>9+</sup>

S
shawn_he 已提交
3817
getOpKey\(slotId: number, callback: AsyncCallback\<string\>): void
S
shawn_he 已提交
3818 3819 3820 3821 3822 3823 3824 3825 3826 3827

Obtains the opkey of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                  | Mandatory| Description                                  |
| -------- | ---------------------- | ---- | -------------------------------------- |
| slotId   | number                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
3828 3829 3830 3831
| callback | AsyncCallback<string\> | Yes  | Callback used to return the result.                            |

**Error codes**

S
shawn_he 已提交
3832 3833
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3834 3835 3836 3837 3838 3839 3840 3841
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 801      | Capability not supported.                    |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |
S
shawn_he 已提交
3842 3843 3844 3845

**Example**

```js
S
shawn_he 已提交
3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856
try {
    sim.getOpKey(0, (err, data) => {
    if (err) {
      console.log("getOpKey failed, err: " + JSON.stringify(err));
    } else {
      console.log('getOpKey successfully, data: ' + JSON.stringify(data));
    }
  });
} catch (err) {
  console.log("getOpKey err: " + JSON.stringify(err));
}
S
shawn_he 已提交
3857 3858 3859 3860 3861
```


## sim.getOpKey<sup>9+</sup>

S
shawn_he 已提交
3862
getOpKey\(slotId: number\): Promise\<string\>
S
shawn_he 已提交
3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877

Obtains the opkey of the SIM card in the specified slot. This API uses a promise to return the result.

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|

**Return value**

| Type            | Description                                     |
| ---------------- | ----------------------------------------- |
S
shawn_he 已提交
3878
| Promise<string\> | Promise used to return the result.|
S
shawn_he 已提交
3879

S
shawn_he 已提交
3880 3881
**Error codes**

S
shawn_he 已提交
3882 3883
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3884 3885 3886 3887 3888 3889 3890 3891 3892
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 801      | Capability not supported.                    |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
3893 3894 3895
**Example**

```js
S
shawn_he 已提交
3896 3897
try {
    let data = sim.getOpKey(0);
S
shawn_he 已提交
3898
    console.log(`getOpKey success, promise: data->${JSON.stringify(data)}`);
S
shawn_he 已提交
3899 3900 3901
} catch (error) {
    console.log(`getOpKey failed, promise: err->${JSON.stringify(error)}`);
}
S
shawn_he 已提交
3902 3903 3904 3905
```

## sim.getOpName<sup>9+</sup>

S
shawn_he 已提交
3906
getOpName\(slotId: number, callback: AsyncCallback\<string\>\): void
S
shawn_he 已提交
3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918

Obtains the OpName of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                  | Mandatory| Description                                  |
| -------- | ---------------------- | ---- | -------------------------------------- |
| slotId   | number                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback<string\> | Yes  | Callback used to return the result.                              |

S
shawn_he 已提交
3919 3920
**Error codes**

S
shawn_he 已提交
3921 3922
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3923 3924 3925 3926 3927 3928 3929 3930 3931
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 801      | Capability not supported.                    |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
3932 3933 3934
**Example**

```js
S
shawn_he 已提交
3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945
try {
    sim.getOpName(0, (err, data) => {
    if (err) {
      console.log("getOpName failed, err: " + JSON.stringify(err));
    } else {
      console.log('getOpName successfully, data: ' + JSON.stringify(data));
    }
  });
} catch (err) {
  console.log("getOpName err: " + JSON.stringify(err));
}
S
shawn_he 已提交
3946 3947 3948 3949 3950
```


## sim.getOpName<sup>9+</sup>

S
shawn_he 已提交
3951
getOpName\(slotId: number\): Promise\<string\>
S
shawn_he 已提交
3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968

Obtains the OpName of the SIM card in the specified slot. This API uses a promise to return the result.

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|

**Return value**

| Type            | Description                                      |
| ---------------- | ------------------------------------------ |
| Promise<string\> | Promise used to return the result.|

S
shawn_he 已提交
3969 3970
**Error codes**

S
shawn_he 已提交
3971 3972
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).

S
shawn_he 已提交
3973 3974 3975 3976 3977 3978 3979 3980 3981
| ID|                 Error Message                    |
| -------- | -------------------------------------------- |
| 401      | Parameter error.                             |
| 801      | Capability not supported.                    |
| 8300001  | Invalid parameter value.                     |
| 8300002  | Operation failed. Cannot connect to service. |
| 8300003  | System internal error.                       |
| 8300999  | Unknown error code.                          |

S
shawn_he 已提交
3982 3983 3984
**Example**

```js
S
shawn_he 已提交
3985 3986
try {
    let data = sim.getOpName(0);
S
shawn_he 已提交
3987
    console.log(`getOpName success, promise: data->${JSON.stringify(data)}`);
S
shawn_he 已提交
3988 3989 3990
} catch (error) {
    console.log(`getOpName failed, promise: err->${JSON.stringify(error)}`);
}
S
shawn_he 已提交
3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015
```

## 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.|

## CardType<sup>7+</sup>

Enumerates SIM card types.

**System capability**: SystemCapability.Telephony.CoreService

| Name| Value| Description|
| ----- | ----- | ----- |
S
shawn_he 已提交
4016 4017 4018 4019 4020 4021 4022 4023 4024 4025
|UNKNOWN_CARD | -1 | Unknown type.|
|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_CARD<sup>8+</sup> | 60 | Single-card (ISIM).|
S
shawn_he 已提交
4026 4027 4028 4029 4030

## LockType<sup>8+</sup>

Enumerates lock types.

S
shawn_he 已提交
4031
**System API**: This is a system API.
S
shawn_he 已提交
4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043

**System capability**: SystemCapability.Telephony.CoreService

| Name    | Value  | Description       |
| -------- | ---- | ----------- |
| PIN_LOCK | 1    | SIM card password lock.|
| FDN_LOCK | 2    | Fixed dialing lock. |

## LockState<sup>8+</sup>

Enumerates lock states.

S
shawn_he 已提交
4044
**System API**: This is a system API.
S
shawn_he 已提交
4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056

**System capability**: SystemCapability.Telephony.CoreService

| Name    | Value  | Description      |
| -------- | ---- | ---------- |
| LOCK_OFF | 0    | The lock is off.|
| LOCK_ON  | 1    | The lock is on.|

## PersoLockType<sup>8+</sup>

Enumerates personalized lock types.

S
shawn_he 已提交
4057
**System API**: This is a system API.
S
shawn_he 已提交
4058 4059 4060

**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
4061 4062 4063
| Name        | Value  | Description                                            |
| ------------ | ---- | ------------------------------------------------ |
| PN_PIN_LOCK  | 0    | Personalized network PIN lock. For details, see *3GPP TS 22.022 [33]*.        |
S
shawn_he 已提交
4064
| PN_PUK_LOCK  | 1    | Personalized network PUK lock.                                  |
S
shawn_he 已提交
4065
| PU_PIN_LOCK  | 2    | Personalized network subset PIN lock. For details, see *3GPP TS 22.022 [33]*.    |
S
shawn_he 已提交
4066
| PU_PUK_LOCK  | 3    | Personalized network subset PUK lock.                              |
S
shawn_he 已提交
4067
| PP_PIN_LOCK  | 4    | Personalized service provider PIN lock. For details, see *3GPP TS 22.022 [33]*.  |
S
shawn_he 已提交
4068
| PP_PUK_LOCK  | 5    | Personalized service provider PUK lock.                             |
S
shawn_he 已提交
4069
| PC_PIN_LOCK  | 6    | Personalized corporate PIN lock. For details, see *3GPP TS 22.022 [33]*.        |
S
shawn_he 已提交
4070
| PC_PUK_LOCK  | 7    | Personalized corporate PUK lock.                                   |
S
shawn_he 已提交
4071
| SIM_PIN_LOCK | 8    | Personalized SIM card PIN lock. For details, see *3GPP TS 22.022 [33]*.       |
S
shawn_he 已提交
4072 4073 4074 4075
| SIM_PUK_LOCK | 9    | Personalized SIM card PUK lock.                                  |

## LockStatusResponse<sup>7+</sup>

S
shawn_he 已提交
4076
Defines the personalized lock information.
S
shawn_he 已提交
4077

S
shawn_he 已提交
4078
**System API**: This is a system API.
S
shawn_he 已提交
4079 4080 4081

**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
4082 4083 4084 4085
| Name           | Type  | Mandatory| Description                 |
| --------------- | ------ | ---- | --------------------- |
| result          | number |  Yes | Operation result.     |
| remain?: number | number |  No | Remaining attempts (can be null).|
S
shawn_he 已提交
4086 4087 4088

## LockInfo<sup>8+</sup>

S
shawn_he 已提交
4089
Defines the personalized lock information.
S
shawn_he 已提交
4090

S
shawn_he 已提交
4091
**System API**: This is a system API.
S
shawn_he 已提交
4092 4093 4094

**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
4095 4096 4097 4098 4099
| Name    |           Type          | Mandatory|   Description  |
| -------- | ------------------------ | ---- | -------- |
| lockType | [LockType](#locktype8)   |  Yes | Lock type.|
| password | string                   |  Yes | Password.  |
| state    | [LockState](#lockstate8) |  Yes | Lock state.|
S
shawn_he 已提交
4100 4101 4102 4103 4104

## PersoLockInfo<sup>8+</sup>

Defines the personalized lock information.

S
shawn_he 已提交
4105
**System API**: This is a system API.
S
shawn_he 已提交
4106 4107 4108

**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
4109 4110 4111 4112
| Name    |               Type              | Mandatory|      Description    |
| -------- | -------------------------------- | ---- | ------------- |
| lockType | [PersoLockType](#persolocktype8) |  Yes | Personalized lock type.|
| password | string                           |  Yes | Password.       |
S
shawn_he 已提交
4113 4114 4115 4116 4117

## IccAccountInfo<sup>7+</sup>

Defines the ICC account information.

S
shawn_he 已提交
4118
**System API**: This is a system API.
S
shawn_he 已提交
4119 4120 4121

**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
4122 4123 4124 4125 4126 4127 4128 4129 4130
| Name      | Type   | Mandatory| Description            |
| ---------- | ------- | ---- | ---------------- |
| simId      | number  |  Yes | SIM card ID.         |
| slotIndex  | number  |  Yes | Card slot ID.          |
| isEsim     | boolean |  Yes | Whether the SIM card is an eSim card.|
| isActive   | boolean |  Yes | Whether the card is activated.    |
| iccId      | string  |  Yes | ICCID number.       |
| showName   | string  |  Yes | SIM card display name.   |
| showNumber | string  |  Yes | SIM card display number.   |
S
shawn_he 已提交
4131 4132 4133 4134 4135

## OperatorConfig<sup>8+</sup>

Defines the carrier configuration.

S
shawn_he 已提交
4136
**System API**: This is a system API.
S
shawn_he 已提交
4137 4138 4139

**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
4140 4141 4142 4143
| Name | Type  | Mandatory| Description|
| ----- | ------ | ---- | ---- |
| field | string |  Yes | Field.|
| value | string |  Yes | Value.  |
S
shawn_he 已提交
4144 4145 4146 4147 4148

## DiallingNumbersInfo<sup>8+</sup>

Defines the contact number information.

S
shawn_he 已提交
4149
**System API**: This is a system API.
S
shawn_he 已提交
4150 4151 4152

**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
4153 4154 4155 4156 4157 4158
| Name        | Type  | Mandatory|    Description   |
| ------------ | ------ | ---- | ---------- |
| alphaTag     | string |  Yes | Tag.    |
| number       | string |  Yes | Call transfer number.    |
| recordNumber | number |  Yes | Record number.|
| pin2         | string |  Yes | PIN 2.|
S
shawn_he 已提交
4159 4160 4161 4162 4163

## ContactType<sup>8+</sup>

Enumerates contact types.

S
shawn_he 已提交
4164
**System API**: This is a system API.
S
shawn_he 已提交
4165 4166 4167 4168

**System capability**: SystemCapability.Telephony.CoreService

| Name           | Value  | Description      |
S
shawn_he 已提交
4169
| --------------- | ---- | ---------- |
S
shawn_he 已提交
4170 4171
| GENERAL_CONTACT | 1    | Common contact number.|
| FIXED_DIALING   | 2    | Fixed dialing number.  |
S
shawn_he 已提交
4172 4173 4174 4175 4176 4177 4178 4179 4180

## OperatorConfigKey<sup>9+</sup>

Enumerates carrier configuration keys.

**System API**: This is a system API.

**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
4181 4182
|                             Name                       |                             Value                        |         Description        |
| ------------------------------------------------------- | ------------------------------------------------------ | -------------------- |
S
shawn_he 已提交
4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194
| KEY_VOICE_MAIL_NUMBER_STRING                            | "voice_mail_number_string"                             | Voice mailbox number.      |
| KEY_IMS_SWITCH_ON_BY_DEFAULT_BOOL                       | "ims_switch_on_by_default_bool"                        | Fixed dialing number.          |
| KEY_HIDE_IMS_SWITCH_BOOL                                | "hide_ims_switch_bool"                                 | Whether to hide the IMS switch.   |
| KEY_VOLTE_SUPPORTED_BOOL                                | "volte_supported_bool"                                 | Whether to support VoLTE. |
| KEY_NR_MODE_SUPPORTED_LIST_INT_ARRAY                    | "nr_mode_supported_list_int_array"                     | List of supported NR modes.  |
| KEY_VOLTE_PROVISIONING_SUPPORTED_BOOL                   | "volte_provisioning_supported_bool"                    | Whether to support VoLTE provisioning. |
| KEY_SS_OVER_UT_SUPPORTED_BOOL                           | "ss_over_ut_supported_bool"                            | Whether SS over UT is supported.  |
| KEY_IMS_GBA_REQUIRED_BOOL                               | "ims_gba_required_bool"                                | Whether GBA is required for IMS.    |
| KEY_UT_PROVISIONING_SUPPORTED_BOOL                      | "ut_provisioning_supported_bool"                       | Whether to support UT provisioning.    |
| KEY_IMS_PREFER_FOR_EMERGENCY_BOOL                       | "ims_prefer_for_emergency_bool"                        | IMS preferences for emergency.     |
| KEY_CALL_WAITING_SERVICE_CLASS_INT                      | "call_waiting_service_class_int"                       | Call waiting service.      |
| KEY_CALL_TRANSFER_VISIBILITY_BOOL                       | "call_transfer_visibility_bool"                        | Call transfer visibility.    |
S
shawn_he 已提交
4195
| KEY_IMS_CALL_DISCONNECT_REASON_INFO_MAPPING_STRING_ARRAY| "ims_call_disconnect_reason_info_mapping_string_array" | List of IMS call disconnection reasons.|
S
shawn_he 已提交
4196 4197 4198 4199 4200 4201 4202
| KEY_FORCE_VOLTE_SWITCH_ON_BOOL                          | "force_volte_switch_on_bool"                           | Whether to forcibly turn on VoLTE.     |
| KEY_ENABLE_OPERATOR_NAME_CUST_BOOL                      | "enable_operator_name_cust_bool"                       | Whether to display the carrier name.|
| KEY_OPERATOR_NAME_CUST_STRING                           | "operator_name_cust_string"                            | Carrier name.        |
| KEY_SPN_DISPLAY_CONDITION_CUST_INT                      | "spn_display_condition_cust_int"                       | SPN display rule.       |
| KEY_PNN_CUST_STRING_ARRAY                               | "pnn_cust_string_array"                                | PLMN name          |
| KEY_OPL_CUST_STRING_ARRAY                               | "opl_cust_string_array"                                | PLMN information of the carrier.    |
| KEY_EMERGENCY_CALL_STRING_ARRAY                         | "emergency_call_string_array"                          | Emergency call list.      |