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