• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.telephony.sim (SIM Management)
2
3The **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.
4
5>**NOTE**
6>
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.
8>
9
10## Modules to Import
11
12```js
13import sim from '@ohos.telephony.sim';
14```
15
16## sim.isSimActive<sup>7+</sup>
17
18isSimActive\(slotId: number, callback: AsyncCallback<boolean\>\): void
19
20Checks whether the SIM card in the specified slot is activated. This API uses an asynchronous callback to return the result.
21
22**System capability**: SystemCapability.Telephony.CoreService
23
24**Parameters**
25
26| Name  | Type                       | Mandatory| Description                                  |
27| -------- | --------------------------- | ---- | -------------------------------------- |
28| slotId   | number                      | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
29| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result.                            |
30
31**Example**
32
33```js
34sim.isSimActive(0, (err, data) => {
35    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
36});
37```
38
39
40## sim.isSimActive<sup>7+</sup>
41
42isSimActive\(slotId: number\): Promise<boolean\>
43
44Checks whether the SIM card in the specified slot is activated. This API uses a promise to return the result.
45
46**System capability**: SystemCapability.Telephony.CoreService
47
48**Parameters**
49
50| Name| Type  | Mandatory| Description                                  |
51| ------ | ------ | ---- | -------------------------------------- |
52| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
53
54**Return value**
55
56| Type                 | Description                              |
57| --------------------- | ---------------------------------- |
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.|
59
60**Example**
61
62```js
63let promise = sim.isSimActive(0);
64promise.then(data => {
65    console.log(`isSimActive success, promise: data->${JSON.stringify(data)}`);
66}).catch(err => {
67    console.log(`isSimActive failed, promise: err->${JSON.stringify(err)}`);
68});
69```
70
71
72## sim.getDefaultVoiceSlotId<sup>7+</sup>
73
74getDefaultVoiceSlotId\(callback: AsyncCallback<number\>\): void
75
76Obtains the default slot ID of the SIM card that provides voice services. This API uses an asynchronous callback to return the result.
77
78**System capability**: SystemCapability.Telephony.CoreService
79
80**Parameters**
81
82| Name  | Type                       | Mandatory| Description      |
83| -------- | --------------------------- | ---- | ---------- |
84| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the result.|
85
86**Example**
87
88```js
89sim.getDefaultVoiceSlotId((err, data) => {
90    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
91});
92```
93
94
95## sim.getDefaultVoiceSlotId<sup>7+</sup>
96
97getDefaultVoiceSlotId\(\): Promise<number\>
98
99Obtains the default slot ID of the SIM card that provides voice services. This API uses a promise to return the result.
100
101**System capability**: SystemCapability.Telephony.CoreService
102
103**Return value**
104
105| Type             | Description                                   |
106| ----------------- | --------------------------------------- |
107| Promise\<number\> | Promise used to return the result.|
108
109**Example**
110
111```js
112let promise = sim.getDefaultVoiceSlotId();
113promise.then(data => {
114    console.log(`getDefaultVoiceSlotId success, promise: data->${JSON.stringify(data)}`);
115}).catch(err => {
116    console.log(`getDefaultVoiceSlotId failed, promise: err->${JSON.stringify(err)}`);
117});
118```
119
120## sim.hasOperatorPrivileges<sup>7+</sup>
121
122hasOperatorPrivileges(slotId: number, callback: AsyncCallback\<boolean\>): void
123
124Checks whether the application (caller) has been granted the operator permission. This API uses an asynchronous callback to return the result.
125
126**System capability**: SystemCapability.Telephony.CoreService
127
128**Parameters**
129
130| Name  | Type                    | Mandatory| Description                                    |
131| -------- | ------------------------ | ---- | ---------------------------------------- |
132| slotId   | number                   | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
133| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.                              |
134
135**Error codes**
136
137For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
138
139| ID|                 Error Message                    |
140| -------- | -------------------------------------------- |
141| 401      | Parameter error.                             |
142| 8300001  | Invalid parameter value.                     |
143| 8300002  | Operation failed. Cannot connect to service. |
144| 8300003  | System internal error.                       |
145| 8300999  | Unknown error code.                          |
146
147**Example**
148
149```js
150sim.hasOperatorPrivileges(0, (err, data) => {
151    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
152});
153```
154
155## sim.hasOperatorPrivileges<sup>7+</sup>
156
157hasOperatorPrivileges(slotId: number): Promise<boolean\>
158
159Checks whether the application (caller) has been granted the operator permission. This API uses a promise to return the result.
160
161**System capability**: SystemCapability.Telephony.CoreService
162
163**Parameters**
164
165| Name| Type  | Mandatory| Description                                    |
166| ------ | ------ | ---- | ---------------------------------------- |
167| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
168
169**Return value**
170
171| Type              | Description                                                       |
172| :----------------- | :---------------------------------------------------------- |
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.|
174
175**Error codes**
176
177For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
178
179| ID|                 Error Message                    |
180| -------- | -------------------------------------------- |
181| 401      | Parameter error.                             |
182| 8300001  | Invalid parameter value.                     |
183| 8300002  | Operation failed. Cannot connect to service. |
184| 8300003  | System internal error.                       |
185| 8300999  | Unknown error code.                          |
186
187**Example**
188
189```js
190let promise = sim.hasOperatorPrivileges(0);
191promise.then(data => {
192    console.log(`hasOperatorPrivileges success, promise: data->${JSON.stringify(data)}`);
193}).catch(err => {
194    console.log(`hasOperatorPrivileges failed, promise: err->${JSON.stringify(err)}`);
195});
196```
197
198## sim.getISOCountryCodeForSim
199
200getISOCountryCodeForSim\(slotId: number, callback: AsyncCallback<string\>\): void
201
202Obtains the ISO country code of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
203
204**System capability**: SystemCapability.Telephony.CoreService
205
206**Parameters**
207
208| Name  | Type                   | Mandatory| Description                                    |
209| -------- | ----------------------- | ---- | ---------------------------------------- |
210| slotId   | number                  | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2  |
211| callback | AsyncCallback\<string\> | Yes  | Callback used to return the result, which is an ISO country code, for example, **CN** (China).|
212
213**Error codes**
214
215For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
216
217| ID|                 Error Message                    |
218| -------- | -------------------------------------------- |
219| 401      | Parameter error.                             |
220| 8300001  | Invalid parameter value.                     |
221| 8300002  | Operation failed. Cannot connect to service. |
222| 8300003  | System internal error.                       |
223| 8300004  | Do not have sim card.                        |
224| 8300999  | Unknown error code.                          |
225
226**Example**
227
228```js
229sim.getISOCountryCodeForSim(0, (err, data) => {
230    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
231});
232```
233
234
235## sim.getISOCountryCodeForSim
236
237getISOCountryCodeForSim\(slotId: number\): Promise<string\>
238
239Obtains the ISO country code of the SIM card in the specified slot. This API uses a promise to return the result.
240
241**System capability**: SystemCapability.Telephony.CoreService
242
243**Parameters**
244
245| Name| Type  | Mandatory| Description                                  |
246| ------ | ------ | ---- | -------------------------------------- |
247| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
248
249**Return value**
250
251| Type             | Description                                                        |
252| ----------------- | ------------------------------------------------------------ |
253| Promise\<string\> | Promise used to return the result, which is an ISO country code, for example, **CN** (China).|
254
255**Error codes**
256
257For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
258
259| ID|                 Error Message                    |
260| -------- | -------------------------------------------- |
261| 401      | Parameter error.                             |
262| 8300001  | Invalid parameter value.                     |
263| 8300002  | Operation failed. Cannot connect to service. |
264| 8300003  | System internal error.                       |
265| 8300004  | Do not have sim card.                        |
266| 8300999  | Unknown error code.                          |
267
268**Example**
269
270```js
271let promise = sim.getISOCountryCodeForSim(0);
272promise.then(data => {
273    console.log(`getISOCountryCodeForSim success, promise: data->${JSON.stringify(data)}`);
274}).catch(err => {
275    console.log(`getISOCountryCodeForSim failed, promise: err->${JSON.stringify(err)}`);
276});
277```
278
279
280## sim.getSimOperatorNumeric
281
282getSimOperatorNumeric\(slotId: number, callback: AsyncCallback<string\>\): void
283
284Obtains 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.
285
286**System capability**: SystemCapability.Telephony.CoreService
287
288**Parameters**
289
290| Name  | Type                   | Mandatory| Description                                  |
291| -------- | ----------------------- | ---- | -------------------------------------- |
292| slotId   | number                  | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
293| callback | AsyncCallback\<string\> | Yes  | Callback used to return the result.                            |
294
295**Error codes**
296
297For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
298
299| ID|                 Error Message                    |
300| -------- | -------------------------------------------- |
301| 401      | Parameter error.                             |
302| 8300001  | Invalid parameter value.                     |
303| 8300002  | Operation failed. Cannot connect to service. |
304| 8300003  | System internal error.                       |
305| 8300004  | Do not have sim card.                        |
306| 8300999  | Unknown error code.                          |
307
308**Example**
309
310```js
311sim.getSimOperatorNumeric(0, (err, data) => {
312    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
313});
314```
315
316
317## sim.getSimOperatorNumeric
318
319getSimOperatorNumeric\(slotId: number\): Promise<string\>
320
321Obtains the PLMN ID of the SIM card in the specified slot. This API uses a promise to return the result.
322
323**System capability**: SystemCapability.Telephony.CoreService
324
325**Parameters**
326
327| Name| Type  | Mandatory| Description                                  |
328| ------ | ------ | ---- | -------------------------------------- |
329| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
330
331**Return value**
332
333| Type             | Description                                            |
334| ----------------- | ------------------------------------------------ |
335| Promise\<string\> | Promise used to return the result.|
336
337**Error codes**
338
339For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
340
341| ID|                 Error Message                    |
342| -------- | -------------------------------------------- |
343| 401      | Parameter error.                             |
344| 8300001  | Invalid parameter value.                     |
345| 8300002  | Operation failed. Cannot connect to service. |
346| 8300003  | System internal error.                       |
347| 8300004  | Do not have sim card.                        |
348| 8300999  | Unknown error code.                          |
349
350**Example**
351
352```js
353let promise = sim.getSimOperatorNumeric(0);
354promise.then(data => {
355    console.log(`getSimOperatorNumeric success, promise: data->${JSON.stringify(data)}`);
356}).catch(err => {
357    console.log(`getSimOperatorNumeric failed, promise: err->${JSON.stringify(err)}`);
358});
359```
360
361
362## sim.getSimSpn
363
364getSimSpn\(slotId: number, callback: AsyncCallback<string\>\): void
365
366Obtains the service provider name (SPN) of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
367
368**System capability**: SystemCapability.Telephony.CoreService
369
370**Parameters**
371
372| Name  | Type                   | Mandatory| Description                                  |
373| -------- | ----------------------- | ---- | -------------------------------------- |
374| slotId   | number                  | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
375| callback | AsyncCallback\<string\> | Yes  | Callback used to return the result.                            |
376
377**Error codes**
378
379For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
380
381| ID|                 Error Message                    |
382| -------- | -------------------------------------------- |
383| 401      | Parameter error.                             |
384| 8300001  | Invalid parameter value.                     |
385| 8300002  | Operation failed. Cannot connect to service. |
386| 8300003  | System internal error.                       |
387| 8300004  | Do not have sim card.                        |
388| 8300999  | Unknown error code.                          |
389
390**Example**
391
392```js
393sim.getSimSpn(0, (err, data) => {
394    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
395});
396```
397
398
399## sim.getSimSpn
400
401getSimSpn\(slotId: number\): Promise<string\>
402
403Obtains the SPN of the SIM card in the specified slot. This API uses a promise to return the result.
404
405**System capability**: SystemCapability.Telephony.CoreService
406
407**Parameters**
408
409| Name| Type  | Mandatory| Description                                  |
410| ------ | ------ | ---- | -------------------------------------- |
411| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
412
413**Return value**
414
415| Type             | Description                                     |
416| ----------------- | ----------------------------------------- |
417| Promise\<string\> | Promise used to return the result.|
418
419**Error codes**
420
421For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
422
423| ID|                 Error Message                    |
424| -------- | -------------------------------------------- |
425| 401      | Parameter error.                             |
426| 8300001  | Invalid parameter value.                     |
427| 8300002  | Operation failed. Cannot connect to service. |
428| 8300003  | System internal error.                       |
429| 8300004  | Do not have sim card.                        |
430| 8300999  | Unknown error code.                          |
431
432**Example**
433
434```js
435let promise = sim.getSimSpn(0);
436promise.then(data => {
437    console.log(`getSimSpn success, promise: data->${JSON.stringify(data)}`);
438}).catch(err => {
439    console.log(`getSimSpn failed, promise: err->${JSON.stringify(err)}`);
440});
441```
442
443
444## sim.getSimState
445
446getSimState\(slotId: number, callback: AsyncCallback<SimState\>\): void
447
448Obtains the state of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
449
450**System capability**: SystemCapability.Telephony.CoreService
451
452**Parameters**
453
454| Name  | Type                                  | Mandatory| Description                                  |
455| -------- | -------------------------------------- | ---- | -------------------------------------- |
456| slotId   | number                                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
457| callback | AsyncCallback\<[SimState](#simstate)\> | Yes  | Callback used to return the result. For details, see [SimState](#simstate). |
458
459**Error codes**
460
461For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
462
463| ID|                 Error Message                    |
464| -------- | -------------------------------------------- |
465| 401      | Parameter error.                             |
466| 8300001  | Invalid parameter value.                     |
467| 8300002  | Operation failed. Cannot connect to service. |
468| 8300003  | System internal error.                       |
469| 8300999  | Unknown error code.                          |
470
471**Example**
472
473```js
474sim.getSimState(0, (err, data) => {
475    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
476});
477```
478
479
480## sim.getSimState
481
482getSimState\(slotId: number\): Promise<SimState\>
483
484Obtains the state of the SIM card in the specified slot. This API uses a promise to return the result.
485
486**System capability**: SystemCapability.Telephony.CoreService
487
488**Parameters**
489
490| Name| Type  | Mandatory| Description                                  |
491| ------ | ------ | ---- | -------------------------------------- |
492| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
493
494**Return value**
495
496| Type                            | Description                                      |
497| -------------------------------- | ------------------------------------------ |
498| Promise\<[SimState](#simstate)\> | Promise used to return the result.|
499
500**Error codes**
501
502For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
503
504| ID|                 Error Message                    |
505| -------- | -------------------------------------------- |
506| 401      | Parameter error.                             |
507| 8300001  | Invalid parameter value.                     |
508| 8300002  | Operation failed. Cannot connect to service. |
509| 8300003  | System internal error.                       |
510| 8300999  | Unknown error code.                          |
511
512**Example**
513
514```js
515let promise = sim.getSimState(0);
516promise.then(data => {
517    console.log(`getSimState success, promise: data->${JSON.stringify(data)}`);
518}).catch(err => {
519    console.log(`getSimState failed, promise: err->${JSON.stringify(err)}`);
520});
521```
522
523## sim.getCardType<sup>7+</sup>
524
525getCardType\(slotId: number, callback: AsyncCallback<CardType\>\): void
526
527Obtains the type of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
528
529**System capability**: SystemCapability.Telephony.CoreService
530
531**Parameters**
532
533| Name  | Type                   | Mandatory| Description                                  |
534| -------- | ----------------------- | ---- | -------------------------------------- |
535| slotId   | number                  | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
536| callback | AsyncCallback\<[CardType](#cardtype7)\> | Yes  | Callback used to return the result.                            |
537
538**Error codes**
539
540For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
541
542| ID|                 Error Message                    |
543| -------- | -------------------------------------------- |
544| 401      | Parameter error.                             |
545| 8300001  | Invalid parameter value.                     |
546| 8300002  | Operation failed. Cannot connect to service. |
547| 8300003  | System internal error.                       |
548| 8300004  | Do not have sim card.                        |
549| 8300999  | Unknown error code.                          |
550
551**Example**
552
553```js
554sim.getCardType(0, (err, data) => {
555    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
556});
557```
558
559
560## sim.getCardType<sup>7+</sup>
561
562getCardType\(slotId: number\): Promise<CardType\>
563
564Obtains the type of the SIM card in the specified slot. This API uses a promise to return the result.
565
566**System capability**: SystemCapability.Telephony.CoreService
567
568**Parameters**
569
570| Name| Type  | Mandatory| Description                                  |
571| ------ | ------ | ---- | -------------------------------------- |
572| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
573
574**Return value**
575
576| Type             | Description                                                        |
577| ----------------- | ------------------------------------------------------------ |
578| Promise\<[CardType](#cardtype7)\> | Promise used to return the result.|
579
580**Error codes**
581
582For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
583
584| ID|                 Error Message                    |
585| -------- | -------------------------------------------- |
586| 401      | Parameter error.                             |
587| 8300001  | Invalid parameter value.                     |
588| 8300002  | Operation failed. Cannot connect to service. |
589| 8300003  | System internal error.                       |
590| 8300999  | Unknown error code.                          |
591
592**Example**
593
594```js
595let promise = sim.getCardType(0);
596promise.then(data => {
597    console.log(`getCardType success, promise: data->${JSON.stringify(data)}`);
598}).catch(err => {
599    console.log(`getCardType failed, promise: err->${JSON.stringify(err)}`);
600});
601```
602
603
604## sim.hasSimCard<sup>7+</sup>
605
606hasSimCard\(slotId: number, callback: AsyncCallback<boolean\>\): void
607
608Checks whether the SIM card in the specified slot is installed. This API uses an asynchronous callback to return the result.
609
610**System capability**: SystemCapability.Telephony.CoreService
611
612**Parameters**
613
614| Name  | Type                       | Mandatory| Description                                  |
615| -------- | --------------------------- | ---- | -------------------------------------- |
616| slotId   | number                      | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
617| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result.                            |
618
619**Error codes**
620
621For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
622
623| ID|                 Error Message                    |
624| -------- | -------------------------------------------- |
625| 401      | Parameter error.                             |
626| 8300001  | Invalid parameter value.                     |
627| 8300002  | Operation failed. Cannot connect to service. |
628| 8300003  | System internal error.                       |
629| 8300999  | Unknown error code.                          |
630
631**Example**
632
633```js
634sim.hasSimCard(0, (err, data) => {
635    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
636});
637```
638
639
640## sim.hasSimCard<sup>7+</sup>
641
642hasSimCard\(slotId: number\): Promise<boolean\>
643
644Checks whether the SIM card in the specified slot is installed. This API uses a promise to return the result.
645
646**System capability**: SystemCapability.Telephony.CoreService
647
648**Parameters**
649
650| Name| Type  | Mandatory| Description                                  |
651| ------ | ------ | ---- | -------------------------------------- |
652| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
653
654**Return value**
655
656| Type                 | Description                              |
657| --------------------- | ---------------------------------- |
658| 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.|
659
660**Error codes**
661
662For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
663
664| ID|                 Error Message                    |
665| -------- | -------------------------------------------- |
666| 401      | Parameter error.                             |
667| 8300001  | Invalid parameter value.                     |
668| 8300002  | Operation failed. Cannot connect to service. |
669| 8300003  | System internal error.                       |
670| 8300004  | Do not have sim card.                        |
671| 8300999  | Unknown error code.                          |
672
673**Example**
674
675```js
676let promise = sim.hasSimCard(0);
677promise.then(data => {
678    console.log(`hasSimCard success, promise: data->${JSON.stringify(data)}`);
679}).catch(err => {
680    console.log(`hasSimCard failed, promise: err->${JSON.stringify(err)}`);
681});
682```
683
684## sim.getSimAccountInfo<sup>7+</sup>
685
686getSimAccountInfo(slotId: number, callback: AsyncCallback<IccAccountInfo\>): void
687
688Obtains SIM card account information. This API uses an asynchronous callback to return the result.
689
690**System API**: This is a system API.
691
692**Required permission**: ohos.permission.GET_TELEPHONY_STATE
693
694**System capability**: SystemCapability.Telephony.CoreService
695
696**Parameters**
697
698| Name  | Type                                               | Mandatory| Description                                  |
699| -------- | --------------------------------------------------- | ---- | -------------------------------------- |
700| slotId   | number                                              | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
701| callback | AsyncCallback\<[IccAccountInfo](#iccaccountinfo7)\> | Yes  | Callback used to return the result.                            |
702
703**Error codes**
704
705For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
706
707| ID|                 Error Message                    |
708| -------- | -------------------------------------------- |
709| 201      | Permission denied.                           |
710| 401      | Parameter error.                             |
711| 8300001  | Invalid parameter value.                     |
712| 8300002  | Operation failed. Cannot connect to service. |
713| 8300003  | System internal error.                       |
714| 8300004  | Do not have sim card.                        |
715| 8300999  | Unknown error code.                          |
716| 8301002  | SIM card operation error.                    |
717
718**Example**
719
720```js
721sim.getSimAccountInfo(0, (err, data) => {
722    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
723});
724```
725
726
727## sim.getSimAccountInfo<sup>7+</sup>
728
729getSimAccountInfo(slotId: number): Promise<IccAccountInfo\>
730
731Obtains SIM card account information. This API uses a promise to return the result.
732
733**System API**: This is a system API.
734
735**Required permission**: ohos.permission.GET_TELEPHONY_STATE
736
737**System capability**: SystemCapability.Telephony.CoreService
738
739**Parameters**
740
741| Name| Type  | Mandatory| Description                                  |
742| ------ | ------ | ---- | -------------------------------------- |
743| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
744
745**Return value**
746
747| Type                                        | Description                                      |
748| -------------------------------------------- | ------------------------------------------ |
749| Promise<[IccAccountInfo](#iccaccountinfo7)\> | Promise used to return the result.|
750
751**Error codes**
752
753For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
754
755| ID|                 Error Message                    |
756| -------- | -------------------------------------------- |
757| 201      | Permission denied.                           |
758| 401      | Parameter error.                             |
759| 8300001  | Invalid parameter value.                     |
760| 8300002  | Operation failed. Cannot connect to service. |
761| 8300003  | System internal error.                       |
762| 8300004  | Do not have sim card.                        |
763| 8300999  | Unknown error code.                          |
764| 8301002  | SIM card operation error.                    |
765
766**Example**
767
768```js
769let promise = sim.getSimAccountInfo(0);
770promise.then(data => {
771    console.log(`getSimAccountInfo success, promise: data->${JSON.stringify(data)}`);
772}).catch(err => {
773    console.log(`getSimAccountInfo failed, promise: err->${JSON.stringify(err)}`);
774});
775```
776
777## sim.getActiveSimAccountInfoList<sup>8+</sup>
778
779getActiveSimAccountInfoList(callback: AsyncCallback<Array<IccAccountInfo\>>): void
780
781Obtains the account information list of the active SIM card. This API uses an asynchronous callback to return the result.
782
783**System API**: This is a system API.
784
785**Required permission**: ohos.permission.GET_TELEPHONY_STATE
786
787**System capability**: SystemCapability.Telephony.CoreService
788
789**Parameters**
790
791| Name  | Type                                                       | Mandatory| Description      |
792| -------- | ----------------------------------------------------------- | ---- | ---------- |
793| callback | AsyncCallback\<Array<[IccAccountInfo](#iccaccountinfo7)\>\> | Yes  | Callback used to return the result.|
794
795**Error codes**
796
797For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
798
799| ID|                 Error Message                    |
800| -------- | -------------------------------------------- |
801| 201      | Permission denied.                           |
802| 401      | Parameter error.                             |
803| 8300001  | Invalid parameter value.                     |
804| 8300002  | Operation failed. Cannot connect to service. |
805| 8300003  | System internal error.                       |
806| 8300004  | Do not have sim card.                        |
807| 8300999  | Unknown error code.                          |
808
809**Example**
810
811```js
812sim.getActiveSimAccountInfoList((err, data) => {
813    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
814});
815```
816
817
818## sim.getActiveSimAccountInfoList<sup>8+</sup>
819
820getActiveSimAccountInfoList(): Promise<Array<IccAccountInfo\>>;
821
822Obtains the account information list of the active SIM card. This API uses a promise to return the result.
823
824**System API**: This is a system API.
825
826**Required permission**: ohos.permission.GET_TELEPHONY_STATE
827
828**System capability**: SystemCapability.Telephony.CoreService
829
830**Return value**
831
832| Type                                                | Description                                          |
833| ---------------------------------------------------- | ---------------------------------------------- |
834| Promise<Array<[IccAccountInfo](#iccaccountinfo7)\>\> | Promise used to return the result.|
835
836**Error codes**
837
838For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
839
840| ID|                 Error Message                    |
841| -------- | -------------------------------------------- |
842| 201      | Permission denied.                           |
843| 401      | Parameter error.                             |
844| 8300001  | Invalid parameter value.                     |
845| 8300002  | Operation failed. Cannot connect to service. |
846| 8300003  | System internal error.                       |
847| 8300004  | Do not have sim card.                        |
848| 8300999  | Unknown error code.                          |
849
850**Example**
851
852```js
853let promise = sim.getActiveSimAccountInfoList();
854promise.then(data => {
855    console.log(`getActiveSimAccountInfoList success, promise: data->${JSON.stringify(data)}`);
856}).catch(err => {
857    console.log(`getActiveSimAccountInfoList failed, promise: err->${JSON.stringify(err)}`);
858});
859```
860
861## sim.setDefaultVoiceSlotId<sup>7+</sup>
862
863setDefaultVoiceSlotId(slotId: number, callback: AsyncCallback<void\>): void
864
865Sets the default slot ID of the SIM card that provides voice services. This API uses an asynchronous callback to return the result.
866
867**System API**: This is a system API.
868
869**Required permission**: ohos.permission.SET_TELEPHONY_STATE
870
871**System capability**: SystemCapability.Telephony.CoreService
872
873**Parameters**
874
875| Name  | Type                     | Mandatory| Description                                                        |
876| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
877| slotId   | number                    | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: Clears the default configuration.|
878| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                                  |
879
880**Error codes**
881
882For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
883
884| ID|                 Error Message                    |
885| -------- | -------------------------------------------- |
886| 201      | Permission denied.                           |
887| 401      | Parameter error.                             |
888| 8300001  | Invalid parameter value.                     |
889| 8300002  | Operation failed. Cannot connect to service. |
890| 8300003  | System internal error.                       |
891| 8300004  | Do not have sim card.                        |
892| 8300999  | Unknown error code.                          |
893| 8301001  | SIM card is not activated.                   |
894
895**Example**
896
897```js
898sim.setDefaultVoiceSlotId(0, (err) => {
899    console.log(`callback: err->${JSON.stringify(err)}`);
900});
901```
902
903
904## sim.setDefaultVoiceSlotId<sup>7+</sup>
905
906setDefaultVoiceSlotId(slotId: number): Promise\<void\>
907
908Sets the default slot ID of the SIM card that provides voice services. This API uses a promise to return the result.
909
910**System API**: This is a system API.
911
912**Required permission**: ohos.permission.SET_TELEPHONY_STATE
913
914**System capability**: SystemCapability.Telephony.CoreService
915
916**Parameters**
917
918| Name| Type  | Mandatory| Description                                                        |
919| ------ | ------ | ---- | ------------------------------------------------------------ |
920| slotId | number | Yes  | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: Clears the default configuration.|
921
922**Return value**
923
924| Type           | Description                           |
925| --------------- | ------------------------------- |
926| Promise\<void\> | Promise used to return the result.|
927
928**Error codes**
929
930For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
931
932| ID|                 Error Message                    |
933| -------- | -------------------------------------------- |
934| 201      | Permission denied.                           |
935| 401      | Parameter error.                             |
936| 8300001  | Invalid parameter value.                     |
937| 8300002  | Operation failed. Cannot connect to service. |
938| 8300003  | System internal error.                       |
939| 8300004  | Do not have sim card.                        |
940| 8300999  | Unknown error code.                          |
941| 8301001  | SIM card is not activated.                   |
942
943**Example**
944
945```js
946let promise = sim.setDefaultVoiceSlotId(0);
947promise.then(() => {
948    console.log(`setDefaultVoiceSlotId success.`);
949}).catch((err) => {
950    console.log(`setDefaultVoiceSlotId failed, promise: err->${JSON.stringify(err)}`);
951});
952```
953
954## sim.setShowName<sup>8+</sup>
955
956setShowName\(slotId: number, name: string, callback: AsyncCallback<void\>\): void
957
958Sets a display name for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
959
960**System API**: This is a system API.
961
962**Required permission**: ohos.permission.SET_TELEPHONY_STATE
963
964**System capability**: SystemCapability.Telephony.CoreService
965
966**Parameters**
967
968| Name  | Type                     | Mandatory| Description                                  |
969| -------- | ------------------------- | ---- | -------------------------------------- |
970| slotId   | number                    | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
971| name     | string                    | Yes  | SIM card name.                             |
972| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                            |
973
974**Error codes**
975
976For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
977
978| ID|                 Error Message                    |
979| -------- | -------------------------------------------- |
980| 201      | Permission denied.                           |
981| 401      | Parameter error.                             |
982| 8300001  | Invalid parameter value.                     |
983| 8300002  | Operation failed. Cannot connect to service. |
984| 8300003  | System internal error.                       |
985| 8300004  | Do not have sim card.                        |
986| 8300999  | Unknown error code.                          |
987
988**Example**
989
990```js
991let name = "ShowName";
992sim.setShowName(0, name, (err) => {
993    console.log(`callback: err->${JSON.stringify(err)}`);
994});
995```
996
997## sim.setShowName<sup>8+</sup>
998
999setShowName\(slotId: number, name: string\): Promise\<void\>
1000
1001Sets a display name for the SIM card in the specified slot. This API uses a promise to return the result.
1002
1003**System API**: This is a system API.
1004
1005**Required permission**: ohos.permission.SET_TELEPHONY_STATE
1006
1007**System capability**: SystemCapability.Telephony.CoreService
1008
1009**Parameters**
1010
1011| Name| Type  | Mandatory| Description                                  |
1012| ------ | ------ | ---- | -------------------------------------- |
1013| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1014| name   | string | Yes  | SIM card name.                             |
1015
1016**Return value**
1017
1018| Type           | Description                           |
1019| --------------- | ------------------------------- |
1020| Promise\<void\> | Promise used to return the result.|
1021
1022**Error codes**
1023
1024For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1025
1026| ID|                 Error Message                    |
1027| -------- | -------------------------------------------- |
1028| 201      | Permission denied.                           |
1029| 401      | Parameter error.                             |
1030| 8300001  | Invalid parameter value.                     |
1031| 8300002  | Operation failed. Cannot connect to service. |
1032| 8300003  | System internal error.                       |
1033| 8300004  | Do not have sim card.                        |
1034| 8300999  | Unknown error code.                          |
1035
1036**Example**
1037
1038```js
1039let name = "ShowName";
1040let promise = sim.setShowName(0, name);
1041promise.then(() => {
1042    console.log(`setShowName success.`);
1043}).catch((err) => {
1044    console.log(`setShowName failed, promise: err->${JSON.stringify(err)}`);
1045});
1046```
1047
1048## sim.getShowName<sup>8+</sup>
1049
1050getShowName(slotId: number, callback: AsyncCallback<string\>): void
1051
1052Obtains the name of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
1053
1054**System API**: This is a system API.
1055
1056**Required permission**: ohos.permission.GET_TELEPHONY_STATE
1057
1058**System capability**: SystemCapability.Telephony.CoreService
1059
1060**Parameters**
1061
1062| Name  | Type                       | Mandatory| Description                                  |
1063| -------- | --------------------------- | ---- | -------------------------------------- |
1064| slotId   | number                      | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1065| callback | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the result.                            |
1066
1067**Error codes**
1068
1069For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1070
1071| ID|                 Error Message                    |
1072| -------- | -------------------------------------------- |
1073| 201      | Permission denied.                           |
1074| 401      | Parameter error.                             |
1075| 8300001  | Invalid parameter value.                     |
1076| 8300002  | Operation failed. Cannot connect to service. |
1077| 8300003  | System internal error.                       |
1078| 8300004  | Do not have sim card.                        |
1079| 8300999  | Unknown error code.                          |
1080
1081**Example**
1082
1083```js
1084sim.getShowName(0, (err, data) => {
1085    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1086});
1087```
1088
1089
1090## sim.getShowName<sup>8+</sup>
1091
1092getShowName(slotId: number): Promise<string\>
1093
1094Obtains the name of the SIM card in the specified slot. This API uses a promise to return the result.
1095
1096**System API**: This is a system API.
1097
1098**Required permission**: ohos.permission.GET_TELEPHONY_STATE
1099
1100**System capability**: SystemCapability.Telephony.CoreService
1101
1102**Parameters**
1103
1104| Name| Type  | Mandatory| Description                                  |
1105| ------ | ------ | ---- | -------------------------------------- |
1106| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1107
1108**Return value**
1109
1110| Type                 | Description                                  |
1111| --------------------- | -------------------------------------- |
1112| Promise&lt;string&gt; | Promise used to return the result.|
1113
1114**Error codes**
1115
1116For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1117
1118| ID|                 Error Message                    |
1119| -------- | -------------------------------------------- |
1120| 201      | Permission denied.                           |
1121| 401      | Parameter error.                             |
1122| 8300001  | Invalid parameter value.                     |
1123| 8300002  | Operation failed. Cannot connect to service. |
1124| 8300003  | System internal error.                       |
1125| 8300004  | Do not have sim card.                        |
1126| 8300999  | Unknown error code.                          |
1127
1128**Example**
1129
1130```js
1131let promise = sim.getShowName(0);
1132promise.then(data => {
1133    console.log(`getShowName success, promise: data->${JSON.stringify(data)}`);
1134}).catch(err => {
1135    console.log(`getShowName failed, promise: err->${JSON.stringify(err)}`);
1136});
1137```
1138
1139## sim.setShowNumber<sup>8+</sup>
1140
1141setShowNumber\(slotId: number, number: string, callback: AsyncCallback<void\>\): void
1142
1143Sets a display number for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
1144
1145**System API**: This is a system API.
1146
1147**Required permission**: ohos.permission.SET_TELEPHONY_STATE
1148
1149**System capability**: SystemCapability.Telephony.CoreService
1150
1151**Parameters**
1152
1153| Name  | Type                     | Mandatory| Description                                  |
1154| -------- | ------------------------- | ---- | -------------------------------------- |
1155| slotId   | number                    | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1156| number   | string                    | Yes  | SIM card number.                             |
1157| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                            |
1158
1159**Error codes**
1160
1161For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1162
1163| ID|                 Error Message                    |
1164| -------- | -------------------------------------------- |
1165| 201      | Permission denied.                           |
1166| 401      | Parameter error.                             |
1167| 8300001  | Invalid parameter value.                     |
1168| 8300002  | Operation failed. Cannot connect to service. |
1169| 8300003  | System internal error.                       |
1170| 8300004  | Do not have sim card.                        |
1171| 8300999  | Unknown error code.                          |
1172
1173**Example**
1174
1175```js
1176let number = '+861xxxxxxxxxx';
1177sim.setShowNumber(0, number, (err) => {
1178    console.log(`callback: err->${JSON.stringify(err)}`);
1179});
1180```
1181
1182
1183## sim.setShowNumber<sup>8+</sup>
1184
1185setShowNumber\(slotId: number, number: string\): Promise\<void\>
1186
1187Sets a display number for the SIM card in the specified slot. This API uses a promise to return the result.
1188
1189**System API**: This is a system API.
1190
1191**Required permission**: ohos.permission.SET_TELEPHONY_STATE
1192
1193**System capability**: SystemCapability.Telephony.CoreService
1194
1195**Parameters**
1196
1197| Name| Type  | Mandatory| Description                                  |
1198| ------ | ------ | ---- | -------------------------------------- |
1199| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1200| number | string | Yes  | SIM card number.                             |
1201
1202**Return value**
1203
1204| Type          | Description                           |
1205| -------------- | ------------------------------- |
1206| Promise<void\> | Promise used to return the result.|
1207
1208**Error codes**
1209
1210For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1211
1212| ID|                 Error Message                    |
1213| -------- | -------------------------------------------- |
1214| 201      | Permission denied.                           |
1215| 401      | Parameter error.                             |
1216| 8300001  | Invalid parameter value.                     |
1217| 8300002  | Operation failed. Cannot connect to service. |
1218| 8300003  | System internal error.                       |
1219| 8300004  | Do not have sim card.                        |
1220| 8300999  | Unknown error code.                          |
1221
1222**Example**
1223
1224```js
1225let number = '+861xxxxxxxxxx';
1226let promise = sim.setShowNumber(0, number);
1227promise.then(() => {
1228    console.log(`setShowNumber success.`);
1229}).catch((err) => {
1230    console.log(`setShowNumber failed, promise: err->${JSON.stringify(err)}`);
1231});
1232```
1233
1234## sim.getShowNumber<sup>8+</sup>
1235
1236getShowNumber(slotId: number, callback: AsyncCallback<string\>): void
1237
1238Obtains the display number of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
1239
1240**System API**: This is a system API.
1241
1242**Required permission**: ohos.permission.GET_TELEPHONY_STATE
1243
1244**System capability**: SystemCapability.Telephony.CoreService
1245
1246**Parameters**
1247
1248| Name  | Type                       | Mandatory| Description                                  |
1249| -------- | --------------------------- | ---- | -------------------------------------- |
1250| slotId   | number                      | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1251| callback | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the result.                            |
1252
1253**Error codes**
1254
1255For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1256
1257| ID|                 Error Message                    |
1258| -------- | -------------------------------------------- |
1259| 201      | Permission denied.                           |
1260| 401      | Parameter error.                             |
1261| 8300001  | Invalid parameter value.                     |
1262| 8300002  | Operation failed. Cannot connect to service. |
1263| 8300003  | System internal error.                       |
1264| 8300004  | Do not have sim card.                        |
1265| 8300999  | Unknown error code.                          |
1266
1267**Example**
1268
1269```js
1270sim.getShowNumber(0, (err, data) => {
1271    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1272});
1273```
1274
1275
1276## sim.getShowNumber<sup>8+</sup>
1277
1278getShowNumber(slotId: number): Promise<string\>
1279
1280Obtains the display number of the SIM card in the specified slot. This API uses a promise to return the result.
1281
1282**System API**: This is a system API.
1283
1284**Required permission**: ohos.permission.GET_TELEPHONY_STATE
1285
1286**System capability**: SystemCapability.Telephony.CoreService
1287
1288**Parameters**
1289
1290| Name| Type  | Mandatory| Description                                  |
1291| ------ | ------ | ---- | -------------------------------------- |
1292| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1293
1294**Return value**
1295
1296| Type                 | Description                             |
1297| --------------------- | --------------------------------- |
1298| Promise&lt;string&gt; | Promise used to return the result.|
1299
1300**Error codes**
1301
1302For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1303
1304| ID|                 Error Message                    |
1305| -------- | -------------------------------------------- |
1306| 201      | Permission denied.                           |
1307| 401      | Parameter error.                             |
1308| 8300001  | Invalid parameter value.                     |
1309| 8300002  | Operation failed. Cannot connect to service. |
1310| 8300003  | System internal error.                       |
1311| 8300004  | Do not have sim card.                        |
1312| 8300999  | Unknown error code.                          |
1313
1314**Example**
1315
1316```js
1317let promise = sim.getShowNumber(0);
1318promise.then(data => {
1319    console.log(`getShowNumber success, promise: data->${JSON.stringify(data)}`);
1320}).catch(err => {
1321    console.log(`getShowNumber failed, promise: err->${JSON.stringify(err)}`);
1322});
1323```
1324
1325## sim.activateSim<sup>8+</sup>
1326
1327activateSim(slotId: number, callback: AsyncCallback<void\>): void
1328
1329Activates a SIM card in a specified card slot. This API uses an asynchronous callback to return the result.
1330
1331**System API**: This is a system API.
1332
1333**Required permission**: ohos.permission.SET_TELEPHONY_STATE
1334
1335**System capability**: SystemCapability.Telephony.CoreService
1336
1337**Parameters**
1338
1339| Name  | Type                     | Mandatory| Description                                  |
1340| -------- | ------------------------- | ---- | -------------------------------------- |
1341| slotId   | number                    | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1342| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                            |
1343
1344**Error codes**
1345
1346For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1347
1348| ID|                 Error Message                    |
1349| -------- | -------------------------------------------- |
1350| 201      | Permission denied.                           |
1351| 401      | Parameter error.                             |
1352| 8300001  | Invalid parameter value.                     |
1353| 8300002  | Operation failed. Cannot connect to service. |
1354| 8300003  | System internal error.                       |
1355| 8300004  | Do not have sim card.                        |
1356| 8300999  | Unknown error code.                          |
1357
1358**Example**
1359
1360```js
1361sim.activateSim(0, (err) => {
1362    console.log(`callback: err->${JSON.stringify(err)}`);
1363});
1364```
1365
1366
1367## sim.activateSim<sup>8+</sup>
1368
1369activateSim(slotId: number): Promise\<void\>
1370
1371Activates the SIM card in the specified slot. This API uses a promise to return the result.
1372
1373**System API**: This is a system API.
1374
1375**Required permission**: ohos.permission.SET_TELEPHONY_STATE
1376
1377**System capability**: SystemCapability.Telephony.CoreService
1378
1379**Parameters**
1380
1381| Name| Type  | Mandatory| Description                                  |
1382| ------ | ------ | ---- | -------------------------------------- |
1383| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1384
1385**Return value**
1386
1387| Type           | Description                           |
1388| --------------- | ------------------------------- |
1389| Promise\<void\> | Promise used to return the result.|
1390
1391**Error codes**
1392
1393For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1394
1395| ID|                 Error Message                    |
1396| -------- | -------------------------------------------- |
1397| 201      | Permission denied.                           |
1398| 401      | Parameter error.                             |
1399| 8300001  | Invalid parameter value.                     |
1400| 8300002  | Operation failed. Cannot connect to service. |
1401| 8300003  | System internal error.                       |
1402| 8300004  | Do not have sim card.                        |
1403| 8300999  | Unknown error code.                          |
1404
1405**Example**
1406
1407```js
1408let promise = sim.activateSim(0);
1409promise.then(() => {
1410    console.log(`activateSim success.`);
1411}).catch((err) => {
1412    console.log(`activateSim failed, promise: err->${JSON.stringify(err)}`);
1413});
1414```
1415
1416## sim.deactivateSim<sup>8+</sup>
1417
1418deactivateSim(slotId: number, callback: AsyncCallback<void\>): void
1419
1420Disables the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
1421
1422**System API**: This is a system API.
1423
1424**Required permission**: ohos.permission.SET_TELEPHONY_STATE
1425
1426**System capability**: SystemCapability.Telephony.CoreService
1427
1428**Parameters**
1429
1430| Name  | Type                     | Mandatory| Description                                  |
1431| -------- | ------------------------- | ---- | -------------------------------------- |
1432| slotId   | number                    | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1433| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                            |
1434
1435**Error codes**
1436
1437For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1438
1439| ID|                 Error Message                    |
1440| -------- | -------------------------------------------- |
1441| 201      | Permission denied.                           |
1442| 401      | Parameter error.                             |
1443| 8300001  | Invalid parameter value.                     |
1444| 8300002  | Operation failed. Cannot connect to service. |
1445| 8300003  | System internal error.                       |
1446| 8300004  | Do not have sim card.                        |
1447| 8300999  | Unknown error code.                          |
1448
1449**Example**
1450
1451```js
1452sim.deactivateSim(0, (err) => {
1453    console.log(`callback: err->${JSON.stringify(err)}`);
1454});
1455```
1456
1457
1458## sim.deactivateSim<sup>8+</sup>
1459
1460deactivateSim(slotId: number): Promise\<void\>
1461
1462Disables the SIM card in the specified slot. This API uses a promise to return the result.
1463
1464**System API**: This is a system API.
1465
1466**Required permission**: ohos.permission.SET_TELEPHONY_STATE
1467
1468**System capability**: SystemCapability.Telephony.CoreService
1469
1470**Parameters**
1471
1472| Name| Type  | Mandatory| Description                                  |
1473| ------ | ------ | ---- | -------------------------------------- |
1474| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1475
1476**Return value**
1477
1478| Type           | Description                           |
1479| --------------- | ------------------------------- |
1480| Promise\<void\> | Promise used to return the result.|
1481
1482**Error codes**
1483
1484For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1485
1486| ID|                 Error Message                    |
1487| -------- | -------------------------------------------- |
1488| 201      | Permission denied.                           |
1489| 401      | Parameter error.                             |
1490| 8300001  | Invalid parameter value.                     |
1491| 8300002  | Operation failed. Cannot connect to service. |
1492| 8300003  | System internal error.                       |
1493| 8300004  | Do not have sim card.                        |
1494| 8300999  | Unknown error code.                          |
1495
1496**Example**
1497
1498```js
1499let promise = sim.deactivateSim(0);
1500promise.then(() => {
1501    console.log(`deactivateSim success.`);
1502}).catch((err) => {
1503    console.log(`deactivateSim failed, promise: err->${JSON.stringify(err)}`);
1504});
1505```
1506
1507## sim.setLockState<sup>7+</sup>
1508
1509setLockState(slotId: number, options: LockInfo, callback: AsyncCallback<LockStatusResponse\>): void
1510
1511Sets the lock status of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
1512
1513**System API**: This is a system API.
1514
1515**Required permission**: ohos.permission.SET_TELEPHONY_STATE
1516
1517**System capability**: SystemCapability.Telephony.CoreService
1518
1519**Parameters**
1520
1521| Name  | Type                                                       | Mandatory| Description                                                        |
1522| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
1523| slotId   | number                                                      | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                      |
1524| callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | Yes  | Callback used to return the result.                                                  |
1525| options  | [LockInfo](#lockinfo8)                                      | Yes  | Lock information.<br>- lockType: [LockType](#locktype8)<br>- password: string<br>- state: [LockState](#lockstate8) |
1526
1527**Error codes**
1528
1529For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1530
1531| ID|                 Error Message                    |
1532| -------- | -------------------------------------------- |
1533| 201      | Permission denied.                           |
1534| 401      | Parameter error.                             |
1535| 8300001  | Invalid parameter value.                     |
1536| 8300002  | Operation failed. Cannot connect to service. |
1537| 8300003  | System internal error.                       |
1538| 8300004  | Do not have sim card.                        |
1539| 8300999  | Unknown error code.                          |
1540| 8301002  | SIM card operation error.                    |
1541
1542**Example**
1543
1544```js
1545let lockInfo = {
1546    lockType: sim.LockType.PIN_LOCK,
1547    password: "1234",
1548    state: sim.LockState.LOCK_OFF
1549};
1550sim.setLockState(0, lockInfo, (err, data) => {
1551    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1552});
1553```
1554
1555
1556## sim.setLockState<sup>7+</sup>
1557
1558setLockState(slotId: number, options: LockInfo): Promise<LockStatusResponse\>
1559
1560Sets the lock status of the SIM card in the specified slot. This API uses a promise to return the result.
1561
1562**System API**: This is a system API.
1563
1564**Required permission**: ohos.permission.SET_TELEPHONY_STATE
1565
1566**System capability**: SystemCapability.Telephony.CoreService
1567
1568**Parameters**
1569
1570| Name | Type                  | Mandatory| Description                                                        |
1571| ------- | ---------------------- | ---- | ------------------------------------------------------------ |
1572| slotId  | number                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                      |
1573| options | [LockInfo](#lockinfo8) | Yes  | Lock information.<br>- lockType: [LockType](#locktype8)<br>- password: string<br>- state: [LockState](#lockstate8) |
1574
1575**Return value**
1576
1577| Type                                                | Description                                        |
1578| ---------------------------------------------------- | -------------------------------------------- |
1579| Promise<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
1580
1581**Error codes**
1582
1583For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1584
1585| ID|                 Error Message                    |
1586| -------- | -------------------------------------------- |
1587| 201      | Permission denied.                           |
1588| 401      | Parameter error.                             |
1589| 8300001  | Invalid parameter value.                     |
1590| 8300002  | Operation failed. Cannot connect to service. |
1591| 8300003  | System internal error.                       |
1592| 8300004  | Do not have sim card.                        |
1593| 8300999  | Unknown error code.                          |
1594| 8301002  | SIM card operation error.                    |
1595
1596**Example**
1597
1598```js
1599let lockInfo = {
1600    lockType: sim.LockType.PIN_LOCK,
1601    password: "1234",
1602    state: sim.LockState.LOCK_OFF
1603};
1604let promise = sim.setLockState(0, lockInfo);
1605promise.then(data => {
1606    console.log(`setLockState success, promise: data->${JSON.stringify(data)}`);
1607}).catch(err => {
1608    console.log(`setLockState failed, promise: err->${JSON.stringify(err)}`);
1609});
1610```
1611
1612## sim.getLockState<sup>8+</sup>
1613
1614getLockState(slotId: number, lockType: LockType, callback: AsyncCallback<LockState\>): void
1615
1616Obtains the lock status of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
1617
1618**System API**: This is a system API.
1619
1620**Required permission**: ohos.permission.GET_TELEPHONY_STATE
1621
1622**System capability**: SystemCapability.Telephony.CoreService
1623
1624**Parameters**
1625
1626| Name  | Type                                     | Mandatory| Description                                   |
1627| -------- | ----------------------------------------- | ---- | --------------------------------------- |
1628| slotId   | number                                    | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
1629| callback | AsyncCallback\<[LockState](#lockstate8)\> | Yes  | Callback used to return the result.                             |
1630| options  | [LockType](#locktype8)                    | Yes  | Lock type.<br>- **1**: PIN lock<br>- **2**: PIN 2 lock|
1631
1632**Error codes**
1633
1634For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1635
1636| ID|                 Error Message                    |
1637| -------- | -------------------------------------------- |
1638| 201      | Permission denied.                           |
1639| 401      | Parameter error.                             |
1640| 8300001  | Invalid parameter value.                     |
1641| 8300002  | Operation failed. Cannot connect to service. |
1642| 8300003  | System internal error.                       |
1643| 8300004  | Do not have sim card.                        |
1644| 8300999  | Unknown error code.                          |
1645| 8301002  | SIM card operation error.                    |
1646
1647**Example**
1648
1649```js
1650sim.getLockState(0, 1, (err, data) => {
1651    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1652});
1653```
1654
1655
1656## sim.getLockState<sup>8+</sup>
1657
1658getLockState(slotId: number, lockType: LockType): Promise<LockState\>
1659
1660Obtains the lock status of the SIM card in the specified slot. This API uses a promise to return the result.
1661
1662**System API**: This is a system API.
1663
1664**Required permission**: ohos.permission.GET_TELEPHONY_STATE
1665
1666**System capability**: SystemCapability.Telephony.CoreService
1667
1668**Parameters**
1669
1670| Name | Type                  | Mandatory| Description                                   |
1671| ------- | ---------------------- | ---- | --------------------------------------- |
1672| slotId  | number                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
1673| options | [LockType](#locktype8) | Yes  | Lock type.<br>- **1**: PIN lock<br>- **2**: PIN 2 lock|
1674
1675**Return value**
1676
1677| Type                              | Description                                        |
1678| ---------------------------------- | -------------------------------------------- |
1679| Promise<[LockState](#lockstate8)\> | Promise used to return the result.|
1680
1681**Error codes**
1682
1683For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1684
1685| ID|                 Error Message                    |
1686| -------- | -------------------------------------------- |
1687| 201      | Permission denied.                           |
1688| 401      | Parameter error.                             |
1689| 8300001  | Invalid parameter value.                     |
1690| 8300002  | Operation failed. Cannot connect to service. |
1691| 8300003  | System internal error.                       |
1692| 8300004  | Do not have sim card.                        |
1693| 8300999  | Unknown error code.                          |
1694| 8301002  | SIM card operation error.                    |
1695
1696**Example**
1697
1698```js
1699let promise = sim.getLockState(0, 1);
1700promise.then(data => {
1701    console.log(`getLockState success, promise: data->${JSON.stringify(data)}`);
1702}).catch(err => {
1703    console.log(`getLockState failed, promise: err->${JSON.stringify(err)}`);
1704});
1705```
1706
1707## sim.alterPin<sup>7+</sup>
1708
1709alterPin(slotId: number, newPin: string, oldPin: string, callback: AsyncCallback<LockStatusResponse\>): void
1710
1711Changes the PIN of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
1712
1713**System API**: This is a system API.
1714
1715**Required permission**: ohos.permission.SET_TELEPHONY_STATE
1716
1717**System capability**: SystemCapability.Telephony.CoreService
1718
1719**Parameters**
1720
1721| Name  | Type                                                       | Mandatory| Description                                  |
1722| -------- | ----------------------------------------------------------- | ---- | -------------------------------------- |
1723| slotId   | number                                                      | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1724| callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | Yes  | Callback used to return the result.                            |
1725| newPin   | string                                                      | Yes  | New PIN.                              |
1726| oldPin   | string                                                      | Yes  | Old PIN.                              |
1727
1728**Error codes**
1729
1730For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1731
1732| ID|                 Error Message                    |
1733| -------- | -------------------------------------------- |
1734| 201      | Permission denied.                           |
1735| 401      | Parameter error.                             |
1736| 8300001  | Invalid parameter value.                     |
1737| 8300002  | Operation failed. Cannot connect to service. |
1738| 8300003  | System internal error.                       |
1739| 8300004  | Do not have sim card.                        |
1740| 8300999  | Unknown error code.                          |
1741| 8301002  | SIM card operation error.                    |
1742
1743**Example**
1744
1745```js
1746sim.alterPin(0, "1234", "0000", (err, data) => {
1747    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1748});
1749```
1750
1751
1752## sim.alterPin<sup>7+</sup>
1753
1754alterPin(slotId: number, newPin: string, oldPin: string): Promise<LockStatusResponse\>;
1755
1756Changes the PIN of the SIM card in the specified slot. This API uses a promise to return the result.
1757
1758**System API**: This is a system API.
1759
1760**Required permission**: ohos.permission.SET_TELEPHONY_STATE
1761
1762**System capability**: SystemCapability.Telephony.CoreService
1763
1764**Parameters**
1765
1766| Name| Type  | Mandatory| Description                                  |
1767| ------ | ------ | ---- | -------------------------------------- |
1768| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1769| newPin | string | Yes  | New PIN.                              |
1770| oldPin | string | Yes  | Old PIN.                              |
1771
1772**Return value**
1773
1774| Type                                                | Description                                         |
1775| ---------------------------------------------------- | --------------------------------------------- |
1776| Promise<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
1777
1778**Error codes**
1779
1780For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1781
1782| ID|                 Error Message                    |
1783| -------- | -------------------------------------------- |
1784| 201      | Permission denied.                           |
1785| 401      | Parameter error.                             |
1786| 8300001  | Invalid parameter value.                     |
1787| 8300002  | Operation failed. Cannot connect to service. |
1788| 8300003  | System internal error.                       |
1789| 8300004  | Do not have sim card.                        |
1790| 8300999  | Unknown error code.                          |
1791| 8301002  | SIM card operation error.                    |
1792
1793**Example**
1794
1795```js
1796let promise = sim.alterPin(0, "1234", "0000");
1797promise.then(data => {
1798    console.log(`alterPin success, promise: data->${JSON.stringify(data)}`);
1799}).catch(err => {
1800    console.log(`alterPin failed, promise: err->${JSON.stringify(err)}`);
1801});
1802```
1803
1804## sim.alterPin2<sup>8+</sup>
1805
1806alterPin2(slotId: number, newPin2: string, oldPin2: string, callback: AsyncCallback<LockStatusResponse\>): void
1807
1808Changes PIN 2 of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
1809
1810**System API**: This is a system API.
1811
1812**Required permission**: ohos.permission.SET_TELEPHONY_STATE
1813
1814**System capability**: SystemCapability.Telephony.CoreService
1815
1816**Parameters**
1817
1818| Name  | Type                                                       | Mandatory| Description                                  |
1819| -------- | ----------------------------------------------------------- | ---- | -------------------------------------- |
1820| slotId   | number                                                      | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1821| callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | Yes  | Callback used to return the result.                            |
1822| newPin2  | string                                                      | Yes  | New PIN.                              |
1823| oldPin2  | string                                                      | Yes  | Old PIN.                              |
1824
1825**Error codes**
1826
1827For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1828
1829| ID|                 Error Message                    |
1830| -------- | -------------------------------------------- |
1831| 201      | Permission denied.                           |
1832| 401      | Parameter error.                             |
1833| 8300001  | Invalid parameter value.                     |
1834| 8300002  | Operation failed. Cannot connect to service. |
1835| 8300003  | System internal error.                       |
1836| 8300004  | Do not have sim card.                        |
1837| 8300999  | Unknown error code.                          |
1838| 8301002  | SIM card operation error.                    |
1839
1840**Example**
1841
1842```js
1843sim.alterPin2(0, "1234", "0000", (err, data) => {
1844    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1845});
1846```
1847
1848
1849## sim.alterPin2<sup>8+</sup>
1850
1851alterPin2(slotId: number, newPin2: string, oldPin2: string): Promise<LockStatusResponse\>
1852
1853Changes PIN 2 of the SIM card in the specified slot. This API uses a promise to return the result.
1854
1855**System API**: This is a system API.
1856
1857**Required permission**: ohos.permission.SET_TELEPHONY_STATE
1858
1859**System capability**: SystemCapability.Telephony.CoreService
1860
1861**Parameters**
1862
1863| Name | Type  | Mandatory| Description                                  |
1864| ------- | ------ | ---- | -------------------------------------- |
1865| slotId  | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1866| newPin2 | string | Yes  | New PIN.                              |
1867| oldPin2 | string | Yes  | Old PIN.                              |
1868
1869**Return value**
1870
1871| Type                                                | Description                                         |
1872| ---------------------------------------------------- | --------------------------------------------- |
1873| Promise<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
1874
1875**Error codes**
1876
1877For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1878
1879| ID|                 Error Message                    |
1880| -------- | -------------------------------------------- |
1881| 201      | Permission denied.                           |
1882| 401      | Parameter error.                             |
1883| 8300001  | Invalid parameter value.                     |
1884| 8300002  | Operation failed. Cannot connect to service. |
1885| 8300003  | System internal error.                       |
1886| 8300004  | Do not have sim card.                        |
1887| 8300999  | Unknown error code.                          |
1888| 8301002  | SIM card operation error.                    |
1889
1890**Example**
1891
1892```js
1893let promise = sim.alterPin2(0, "1234", "0000");
1894promise.then(data => {
1895    console.log(`alterPin2 success, promise: data->${JSON.stringify(data)}`);
1896}).catch(err => {
1897    console.log(`alterPin2 failed, promise: err->${JSON.stringify(err)}`);
1898});
1899```
1900
1901## sim.unlockPin<sup>7+</sup>
1902
1903unlockPin(slotId: number, pin: string, callback: AsyncCallback<LockStatusResponse\>): void
1904
1905Unlocks the PIN of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
1906
1907**System API**: This is a system API.
1908
1909**Required permission**: ohos.permission.SET_TELEPHONY_STATE
1910
1911**System capability**: SystemCapability.Telephony.CoreService
1912
1913**Parameters**
1914
1915| Name  | Type                                                        | Mandatory| Description                                  |
1916| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
1917| slotId   | number                                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1918| pin      | string                                                       | Yes  | PIN of the SIM card.                           |
1919| callback | AsyncCallback&lt;[LockStatusResponse](#lockstatusresponse7)> | Yes  | Callback used to return the result.                            |
1920
1921**Error codes**
1922
1923For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1924
1925| ID|                 Error Message                    |
1926| -------- | -------------------------------------------- |
1927| 201      | Permission denied.                           |
1928| 401      | Parameter error.                             |
1929| 8300001  | Invalid parameter value.                     |
1930| 8300002  | Operation failed. Cannot connect to service. |
1931| 8300003  | System internal error.                       |
1932| 8300004  | Do not have sim card.                        |
1933| 8300999  | Unknown error code.                          |
1934| 8301002  | SIM card operation error.                    |
1935
1936**Example**
1937
1938```js
1939let pin = '1234';
1940sim.unlockPin(0, pin, (err, data) => {
1941    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1942});
1943```
1944
1945
1946## sim.unlockPin<sup>7+</sup>
1947
1948unlockPin(slotId: number, pin: string): Promise&lt;LockStatusResponse\>
1949
1950Unlocks the PIN of the SIM card in the specified slot. This API uses a promise to return the result.
1951
1952**System API**: This is a system API.
1953
1954**Required permission**: ohos.permission.SET_TELEPHONY_STATE
1955
1956**System capability**: SystemCapability.Telephony.CoreService
1957
1958**Parameters**
1959
1960| Name| Type  | Mandatory| Description                                  |
1961| ------ | ------ | ---- | -------------------------------------- |
1962| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
1963| pin    | string | Yes  | PIN of the SIM card.                           |
1964
1965**Return value**
1966
1967| Type                                                | Description                                              |
1968| ---------------------------------------------------- | -------------------------------------------------- |
1969| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
1970
1971**Error codes**
1972
1973For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
1974
1975| ID|                 Error Message                    |
1976| -------- | -------------------------------------------- |
1977| 201      | Permission denied.                           |
1978| 401      | Parameter error.                             |
1979| 8300001  | Invalid parameter value.                     |
1980| 8300002  | Operation failed. Cannot connect to service. |
1981| 8300003  | System internal error.                       |
1982| 8300004  | Do not have sim card.                        |
1983| 8300999  | Unknown error code.                          |
1984| 8301002  | SIM card operation error.                    |
1985
1986**Example**
1987
1988```js
1989let pin = '1234';
1990let promise = sim.unlockPin(0, pin);
1991promise.then(data => {
1992    console.log(`unlockPin success, promise: data->${JSON.stringify(data)}`);
1993}).catch(err => {
1994    console.log(`unlockPin failed, promise: err->${JSON.stringify(err)}`);
1995});
1996```
1997
1998## sim.unlockPuk<sup>7+</sup>
1999
2000unlockPuk(slotId: number, newPin: string, puk: string, callback: AsyncCallback<LockStatusResponse\>): void
2001
2002Unlocks the PUK of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
2003
2004**System API**: This is a system API.
2005
2006**Required permission**: ohos.permission.SET_TELEPHONY_STATE
2007
2008**System capability**: SystemCapability.Telephony.CoreService
2009
2010**Parameters**
2011
2012| Name  | Type                                                        | Mandatory| Description                                  |
2013| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
2014| slotId   | number                                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2015| newPin   | string                                                       | Yes  | New PIN.                       |
2016| puk      | string                                                       | Yes  | PUK of the SIM card.                   |
2017| callback | AsyncCallback&lt;[LockStatusResponse](#lockstatusresponse7)&gt; | Yes  | Callback used to return the result.                            |
2018
2019**Error codes**
2020
2021For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2022
2023| ID|                 Error Message                    |
2024| -------- | -------------------------------------------- |
2025| 201      | Permission denied.                           |
2026| 401      | Parameter error.                             |
2027| 8300001  | Invalid parameter value.                     |
2028| 8300002  | Operation failed. Cannot connect to service. |
2029| 8300003  | System internal error.                       |
2030| 8300004  | Do not have sim card.                        |
2031| 8300999  | Unknown error code.                          |
2032| 8301002  | SIM card operation error.                    |
2033
2034**Example**
2035
2036```js
2037let puk = '1xxxxxxx';
2038let newPin = '1235';
2039sim.unlockPuk(0, newPin, puk, (err, data) => {
2040    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
2041});
2042```
2043
2044
2045## sim.unlockPuk<sup>7+</sup>
2046
2047unlockPuk(slotId: number, newPin: string, puk: string): Promise&lt;LockStatusResponse\>
2048
2049Unlocks the PUK of the SIM card in the specified slot. This API uses a promise to return the result.
2050
2051**System API**: This is a system API.
2052
2053**Required permission**: ohos.permission.SET_TELEPHONY_STATE
2054
2055**System capability**: SystemCapability.Telephony.CoreService
2056
2057**Parameters**
2058
2059| Name| Type  | Mandatory| Description                                  |
2060| ------ | ------ | ---- | -------------------------------------- |
2061| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2062| newPin | string | Yes  | New PIN.                       |
2063| puk    | string | Yes  | PUK of the SIM card.                   |
2064
2065**Return value**
2066
2067| Type                                                | Description                                              |
2068| ---------------------------------------------------- | -------------------------------------------------- |
2069| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
2070
2071**Error codes**
2072
2073For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2074
2075| ID|                 Error Message                    |
2076| -------- | -------------------------------------------- |
2077| 201      | Permission denied.                           |
2078| 401      | Parameter error.                             |
2079| 8300001  | Invalid parameter value.                     |
2080| 8300002  | Operation failed. Cannot connect to service. |
2081| 8300003  | System internal error.                       |
2082| 8300004  | Do not have sim card.                        |
2083| 8300999  | Unknown error code.                          |
2084| 8301002  | SIM card operation error.                    |
2085
2086**Example**
2087
2088```js
2089let puk = '1xxxxxxx';
2090let newPin = '1235';
2091let promise = sim.unlockPuk(0, newPin, puk);
2092promise.then(data => {
2093    console.log(`unlockPuk success, promise: data->${JSON.stringify(data)}`);
2094}).catch(err => {
2095    console.log(`unlockPuk failed, promise: err->${JSON.stringify(err)}`);
2096});
2097```
2098
2099## sim.unlockPin2<sup>8+</sup>
2100
2101unlockPin2(slotId: number, pin2: string, callback: AsyncCallback<LockStatusResponse\>): void
2102
2103Unlocks PIN 2 of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
2104
2105**System API**: This is a system API.
2106
2107**Required permission**: ohos.permission.SET_TELEPHONY_STATE
2108
2109**System capability**: SystemCapability.Telephony.CoreService
2110
2111**Parameters**
2112
2113| Name  | Type                                                        | Mandatory| Description                                  |
2114| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
2115| slotId   | number                                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2116| pin2     | string                                                       | Yes  | PIN of the SIM card.                           |
2117| callback | AsyncCallback&lt;[LockStatusResponse](#lockstatusresponse7)&gt; | Yes  | Callback used to return the result.                            |
2118
2119**Error codes**
2120
2121For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2122
2123| ID|                 Error Message                    |
2124| -------- | -------------------------------------------- |
2125| 201      | Permission denied.                           |
2126| 401      | Parameter error.                             |
2127| 8300001  | Invalid parameter value.                     |
2128| 8300002  | Operation failed. Cannot connect to service. |
2129| 8300003  | System internal error.                       |
2130| 8300004  | Do not have sim card.                        |
2131| 8300999  | Unknown error code.                          |
2132| 8301002  | SIM card operation error.                    |
2133
2134**Example**
2135
2136```js
2137let pin2 = '1234';
2138sim.unlockPin2(0, pin2, (err, data) => {
2139    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
2140});
2141```
2142
2143
2144## sim.unlockPin2<sup>8+</sup>
2145
2146unlockPin2(slotId: number, pin2: string): Promise&lt;LockStatusResponse\>
2147
2148Unlocks PIN 2 of the SIM card in the specified slot. This API uses a promise to return the result.
2149
2150**System API**: This is a system API.
2151
2152**Required permission**: ohos.permission.SET_TELEPHONY_STATE
2153
2154**System capability**: SystemCapability.Telephony.CoreService
2155
2156**Parameters**
2157
2158| Name| Type  | Mandatory| Description                                  |
2159| ------ | ------ | ---- | -------------------------------------- |
2160| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2161| pin2   | string | Yes  | PIN of the SIM card.                           |
2162
2163**Return value**
2164
2165| Type                                                 | Description                                              |
2166| ----------------------------------------------------- | -------------------------------------------------- |
2167| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
2168
2169**Error codes**
2170
2171For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2172
2173| ID|                 Error Message                    |
2174| -------- | -------------------------------------------- |
2175| 201      | Permission denied.                           |
2176| 401      | Parameter error.                             |
2177| 8300001  | Invalid parameter value.                     |
2178| 8300002  | Operation failed. Cannot connect to service. |
2179| 8300003  | System internal error.                       |
2180| 8300004  | Do not have sim card.                        |
2181| 8300999  | Unknown error code.                          |
2182| 8301002  | SIM card operation error.                    |
2183
2184**Example**
2185
2186```js
2187let pin2='1234';
2188let promise = sim.unlockPin2(0, pin2);
2189promise.then(data => {
2190    console.log(`unlockPin2 success, promise: data->${JSON.stringify(data)}`);
2191}).catch(err => {
2192    console.log(`unlockPin2 failed, promise: err->${JSON.stringify(err)}`);
2193});
2194```
2195
2196## sim.unlockPuk2<sup>8+</sup>
2197
2198unlockPuk2(slotId: number, newPin2: string, puk2: string, callback: AsyncCallback<LockStatusResponse\>): void
2199
2200Unlocks PUK 2 of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
2201
2202**System API**: This is a system API.
2203
2204**Required permission**: ohos.permission.SET_TELEPHONY_STATE
2205
2206**System capability**: SystemCapability.Telephony.CoreService
2207
2208**Parameters**
2209
2210| Name  | Type                                                        | Mandatory| Description                                  |
2211| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
2212| slotId   | number                                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2213| newPin2  | string                                                       | Yes  | New PIN 2.                       |
2214| puk2     | string                                                       | Yes  | PUK of the SIM card.                   |
2215| callback | AsyncCallback&lt;[LockStatusResponse](#lockstatusresponse7)&gt; | Yes  | Callback used to return the result.                            |
2216
2217**Error codes**
2218
2219For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2220
2221| ID|                 Error Message                    |
2222| -------- | -------------------------------------------- |
2223| 201      | Permission denied.                           |
2224| 401      | Parameter error.                             |
2225| 8300001  | Invalid parameter value.                     |
2226| 8300002  | Operation failed. Cannot connect to service. |
2227| 8300003  | System internal error.                       |
2228| 8300004  | Do not have sim card.                        |
2229| 8300999  | Unknown error code.                          |
2230| 8301002  | SIM card operation error.                    |
2231
2232**Example**
2233
2234```js
2235let puk2 = '1xxxxxxx';
2236let newPin2 = '1235';
2237sim.unlockPuk2(0, newPin2, puk2, (err, data) => {
2238    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
2239});
2240```
2241
2242
2243## sim.unlockPuk2<sup>8+</sup>
2244
2245unlockPuk2(slotId: number, newPin2: string, puk2: string): Promise&lt;LockStatusResponse\>
2246
2247Unlocks PUK 2 of the SIM card in the specified slot. This API uses a promise to return the result.
2248
2249**System API**: This is a system API.
2250
2251**Required permission**: ohos.permission.SET_TELEPHONY_STATE
2252
2253**System capability**: SystemCapability.Telephony.CoreService
2254
2255**Parameters**
2256
2257| Name | Type  | Mandatory| Description                                  |
2258| ------- | ------ | ---- | -------------------------------------- |
2259| slotId  | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2260| newPin2 | string | Yes  | New PIN 2.                       |
2261| puk2    | string | Yes  | PUK of the SIM card.                   |
2262
2263**Return value**
2264
2265| Type                                                | Description                                              |
2266| ---------------------------------------------------- | -------------------------------------------------- |
2267| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
2268
2269**Error codes**
2270
2271For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2272
2273| ID|                 Error Message                    |
2274| -------- | -------------------------------------------- |
2275| 201      | Permission denied.                           |
2276| 401      | Parameter error.                             |
2277| 8300001  | Invalid parameter value.                     |
2278| 8300002  | Operation failed. Cannot connect to service. |
2279| 8300003  | System internal error.                       |
2280| 8300004  | Do not have sim card.                        |
2281| 8300999  | Unknown error code.                          |
2282| 8301002  | SIM card operation error.                    |
2283
2284**Example**
2285
2286```js
2287let puk2 = '1xxxxxxx';
2288let newPin2 = '1235';
2289let promise = sim.unlockPuk2(0, newPin2, puk2);
2290promise.then(data => {
2291    console.log(`unlockPuk2 success, promise: data->${JSON.stringify(data)}`);
2292}).catch(err => {
2293    console.log(`unlockPuk2 failed, promise: err->${JSON.stringify(err)}`);
2294});
2295```
2296
2297## sim.getMaxSimCount<sup>7+</sup>
2298
2299getMaxSimCount\(\): number
2300
2301Obtains the number of card slots.
2302
2303**System capability**: SystemCapability.Telephony.CoreService
2304
2305**Return value**
2306
2307| Type             | Description                                                        |
2308| ----------------- | ------------------------------------------------------------ |
2309| number | Number of card slots.|
2310
2311**Example**
2312
2313```js
2314console.log("Result: "+ sim.getMaxSimCount())
2315```
2316
2317## sim.getSimIccId<sup>7+</sup>
2318
2319getSimIccId(slotId: number, callback: AsyncCallback<string\>): void
2320
2321Obtains the ICCID of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
2322
2323**System API**: This is a system API.
2324
2325**Required permission**: ohos.permission.GET_TELEPHONY_STATE
2326
2327**System capability**: SystemCapability.Telephony.CoreService
2328
2329**Parameters**
2330
2331| Name  | Type                  | Mandatory| Description                                  |
2332| -------- | ---------------------- | ---- | -------------------------------------- |
2333| slotId   | number                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2334| callback | AsyncCallback<string\> | Yes  | Callback used to return the result.                            |
2335
2336**Error codes**
2337
2338For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2339
2340| ID|                 Error Message                    |
2341| -------- | -------------------------------------------- |
2342| 201      | Permission denied.                           |
2343| 401      | Parameter error.                             |
2344| 8300001  | Invalid parameter value.                     |
2345| 8300002  | Operation failed. Cannot connect to service. |
2346| 8300003  | System internal error.                       |
2347| 8300004  | Do not have sim card.                        |
2348| 8300999  | Unknown error code.                          |
2349
2350**Example**
2351
2352```js
2353sim.getSimIccId(0, (err, data) => {
2354    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
2355});
2356```
2357
2358
2359## sim.getSimIccId<sup>7+</sup>
2360
2361getSimIccId(slotId: number): Promise<string\>
2362
2363Obtains the ICCID of the SIM card in the specified slot. This API uses a promise to return the result.
2364
2365**System API**: This is a system API.
2366
2367**Required permission**: ohos.permission.GET_TELEPHONY_STATE
2368
2369**System capability**: SystemCapability.Telephony.CoreService
2370
2371**Parameters**
2372
2373| Name| Type  | Mandatory| Description                                  |
2374| ------ | ------ | ---- | -------------------------------------- |
2375| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2376
2377**Return value**
2378
2379| Type            | Description                                       |
2380| ---------------- | ------------------------------------------- |
2381| Promise<string\> | Promise used to return the result.|
2382
2383**Error codes**
2384
2385For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2386
2387| ID|                 Error Message                    |
2388| -------- | -------------------------------------------- |
2389| 201      | Permission denied.                           |
2390| 401      | Parameter error.                             |
2391| 8300001  | Invalid parameter value.                     |
2392| 8300002  | Operation failed. Cannot connect to service. |
2393| 8300003  | System internal error.                       |
2394| 8300004  | Do not have sim card.                        |
2395| 8300999  | Unknown error code.                          |
2396
2397**Example**
2398
2399```js
2400let promise = sim.getSimIccId(0);
2401promise.then(data => {
2402    console.log(`getSimIccId success, promise: data->${JSON.stringify(data)}`);
2403}).catch(err => {
2404    console.log(`getSimIccId failed, promise: err->${JSON.stringify(err)}`);
2405});
2406```
2407
2408## sim.getVoiceMailIdentifier<sup>8+</sup>
2409
2410getVoiceMailIdentifier(slotId: number, callback: AsyncCallback<string\>): void
2411
2412Obtains the voice mailbox alpha identifier of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
2413
2414**System API**: This is a system API.
2415
2416**Required permission**: ohos.permission.GET_TELEPHONY_STATE
2417
2418**System capability**: SystemCapability.Telephony.CoreService
2419
2420**Parameters**
2421
2422| Name  | Type                  | Mandatory| Description                                  |
2423| -------- | ---------------------- | ---- | -------------------------------------- |
2424| slotId   | number                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2425| callback | AsyncCallback<string\> | Yes  | Callback used to return the result.                            |
2426
2427**Error codes**
2428
2429For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2430
2431| ID|                 Error Message                    |
2432| -------- | -------------------------------------------- |
2433| 201      | Permission denied.                           |
2434| 401      | Parameter error.                             |
2435| 8300001  | Invalid parameter value.                     |
2436| 8300002  | Operation failed. Cannot connect to service. |
2437| 8300003  | System internal error.                       |
2438| 8300004  | Do not have sim card.                        |
2439| 8300999  | Unknown error code.                          |
2440
2441**Example**
2442
2443```js
2444sim.getVoiceMailIdentifier(0, (err, data) => {
2445    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
2446});
2447```
2448
2449
2450## sim.getVoiceMailIdentifier<sup>8+</sup>
2451
2452getVoiceMailIdentifier(slotId: number): Promise<string\>
2453
2454Obtains the voice mailbox alpha identifier of the SIM card in the specified slot. This API uses a promise to return the result.
2455
2456**System API**: This is a system API.
2457
2458**Required permission**: ohos.permission.GET_TELEPHONY_STATE
2459
2460**System capability**: SystemCapability.Telephony.CoreService
2461
2462**Parameters**
2463
2464| Name| Type  | Mandatory| Description                                  |
2465| ------ | ------ | ---- | -------------------------------------- |
2466| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2467
2468**Return value**
2469
2470| Type            | Description                                             |
2471| ---------------- | ------------------------------------------------- |
2472| Promise<string\> | Promise used to return the result.|
2473
2474**Error codes**
2475
2476For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2477
2478| ID|                 Error Message                    |
2479| -------- | -------------------------------------------- |
2480| 201      | Permission denied.                           |
2481| 401      | Parameter error.                             |
2482| 8300001  | Invalid parameter value.                     |
2483| 8300002  | Operation failed. Cannot connect to service. |
2484| 8300003  | System internal error.                       |
2485| 8300004  | Do not have sim card.                        |
2486| 8300999  | Unknown error code.                          |
2487
2488**Example**
2489
2490```js
2491let promise = sim.getVoiceMailIdentifier(0);
2492promise.then(data => {
2493    console.log(`getVoiceMailIdentifier success, promise: data->${JSON.stringify(data)}`);
2494}).catch(err => {
2495    console.log(`getVoiceMailIdentifier failed, promise: err->${JSON.stringify(err)}`);
2496});
2497```
2498
2499## sim.getVoiceMailNumber<sup>8+</sup>
2500
2501getVoiceMailNumber(slotId: number, callback: AsyncCallback<string\>): void
2502
2503Obtains the voice mailbox number of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
2504
2505**System API**: This is a system API.
2506
2507**Required permission**: ohos.permission.GET_TELEPHONY_STATE
2508
2509**System capability**: SystemCapability.Telephony.CoreService
2510
2511**Parameters**
2512
2513| Name  | Type                  | Mandatory| Description                                  |
2514| -------- | ---------------------- | ---- | -------------------------------------- |
2515| slotId   | number                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2516| callback | AsyncCallback<string\> | Yes  | Callback used to return the result.                            |
2517
2518**Error codes**
2519
2520For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2521
2522| ID|                 Error Message                    |
2523| -------- | -------------------------------------------- |
2524| 201      | Permission denied.                           |
2525| 401      | Parameter error.                             |
2526| 8300001  | Invalid parameter value.                     |
2527| 8300002  | Operation failed. Cannot connect to service. |
2528| 8300003  | System internal error.                       |
2529| 8300004  | Do not have sim card.                        |
2530| 8300999  | Unknown error code.                          |
2531
2532**Example**
2533
2534```js
2535sim.getVoiceMailNumber(0, (err, data) => {
2536    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
2537});
2538```
2539
2540
2541## sim.getVoiceMailNumber<sup>8+</sup>
2542
2543getVoiceMailNumber(slotId: number): Promise<string\>
2544
2545Obtains the voice mailbox number of the SIM card in the specified slot. This API uses a promise to return the result.
2546
2547**System API**: This is a system API.
2548
2549**Required permission**: ohos.permission.GET_TELEPHONY_STATE
2550
2551**System capability**: SystemCapability.Telephony.CoreService
2552
2553**Parameters**
2554
2555| Name| Type  | Mandatory| Description                                  |
2556| ------ | ------ | ---- | -------------------------------------- |
2557| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2558
2559**Return value**
2560
2561| Type            | Description                                            |
2562| ---------------- | ------------------------------------------------ |
2563| Promise<string\> | Promise used to return the result.|
2564
2565**Error codes**
2566
2567For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2568
2569| ID|                 Error Message                    |
2570| -------- | -------------------------------------------- |
2571| 201      | Permission denied.                           |
2572| 401      | Parameter error.                             |
2573| 8300001  | Invalid parameter value.                     |
2574| 8300002  | Operation failed. Cannot connect to service. |
2575| 8300003  | System internal error.                       |
2576| 8300004  | Do not have sim card.                        |
2577| 8300999  | Unknown error code.                          |
2578
2579**Example**
2580
2581```js
2582let promise = sim.getVoiceMailNumber(0);
2583promise.then(data => {
2584    console.log(`getVoiceMailNumber success, promise: data->${JSON.stringify(data)}`);
2585}).catch(err => {
2586    console.log(`getVoiceMailNumber failed, promise: err->${JSON.stringify(err)}`);
2587});
2588```
2589
2590
2591## sim.setVoiceMailInfo<sup>8+</sup>
2592
2593setVoiceMailInfo(slotId: number, mailName: string, mailNumber: string, callback: AsyncCallback<void\>): void
2594
2595Sets voice mailbox information for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
2596
2597**System API**: This is a system API.
2598
2599**Required permission**: ohos.permission.SET_TELEPHONY_STATE
2600
2601**System capability**: SystemCapability.Telephony.CoreService
2602
2603**Parameters**
2604
2605| Name    | Type                | Mandatory| Description                                  |
2606| ---------- | -------------------- | ---- | -------------------------------------- |
2607| slotId     | number               | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2608| mailName   | string               | Yes  | Voice mailbox name.                              |
2609| mailNumber | string               | Yes  | Voice mailbox number.                              |
2610| callback   | AsyncCallback<void\> | Yes  | Callback used to return the result.                            |
2611
2612**Error codes**
2613
2614For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2615
2616| ID|                 Error Message                    |
2617| -------- | -------------------------------------------- |
2618| 201      | Permission denied.                           |
2619| 401      | Parameter error.                             |
2620| 8300001  | Invalid parameter value.                     |
2621| 8300002  | Operation failed. Cannot connect to service. |
2622| 8300003  | System internal error.                       |
2623| 8300004  | Do not have sim card.                        |
2624| 8300999  | Unknown error code.                          |
2625| 8301002  | SIM card operation error.                    |
2626
2627**Example**
2628
2629```js
2630sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com", (err) => {
2631    console.log(`callback: err->${JSON.stringify(err)}`);
2632});
2633```
2634
2635
2636## sim.setVoiceMailInfo<sup>8+</sup>
2637
2638setVoiceMailInfo(slotId: number, mailName: string, mailNumber: string): Promise<void\>
2639
2640Sets voice mailbox information for the SIM card in the specified slot. This API uses a promise to return the result.
2641
2642**System API**: This is a system API.
2643
2644**Required permission**: ohos.permission.SET_TELEPHONY_STATE
2645
2646**System capability**: SystemCapability.Telephony.CoreService
2647
2648**Parameters**
2649
2650| Name    | Type  | Mandatory| Description                                  |
2651| ---------- | ------ | ---- | -------------------------------------- |
2652| slotId     | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2653| mailName   | string | Yes  | Voice mailbox name.                              |
2654| mailNumber | string | Yes  | Voice mailbox number.                              |
2655
2656**Return value**
2657
2658| Type          | Description                   |
2659| -------------- | ----------------------- |
2660| Promise<void\> | Promise used to return the result.|
2661
2662**Error codes**
2663
2664For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2665
2666| ID|                 Error Message                    |
2667| -------- | -------------------------------------------- |
2668| 201      | Permission denied.                           |
2669| 401      | Parameter error.                             |
2670| 8300001  | Invalid parameter value.                     |
2671| 8300002  | Operation failed. Cannot connect to service. |
2672| 8300003  | System internal error.                       |
2673| 8300004  | Do not have sim card.                        |
2674| 8300999  | Unknown error code.                          |
2675| 8301002  | SIM card operation error.                    |
2676
2677**Example**
2678
2679```js
2680let promise = sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com");
2681promise.then(() => {
2682    console.log(`setVoiceMailInfo success.`);
2683}).catch((err) => {
2684    console.log(`setVoiceMailInfo failed, promise: err->${JSON.stringify(err)}`);
2685});
2686```
2687
2688## sim.getSimTelephoneNumber<sup>8+</sup>
2689
2690getSimTelephoneNumber(slotId: number, callback: AsyncCallback<string\>): void
2691
2692Obtains the MSISDN of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
2693
2694**System API**: This is a system API.
2695
2696**Required permission**: ohos.permission.GET_TELEPHONY_STATE
2697
2698**System capability**: SystemCapability.Telephony.CoreService
2699
2700**Parameters**
2701
2702| Name  | Type                  | Mandatory| Description                                  |
2703| -------- | ---------------------- | ---- | -------------------------------------- |
2704| slotId   | number                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2705| callback | AsyncCallback<string\> | Yes  | Callback used to return the result.                            |
2706
2707**Error codes**
2708
2709For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2710
2711| ID|                 Error Message                    |
2712| -------- | -------------------------------------------- |
2713| 201      | Permission denied.                           |
2714| 401      | Parameter error.                             |
2715| 8300001  | Invalid parameter value.                     |
2716| 8300002  | Operation failed. Cannot connect to service. |
2717| 8300003  | System internal error.                       |
2718| 8300004  | Do not have sim card.                        |
2719| 8300999  | Unknown error code.                          |
2720
2721**Example**
2722
2723```js
2724sim.getSimTelephoneNumber(0, (err, data) => {
2725    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
2726});
2727```
2728
2729
2730## sim.getSimTelephoneNumber<sup>8+</sup>
2731
2732getSimTelephoneNumber(slotId: number): Promise<string\>
2733
2734Obtains the MSISDN of the SIM card in the specified slot. This API uses a promise to return the result.
2735
2736**System API**: This is a system API.
2737
2738**Required permission**: ohos.permission.GET_TELEPHONY_STATE
2739
2740**System capability**: SystemCapability.Telephony.CoreService
2741
2742**Parameters**
2743
2744| Name| Type  | Mandatory| Description                                  |
2745| ------ | ------ | ---- | -------------------------------------- |
2746| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2747
2748**Return value**
2749
2750| Type            | Description                                        |
2751| ---------------- | -------------------------------------------- |
2752| Promise<string\> | Promise used to return the result.|
2753
2754**Error codes**
2755
2756For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2757
2758| ID|                 Error Message                    |
2759| -------- | -------------------------------------------- |
2760| 201      | Permission denied.                           |
2761| 401      | Parameter error.                             |
2762| 8300001  | Invalid parameter value.                     |
2763| 8300002  | Operation failed. Cannot connect to service. |
2764| 8300003  | System internal error.                       |
2765| 8300004  | Do not have sim card.                        |
2766| 8300999  | Unknown error code.                          |
2767
2768**Example**
2769
2770```js
2771let promise = sim.getSimTelephoneNumber(0);
2772promise.then(data => {
2773    console.log(`getSimTelephoneNumber success, promise: data->${JSON.stringify(data)}`);
2774}).catch(err => {
2775    console.log(`getSimTelephoneNumber failed, promise: err->${JSON.stringify(err)}`);
2776});
2777```
2778
2779## sim.getSimGid1<sup>7+</sup>
2780
2781getSimGid1(slotId: number, callback: AsyncCallback<string\>): void
2782
2783Obtains the group identifier level 1 (GID1) of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
2784
2785**System API**: This is a system API.
2786
2787**Required permission**: ohos.permission.GET_TELEPHONY_STATE
2788
2789**System capability**: SystemCapability.Telephony.CoreService
2790
2791**Parameters**
2792
2793| Name  | Type                   | Mandatory| Description                                  |
2794| -------- | ----------------------- | ---- | -------------------------------------- |
2795| slotId   | number                  | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2796| callback | AsyncCallback\<string\> | Yes  | Callback used to return the result.                            |
2797
2798**Error codes**
2799
2800For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2801
2802| ID|                 Error Message                    |
2803| -------- | -------------------------------------------- |
2804| 201      | Permission denied.                           |
2805| 401      | Parameter error.                             |
2806| 8300001  | Invalid parameter value.                     |
2807| 8300002  | Operation failed. Cannot connect to service. |
2808| 8300003  | System internal error.                       |
2809| 8300004  | Do not have sim card.                        |
2810| 8300999  | Unknown error code.                          |
2811
2812**Example**
2813
2814```js
2815sim.getSimGid1(0, (err, data) => {
2816    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
2817});
2818```
2819
2820
2821## sim.getSimGid1<sup>7+</sup>
2822
2823getSimGid1(slotId: number): Promise<string\>
2824
2825Obtains the GID1 of the SIM card in the specified slot. This API uses a promise to return the result.
2826
2827**System API**: This is a system API.
2828
2829**Required permission**: ohos.permission.GET_TELEPHONY_STATE
2830
2831**System capability**: SystemCapability.Telephony.CoreService
2832
2833**Parameters**
2834
2835| Name| Type  | Mandatory| Description                                  |
2836| ------ | ------ | ---- | -------------------------------------- |
2837| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2838
2839**Return value**
2840
2841| Type            | Description                                             |
2842| ---------------- | ------------------------------------------------- |
2843| Promise<string\> | Promise used to return the result.|
2844
2845**Error codes**
2846
2847For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2848
2849| ID|                 Error Message                    |
2850| -------- | -------------------------------------------- |
2851| 201      | Permission denied.                           |
2852| 401      | Parameter error.                             |
2853| 8300001  | Invalid parameter value.                     |
2854| 8300002  | Operation failed. Cannot connect to service. |
2855| 8300003  | System internal error.                       |
2856| 8300999  | Unknown error code.                          |
2857
2858**Example**
2859
2860```js
2861let promise = sim.getSimGid1(0);
2862promise.then(data => {
2863    console.log(`getSimGid1 success, promise: data->${JSON.stringify(data)}`);
2864}).catch(err => {
2865    console.log(`getSimGid1 failed, promise: err->${JSON.stringify(err)}`);
2866});
2867```
2868
2869## sim.getIMSI
2870
2871getIMSI(slotId: number, callback: AsyncCallback<string\>): void
2872
2873Obtains the international mobile subscriber identity (IMSI) of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
2874
2875**System API**: This is a system API.
2876
2877**Required permission**: ohos.permission.GET_TELEPHONY_STATE
2878
2879**System capability**: SystemCapability.Telephony.CoreService
2880
2881**Parameters**
2882
2883| Name  | Type                   | Mandatory| Description                                  |
2884| -------- | ----------------------- | ---- | -------------------------------------- |
2885| slotId   | number                  | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2886| callback | AsyncCallback\<string\> | Yes  | Callback used to return the result.                            |
2887
2888**Error codes**
2889
2890For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2891
2892| ID|                 Error Message                    |
2893| -------- | -------------------------------------------- |
2894| 201      | Permission denied.                           |
2895| 401      | Parameter error.                             |
2896| 8300001  | Invalid parameter value.                     |
2897| 8300002  | Operation failed. Cannot connect to service. |
2898| 8300003  | System internal error.                       |
2899| 8300999  | Unknown error code.                          |
2900
2901**Example**
2902
2903```js
2904sim.getIMSI(0, (err, data) => {
2905    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
2906});
2907```
2908
2909
2910## sim.getIMSI
2911
2912getIMSI(slotId: number): Promise<string\>
2913
2914Obtains the IMSI of the SIM card in the specified slot. This API uses a promise to return the result.
2915
2916**System API**: This is a system API.
2917
2918**Required permission**: ohos.permission.GET_TELEPHONY_STATE
2919
2920**System capability**: SystemCapability.Telephony.CoreService
2921
2922**Parameters**
2923
2924| Name| Type  | Mandatory| Description                                  |
2925| ------ | ------ | ---- | -------------------------------------- |
2926| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2927
2928**Return value**
2929
2930| Type            | Description                                       |
2931| ---------------- | ------------------------------------------- |
2932| Promise<string\> | Promise used to return the result.|
2933
2934**Error codes**
2935
2936For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2937
2938| ID|                 Error Message                    |
2939| -------- | -------------------------------------------- |
2940| 201      | Permission denied.                           |
2941| 401      | Parameter error.                             |
2942| 8300001  | Invalid parameter value.                     |
2943| 8300002  | Operation failed. Cannot connect to service. |
2944| 8300003  | System internal error.                       |
2945| 8300004  | Do not have sim card.                        |
2946| 8300999  | Unknown error code.                          |
2947
2948**Example**
2949
2950```js
2951let promise = sim.getIMSI(0);
2952promise.then(data => {
2953    console.log(`getIMSI success, promise: data->${JSON.stringify(data)}`);
2954}).catch(err => {
2955    console.log(`getIMSI failed, promise: err->${JSON.stringify(err)}`);
2956});
2957```
2958
2959## sim.getOperatorConfigs<sup>8+</sup>
2960
2961getOperatorConfigs(slotId: number, callback: AsyncCallback<Array<OperatorConfig\>>): void
2962
2963Obtains the carrier configuration of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
2964
2965**System API**: This is a system API.
2966
2967**Required permission**: ohos.permission.GET_TELEPHONY_STATE
2968
2969**System capability**: SystemCapability.Telephony.CoreService
2970
2971**Parameters**
2972
2973| Name  | Type                                                     | Mandatory| Description                                  |
2974| -------- | --------------------------------------------------------- | ---- | -------------------------------------- |
2975| slotId   | number                                                    | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
2976| callback | AsyncCallback<Array<[OperatorConfig](#operatorconfig8)\>> | Yes  | Callback used to return the result.                            |
2977
2978**Error codes**
2979
2980For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
2981
2982| ID|                 Error Message                    |
2983| -------- | -------------------------------------------- |
2984| 201      | Permission denied.                           |
2985| 401      | Parameter error.                             |
2986| 8300001  | Invalid parameter value.                     |
2987| 8300002  | Operation failed. Cannot connect to service. |
2988| 8300003  | System internal error.                       |
2989| 8300004  | Do not have sim card.                        |
2990| 8300999  | Unknown error code.                          |
2991
2992**Example**
2993
2994```js
2995sim.getOperatorConfigs(0, (err, data) => {
2996    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
2997});
2998```
2999
3000
3001## sim.getOperatorConfigs<sup>8+</sup>
3002
3003getOperatorConfigs(slotId: number): Promise<Array<OperatorConfig\>>
3004
3005Obtains the carrier configuration of the SIM card in the specified slot. This API uses a promise to return the result.
3006
3007**System API**: This is a system API.
3008
3009**Required permission**: ohos.permission.GET_TELEPHONY_STATE
3010
3011**System capability**: SystemCapability.Telephony.CoreService
3012
3013**Parameters**
3014
3015| Name| Type  | Mandatory| Description                                  |
3016| ------ | ------ | ---- | -------------------------------------- |
3017| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
3018
3019**Return value**
3020
3021| Type                                               | Description                         |
3022| --------------------------------------------------- | ----------------------------- |
3023| Promise<Array<[OperatorConfig](#operatorconfig8)\>> | Promise used to return the result.|
3024
3025**Error codes**
3026
3027For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3028
3029| ID|                 Error Message                    |
3030| -------- | -------------------------------------------- |
3031| 201      | Permission denied.                           |
3032| 401      | Parameter error.                             |
3033| 8300001  | Invalid parameter value.                     |
3034| 8300002  | Operation failed. Cannot connect to service. |
3035| 8300003  | System internal error.                       |
3036| 8300004  | Do not have sim card.                        |
3037| 8300999  | Unknown error code.                          |
3038
3039**Example**
3040
3041```js
3042let promise = sim.getOperatorConfigs(0);
3043promise.then(data => {
3044    console.log(`getOperatorConfigs success, promise: data->${JSON.stringify(data)}`);
3045}).catch(err => {
3046    console.log(`getOperatorConfigs failed, promise: err->${JSON.stringify(err)}`);
3047});
3048```
3049
3050## sim.queryIccDiallingNumbers<sup>8+</sup>
3051
3052queryIccDiallingNumbers(slotId: number, type: ContactType, callback: AsyncCallback<Array<DiallingNumbersInfo\>>): void
3053
3054Queries contact numbers of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
3055
3056**System API**: This is a system API.
3057
3058**Permission required**: ohos.permission.READ_CONTACTS
3059
3060**System capability**: SystemCapability.Telephony.CoreService
3061
3062**Parameters**
3063
3064| Name  | Type                                                        | Mandatory| Description                                                      |
3065| -------- | ------------------------------------------------------------ | ---- | ---------------------------------------------------------- |
3066| slotId   | number                                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                    |
3067| type     | [ContactType](#contacttype8)                                 | Yes  | Contact type.<br>- **1**: GENERAL_CONTACT<br>- **2**: FIXED_DIALING|
3068| callback | AsyncCallback<Array<[DiallingNumbersInfo](#diallingnumbersinfo8)\>> | Yes  | Callback used to return the result.                                         |
3069
3070**Error codes**
3071
3072For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3073
3074| ID|                 Error Message                    |
3075| -------- | -------------------------------------------- |
3076| 201      | Permission denied.                           |
3077| 401      | Parameter error.                             |
3078| 8300001  | Invalid parameter value.                     |
3079| 8300002  | Operation failed. Cannot connect to service. |
3080| 8300003  | System internal error.                       |
3081| 8300004  | Do not have sim card.                        |
3082| 8300999  | Unknown error code.                          |
3083| 8301002  | SIM card operation error.                    |
3084
3085**Example**
3086
3087```js
3088sim.queryIccDiallingNumbers(0, 1, (err, data) => {
3089    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
3090});
3091```
3092
3093
3094## sim.queryIccDiallingNumbers<sup>8+</sup>
3095
3096queryIccDiallingNumbers(slotId: number, type: ContactType): Promise<Array<DiallingNumbersInfo\>>
3097
3098Queries contact numbers of the SIM card in the specified slot. This API uses a promise to return the result.
3099
3100**System API**: This is a system API.
3101
3102**Permission required**: ohos.permission.READ_CONTACTS
3103
3104**System capability**: SystemCapability.Telephony.CoreService
3105
3106**Parameters**
3107
3108| Name| Type       | Mandatory| Description                                                      |
3109| ------ | ----------- | ---- | ---------------------------------------------------------- |
3110| slotId | number      | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                    |
3111| type   | [ContactType](#contacttype8)  | Yes  | Contact type.<br>- **1**: GENERAL_CONTACT<br>- **2**: FIXED_DIALING|
3112
3113**Return value**
3114
3115| Type                                                        | Description                          |
3116| ------------------------------------------------------------ | ------------------------------ |
3117| Promise<Array<[DiallingNumbersInfo](#diallingnumbersinfo8)\>> | Promise used to return the result.|
3118
3119**Error codes**
3120
3121For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3122
3123| ID|                 Error Message                    |
3124| -------- | -------------------------------------------- |
3125| 201      | Permission denied.                           |
3126| 401      | Parameter error.                             |
3127| 8300001  | Invalid parameter value.                     |
3128| 8300002  | Operation failed. Cannot connect to service. |
3129| 8300003  | System internal error.                       |
3130| 8300004  | Do not have sim card.                        |
3131| 8300999  | Unknown error code.                          |
3132| 8301002  | SIM card operation error.                    |
3133
3134**Example**
3135
3136```js
3137let promise = sim.queryIccDiallingNumbers(0, 1);
3138promise.then(data => {
3139    console.log(`queryIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`);
3140}).catch(err => {
3141    console.log(`queryIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`);
3142});
3143```
3144
3145## sim.addIccDiallingNumbers<sup>8+</sup>
3146
3147addIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback<void\>): void
3148
3149Adds contact numbers for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
3150
3151**System API**: This is a system API.
3152
3153**Permission required**: ohos.permission.WRITE_CONTACTS
3154
3155**System capability**: SystemCapability.Telephony.CoreService
3156
3157**Parameters**
3158
3159| Name         | Type                                        | Mandatory| Description                                                      |
3160| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
3161| slotId          | number                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                    |
3162| type            | [ContactType](#contacttype8)                 | Yes  | Contact type.<br>- **1**: GENERAL_CONTACT<br>- **2**: FIXED_DIALING |
3163| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes  | Contact number information.                                              |
3164| callback        | AsyncCallback<void\>                         | Yes  | Callback used to return the result.                                                  |
3165
3166**Error codes**
3167
3168For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3169
3170| ID|                 Error Message                    |
3171| -------- | -------------------------------------------- |
3172| 201      | Permission denied.                           |
3173| 401      | Parameter error.                             |
3174| 8300001  | Invalid parameter value.                     |
3175| 8300002  | Operation failed. Cannot connect to service. |
3176| 8300003  | System internal error.                       |
3177| 8300004  | Do not have sim card.                        |
3178| 8300999  | Unknown error code.                          |
3179| 8301002  | SIM card operation error.                    |
3180
3181**Example**
3182
3183```js
3184let diallingNumbersInof = {
3185    alphaTag: "alpha",
3186    number: "138xxxxxxxx",
3187    pin2: "1234"
3188};
3189sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err) => {
3190    console.log(`callback: err->${JSON.stringify(err)}`);
3191});
3192```
3193
3194
3195## sim.addIccDiallingNumbers<sup>8+</sup>
3196
3197addIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo): Promise<void\>
3198
3199Adds contact numbers for the SIM card in the specified slot. This API uses a promise to return the result.
3200
3201**System API**: This is a system API.
3202
3203**Permission required**: ohos.permission.WRITE_CONTACTS
3204
3205**System capability**: SystemCapability.Telephony.CoreService
3206
3207**Parameters**
3208
3209| Name         | Type                                        | Mandatory| Description                                                      |
3210| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
3211| slotId          | number                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                    |
3212| type            | [ContactType](#contacttype8)                 | Yes  | Contact type.<br>- **1**: GENERAL_CONTACT<br>- **2**: FIXED_DIALING |
3213| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes  | Contact number information.                                              |
3214
3215**Return value**
3216
3217| Type          | Description                       |
3218| -------------- | --------------------------- |
3219| Promise<void\> | Promise used to return the result.|
3220
3221**Error codes**
3222
3223For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3224
3225| ID|                 Error Message                    |
3226| -------- | -------------------------------------------- |
3227| 201      | Permission denied.                           |
3228| 401      | Parameter error.                             |
3229| 8300001  | Invalid parameter value.                     |
3230| 8300002  | Operation failed. Cannot connect to service. |
3231| 8300003  | System internal error.                       |
3232| 8300004  | Do not have sim card.                        |
3233| 8300999  | Unknown error code.                          |
3234| 8301002  | SIM card operation error.                    |
3235
3236**Example**
3237
3238```js
3239let diallingNumbersInof = {
3240    alphaTag: "alpha",
3241    number: "138xxxxxxxx"
3242};
3243let promise = sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof);
3244promise.then(() => {
3245    console.log(`addIccDiallingNumbers success.`);
3246}).catch((err) => {
3247    console.log(`addIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`);
3248});
3249```
3250
3251## sim.delIccDiallingNumbers<sup>8+</sup>
3252
3253delIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback<void\>): void
3254
3255Deletes contact numbers from the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
3256
3257**System API**: This is a system API.
3258
3259**Permission required**: ohos.permission.WRITE_CONTACTS
3260
3261**System capability**: SystemCapability.Telephony.CoreService
3262
3263**Parameters**
3264
3265| Name         | Type                                        | Mandatory| Description                                                      |
3266| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
3267| slotId          | number                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                    |
3268| type            | [ContactType](#contacttype8)                 | Yes  | Contact type.<br>- **1**: GENERAL_CONTACT<br>- **2**: FIXED_DIALING |
3269| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes  | Contact number information.                                              |
3270| callback        | AsyncCallback<void\>                         | Yes  | Callback used to return the result.                                                  |
3271
3272**Error codes**
3273
3274For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3275
3276| ID|                 Error Message                    |
3277| -------- | -------------------------------------------- |
3278| 201      | Permission denied.                           |
3279| 401      | Parameter error.                             |
3280| 8300001  | Invalid parameter value.                     |
3281| 8300002  | Operation failed. Cannot connect to service. |
3282| 8300003  | System internal error.                       |
3283| 8300004  | Do not have sim card.                        |
3284| 8300999  | Unknown error code.                          |
3285| 8301002  | SIM card operation error.                    |
3286
3287**Example**
3288
3289```js
3290let diallingNumbersInof = {
3291    alphaTag: "alpha",
3292    number: "138xxxxxxxx",
3293    recordNumber: 123,
3294    pin2: "1234"
3295};
3296sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err) => {
3297    console.log(`callback: err->${JSON.stringify(err)}`);
3298});
3299```
3300
3301
3302## sim.delIccDiallingNumbers<sup>8+</sup>
3303
3304delIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo): Promise<void\>
3305
3306Deletes contact numbers from the SIM card in the specified slot. This API uses a promise to return the result.
3307
3308**System API**: This is a system API.
3309
3310**Permission required**: ohos.permission.WRITE_CONTACTS
3311
3312**System capability**: SystemCapability.Telephony.CoreService
3313
3314**Parameters**
3315
3316| Name         | Type                                        | Mandatory| Description                                                      |
3317| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
3318| slotId          | number                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                    |
3319| type            | [ContactType](#contacttype8)                 | Yes  | Contact type.<br>- **1**: GENERAL_CONTACT<br>- **2**: FIXED_DIALING |
3320| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes  | Contact number information.                                              |
3321
3322**Return value**
3323
3324| Type          | Description                       |
3325| -------------- | --------------------------- |
3326| Promise<void\> | Promise used to return the result.|
3327
3328**Error codes**
3329
3330For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3331
3332| ID|                 Error Message                    |
3333| -------- | -------------------------------------------- |
3334| 201      | Permission denied.                           |
3335| 401      | Parameter error.                             |
3336| 8300001  | Invalid parameter value.                     |
3337| 8300002  | Operation failed. Cannot connect to service. |
3338| 8300003  | System internal error.                       |
3339| 8300004  | Do not have sim card.                        |
3340| 8300999  | Unknown error code.                          |
3341| 8301002  | SIM card operation error.                    |
3342
3343**Example**
3344
3345```js
3346let diallingNumbersInof = {
3347    alphaTag: "alpha",
3348    number: "138xxxxxxxx"
3349};
3350let promise = sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof);
3351promise.then(() => {
3352    console.log(`delIccDiallingNumbers success.`);
3353}).catch((err) => {
3354    console.log(`delIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`);
3355});
3356```
3357
3358## sim.updateIccDiallingNumbers<sup>8+</sup>
3359
3360updateIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback<void\>): void
3361
3362Updates contact numbers for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
3363
3364**System API**: This is a system API.
3365
3366**Permission required**: ohos.permission.WRITE_CONTACTS
3367
3368**System capability**: SystemCapability.Telephony.CoreService
3369
3370**Parameters**
3371
3372| Name         | Type                                        | Mandatory| Description                                                      |
3373| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
3374| slotId          | number                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                    |
3375| type            | [ContactType](#contacttype8)                 | Yes  | Contact type.<br>- **1**: GENERAL_CONTACT<br>- **2**: FIXED_DIALING |
3376| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes  | Contact number information.                                              |
3377| callback        | AsyncCallback<void\>                         | Yes  | Callback used to return the result.                                                  |
3378
3379**Error codes**
3380
3381For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3382
3383| ID|                 Error Message                    |
3384| -------- | -------------------------------------------- |
3385| 201      | Permission denied.                           |
3386| 401      | Parameter error.                             |
3387| 8300001  | Invalid parameter value.                     |
3388| 8300002  | Operation failed. Cannot connect to service. |
3389| 8300003  | System internal error.                       |
3390| 8300004  | Do not have sim card.                        |
3391| 8300999  | Unknown error code.                          |
3392| 8301002  | SIM card operation error.                    |
3393
3394**Example**
3395
3396```js
3397let diallingNumbersInof = {
3398    alphaTag: "alpha",
3399    number: "138xxxxxxxx",
3400    recordNumber: 123,
3401    pin2: "1234"
3402};
3403sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err) => {
3404    console.log(`callback: err->${JSON.stringify(err)}`);
3405});
3406```
3407
3408
3409## sim.updateIccDiallingNumbers<sup>8+</sup>
3410
3411updateIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo): Promise<void\>
3412
3413Updates contact numbers for the SIM card in the specified slot. This API uses a promise to return the result.
3414
3415**System API**: This is a system API.
3416
3417**Permission required**: ohos.permission.WRITE_CONTACTS
3418
3419**System capability**: SystemCapability.Telephony.CoreService
3420
3421**Parameters**
3422
3423| Name         | Type                                        | Mandatory| Description                                                      |
3424| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
3425| slotId          | number                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                    |
3426| type            | [ContactType](#contacttype8)                 | Yes  | Contact type.<br>- **1**: GENERAL_CONTACT<br>- **2**: FIXED_DIALING |
3427| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes  | Contact number information.                                              |
3428
3429**Return value**
3430
3431| Type          | Description                         |
3432| -------------- | ----------------------------- |
3433| Promise<void\> | Promise used to return the result.|
3434
3435**Error codes**
3436
3437For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3438
3439| ID|                 Error Message                    |
3440| -------- | -------------------------------------------- |
3441| 201      | Permission denied.                           |
3442| 401      | Parameter error.                             |
3443| 8300001  | Invalid parameter value.                     |
3444| 8300002  | Operation failed. Cannot connect to service. |
3445| 8300003  | System internal error.                       |
3446| 8300004  | Do not have sim card.                        |
3447| 8300999  | Unknown error code.                          |
3448| 8301002  | SIM card operation error.                    |
3449
3450**Example**
3451
3452```js
3453let diallingNumbersInof = {
3454    alphaTag: "alpha",
3455    number: "138xxxxxxxx",
3456    recordNumber: 123
3457};
3458let promise = sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof);
3459promise.then(() => {
3460    console.log(`updateIccDiallingNumbers success.`);
3461}).catch((err) => {
3462    console.log(`updateIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`);
3463});
3464```
3465
3466## sim.sendEnvelopeCmd<sup>8+</sup>
3467
3468sendEnvelopeCmd(slotId: number, cmd: string, callback: AsyncCallback<void\>): void
3469
3470Sends an envelope command to the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
3471
3472**System API**: This is a system API.
3473
3474**Required permission**: ohos.permission.SET_TELEPHONY_STATE
3475
3476**System capability**: SystemCapability.Telephony.CoreService
3477
3478**Parameters**
3479
3480| Name  | Type                | Mandatory| Description                                  |
3481| -------- | -------------------- | ---- | -------------------------------------- |
3482| slotId   | number               | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
3483| cmd      | string               | Yes  | Envelope command.                                  |
3484| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.                                    |
3485
3486**Error codes**
3487
3488For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3489
3490| ID|                 Error Message                    |
3491| -------- | -------------------------------------------- |
3492| 201      | Permission denied.                           |
3493| 401      | Parameter error.                             |
3494| 8300001  | Invalid parameter value.                     |
3495| 8300002  | Operation failed. Cannot connect to service. |
3496| 8300003  | System internal error.                       |
3497| 8300004  | Do not have sim card.                        |
3498| 8300999  | Unknown error code.                          |
3499
3500**Example**
3501
3502```js
3503sim.sendEnvelopeCmd(0, "ls", (err) => {
3504    console.log(`callback: err->${JSON.stringify(err)}`);
3505});
3506```
3507
3508
3509## sim.sendEnvelopeCmd<sup>8+</sup>
3510
3511sendEnvelopeCmd(slotId: number, cmd: string): Promise<void\>
3512
3513Sends an envelope command to the SIM card in the specified slot. This API uses a promise to return the result.
3514
3515**System API**: This is a system API.
3516
3517**Required permission**: ohos.permission.SET_TELEPHONY_STATE
3518
3519**System capability**: SystemCapability.Telephony.CoreService
3520
3521**Parameters**
3522
3523| Name| Type  | Mandatory| Description                                  |
3524| ------ | ------ | ---- | -------------------------------------- |
3525| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
3526| cmd    | string | Yes  | Envelope command.                                  |
3527
3528**Return value**
3529
3530| Type          | Description                       |
3531| -------------- | --------------------------- |
3532| Promise<void\> | Promise used to return the result.|
3533
3534**Error codes**
3535
3536For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3537
3538| ID|                 Error Message                    |
3539| -------- | -------------------------------------------- |
3540| 201      | Permission denied.                           |
3541| 401      | Parameter error.                             |
3542| 8300001  | Invalid parameter value.                     |
3543| 8300002  | Operation failed. Cannot connect to service. |
3544| 8300003  | System internal error.                       |
3545| 8300004  | Do not have sim card.                        |
3546| 8300999  | Unknown error code.                          |
3547
3548**Example**
3549
3550```js
3551let promise = sim.sendEnvelopeCmd(0, "ls");
3552promise.then(() => {
3553    console.log(`sendEnvelopeCmd success.`);
3554}).catch((err) => {
3555    console.log(`sendEnvelopeCmd failed, promise: err->${JSON.stringify(err)}`);
3556});
3557```
3558
3559## sim.sendTerminalResponseCmd<sup>8+</sup>
3560
3561sendTerminalResponseCmd(slotId: number, cmd: string, callback: AsyncCallback<void\>): void
3562
3563Sends a terminal response command to the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
3564
3565**System API**: This is a system API.
3566
3567**Required permission**: ohos.permission.SET_TELEPHONY_STATE
3568
3569**System capability**: SystemCapability.Telephony.CoreService
3570
3571**Parameters**
3572
3573| Name  | Type                | Mandatory| Description                                  |
3574| -------- | -------------------- | ---- | -------------------------------------- |
3575| slotId   | number               | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
3576| cmd      | string               | Yes  | Envelope command.                                  |
3577| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.                            |
3578
3579**Error codes**
3580
3581For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3582
3583| ID|                 Error Message                    |
3584| -------- | -------------------------------------------- |
3585| 201      | Permission denied.                           |
3586| 401      | Parameter error.                             |
3587| 8300001  | Invalid parameter value.                     |
3588| 8300002  | Operation failed. Cannot connect to service. |
3589| 8300003  | System internal error.                       |
3590| 8300999  | Unknown error code.                          |
3591
3592**Example**
3593
3594```js
3595sim.sendTerminalResponseCmd(0, "ls", (err) => {
3596    console.log(`callback: err->${JSON.stringify(err)}`);
3597});
3598```
3599
3600
3601## sim.sendTerminalResponseCmd<sup>8+</sup>
3602
3603sendTerminalResponseCmd(slotId: number, cmd: string): Promise<void\>
3604
3605Sends a terminal response command to the SIM card in the specified slot. This API uses a promise to return the result.
3606
3607**System API**: This is a system API.
3608
3609**Required permission**: ohos.permission.SET_TELEPHONY_STATE
3610
3611**System capability**: SystemCapability.Telephony.CoreService
3612
3613**Parameters**
3614
3615| Name| Type  | Mandatory| Description                                  |
3616| ------ | ------ | ---- | -------------------------------------- |
3617| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
3618| cmd    | string | Yes  | Envelope command.                                  |
3619
3620**Return value**
3621
3622| Type          | Description                       |
3623| -------------- | --------------------------- |
3624| Promise<void\> | Promise used to return the result.|
3625
3626**Error codes**
3627
3628For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3629
3630| ID|                 Error Message                    |
3631| -------- | -------------------------------------------- |
3632| 201      | Permission denied.                           |
3633| 401      | Parameter error.                             |
3634| 8300001  | Invalid parameter value.                     |
3635| 8300002  | Operation failed. Cannot connect to service. |
3636| 8300003  | System internal error.                       |
3637| 8300999  | Unknown error code.                          |
3638
3639**Example**
3640
3641```js
3642let promise = sim.sendTerminalResponseCmd(0, "ls");
3643promise.then(() => {
3644    console.log(`sendTerminalResponseCmd success.`);
3645}).catch((err) => {
3646    console.log(`sendTerminalResponseCmd failed, promise: err->${JSON.stringify(err)}`);
3647});
3648```
3649
3650
3651## sim.unlockSimLock<sup>8+</sup>
3652
3653unlockSimLock(slotId: number, lockInfo: PersoLockInfo, callback: AsyncCallback<LockStatusResponse\>): void
3654
3655Unlocks the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
3656
3657**System API**: This is a system API.
3658
3659**Required permission**: ohos.permission.SET_TELEPHONY_STATE
3660
3661**System capability**: SystemCapability.Telephony.CoreService
3662
3663**Parameters**
3664
3665| Name  | Type                                                      | Mandatory| Description                                  |
3666| -------- | ---------------------------------------------------------- | ---- | -------------------------------------- |
3667| slotId   | number                                                     | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
3668| lockInfo | [PersoLockInfo](#persolockinfo8)                           | Yes  | Personalized lock information.                        |
3669| callback | AsyncCallback<[LockStatusResponse](#lockstatusresponse7)\> | Yes  | Callback used to return the result.                              |
3670
3671**Error codes**
3672
3673For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3674
3675| ID|                 Error Message                    |
3676| -------- | -------------------------------------------- |
3677| 201      | Permission denied.                           |
3678| 401      | Parameter error.                             |
3679| 8300001  | Invalid parameter value.                     |
3680| 8300002  | Operation failed. Cannot connect to service. |
3681| 8300003  | System internal error.                       |
3682| 8300004  | Do not have sim card.                        |
3683| 8300999  | Unknown error code.                          |
3684| 8301002  | SIM card operation error.                    |
3685
3686**Example**
3687
3688```js
3689let persoLockInfo = {
3690    lockType: sim.PersoLockType.PN_PIN_LOCK,
3691    password: "1234"
3692};
3693sim.unlockSimLock(0, persoLockInfo, (err, data) => {
3694    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
3695});
3696```
3697
3698
3699## sim.unlockSimLock<sup>8+</sup>
3700
3701unlockSimLock(slotId: number, lockInfo: PersoLockInfo): Promise<LockStatusResponse\>
3702
3703Unlocks the SIM card in the specified slot. This API uses a promise to return the result.
3704
3705**System API**: This is a system API.
3706
3707**Required permission**: ohos.permission.SET_TELEPHONY_STATE
3708
3709**System capability**: SystemCapability.Telephony.CoreService
3710
3711**Parameters**
3712
3713| Name  | Type                            | Mandatory| Description                                  |
3714| -------- | -------------------------------- | ---- | -------------------------------------- |
3715| slotId   | number                           | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
3716| lockInfo | [PersoLockInfo](#persolockinfo8) | Yes  | Personalized lock information.                        |
3717
3718**Return value**
3719
3720| Type                                                | Description                     |
3721| ---------------------------------------------------- | ------------------------- |
3722| Promise<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
3723
3724**Error codes**
3725
3726For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3727
3728| ID|                 Error Message                    |
3729| -------- | -------------------------------------------- |
3730| 201      | Permission denied.                           |
3731| 401      | Parameter error.                             |
3732| 8300001  | Invalid parameter value.                     |
3733| 8300002  | Operation failed. Cannot connect to service. |
3734| 8300003  | System internal error.                       |
3735| 8300004  | Do not have sim card.                        |
3736| 8300999  | Unknown error code.                          |
3737| 8301002  | SIM card operation error.                    |
3738
3739**Example**
3740
3741```js
3742let persoLockInfo = {
3743    lockType: sim.PersoLockType.PN_PIN_LOCK,
3744    password: "1234"
3745};
3746let promise = sim.unlockSimLock(0, persoLockInfo);
3747promise.then(data => {
3748    console.log(`unlockSimLock success, promise: data->${JSON.stringify(data)}`);
3749}).catch(err => {
3750    console.log(`unlockSimLock failed, promise: err->${JSON.stringify(err)}`);
3751});
3752```
3753
3754## sim.getOpKey<sup>9+</sup>
3755
3756getOpKey(slotId: number, callback: AsyncCallback<string\>): void
3757
3758Obtains the opkey of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
3759
3760**System capability**: SystemCapability.Telephony.CoreService
3761
3762**Parameters**
3763
3764| Name  | Type                  | Mandatory| Description                                  |
3765| -------- | ---------------------- | ---- | -------------------------------------- |
3766| slotId   | number                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
3767| callback | AsyncCallback<string\> | Yes  | Callback used to return the result.                            |
3768
3769**Error codes**
3770
3771For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3772
3773| ID|                 Error Message                    |
3774| -------- | -------------------------------------------- |
3775| 401      | Parameter error.                             |
3776| 801      | Capability not supported.                    |
3777| 8300001  | Invalid parameter value.                     |
3778| 8300002  | Operation failed. Cannot connect to service. |
3779| 8300003  | System internal error.                       |
3780| 8300999  | Unknown error code.                          |
3781
3782**Example**
3783
3784```js
3785try {
3786    sim.getOpKey(0, (err, data) => {
3787    if (err) {
3788      console.log("getOpKey failed, err: " + JSON.stringify(err));
3789    } else {
3790      console.log('getOpKey successfully, data: ' + JSON.stringify(data));
3791    }
3792  });
3793} catch (err) {
3794  console.log("getOpKey err: " + JSON.stringify(err));
3795}
3796```
3797
3798
3799## sim.getOpKey<sup>9+</sup>
3800
3801getOpKey(slotId: number): Promise<string\>
3802
3803Obtains the opkey of the SIM card in the specified slot. This API uses a promise to return the result.
3804
3805**System capability**: SystemCapability.Telephony.CoreService
3806
3807**Parameters**
3808
3809| Name| Type  | Mandatory| Description                                  |
3810| ------ | ------ | ---- | -------------------------------------- |
3811| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
3812
3813**Return value**
3814
3815| Type            | Description                                     |
3816| ---------------- | ----------------------------------------- |
3817| Promise<string\> | Promise used to return the result.|
3818
3819**Error codes**
3820
3821For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3822
3823| ID|                 Error Message                    |
3824| -------- | -------------------------------------------- |
3825| 401      | Parameter error.                             |
3826| 801      | Capability not supported.                    |
3827| 8300001  | Invalid parameter value.                     |
3828| 8300002  | Operation failed. Cannot connect to service. |
3829| 8300003  | System internal error.                       |
3830| 8300999  | Unknown error code.                          |
3831
3832**Example**
3833
3834```js
3835try {
3836    let data = sim.getOpKey(0);
3837    console.log(`getOpKey success, promise: data->${JSON.stringify(data)}`);
3838} catch (error) {
3839    console.log(`getOpKey failed, promise: err->${JSON.stringify(error)}`);
3840}
3841```
3842
3843## sim.getOpName<sup>9+</sup>
3844
3845getOpName(slotId: number, callback: AsyncCallback<string\>): void
3846
3847Obtains the OpName of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
3848
3849**System capability**: SystemCapability.Telephony.CoreService
3850
3851**Parameters**
3852
3853| Name  | Type                  | Mandatory| Description                                  |
3854| -------- | ---------------------- | ---- | -------------------------------------- |
3855| slotId   | number                 | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
3856| callback | AsyncCallback<string\> | Yes  | Callback used to return the result.                              |
3857
3858**Error codes**
3859
3860For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3861
3862| ID|                 Error Message                    |
3863| -------- | -------------------------------------------- |
3864| 401      | Parameter error.                             |
3865| 801      | Capability not supported.                    |
3866| 8300001  | Invalid parameter value.                     |
3867| 8300002  | Operation failed. Cannot connect to service. |
3868| 8300003  | System internal error.                       |
3869| 8300004  | Do not have sim card.                        |
3870| 8300999  | Unknown error code.                          |
3871
3872**Example**
3873
3874```js
3875try {
3876    sim.getOpName(0, (err, data) => {
3877    if (err) {
3878      console.log("getOpName failed, err: " + JSON.stringify(err));
3879    } else {
3880      console.log('getOpName successfully, data: ' + JSON.stringify(data));
3881    }
3882  });
3883} catch (err) {
3884  console.log("getOpName err: " + JSON.stringify(err));
3885}
3886```
3887
3888
3889## sim.getOpName<sup>9+</sup>
3890
3891getOpName(slotId: number): Promise<string\>
3892
3893Obtains the OpName of the SIM card in the specified slot. This API uses a promise to return the result.
3894
3895**System capability**: SystemCapability.Telephony.CoreService
3896
3897**Parameters**
3898
3899| Name| Type  | Mandatory| Description                                  |
3900| ------ | ------ | ---- | -------------------------------------- |
3901| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
3902
3903**Return value**
3904
3905| Type            | Description                                      |
3906| ---------------- | ------------------------------------------ |
3907| Promise<string\> | Promise used to return the result.|
3908
3909**Error codes**
3910
3911For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
3912
3913| ID|                 Error Message                    |
3914| -------- | -------------------------------------------- |
3915| 401      | Parameter error.                             |
3916| 801      | Capability not supported.                    |
3917| 8300001  | Invalid parameter value.                     |
3918| 8300002  | Operation failed. Cannot connect to service. |
3919| 8300003  | System internal error.                       |
3920| 8300004  | Do not have sim card.                        |
3921| 8300999  | Unknown error code.                          |
3922
3923**Example**
3924
3925```js
3926try {
3927    let data = sim.getOpName(0);
3928    console.log(`getOpName success, promise: data->${JSON.stringify(data)}`);
3929} catch (error) {
3930    console.log(`getOpName failed, promise: err->${JSON.stringify(error)}`);
3931}
3932```
3933
3934## SimState
3935
3936Enumerates SIM card states.
3937
3938**System capability**: SystemCapability.Telephony.CoreService
3939
3940| Name                 | Value  | Description                                                      |
3941| --------------------- | ---- | ---------------------------------------------------------- |
3942| SIM_STATE_UNKNOWN     | 0    | The SIM card is in **unknown** state; that is, the SIM card status cannot be obtained.                     |
3943| SIM_STATE_NOT_PRESENT | 1    | The SIM card is in **not present** state; that is, no SIM card is inserted into the card slot.     |
3944| 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.  |
3945| 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.   |
3946| SIM_STATE_READY       | 4    | The SIM card is in **ready** state; that is, the SIM card has been installed and is working properly.           |
3947| 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.|
3948
3949## CardType<sup>7+</sup>
3950
3951Enumerates SIM card types.
3952
3953**System capability**: SystemCapability.Telephony.CoreService
3954
3955| Name| Value| Description|
3956| ----- | ----- | ----- |
3957|UNKNOWN_CARD | -1 | Unknown type.|
3958|SINGLE_MODE_SIM_CARD | 10 | Single-card (SIM).|
3959|SINGLE_MODE_USIM_CARD | 20 | Single-card (USIM).|
3960|SINGLE_MODE_RUIM_CARD | 30 | Single-card (RUIM).|
3961|DUAL_MODE_CG_CARD | 40 | Dual-card (CDMA+GSM).|
3962|CT_NATIONAL_ROAMING_CARD | 41 | China Telecom internal roaming card.|
3963|CU_DUAL_MODE_CARD | 42 | China Unicom dual-mode card.|
3964|DUAL_MODE_TELECOM_LTE_CARD | 43 | China Telecom dual-mode LTE card.|
3965|DUAL_MODE_UG_CARD | 50 | Dual-mode card (UMTS+GSM).|
3966|SINGLE_MODE_ISIM_CARD<sup>8+</sup> | 60 | Single-card (ISIM).|
3967
3968## LockType<sup>8+</sup>
3969
3970Enumerates lock types.
3971
3972**System API**: This is a system API.
3973
3974**System capability**: SystemCapability.Telephony.CoreService
3975
3976| Name    | Value  | Description       |
3977| -------- | ---- | ----------- |
3978| PIN_LOCK | 1    | SIM card password lock.|
3979| FDN_LOCK | 2    | Fixed dialing lock. |
3980
3981## LockState<sup>8+</sup>
3982
3983Enumerates lock states.
3984
3985**System API**: This is a system API.
3986
3987**System capability**: SystemCapability.Telephony.CoreService
3988
3989| Name    | Value  | Description      |
3990| -------- | ---- | ---------- |
3991| LOCK_OFF | 0    | The lock is off.|
3992| LOCK_ON  | 1    | The lock is on.|
3993
3994## PersoLockType<sup>8+</sup>
3995
3996Enumerates personalized lock types.
3997
3998**System API**: This is a system API.
3999
4000**System capability**: SystemCapability.Telephony.CoreService
4001
4002| Name        | Value  | Description                                            |
4003| ------------ | ---- | ------------------------------------------------ |
4004| PN_PIN_LOCK  | 0    | Personalized network PIN lock. For details, see *3GPP TS 22.022 [33]*.        |
4005| PN_PUK_LOCK  | 1    | Personalized network PUK lock.                                  |
4006| PU_PIN_LOCK  | 2    | Personalized network subset PIN lock. For details, see *3GPP TS 22.022 [33]*.    |
4007| PU_PUK_LOCK  | 3    | Personalized network subset PUK lock.                              |
4008| PP_PIN_LOCK  | 4    | Personalized service provider PIN lock. For details, see *3GPP TS 22.022 [33]*.  |
4009| PP_PUK_LOCK  | 5    | Personalized service provider PUK lock.                             |
4010| PC_PIN_LOCK  | 6    | Personalized corporate PIN lock. For details, see *3GPP TS 22.022 [33]*.        |
4011| PC_PUK_LOCK  | 7    | Personalized corporate PUK lock.                                   |
4012| SIM_PIN_LOCK | 8    | Personalized SIM card PIN lock. For details, see *3GPP TS 22.022 [33]*.       |
4013| SIM_PUK_LOCK | 9    | Personalized SIM card PUK lock.                                  |
4014
4015## LockStatusResponse<sup>7+</sup>
4016
4017Defines the personalized lock information.
4018
4019**System API**: This is a system API.
4020
4021**System capability**: SystemCapability.Telephony.CoreService
4022
4023| Name           | Type  | Mandatory| Description                 |
4024| --------------- | ------ | ---- | --------------------- |
4025| result          | number |  Yes | Operation result.     |
4026| remain?: number | number |  No | Remaining attempts (can be null).|
4027
4028## LockInfo<sup>8+</sup>
4029
4030Defines the personalized lock information.
4031
4032**System API**: This is a system API.
4033
4034**System capability**: SystemCapability.Telephony.CoreService
4035
4036| Name    |           Type          | Mandatory|   Description  |
4037| -------- | ------------------------ | ---- | -------- |
4038| lockType | [LockType](#locktype8)   |  Yes | Lock type.|
4039| password | string                   |  Yes | Password.  |
4040| state    | [LockState](#lockstate8) |  Yes | Lock state.|
4041
4042## PersoLockInfo<sup>8+</sup>
4043
4044Defines the personalized lock information.
4045
4046**System API**: This is a system API.
4047
4048**System capability**: SystemCapability.Telephony.CoreService
4049
4050| Name    |               Type              | Mandatory|      Description    |
4051| -------- | -------------------------------- | ---- | ------------- |
4052| lockType | [PersoLockType](#persolocktype8) |  Yes | Personalized lock type.|
4053| password | string                           |  Yes | Password.       |
4054
4055## IccAccountInfo<sup>7+</sup>
4056
4057Defines the ICC account information.
4058
4059**System API**: This is a system API.
4060
4061**System capability**: SystemCapability.Telephony.CoreService
4062
4063| Name      | Type   | Mandatory| Description            |
4064| ---------- | ------- | ---- | ---------------- |
4065| simId      | number  |  Yes | SIM card ID.         |
4066| slotIndex  | number  |  Yes | Card slot ID.          |
4067| isEsim     | boolean |  Yes | Whether the SIM card is an eSim card.|
4068| isActive   | boolean |  Yes | Whether the card is activated.    |
4069| iccId      | string  |  Yes | ICCID number.       |
4070| showName   | string  |  Yes | SIM card display name.   |
4071| showNumber | string  |  Yes | SIM card display number.   |
4072
4073## OperatorConfig<sup>8+</sup>
4074
4075Defines the carrier configuration.
4076
4077**System API**: This is a system API.
4078
4079**System capability**: SystemCapability.Telephony.CoreService
4080
4081| Name | Type  | Mandatory| Description|
4082| ----- | ------ | ---- | ---- |
4083| field | string |  Yes | Field.|
4084| value | string |  Yes | Value.  |
4085
4086## DiallingNumbersInfo<sup>8+</sup>
4087
4088Defines the contact number information.
4089
4090**System API**: This is a system API.
4091
4092**System capability**: SystemCapability.Telephony.CoreService
4093
4094| Name        | Type  | Mandatory|    Description   |
4095| ------------ | ------ | ---- | ---------- |
4096| alphaTag     | string |  Yes | Tag.    |
4097| number       | string |  Yes | Call transfer number.    |
4098| recordNumber | number |  Yes | Record number.|
4099| pin2         | string |  Yes | PIN 2.|
4100
4101## ContactType<sup>8+</sup>
4102
4103Enumerates contact types.
4104
4105**System API**: This is a system API.
4106
4107**System capability**: SystemCapability.Telephony.CoreService
4108
4109| Name           | Value  | Description      |
4110| --------------- | ---- | ---------- |
4111| GENERAL_CONTACT | 1    | Common contact number.|
4112| FIXED_DIALING   | 2    | Fixed dialing number.  |
4113
4114## OperatorConfigKey<sup>9+</sup>
4115
4116Enumerates carrier configuration keys.
4117
4118**System API**: This is a system API.
4119
4120**System capability**: SystemCapability.Telephony.CoreService
4121
4122|                             Name                       |                             Value                        |         Description        |
4123| ------------------------------------------------------- | ------------------------------------------------------ | -------------------- |
4124| KEY_VOICE_MAIL_NUMBER_STRING                            | "voice_mail_number_string"                             | Voice mailbox number.      |
4125| KEY_IMS_SWITCH_ON_BY_DEFAULT_BOOL                       | "ims_switch_on_by_default_bool"                        | Fixed dialing number.          |
4126| KEY_HIDE_IMS_SWITCH_BOOL                                | "hide_ims_switch_bool"                                 | Whether to hide the IMS switch.   |
4127| KEY_VOLTE_SUPPORTED_BOOL                                | "volte_supported_bool"                                 | Whether to support VoLTE. |
4128| KEY_NR_MODE_SUPPORTED_LIST_INT_ARRAY                    | "nr_mode_supported_list_int_array"                     | List of supported NR modes.  |
4129| KEY_VOLTE_PROVISIONING_SUPPORTED_BOOL                   | "volte_provisioning_supported_bool"                    | Whether to support VoLTE provisioning. |
4130| KEY_SS_OVER_UT_SUPPORTED_BOOL                           | "ss_over_ut_supported_bool"                            | Whether SS over UT is supported.  |
4131| KEY_IMS_GBA_REQUIRED_BOOL                               | "ims_gba_required_bool"                                | Whether GBA is required for IMS.    |
4132| KEY_UT_PROVISIONING_SUPPORTED_BOOL                      | "ut_provisioning_supported_bool"                       | Whether to support UT provisioning.    |
4133| KEY_IMS_PREFER_FOR_EMERGENCY_BOOL                       | "ims_prefer_for_emergency_bool"                        | IMS preferences for emergency.     |
4134| KEY_CALL_WAITING_SERVICE_CLASS_INT                      | "call_waiting_service_class_int"                       | Call waiting service.      |
4135| KEY_CALL_TRANSFER_VISIBILITY_BOOL                       | "call_transfer_visibility_bool"                        | Call transfer visibility.    |
4136| KEY_IMS_CALL_DISCONNECT_REASON_INFO_MAPPING_STRING_ARRAY| "ims_call_disconnect_reason_info_mapping_string_array" | List of IMS call disconnection reasons.|
4137| KEY_FORCE_VOLTE_SWITCH_ON_BOOL                          | "force_volte_switch_on_bool"                           | Whether to forcibly turn on VoLTE.     |
4138| KEY_ENABLE_OPERATOR_NAME_CUST_BOOL                      | "enable_operator_name_cust_bool"                       | Whether to display the carrier name.|
4139| KEY_OPERATOR_NAME_CUST_STRING                           | "operator_name_cust_string"                            | Carrier name.        |
4140| KEY_SPN_DISPLAY_CONDITION_CUST_INT                      | "spn_display_condition_cust_int"                       | SPN display rule.       |
4141| KEY_PNN_CUST_STRING_ARRAY                               | "pnn_cust_string_array"                                | PLMN name          |
4142| KEY_OPL_CUST_STRING_ARRAY                               | "opl_cust_string_array"                                | PLMN information of the carrier.    |
4143| KEY_EMERGENCY_CALL_STRING_ARRAY                         | "emergency_call_string_array"                          | Emergency call list.      |
4144