• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.telephony.sim (SIM卡管理)
2
3SIM卡管理模块提供了SIM卡管理的基础能力,包括获取指定卡槽SIM卡的名称、号码、ISO国家码、归属PLMN号、服务提供商名称、SIM卡状态、卡类型、是否插卡、是否激活、锁状态,设置指定卡槽SIM卡显示的名称、号码、锁状态,激活、禁用指定卡槽SIM卡,更改Pin密码,以及解锁指定卡槽SIM卡密码、SIM卡密码的解锁密码等。
4
5>**说明:**
6>
7>本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8>
9
10## 导入模块
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
20获取指定卡槽SIM卡是否激活。使用callback异步回调。
21
22**系统能力**:SystemCapability.Telephony.CoreService
23
24**参数:**
25
26| 参数名   | 类型                        | 必填 | 说明                                   |
27| -------- | --------------------------- | ---- | -------------------------------------- |
28| slotId   | number                      | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
29| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回指定卡槽是否激活,如果激活返回true。                             |
30
31**示例:**
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
47获取指定卡槽SIM卡是否激活。使用Promise异步回调。
48
49**系统能力**:SystemCapability.Telephony.CoreService
50
51**参数:**
52
53| 参数名 | 类型   | 必填 | 说明                                   |
54| ------ | ------ | ---- | -------------------------------------- |
55| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
56
57**返回值:**
58
59| 类型                  | 说明                               |
60| --------------------- | ---------------------------------- |
61| Promise&lt;boolean&gt; | 以Promise形式返回指定卡槽是否激活,如果激活返回true。 |
62
63**示例:**
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
80获取指定卡槽SIM卡是否激活。
81
82**系统能力**:SystemCapability.Telephony.CoreService
83
84**参数:**
85
86| 参数名 | 类型   | 必填 | 说明                                   |
87| ------ | ------ | ---- | -------------------------------------- |
88| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
89
90**返回值:**
91
92| 类型                  | 说明                               |
93| --------------------- | ---------------------------------- |
94| boolean | 返回指定卡槽是否激活,如果激活返回true。 |
95
96**示例:**
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
108获取默认语音业务的卡槽ID。使用callback异步回调。
109
110**系统能力**:SystemCapability.Telephony.CoreService
111
112**参数:**
113
114| 参数名   | 类型                        | 必填 | 说明       |
115| -------- | --------------------------- | ---- | ---------- |
116| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。<br />- 0:卡槽1<br />- 1:卡槽2<br />- -1:未设置或服务不可用 |
117
118**示例:**
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
134获取默认语音业务的卡槽ID。使用Promise异步回调。
135
136**系统能力**:SystemCapability.Telephony.CoreService
137
138**返回值:**
139
140| 类型              | 说明                                    |
141| ----------------- | --------------------------------------- |
142| Promise\<number\> | 以Promise形式返回默认语音业务的卡槽ID。<br />- 0:卡槽1<br />- 1:卡槽2<br />- -1:未设置或服务不可用 |
143
144**示例:**
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
161检查应用(调用者)是否已被授予运营商权限。使用callback异步回调。
162
163**系统能力**:SystemCapability.Telephony.CoreService
164
165**参数:**
166
167| 参数名   | 类型                     | 必填 | 说明                                     |
168| -------- | ------------------------ | ---- | ---------------------------------------- |
169| slotId   | number                   | 是   | 卡槽ID。<br />- 0:卡槽1<br />- 1:卡槽2 |
170| callback | AsyncCallback\<boolean\> | 是   | 回调函数。 返回检查应用(调用者)是否已被授予运营商权限。                              |
171
172**错误码:**
173
174以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
175
176| 错误码ID |                 错误信息                     |
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**示例:**
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
199检查应用(调用者)是否已被授予运营商权限。使用Promise异步回调。
200
201**系统能力**:SystemCapability.Telephony.CoreService
202
203**参数:**
204
205| 参数名 | 类型   | 必填 | 说明                                     |
206| ------ | ------ | ---- | ---------------------------------------- |
207| slotId | number | 是   | 卡槽ID。<br />- 0:卡槽1<br />- 1:卡槽2 |
208
209**返回值:**
210
211| 类型               | 说明                                                        |
212| :----------------- | :---------------------------------------------------------- |
213| Promise\<boolean\> | 以Promise形式返回检查应用(调用者)是否已被授予运营商权限。 |
214
215**错误码:**
216
217以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
218
219| 错误码ID |                 错误信息                     |
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**示例:**
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
244获取指定卡槽SIM卡的ISO国家码。使用callback异步回调。
245
246**系统能力**:SystemCapability.Telephony.CoreService
247
248**参数:**
249
250| 参数名   | 类型                    | 必填 | 说明                                     |
251| -------- | ----------------------- | ---- | ---------------------------------------- |
252| slotId   | number                  | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2   |
253| callback | AsyncCallback\<string\> | 是   | 回调函数。返回国家码,例如:CN(中国)。 |
254
255**错误码:**
256
257以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
258
259| 错误码ID |                 错误信息                     |
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**示例:**
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
284获取指定卡槽SIM卡的ISO国家码。使用Promise异步回调。
285
286**系统能力**:SystemCapability.Telephony.CoreService
287
288**参数:**
289
290| 参数名 | 类型   | 必填 | 说明                                   |
291| ------ | ------ | ---- | -------------------------------------- |
292| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
293
294**返回值:**
295
296| 类型              | 说明                                                         |
297| ----------------- | ------------------------------------------------------------ |
298| Promise\<string\> | 以Promise形式返回获取指定卡槽SIM卡的ISO国家码,例如:CN(中国)。 |
299
300**错误码:**
301
302以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
303
304| 错误码ID |                 错误信息                     |
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**示例:**
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
330获取指定卡槽SIM卡的ISO国家码。
331
332**系统能力**:SystemCapability.Telephony.CoreService
333
334**参数:**
335
336| 参数名 | 类型   | 必填 | 说明                                   |
337| ------ | ------ | ---- | -------------------------------------- |
338| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
339
340**返回值:**
341
342| 类型              | 说明                                                         |
343| ----------------- | ------------------------------------------------------------ |
344| string | 返回获取指定卡槽SIM卡的ISO国家码,例如:CN(中国)。 |
345
346
347**示例:**
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
359获取指定卡槽SIM卡的归属PLMN(Public Land Mobile Network)号。使用callback异步回调。
360
361**系统能力**:SystemCapability.Telephony.CoreService
362
363**参数:**
364
365| 参数名   | 类型                    | 必填 | 说明                                   |
366| -------- | ----------------------- | ---- | -------------------------------------- |
367| slotId   | number                  | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
368| callback | AsyncCallback\<string\> | 是   | 回调函数。返回指定卡槽SIM卡的归属PLMN号。                          |
369
370**错误码:**
371
372以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
373
374| 错误码ID |                 错误信息                     |
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**示例:**
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
399获取指定卡槽SIM卡的归属PLMN(Public Land Mobile Network)号。使用Promise异步回调。
400
401**系统能力**:SystemCapability.Telephony.CoreService
402
403**参数:**
404
405| 参数名 | 类型   | 必填 | 说明                                   |
406| ------ | ------ | ---- | -------------------------------------- |
407| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
408
409**返回值:**
410
411| 类型              | 说明                                             |
412| ----------------- | ------------------------------------------------ |
413| Promise\<string\> | 以Promise形式返回获取指定卡槽SIM卡的归属PLMN号。 |
414
415**错误码:**
416
417以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
418
419| 错误码ID |                 错误信息                     |
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**示例:**
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
445获取指定卡槽SIM卡的归属PLMN(Public Land Mobile Network)号。
446
447**系统能力**:SystemCapability.Telephony.CoreService
448
449**参数:**
450
451| 参数名 | 类型   | 必填 | 说明                                   |
452| ------ | ------ | ---- | -------------------------------------- |
453| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
454
455**返回值:**
456
457| 类型              | 说明                                             |
458| ----------------- | ------------------------------------------------ |
459| string | 返回获取指定卡槽SIM卡的归属PLMN号。 |
460
461
462**示例:**
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
474获取指定卡槽SIM卡的服务提供商名称(Service Provider Name,SPN)。使用callback异步回调。
475
476**系统能力**:SystemCapability.Telephony.CoreService
477
478**参数:**
479
480| 参数名   | 类型                    | 必填 | 说明                                   |
481| -------- | ----------------------- | ---- | -------------------------------------- |
482| slotId   | number                  | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
483| callback | AsyncCallback\<string\> | 是   | 回调函数。返回指定卡槽SIM卡的SPN。                             |
484
485**错误码:**
486
487以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
488
489| 错误码ID |                 错误信息                     |
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**示例:**
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
514获取指定卡槽SIM卡的服务提供商名称(Service Provider Name,SPN)。使用Promise异步回调。
515
516**系统能力**:SystemCapability.Telephony.CoreService
517
518**参数:**
519
520| 参数名 | 类型   | 必填 | 说明                                   |
521| ------ | ------ | ---- | -------------------------------------- |
522| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
523
524**返回值:**
525
526| 类型              | 说明                                      |
527| ----------------- | ----------------------------------------- |
528| Promise\<string\> | 以Promise形式返回获取指定卡槽SIM卡的SPN。 |
529
530**错误码:**
531
532以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
533
534| 错误码ID |                 错误信息                     |
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**示例:**
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
560获取指定卡槽SIM卡的服务提供商名称(Service Provider Name,SPN)。
561
562**系统能力**:SystemCapability.Telephony.CoreService
563
564**参数:**
565
566| 参数名 | 类型   | 必填 | 说明                                   |
567| ------ | ------ | ---- | -------------------------------------- |
568| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
569
570**返回值:**
571
572| 类型              | 说明                                      |
573| ----------------- | ----------------------------------------- |
574| string | 返回获取指定卡槽SIM卡的SPN。 |
575
576
577**示例:**
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
589获取指定卡槽的SIM卡状态。使用callback异步回调。
590
591**系统能力**:SystemCapability.Telephony.CoreService
592
593**参数:**
594
595| 参数名   | 类型                                   | 必填 | 说明                                   |
596| -------- | -------------------------------------- | ---- | -------------------------------------- |
597| slotId   | number                                 | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
598| callback | AsyncCallback\<[SimState](#simstate)\> | 是   | 回调函数。参考[SimState](#simstate)。  |
599
600**错误码:**
601
602以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
603
604| 错误码ID |                 错误信息                     |
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**示例:**
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
628获取指定卡槽的SIM卡状态。使用Promise异步回调。
629
630**系统能力**:SystemCapability.Telephony.CoreService
631
632**参数:**
633
634| 参数名 | 类型   | 必填 | 说明                                   |
635| ------ | ------ | ---- | -------------------------------------- |
636| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
637
638**返回值:**
639
640| 类型                             | 说明                                       |
641| -------------------------------- | ------------------------------------------ |
642| Promise\<[SimState](#simstate)\> | 以Promise形式返回获取指定卡槽的SIM卡状态。 |
643
644**错误码:**
645
646以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
647
648| 错误码ID |                 错误信息                     |
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**示例:**
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
673获取指定卡槽的SIM卡状态。
674
675**系统能力**:SystemCapability.Telephony.CoreService
676
677**参数:**
678
679| 参数名 | 类型   | 必填 | 说明                                   |
680| ------ | ------ | ---- | -------------------------------------- |
681| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
682
683**返回值:**
684
685| 类型                         | 说明                                       |
686| ---------------------------- | ------------------------------------------ |
687| [SimState](#simstate) | 返回获取指定卡槽的SIM卡状态。 |
688
689
690**示例:**
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
701获取指定卡槽SIM卡的卡类型。使用callback异步回调。
702
703**系统能力**:SystemCapability.Telephony.CoreService
704
705**参数:**
706
707| 参数名   | 类型                    | 必填 | 说明                                   |
708| -------- | ----------------------- | ---- | -------------------------------------- |
709| slotId   | number                  | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
710| callback | AsyncCallback\<[CardType](#cardtype7)\> | 是   | 回调函数。                             |
711
712**错误码:**
713
714以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
715
716| 错误码ID |                 错误信息                     |
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**示例:**
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
741获取指定卡槽SIM卡的卡类型。使用Promise异步回调。
742
743**系统能力**:SystemCapability.Telephony.CoreService
744
745**参数:**
746
747| 参数名 | 类型   | 必填 | 说明                                   |
748| ------ | ------ | ---- | -------------------------------------- |
749| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
750
751**返回值:**
752
753| 类型              | 说明                                                         |
754| ----------------- | ------------------------------------------------------------ |
755| Promise\<[CardType](#cardtype7)\> | 以Promise形式返回指定卡槽SIM卡的卡类型。 |
756
757**错误码:**
758
759以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
760
761| 错误码ID |                 错误信息                     |
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**示例:**
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
787获取指定卡槽SIM卡的卡类型。
788
789**系统能力**:SystemCapability.Telephony.CoreService
790
791**参数:**
792
793| 参数名 | 类型   | 必填 | 说明                                   |
794| ------ | ------ | ---- | -------------------------------------- |
795| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
796
797**返回值:**
798
799| 类型              | 说明                                                         |
800| ----------------- | ------------------------------------------------------------ |
801| [CardType](#cardtype7) | 返回指定卡槽SIM卡的卡类型。 |
802
803
804**示例:**
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
816获取指定卡槽SIM卡是否插卡。使用callback异步回调。
817
818**系统能力**:SystemCapability.Telephony.CoreService
819
820**参数:**
821
822| 参数名   | 类型                        | 必填 | 说明                                   |
823| -------- | --------------------------- | ---- | -------------------------------------- |
824| slotId   | number                      | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
825| callback | AsyncCallback&lt;boolean&gt; | 是  | 回调返回指定卡槽是否插卡,如果插卡返回true。                           |
826
827**错误码:**
828
829以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
830
831| 错误码ID |                 错误信息                     |
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**示例:**
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
855获取指定卡槽SIM卡是否插卡。使用Promise异步回调。
856
857**系统能力**:SystemCapability.Telephony.CoreService
858
859**参数:**
860
861| 参数名 | 类型   | 必填 | 说明                                   |
862| ------ | ------ | ---- | -------------------------------------- |
863| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
864
865**返回值:**
866
867| 类型                  | 说明                               |
868| --------------------- | ---------------------------------- |
869| Promise&lt;boolean&gt; | 以Promise形式返回指定卡槽是否插卡,如果插卡返回true。 |
870
871**错误码:**
872
873以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
874
875| 错误码ID |                 错误信息                     |
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**示例:**
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
900获取指定卡槽SIM卡是否插卡。
901
902**系统能力**:SystemCapability.Telephony.CoreService
903
904**参数:**
905
906| 参数名 | 类型   | 必填 | 说明                                   |
907| ------ | ------ | ---- | -------------------------------------- |
908| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
909
910**返回值:**
911
912| 类型                  | 说明                               |
913| --------------------- | ---------------------------------- |
914| boolean | 返回指定卡槽是否插卡,如果插卡返回true。 |
915
916**示例:**
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
927获取SIM卡帐户信息。使用callback异步回调。
928
929>**说明:**
930>
931>如果没有GET_TELEPHONY_STATE权限,获取到的ICCID和号码信息为空。
932
933**需要权限**:ohos.permission.GET_TELEPHONY_STATE
934
935**系统能力**:SystemCapability.Telephony.CoreService
936
937**参数:**
938
939| 参数名   | 类型                                                | 必填 | 说明                                   |
940| -------- | --------------------------------------------------- | ---- | -------------------------------------- |
941| slotId   | number                                              | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
942| callback | AsyncCallback\<[IccAccountInfo](#iccaccountinfo10)\> | 是   | 回调函数。返回指定卡槽SIM卡的帐户信息。                             |
943
944**错误码:**
945
946以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
947
948| 错误码ID |                 错误信息                     |
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**示例:**
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
974获取SIM卡帐户信息。使用Promise异步回调。
975
976>**说明:**
977>
978>如果没有GET_TELEPHONY_STATE权限,获取到的ICCID和号码信息为空。
979
980**需要权限**:ohos.permission.GET_TELEPHONY_STATE
981
982**系统能力**:SystemCapability.Telephony.CoreService
983
984**参数:**
985
986| 参数名 | 类型   | 必填 | 说明                                   |
987| ------ | ------ | ---- | -------------------------------------- |
988| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
989
990**返回值:**
991
992| 类型                                         | 说明                                       |
993| -------------------------------------------- | ------------------------------------------ |
994| Promise<[IccAccountInfo](#iccaccountinfo10)\> | 以Promise形式返回指定卡槽SIM卡的帐户信息。 |
995
996**错误码:**
997
998以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
999
1000| 错误码ID |                 错误信息                     |
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**示例:**
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
1027获取激活SIM卡帐户信息列表。使用callback异步回调。
1028
1029>**说明:**
1030>
1031>如果没有GET_TELEPHONY_STATE权限,获取到的ICCID和号码信息为空。
1032
1033**需要权限**:ohos.permission.GET_TELEPHONY_STATE
1034
1035**系统能力**:SystemCapability.Telephony.CoreService
1036
1037**参数:**
1038
1039| 参数名   | 类型                                                        | 必填 | 说明       |
1040| -------- | ----------------------------------------------------------- | ---- | ---------- |
1041| callback | AsyncCallback\<Array<[IccAccountInfo](#iccaccountinfo10)\>\> | 是   | 回调函数。返回激活SIM卡帐户信息列表。 |
1042
1043**错误码:**
1044
1045以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1046
1047| 错误码ID |                 错误信息                     |
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**示例:**
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
1071获取激活SIM卡帐户信息列表。使用Promise异步回调。
1072
1073>**说明:**
1074>
1075>如果没有GET_TELEPHONY_STATE权限,获取到的ICCID和号码信息为空。
1076
1077**需要权限**:ohos.permission.GET_TELEPHONY_STATE
1078
1079**系统能力**:SystemCapability.Telephony.CoreService
1080
1081**返回值:**
1082
1083| 类型                                                 | 说明                                           |
1084| ---------------------------------------------------- | ---------------------------------------------- |
1085| Promise<Array<[IccAccountInfo](#iccaccountinfo10)\>\> | 以Promise形式返回激活卡槽SIM卡的帐户信息列表。 |
1086
1087**错误码:**
1088
1089以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1090
1091| 错误码ID |                 错误信息                     |
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**示例:**
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
1115设置默认语音业务的卡槽ID。使用callback异步回调。
1116
1117**系统接口:** 此接口为系统接口。
1118
1119**需要权限**:ohos.permission.SET_TELEPHONY_STATE
1120
1121**系统能力**:SystemCapability.Telephony.CoreService
1122
1123**参数:**
1124
1125| 参数名   | 类型                      | 必填 | 说明                                                         |
1126| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
1127| slotId   | number                    | 是   | SIM卡槽ID:<br/>- 0:卡槽1<br/>- 1:卡槽2<br/>- -1:清除默认配置 |
1128| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。                                                   |
1129
1130**错误码:**
1131
1132以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1133
1134| 错误码ID |                 错误信息                     |
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**示例:**
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
1162设置默认语音业务的卡槽ID。使用Promise异步回调。
1163
1164**系统接口:** 此接口为系统接口。
1165
1166**需要权限**:ohos.permission.SET_TELEPHONY_STATE
1167
1168**系统能力**:SystemCapability.Telephony.CoreService
1169
1170**参数:**
1171
1172| 参数名 | 类型   | 必填 | 说明                                                         |
1173| ------ | ------ | ---- | ------------------------------------------------------------ |
1174| slotId | number | 是   | SIM卡槽ID:<br/>- 0:卡槽1<br/>- 1:卡槽2<br/>- -1:清除默认配置 |
1175
1176**返回值:**
1177
1178| 类型            | 说明                            |
1179| --------------- | ------------------------------- |
1180| Promise\<void\> | 以Promise形式异步返回设置结果。 |
1181
1182**错误码:**
1183
1184以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1185
1186| 错误码ID |                 错误信息                     |
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**示例:**
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
1215设置指定卡槽SIM卡显示的名称。使用callback异步回调。
1216
1217**系统接口:** 此接口为系统接口。
1218
1219**需要权限**:ohos.permission.SET_TELEPHONY_STATE
1220
1221**系统能力**:SystemCapability.Telephony.CoreService
1222
1223**参数:**
1224
1225| 参数名   | 类型                      | 必填 | 说明                                   |
1226| -------- | ------------------------- | ---- | -------------------------------------- |
1227| slotId   | number                    | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1228| name     | string                    | 是   | SIM卡名称。                              |
1229| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。                             |
1230
1231**错误码:**
1232
1233以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1234
1235| 错误码ID |                 错误信息                     |
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**示例:**
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
1262设置指定卡槽SIM卡显示的名称。使用Promise异步回调。
1263
1264**系统接口:** 此接口为系统接口。
1265
1266**需要权限**:ohos.permission.SET_TELEPHONY_STATE
1267
1268**系统能力**:SystemCapability.Telephony.CoreService
1269
1270**参数:**
1271
1272| 参数名 | 类型   | 必填 | 说明                                   |
1273| ------ | ------ | ---- | -------------------------------------- |
1274| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1275| name   | string | 是   | SIM卡名称。                              |
1276
1277**返回值:**
1278
1279| 类型            | 说明                            |
1280| --------------- | ------------------------------- |
1281| Promise\<void\> | 以Promise形式异步返回设置结果。 |
1282
1283**错误码:**
1284
1285以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1286
1287| 错误码ID |                 错误信息                     |
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**示例:**
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
1316获取指定卡槽SIM卡的名称。使用callback异步回调。
1317
1318**系统接口:** 此接口为系统接口。
1319
1320**需要权限**:ohos.permission.GET_TELEPHONY_STATE
1321
1322**系统能力**:SystemCapability.Telephony.CoreService
1323
1324**参数:**
1325
1326| 参数名   | 类型                        | 必填 | 说明                                   |
1327| -------- | --------------------------- | ---- | -------------------------------------- |
1328| slotId   | number                      | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1329| callback | AsyncCallback&lt;string&gt; | 是   | 回调函数。返回指定卡槽SIM卡的名称。                             |
1330
1331**错误码:**
1332
1333以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1334
1335| 错误码ID |                 错误信息                     |
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**示例:**
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
1362获取指定卡槽SIM卡的名称。使用Promise异步回调。
1363
1364**系统接口:** 此接口为系统接口。
1365
1366**需要权限**:ohos.permission.GET_TELEPHONY_STATE
1367
1368**系统能力**:SystemCapability.Telephony.CoreService
1369
1370**参数:**
1371
1372| 参数名 | 类型   | 必填 | 说明                                   |
1373| ------ | ------ | ---- | -------------------------------------- |
1374| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1375
1376**返回值:**
1377
1378| 类型                  | 说明                                   |
1379| --------------------- | -------------------------------------- |
1380| Promise&lt;string&gt; | 以Promise形式返回指定卡槽SIM卡的名称。 |
1381
1382**错误码:**
1383
1384以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1385
1386| 错误码ID |                 错误信息                     |
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**示例:**
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
1414设置指定卡槽SIM卡的号码。使用callback异步回调。
1415
1416**系统接口:** 此接口为系统接口。
1417
1418**需要权限**:ohos.permission.SET_TELEPHONY_STATE
1419
1420**系统能力**:SystemCapability.Telephony.CoreService
1421
1422**参数:**
1423
1424| 参数名   | 类型                      | 必填 | 说明                                   |
1425| -------- | ------------------------- | ---- | -------------------------------------- |
1426| slotId   | number                    | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1427| number   | string                    | 是   | SIM卡号码。                              |
1428| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。                             |
1429
1430**错误码:**
1431
1432以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1433
1434| 错误码ID |                 错误信息                     |
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**示例:**
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
1462设置指定卡槽SIM卡的号码。使用Promise异步回调。
1463
1464**系统接口:** 此接口为系统接口。
1465
1466**需要权限**:ohos.permission.SET_TELEPHONY_STATE
1467
1468**系统能力**:SystemCapability.Telephony.CoreService
1469
1470**参数:**
1471
1472| 参数名 | 类型   | 必填 | 说明                                   |
1473| ------ | ------ | ---- | -------------------------------------- |
1474| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1475| number | string | 是   | SIM卡号码。                              |
1476
1477**返回值:**
1478
1479| 类型           | 说明                            |
1480| -------------- | ------------------------------- |
1481| Promise<void\> | 以Promise形式异步返回设置结果。 |
1482
1483**错误码:**
1484
1485以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1486
1487| 错误码ID |                 错误信息                     |
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**示例:**
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
1516获取指定卡槽SIM卡的号码。使用callback异步回调。
1517
1518**系统接口:** 此接口为系统接口。
1519
1520**需要权限**:ohos.permission.GET_TELEPHONY_STATE
1521
1522**系统能力**:SystemCapability.Telephony.CoreService
1523
1524**参数:**
1525
1526| 参数名   | 类型                        | 必填 | 说明                                   |
1527| -------- | --------------------------- | ---- | -------------------------------------- |
1528| slotId   | number                      | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1529| callback | AsyncCallback&lt;string&gt; | 是   | 回调函数。返回指定卡槽的号码。                             |
1530
1531**错误码:**
1532
1533以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1534
1535| 错误码ID |                 错误信息                     |
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**示例:**
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
1562获取指定卡槽SIM卡的号码。使用Promise异步回调。
1563
1564**系统接口:** 此接口为系统接口。
1565
1566**需要权限**:ohos.permission.GET_TELEPHONY_STATE
1567
1568**系统能力**:SystemCapability.Telephony.CoreService
1569
1570**参数:**
1571
1572| 参数名 | 类型   | 必填 | 说明                                   |
1573| ------ | ------ | ---- | -------------------------------------- |
1574| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1575
1576**返回值:**
1577
1578| 类型                  | 说明                              |
1579| --------------------- | --------------------------------- |
1580| Promise&lt;string&gt; | 以Promise形式返回指定卡槽的号码。 |
1581
1582**错误码:**
1583
1584以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1585
1586| 错误码ID |                 错误信息                     |
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**示例:**
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
1614激活指定卡槽SIM卡。使用callback异步回调。
1615
1616**系统接口:** 此接口为系统接口。
1617
1618**需要权限**:ohos.permission.SET_TELEPHONY_STATE
1619
1620**系统能力**:SystemCapability.Telephony.CoreService
1621
1622**参数:**
1623
1624| 参数名   | 类型                      | 必填 | 说明                                   |
1625| -------- | ------------------------- | ---- | -------------------------------------- |
1626| slotId   | number                    | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1627| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。                             |
1628
1629**错误码:**
1630
1631以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1632
1633| 错误码ID |                 错误信息                     |
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**示例:**
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
1660激活指定卡槽SIM卡。使用Promise异步回调。
1661
1662**系统接口:** 此接口为系统接口。
1663
1664**需要权限**:ohos.permission.SET_TELEPHONY_STATE
1665
1666**系统能力**:SystemCapability.Telephony.CoreService
1667
1668**参数:**
1669
1670| 参数名 | 类型   | 必填 | 说明                                   |
1671| ------ | ------ | ---- | -------------------------------------- |
1672| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1673
1674**返回值:**
1675
1676| 类型            | 说明                            |
1677| --------------- | ------------------------------- |
1678| Promise\<void\> | 以Promise形式异步返回设置结果。 |
1679
1680**错误码:**
1681
1682以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1683
1684| 错误码ID |                 错误信息                     |
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**示例:**
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
1712禁用指定卡槽SIM卡。使用callback异步回调。
1713
1714**系统接口:** 此接口为系统接口。
1715
1716**需要权限**:ohos.permission.SET_TELEPHONY_STATE
1717
1718**系统能力**:SystemCapability.Telephony.CoreService
1719
1720**参数:**
1721
1722| 参数名   | 类型                      | 必填 | 说明                                   |
1723| -------- | ------------------------- | ---- | -------------------------------------- |
1724| slotId   | number                    | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1725| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。                             |
1726
1727**错误码:**
1728
1729以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1730
1731| 错误码ID |                 错误信息                     |
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**示例:**
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
1758禁用指定卡槽SIM卡。使用Promise异步回调。
1759
1760**系统接口:** 此接口为系统接口。
1761
1762**需要权限**:ohos.permission.SET_TELEPHONY_STATE
1763
1764**系统能力**:SystemCapability.Telephony.CoreService
1765
1766**参数:**
1767
1768| 参数名 | 类型   | 必填 | 说明                                   |
1769| ------ | ------ | ---- | -------------------------------------- |
1770| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1771
1772**返回值:**
1773
1774| 类型            | 说明                            |
1775| --------------- | ------------------------------- |
1776| Promise\<void\> | 以Promise形式异步返回设置结果。 |
1777
1778**错误码:**
1779
1780以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1781
1782| 错误码ID |                 错误信息                     |
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**示例:**
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
1810设置指定卡槽SIM卡的锁状态。使用callback异步回调。
1811
1812**系统接口:** 此接口为系统接口。
1813
1814**需要权限**:ohos.permission.SET_TELEPHONY_STATE
1815
1816**系统能力**:SystemCapability.Telephony.CoreService
1817
1818**参数:**
1819
1820| 参数名   | 类型                                                        | 必填 | 说明                                                         |
1821| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
1822| slotId   | number                                                      | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2                       |
1823| callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | 是   | 回调函数。                                                   |
1824| options  | [LockInfo](#lockinfo8)                                      | 是   | 锁信息。<br/>- lockType: [LockType](#locktype8)<br/>- password: string<br/>- state: [LockState](#lockstate8) |
1825
1826**错误码:**
1827
1828以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1829
1830| 错误码ID |                 错误信息                     |
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**示例:**
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
1863设置指定卡槽SIM卡的锁状态。使用Promise异步回调。
1864
1865**系统接口:** 此接口为系统接口。
1866
1867**需要权限**:ohos.permission.SET_TELEPHONY_STATE
1868
1869**系统能力**:SystemCapability.Telephony.CoreService
1870
1871**参数:**
1872
1873| 参数名  | 类型                   | 必填 | 说明                                                         |
1874| ------- | ---------------------- | ---- | ------------------------------------------------------------ |
1875| slotId  | number                 | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2                       |
1876| options | [LockInfo](#lockinfo8) | 是   | 锁信息。<br/>- lockType: [LockType](#locktype8)<br/>- password: string<br/>- state: [LockState](#lockstate8) |
1877
1878**返回值:**
1879
1880| 类型                                                 | 说明                                         |
1881| ---------------------------------------------------- | -------------------------------------------- |
1882| Promise<[LockStatusResponse](#lockstatusresponse7)\> | 以Promise形式返回获取指定卡槽SIM卡的锁状态。 |
1883
1884**错误码:**
1885
1886以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1887
1888| 错误码ID |                 错误信息                     |
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**示例:**
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
1922获取指定卡槽SIM卡的锁状态。使用callback异步回调。
1923
1924**系统接口:** 此接口为系统接口。
1925
1926**需要权限**:ohos.permission.GET_TELEPHONY_STATE
1927
1928**系统能力**:SystemCapability.Telephony.CoreService
1929
1930**参数:**
1931
1932| 参数名   | 类型                                      | 必填 | 说明                                    |
1933| -------- | ----------------------------------------- | ---- | --------------------------------------- |
1934| slotId   | number                                    | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2  |
1935| callback | AsyncCallback\<[LockState](#lockstate8)\> | 是   | 回调函数。                              |
1936| options  | [LockType](#locktype8)                    | 是   | 锁类型。<br/>- 1: PIN锁<br/>- 2: PIN2锁 |
1937
1938**错误码:**
1939
1940以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1941
1942| 错误码ID |                 错误信息                     |
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**示例:**
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
1970获取指定卡槽SIM卡的锁状态。使用Promise异步回调。
1971
1972**系统接口:** 此接口为系统接口。
1973
1974**需要权限**:ohos.permission.GET_TELEPHONY_STATE
1975
1976**系统能力**:SystemCapability.Telephony.CoreService
1977
1978**参数:**
1979
1980| 参数名  | 类型                   | 必填 | 说明                                    |
1981| ------- | ---------------------- | ---- | --------------------------------------- |
1982| slotId  | number                 | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2  |
1983| options | [LockType](#locktype8) | 是   | 锁类型。<br/>- 1: PIN锁<br/>- 2: PIN2锁 |
1984
1985**返回值:**
1986
1987| 类型                               | 说明                                         |
1988| ---------------------------------- | -------------------------------------------- |
1989| Promise<[LockState](#lockstate8)\> | 以Promise形式返回获取指定卡槽SIM卡的锁状态。 |
1990
1991**错误码:**
1992
1993以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
1994
1995| 错误码ID |                 错误信息                     |
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**示例:**
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
2024更改Pin密码。使用callback异步回调。
2025
2026**系统接口:** 此接口为系统接口。
2027
2028**需要权限**:ohos.permission.SET_TELEPHONY_STATE
2029
2030**系统能力**:SystemCapability.Telephony.CoreService
2031
2032**参数:**
2033
2034| 参数名   | 类型                                                        | 必填 | 说明                                   |
2035| -------- | ----------------------------------------------------------- | ---- | -------------------------------------- |
2036| slotId   | number                                                      | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2037| callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | 是   | 回调函数。                             |
2038| newPin   | string                                                      | 是   | 新密码。                               |
2039| oldPin   | string                                                      | 是   | 旧密码。                               |
2040
2041**错误码:**
2042
2043以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2044
2045| 错误码ID |                 错误信息                     |
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**示例:**
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
2073更改Pin密码。使用Promise异步回调。
2074
2075**系统接口:** 此接口为系统接口。
2076
2077**需要权限**:ohos.permission.SET_TELEPHONY_STATE
2078
2079**系统能力**:SystemCapability.Telephony.CoreService
2080
2081**参数:**
2082
2083| 参数名 | 类型   | 必填 | 说明                                   |
2084| ------ | ------ | ---- | -------------------------------------- |
2085| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2086| newPin | string | 是   | 新密码。                               |
2087| oldPin | string | 是   | 旧密码。                               |
2088
2089**返回值:**
2090
2091| 类型                                                 | 说明                                          |
2092| ---------------------------------------------------- | --------------------------------------------- |
2093| Promise<[LockStatusResponse](#lockstatusresponse7)\> | 以Promise形式返回指定卡槽SIM卡的Pin是否成功。 |
2094
2095**错误码:**
2096
2097以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2098
2099| 错误码ID |                 错误信息                     |
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**示例:**
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
2128更改Pin2密码。使用callback异步回调。
2129
2130**系统接口:** 此接口为系统接口。
2131
2132**需要权限**:ohos.permission.SET_TELEPHONY_STATE
2133
2134**系统能力**:SystemCapability.Telephony.CoreService
2135
2136**参数:**
2137
2138| 参数名   | 类型                                                        | 必填 | 说明                                   |
2139| -------- | ----------------------------------------------------------- | ---- | -------------------------------------- |
2140| slotId   | number                                                      | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2141| callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | 是   | 回调函数。                             |
2142| newPin2  | string                                                      | 是   | 新密码。                               |
2143| oldPin2  | string                                                      | 是   | 旧密码。                               |
2144
2145**错误码:**
2146
2147以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2148
2149| 错误码ID |                 错误信息                     |
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**示例:**
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
2177更改Pin2密码。使用Promise异步回调。
2178
2179**系统接口:** 此接口为系统接口。
2180
2181**需要权限**:ohos.permission.SET_TELEPHONY_STATE
2182
2183**系统能力**:SystemCapability.Telephony.CoreService
2184
2185**参数:**
2186
2187| 参数名  | 类型   | 必填 | 说明                                   |
2188| ------- | ------ | ---- | -------------------------------------- |
2189| slotId  | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2190| newPin2 | string | 是   | 新密码。                               |
2191| oldPin2 | string | 是   | 旧密码。                               |
2192
2193**返回值:**
2194
2195| 类型                                                 | 说明                                          |
2196| ---------------------------------------------------- | --------------------------------------------- |
2197| Promise<[LockStatusResponse](#lockstatusresponse7)\> | 以Promise形式返回指定卡槽SIM卡的Pin是否成功。 |
2198
2199**错误码:**
2200
2201以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2202
2203| 错误码ID |                 错误信息                     |
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**示例:**
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
2232解锁指定卡槽SIM卡密码。使用callback异步回调。
2233
2234**系统接口:** 此接口为系统接口。
2235
2236**需要权限**:ohos.permission.SET_TELEPHONY_STATE
2237
2238**系统能力**:SystemCapability.Telephony.CoreService
2239
2240**参数:**
2241
2242| 参数名   | 类型                                                         | 必填 | 说明                                   |
2243| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
2244| slotId   | number                                                       | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2245| pin      | string                                                       | 是   | SIM卡的密码。                            |
2246| callback | AsyncCallback&lt;[LockStatusResponse](#lockstatusresponse7)> | 是   | 回调函数。                             |
2247
2248**错误码:**
2249
2250以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2251
2252| 错误码ID |                 错误信息                     |
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**示例:**
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
2281解锁指定卡槽SIM卡密码。使用Promise异步回调。
2282
2283**系统接口:** 此接口为系统接口。
2284
2285**需要权限**:ohos.permission.SET_TELEPHONY_STATE
2286
2287**系统能力**:SystemCapability.Telephony.CoreService
2288
2289**参数:**
2290
2291| 参数名 | 类型   | 必填 | 说明                                   |
2292| ------ | ------ | ---- | -------------------------------------- |
2293| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2294| pin    | string | 是   | SIM卡的密码。                            |
2295
2296**返回值:**
2297
2298| 类型                                                 | 说明                                               |
2299| ---------------------------------------------------- | -------------------------------------------------- |
2300| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | 以Promise形式返回获取指定卡槽的SIM卡锁状态的响应。 |
2301
2302**错误码:**
2303
2304以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2305
2306| 错误码ID |                 错误信息                     |
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**示例:**
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
2336解锁指定卡槽SIM卡密码的解锁密码。使用callback异步回调。
2337
2338**系统接口:** 此接口为系统接口。
2339
2340**需要权限**:ohos.permission.SET_TELEPHONY_STATE
2341
2342**系统能力**:SystemCapability.Telephony.CoreService
2343
2344**参数:**
2345
2346| 参数名   | 类型                                                         | 必填 | 说明                                   |
2347| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
2348| slotId   | number                                                       | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2349| newPin   | string                                                       | 是   | 重置SIM卡的密码。                        |
2350| puk      | string                                                       | 是   | SIM卡密码的解锁密码。                    |
2351| callback | AsyncCallback&lt;[LockStatusResponse](#lockstatusresponse7)&gt; | 是   | 回调函数。                             |
2352
2353**错误码:**
2354
2355以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2356
2357| 错误码ID |                 错误信息                     |
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**示例:**
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
2387解锁指定卡槽SIM卡密码的解锁密码。使用Promise异步回调。
2388
2389**系统接口:** 此接口为系统接口。
2390
2391**需要权限**:ohos.permission.SET_TELEPHONY_STATE
2392
2393**系统能力**:SystemCapability.Telephony.CoreService
2394
2395**参数:**
2396
2397| 参数名 | 类型   | 必填 | 说明                                   |
2398| ------ | ------ | ---- | -------------------------------------- |
2399| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2400| newPin | string | 是   | 重置SIM卡的密码。                        |
2401| puk    | string | 是   | SIM卡密码的解锁密码。                    |
2402
2403**返回值:**
2404
2405| 类型                                                 | 说明                                               |
2406| ---------------------------------------------------- | -------------------------------------------------- |
2407| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | 以Promise形式返回获取指定卡槽的SIM卡锁状态的响应。 |
2408
2409**错误码:**
2410
2411以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2412
2413| 错误码ID |                 错误信息                     |
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**示例:**
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
2444解锁指定卡槽SIM卡密码。使用callback异步回调。
2445
2446**系统接口:** 此接口为系统接口。
2447
2448**需要权限**:ohos.permission.SET_TELEPHONY_STATE
2449
2450**系统能力**:SystemCapability.Telephony.CoreService
2451
2452**参数:**
2453
2454| 参数名   | 类型                                                         | 必填 | 说明                                   |
2455| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
2456| slotId   | number                                                       | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2457| pin2     | string                                                       | 是   | SIM卡的密码。                            |
2458| callback | AsyncCallback&lt;[LockStatusResponse](#lockstatusresponse7)&gt; | 是   | 回调函数。                             |
2459
2460**错误码:**
2461
2462以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2463
2464| 错误码ID |                 错误信息                     |
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**示例:**
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
2493解锁指定卡槽SIM卡密码。使用Promise异步回调。
2494
2495**系统接口:** 此接口为系统接口。
2496
2497**需要权限**:ohos.permission.SET_TELEPHONY_STATE
2498
2499**系统能力**:SystemCapability.Telephony.CoreService
2500
2501**参数:**
2502
2503| 参数名 | 类型   | 必填 | 说明                                   |
2504| ------ | ------ | ---- | -------------------------------------- |
2505| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2506| pin2   | string | 是   | SIM卡的密码。                            |
2507
2508**返回值:**
2509
2510| 类型                                                  | 说明                                               |
2511| ----------------------------------------------------- | -------------------------------------------------- |
2512| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | 以Promise形式返回获取指定卡槽的SIM卡锁状态的响应。 |
2513
2514**错误码:**
2515
2516以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2517
2518| 错误码ID |                 错误信息                     |
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**示例:**
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
2548解锁指定卡槽SIM卡密码的解锁密码。使用callback异步回调。
2549
2550**系统接口:** 此接口为系统接口。
2551
2552**需要权限**:ohos.permission.SET_TELEPHONY_STATE
2553
2554**系统能力**:SystemCapability.Telephony.CoreService
2555
2556**参数:**
2557
2558| 参数名   | 类型                                                         | 必填 | 说明                                   |
2559| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
2560| slotId   | number                                                       | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2561| newPin2  | string                                                       | 是   | 重置SIM卡的密码。                        |
2562| puk2     | string                                                       | 是   | SIM卡密码的解锁密码。                    |
2563| callback | AsyncCallback&lt;[LockStatusResponse](#lockstatusresponse7)&gt; | 是   | 回调函数。                             |
2564
2565**错误码:**
2566
2567以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2568
2569| 错误码ID |                 错误信息                     |
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**示例:**
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
2599解锁指定卡槽SIM卡密码的解锁密码。使用Promise异步回调。
2600
2601**系统接口:** 此接口为系统接口。
2602
2603**需要权限**:ohos.permission.SET_TELEPHONY_STATE
2604
2605**系统能力**:SystemCapability.Telephony.CoreService
2606
2607**参数:**
2608
2609| 参数名  | 类型   | 必填 | 说明                                   |
2610| ------- | ------ | ---- | -------------------------------------- |
2611| slotId  | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2612| newPin2 | string | 是   | 重置SIM卡的密码。                        |
2613| puk2    | string | 是   | SIM卡密码的解锁密码。                    |
2614
2615**返回值:**
2616
2617| 类型                                                 | 说明                                               |
2618| ---------------------------------------------------- | -------------------------------------------------- |
2619| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | 以Promise形式返回获取指定卡槽的SIM卡锁状态的响应。 |
2620
2621**错误码:**
2622
2623以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2624
2625| 错误码ID |                 错误信息                     |
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**示例:**
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
2656获取卡槽数量。
2657
2658**系统能力**:SystemCapability.Telephony.CoreService
2659
2660**返回值:**
2661
2662| 类型              | 说明                                                         |
2663| ----------------- | ------------------------------------------------------------ |
2664| number | 卡槽数量。 |
2665
2666**示例:**
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
2678获取指定卡槽SIM卡的ICCID。使用callback异步回调。
2679
2680**系统接口:** 此接口为系统接口。
2681
2682**需要权限**:ohos.permission.GET_TELEPHONY_STATE
2683
2684**系统能力**:SystemCapability.Telephony.CoreService
2685
2686**参数:**
2687
2688| 参数名   | 类型                   | 必填 | 说明                                   |
2689| -------- | ---------------------- | ---- | -------------------------------------- |
2690| slotId   | number                 | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2691| callback | AsyncCallback<string\> | 是   | 回调函数。                             |
2692
2693**错误码:**
2694
2695以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2696
2697| 错误码ID |                 错误信息                     |
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**示例:**
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
2724获取指定卡槽SIM卡的ICCID。使用Promise异步回调。
2725
2726**系统接口:** 此接口为系统接口。
2727
2728**需要权限**:ohos.permission.GET_TELEPHONY_STATE
2729
2730**系统能力**:SystemCapability.Telephony.CoreService
2731
2732**参数:**
2733
2734| 参数名 | 类型   | 必填 | 说明                                   |
2735| ------ | ------ | ---- | -------------------------------------- |
2736| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2737
2738**返回值:**
2739
2740| 类型             | 说明                                        |
2741| ---------------- | ------------------------------------------- |
2742| Promise<string\> | 以Promise形式返回获取指定卡槽SIM卡的ICCID。 |
2743
2744**错误码:**
2745
2746以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2747
2748| 错误码ID |                 错误信息                     |
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**示例:**
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
2776获取指定卡槽中SIM卡语音信箱的alpha标识符。使用callback异步回调。
2777
2778**系统接口:** 此接口为系统接口。
2779
2780**需要权限**:ohos.permission.GET_TELEPHONY_STATE
2781
2782**系统能力**:SystemCapability.Telephony.CoreService
2783
2784**参数:**
2785
2786| 参数名   | 类型                   | 必填 | 说明                                   |
2787| -------- | ---------------------- | ---- | -------------------------------------- |
2788| slotId   | number                 | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2789| callback | AsyncCallback<string\> | 是   | 回调函数。                             |
2790
2791**错误码:**
2792
2793以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2794
2795| 错误码ID |                 错误信息                     |
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**示例:**
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
2822获取指定卡槽中SIM卡语音信箱的alpha标识符。使用Promise异步回调。
2823
2824**系统接口:** 此接口为系统接口。
2825
2826**需要权限**:ohos.permission.GET_TELEPHONY_STATE
2827
2828**系统能力**:SystemCapability.Telephony.CoreService
2829
2830**参数:**
2831
2832| 参数名 | 类型   | 必填 | 说明                                   |
2833| ------ | ------ | ---- | -------------------------------------- |
2834| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2835
2836**返回值:**
2837
2838| 类型             | 说明                                              |
2839| ---------------- | ------------------------------------------------- |
2840| Promise<string\> | 以Promise形式返回获取指定卡槽SIM卡的alpha标识符。 |
2841
2842**错误码:**
2843
2844以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2845
2846| 错误码ID |                 错误信息                     |
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**示例:**
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
2874获取指定卡槽中SIM卡的语音信箱号。使用callback异步回调。
2875
2876**系统接口:** 此接口为系统接口。
2877
2878**需要权限**:ohos.permission.GET_TELEPHONY_STATE
2879
2880**系统能力**:SystemCapability.Telephony.CoreService
2881
2882**参数:**
2883
2884| 参数名   | 类型                   | 必填 | 说明                                   |
2885| -------- | ---------------------- | ---- | -------------------------------------- |
2886| slotId   | number                 | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2887| callback | AsyncCallback<string\> | 是   | 回调函数。                             |
2888
2889**错误码:**
2890
2891以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2892
2893| 错误码ID |                 错误信息                     |
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**示例:**
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
2920获取指定卡槽中SIM卡的语音信箱号。使用Promise异步回调。
2921
2922**系统接口:** 此接口为系统接口。
2923
2924**需要权限**:ohos.permission.GET_TELEPHONY_STATE
2925
2926**系统能力**:SystemCapability.Telephony.CoreService
2927
2928**参数:**
2929
2930| 参数名 | 类型   | 必填 | 说明                                   |
2931| ------ | ------ | ---- | -------------------------------------- |
2932| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2933
2934**返回值:**
2935
2936| 类型             | 说明                                             |
2937| ---------------- | ------------------------------------------------ |
2938| Promise<string\> | 以Promise形式返回获取指定卡槽SIM卡的语音信箱号。 |
2939
2940**错误码:**
2941
2942以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2943
2944| 错误码ID |                 错误信息                     |
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**示例:**
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
2973设置语音邮件信息。使用callback异步回调。
2974
2975**系统接口:** 此接口为系统接口。
2976
2977**需要权限**:ohos.permission.SET_TELEPHONY_STATE
2978
2979**系统能力**:SystemCapability.Telephony.CoreService
2980
2981**参数:**
2982
2983| 参数名     | 类型                 | 必填 | 说明                                   |
2984| ---------- | -------------------- | ---- | -------------------------------------- |
2985| slotId     | number               | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
2986| mailName   | string               | 是   | 邮件名字                               |
2987| mailNumber | string               | 是   | 邮件号码                               |
2988| callback   | AsyncCallback<void\> | 是   | 回调函数。                             |
2989
2990**错误码:**
2991
2992以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
2993
2994| 错误码ID |                 错误信息                     |
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**示例:**
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
3022设置语音邮件信息。使用Promise异步回调。
3023
3024**系统接口:** 此接口为系统接口。
3025
3026**需要权限**:ohos.permission.SET_TELEPHONY_STATE
3027
3028**系统能力**:SystemCapability.Telephony.CoreService
3029
3030**参数:**
3031
3032| 参数名     | 类型   | 必填 | 说明                                   |
3033| ---------- | ------ | ---- | -------------------------------------- |
3034| slotId     | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
3035| mailName   | string | 是   | 邮件名字。                               |
3036| mailNumber | string | 是   | 邮件号码。                               |
3037
3038**返回值:**
3039
3040| 类型           | 说明                    |
3041| -------------- | ----------------------- |
3042| Promise<void\> | 以Promise形式返回结果。 |
3043
3044**错误码:**
3045
3046以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3047
3048| 错误码ID |                 错误信息                     |
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**示例:**
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
3077获取指定卡槽中SIM卡的MSISDN。使用callback异步回调。
3078
3079**系统接口:** 此接口为系统接口。
3080
3081**需要权限**:ohos.permission.GET_PHONE_NUMBERS
3082
3083**系统能力**:SystemCapability.Telephony.CoreService
3084
3085**参数:**
3086
3087| 参数名   | 类型                   | 必填 | 说明                                   |
3088| -------- | ---------------------- | ---- | -------------------------------------- |
3089| slotId   | number                 | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
3090| callback | AsyncCallback<string\> | 是   | 回调函数。                             |
3091
3092**错误码:**
3093
3094以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3095
3096| 错误码ID |                 错误信息                     |
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**示例:**
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
3123获取指定卡槽中SIM卡的MSISDN。使用Promise异步回调。
3124
3125**系统接口:** 此接口为系统接口。
3126
3127**需要权限**:ohos.permission.GET_PHONE_NUMBERS
3128
3129**系统能力**:SystemCapability.Telephony.CoreService
3130
3131**参数:**
3132
3133| 参数名 | 类型   | 必填 | 说明                                   |
3134| ------ | ------ | ---- | -------------------------------------- |
3135| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
3136
3137**返回值:**
3138
3139| 类型             | 说明                                         |
3140| ---------------- | -------------------------------------------- |
3141| Promise<string\> | 以Promise形式返回获取指定卡槽SIM卡的MSISDN。 |
3142
3143**错误码:**
3144
3145以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3146
3147| 错误码ID |                 错误信息                     |
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**示例:**
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
3175获取指定卡槽中SIM卡的组标识符级别1(GID1)。使用callback异步回调。
3176
3177**系统接口:** 此接口为系统接口。
3178
3179**需要权限**:ohos.permission.GET_TELEPHONY_STATE
3180
3181**系统能力**:SystemCapability.Telephony.CoreService
3182
3183**参数:**
3184
3185| 参数名   | 类型                    | 必填 | 说明                                   |
3186| -------- | ----------------------- | ---- | -------------------------------------- |
3187| slotId   | number                  | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
3188| callback | AsyncCallback\<string\> | 是   | 回调函数。                             |
3189
3190**错误码:**
3191
3192以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3193
3194| 错误码ID |                 错误信息                     |
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**示例:**
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
3221获取指定卡槽中SIM卡的组标识符级别1(GID1)。使用Promise异步回调。
3222
3223**系统接口:** 此接口为系统接口。
3224
3225**需要权限**:ohos.permission.GET_TELEPHONY_STATE
3226
3227**系统能力**:SystemCapability.Telephony.CoreService
3228
3229**参数:**
3230
3231| 参数名 | 类型   | 必填 | 说明                                   |
3232| ------ | ------ | ---- | -------------------------------------- |
3233| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
3234
3235**返回值:**
3236
3237| 类型             | 说明                                              |
3238| ---------------- | ------------------------------------------------- |
3239| Promise<string\> | 以Promise形式返回获取指定卡槽SIM卡的标识符级别1。 |
3240
3241**错误码:**
3242
3243以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3244
3245| 错误码ID |                 错误信息                     |
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**示例:**
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
3273获取国际移动用户识别码。使用callback异步回调。
3274
3275**系统接口:** 此接口为系统接口。
3276
3277**需要权限**:ohos.permission.GET_TELEPHONY_STATE
3278
3279**系统能力**:SystemCapability.Telephony.CoreService
3280
3281**参数:**
3282
3283| 参数名   | 类型                    | 必填 | 说明                                   |
3284| -------- | ----------------------- | ---- | -------------------------------------- |
3285| slotId   | number                  | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
3286| callback | AsyncCallback\<string\> | 是   | 回调函数。                             |
3287
3288**错误码:**
3289
3290以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3291
3292| 错误码ID |                 错误信息                     |
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**示例:**
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
3319获取国际移动用户识别码。使用Promise异步回调。
3320
3321**系统接口:** 此接口为系统接口。
3322
3323**需要权限**:ohos.permission.GET_TELEPHONY_STATE
3324
3325**系统能力**:SystemCapability.Telephony.CoreService
3326
3327**参数:**
3328
3329| 参数名 | 类型   | 必填 | 说明                                   |
3330| ------ | ------ | ---- | -------------------------------------- |
3331| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
3332
3333**返回值:**
3334
3335| 类型             | 说明                                        |
3336| ---------------- | ------------------------------------------- |
3337| Promise<string\> | 以Promise形式返回获取的国际移动用户识别码。 |
3338
3339**错误码:**
3340
3341以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3342
3343| 错误码ID |                 错误信息                     |
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**示例:**
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
3371获取运营商配置。使用callback异步回调。
3372
3373**系统接口:** 此接口为系统接口。
3374
3375**需要权限**:ohos.permission.GET_TELEPHONY_STATE
3376
3377**系统能力**:SystemCapability.Telephony.CoreService
3378
3379**参数:**
3380
3381| 参数名   | 类型                                                      | 必填 | 说明                                   |
3382| -------- | --------------------------------------------------------- | ---- | -------------------------------------- |
3383| slotId   | number                                                    | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
3384| callback | AsyncCallback<Array<[OperatorConfig](#operatorconfig8)\>> | 是   | 回调函数。                             |
3385
3386**错误码:**
3387
3388以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3389
3390| 错误码ID |                 错误信息                     |
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**示例:**
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
3416获取运营商配置。使用Promise异步回调。
3417
3418**系统接口:** 此接口为系统接口。
3419
3420**需要权限**:ohos.permission.GET_TELEPHONY_STATE
3421
3422**系统能力**:SystemCapability.Telephony.CoreService
3423
3424**参数:**
3425
3426| 参数名 | 类型   | 必填 | 说明                                   |
3427| ------ | ------ | ---- | -------------------------------------- |
3428| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
3429
3430**返回值:**
3431
3432| 类型                                                | 说明                          |
3433| --------------------------------------------------- | ----------------------------- |
3434| Promise<Array<[OperatorConfig](#operatorconfig8)\>> | 以Promise形式返回运营商配置。 |
3435
3436**错误码:**
3437
3438以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3439
3440| 错误码ID |                 错误信息                     |
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**示例:**
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
3467查询SIM卡联系人号码。使用callback异步回调。
3468
3469**系统接口:** 此接口为系统接口。
3470
3471**需要权限**:ohos.permission.READ_CONTACTS
3472
3473**系统能力**:SystemCapability.Telephony.CoreService
3474
3475**参数:**
3476
3477| 参数名   | 类型                                                         | 必填 | 说明                                                       |
3478| -------- | ------------------------------------------------------------ | ---- | ---------------------------------------------------------- |
3479| slotId   | number                                                       | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2                     |
3480| type     | [ContactType](#contacttype8)                                 | 是   | 联系人类型。<br/>- 1 : GENERAL_CONTACT<br/>- 2 : FIXED_DIALING |
3481| callback | AsyncCallback<Array<[DiallingNumbersInfo](#diallingnumbersinfo8)\>> | 是   | 回调函数。                                          |
3482
3483**错误码:**
3484
3485以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3486
3487| 错误码ID |                 错误信息                     |
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**示例:**
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
3515查询SIM卡联系人号码。使用Promise异步回调。
3516
3517**系统接口:** 此接口为系统接口。
3518
3519**需要权限**:ohos.permission.READ_CONTACTS
3520
3521**系统能力**:SystemCapability.Telephony.CoreService
3522
3523**参数:**
3524
3525| 参数名 | 类型        | 必填 | 说明                                                       |
3526| ------ | ----------- | ---- | ---------------------------------------------------------- |
3527| slotId | number      | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2                     |
3528| type   | [ContactType](#contacttype8)  | 是   | 联系人类型。<br/>- 1 : GENERAL_CONTACT<br/>- 2 : FIXED_DIALING |
3529
3530**返回值:**
3531
3532| 类型                                                         | 说明                           |
3533| ------------------------------------------------------------ | ------------------------------ |
3534| Promise<Array<[DiallingNumbersInfo](#diallingnumbersinfo8)\>> | 以Promise形式返回Icc拨号号码。|
3535
3536**错误码:**
3537
3538以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3539
3540| 错误码ID |                 错误信息                     |
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**示例:**
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
3569添加SIM卡联系人号码。使用callback异步回调。
3570
3571**系统接口:** 此接口为系统接口。
3572
3573**需要权限**:ohos.permission.WRITE_CONTACTS
3574
3575**系统能力**:SystemCapability.Telephony.CoreService
3576
3577**参数:**
3578
3579| 参数名          | 类型                                         | 必填 | 说明                                                       |
3580| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
3581| slotId          | number                                       | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2                     |
3582| type            | [ContactType](#contacttype8)                 | 是   | 联系人类型。<br/>- 1 : GENERAL_CONTACT<br/>- 2 : FIXED_DIALING |
3583| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是   | 拨号号码信息。                                               |
3584| callback        | AsyncCallback<void\>                         | 是   | 回调函数。                                                   |
3585
3586**错误码:**
3587
3588以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3589
3590| 错误码ID |                 错误信息                     |
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**示例:**
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
3623添加SIM卡联系人号码。使用Promise异步回调。
3624
3625**系统接口:** 此接口为系统接口。
3626
3627**需要权限**:ohos.permission.WRITE_CONTACTS
3628
3629**系统能力**:SystemCapability.Telephony.CoreService
3630
3631**参数:**
3632
3633| 参数名          | 类型                                         | 必填 | 说明                                                       |
3634| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
3635| slotId          | number                                       | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2                     |
3636| type            | [ContactType](#contacttype8)                 | 是   | 联系人类型。<br/>- 1 : GENERAL_CONTACT<br/>- 2 : FIXED_DIALING |
3637| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是   | 拨号号码信息。                                               |
3638
3639**返回值:**
3640
3641| 类型           | 说明                        |
3642| -------------- | --------------------------- |
3643| Promise<void\> | 以Promise形式返回添加结果。 |
3644
3645**错误码:**
3646
3647以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3648
3649| 错误码ID |                 错误信息                     |
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**示例:**
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
3682删除SIM卡联系人号码。使用callback异步回调。
3683
3684**系统接口:** 此接口为系统接口。
3685
3686**需要权限**:ohos.permission.WRITE_CONTACTS
3687
3688**系统能力**:SystemCapability.Telephony.CoreService
3689
3690**参数:**
3691
3692| 参数名          | 类型                                         | 必填 | 说明                                                       |
3693| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
3694| slotId          | number                                       | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2                     |
3695| type            | [ContactType](#contacttype8)                 | 是   | 联系人类型。<br/>- 1 : GENERAL_CONTACT<br/>- 2 : FIXED_DIALING |
3696| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是   | 拨号号码信息。                                               |
3697| callback        | AsyncCallback<void\>                         | 是   | 回调函数。                                                   |
3698
3699**错误码:**
3700
3701以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3702
3703| 错误码ID |                 错误信息                     |
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**示例:**
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
3737删除SIM卡联系人号码。使用Promise异步回调。
3738
3739**系统接口:** 此接口为系统接口。
3740
3741**需要权限**:ohos.permission.WRITE_CONTACTS
3742
3743**系统能力**:SystemCapability.Telephony.CoreService
3744
3745**参数:**
3746
3747| 参数名          | 类型                                         | 必填 | 说明                                                       |
3748| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
3749| slotId          | number                                       | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2                     |
3750| type            | [ContactType](#contacttype8)                 | 是   | 联系人类型。<br/>- 1 : GENERAL_CONTACT<br/>- 2 : FIXED_DIALING |
3751| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是   | 拨号号码信息。                                               |
3752
3753**返回值:**
3754
3755| 类型           | 说明                        |
3756| -------------- | --------------------------- |
3757| Promise<void\> | 以Promise形式返回删除结果。 |
3758
3759**错误码:**
3760
3761以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3762
3763| 错误码ID |                 错误信息                     |
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**示例:**
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
3796更新SIM卡联系人号码。使用callback异步回调。
3797
3798**系统接口:** 此接口为系统接口。
3799
3800**需要权限**:ohos.permission.WRITE_CONTACTS
3801
3802**系统能力**:SystemCapability.Telephony.CoreService
3803
3804**参数:**
3805
3806| 参数名          | 类型                                         | 必填 | 说明                                                       |
3807| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
3808| slotId          | number                                       | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2                     |
3809| type            | [ContactType](#contacttype8)                 | 是   | 联系人类型。<br/>- 1 : GENERAL_CONTACT<br/>- 2 : FIXED_DIALING |
3810| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是   | 拨号号码信息。                                               |
3811| callback        | AsyncCallback<void\>                         | 是   | 回调函数。                                                   |
3812
3813**错误码:**
3814
3815以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3816
3817| 错误码ID |                 错误信息                     |
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**示例:**
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
3851更新SIM卡联系人号码。使用Promise异步回调。
3852
3853**系统接口:** 此接口为系统接口。
3854
3855**需要权限**:ohos.permission.WRITE_CONTACTS
3856
3857**系统能力**:SystemCapability.Telephony.CoreService
3858
3859**参数:**
3860
3861| 参数名          | 类型                                         | 必填 | 说明                                                       |
3862| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
3863| slotId          | number                                       | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2                     |
3864| type            | [ContactType](#contacttype8)                 | 是   | 联系人类型。<br/>- 1 : GENERAL_CONTACT<br/>- 2 : FIXED_DIALING |
3865| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是   | 拨号号码信息。                                               |
3866
3867**返回值:**
3868
3869| 类型           | 说明                          |
3870| -------------- | ----------------------------- |
3871| Promise<void\> | 以Promise形式返回更新的结果。 |
3872
3873**错误码:**
3874
3875以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3876
3877| 错误码ID |                 错误信息                     |
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**示例:**
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
3911发送信封命令。使用callback异步回调。
3912
3913**系统接口:** 此接口为系统接口。
3914
3915**需要权限**:ohos.permission.SET_TELEPHONY_STATE
3916
3917**系统能力**:SystemCapability.Telephony.CoreService
3918
3919**参数:**
3920
3921| 参数名   | 类型                 | 必填 | 说明                                   |
3922| -------- | -------------------- | ---- | -------------------------------------- |
3923| slotId   | number               | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
3924| cmd      | string               | 是   | 命令。                                   |
3925| callback | AsyncCallback<void\> | 是   | 回调函数。                                     |
3926
3927**错误码:**
3928
3929以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3930
3931| 错误码ID |                 错误信息                     |
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**示例:**
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
3958发送信封命令。使用Promise异步回调。
3959
3960**系统接口:** 此接口为系统接口。
3961
3962**需要权限**:ohos.permission.SET_TELEPHONY_STATE
3963
3964**系统能力**:SystemCapability.Telephony.CoreService
3965
3966**参数:**
3967
3968| 参数名 | 类型   | 必填 | 说明                                   |
3969| ------ | ------ | ---- | -------------------------------------- |
3970| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
3971| cmd    | string | 是   | 命令。                                   |
3972
3973**返回值:**
3974
3975| 类型           | 说明                        |
3976| -------------- | --------------------------- |
3977| Promise<void\> | 以Promise形式返回发送结果。 |
3978
3979**错误码:**
3980
3981以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
3982
3983| 错误码ID |                 错误信息                     |
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**示例:**
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
4011发送终端响应命令。使用callback异步回调。
4012
4013**系统接口:** 此接口为系统接口。
4014
4015**需要权限**:ohos.permission.SET_TELEPHONY_STATE
4016
4017**系统能力**:SystemCapability.Telephony.CoreService
4018
4019**参数:**
4020
4021| 参数名   | 类型                 | 必填 | 说明                                   |
4022| -------- | -------------------- | ---- | -------------------------------------- |
4023| slotId   | number               | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
4024| cmd      | string               | 是   | 命令。                                   |
4025| callback | AsyncCallback<void\> | 是   | 回调函数。                             |
4026
4027**错误码:**
4028
4029以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
4030
4031| 错误码ID |                 错误信息                     |
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**示例:**
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
4058发送终端响应命令。使用Promise异步回调。
4059
4060**系统接口:** 此接口为系统接口。
4061
4062**需要权限**:ohos.permission.SET_TELEPHONY_STATE
4063
4064**系统能力**:SystemCapability.Telephony.CoreService
4065
4066**参数:**
4067
4068| 参数名 | 类型   | 必填 | 说明                                   |
4069| ------ | ------ | ---- | -------------------------------------- |
4070| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
4071| cmd    | string | 是   | 命令。                                   |
4072
4073**返回值:**
4074
4075| 类型           | 说明                        |
4076| -------------- | --------------------------- |
4077| Promise<void\> | 以Promise形式返回发送结果。 |
4078
4079**错误码:**
4080
4081以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
4082
4083| 错误码ID |                 错误信息                     |
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**示例:**
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
4112解锁SIM卡锁。使用callback异步回调。
4113
4114**系统接口:** 此接口为系统接口。
4115
4116**需要权限**:ohos.permission.SET_TELEPHONY_STATE
4117
4118**系统能力**:SystemCapability.Telephony.CoreService
4119
4120**参数:**
4121
4122| 参数名   | 类型                                                       | 必填 | 说明                                   |
4123| -------- | ---------------------------------------------------------- | ---- | -------------------------------------- |
4124| slotId   | number                                                     | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
4125| lockInfo | [PersoLockInfo](#persolockinfo8)                           | 是   | 定制锁类型信息。                         |
4126| callback | AsyncCallback<[LockStatusResponse](#lockstatusresponse7)\> | 是   | 回调函数。                               |
4127
4128**错误码:**
4129
4130以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
4131
4132| 错误码ID |                 错误信息                     |
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**示例:**
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
4164解锁SIM卡锁。使用Promise异步回调。
4165
4166**系统接口:** 此接口为系统接口。
4167
4168**需要权限**:ohos.permission.SET_TELEPHONY_STATE
4169
4170**系统能力**:SystemCapability.Telephony.CoreService
4171
4172**参数:**
4173
4174| 参数名   | 类型                             | 必填 | 说明                                   |
4175| -------- | -------------------------------- | ---- | -------------------------------------- |
4176| slotId   | number                           | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
4177| lockInfo | [PersoLockInfo](#persolockinfo8) | 是   | 定制锁类型信息。                         |
4178
4179**返回值:**
4180
4181| 类型                                                 | 说明                      |
4182| ---------------------------------------------------- | ------------------------- |
4183| Promise<[LockStatusResponse](#lockstatusresponse7)\> | 以Promise形式返回锁状态。 |
4184
4185**错误码:**
4186
4187以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
4188
4189| 错误码ID |                 错误信息                     |
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**示例:**
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
4222获取指定卡槽中SIM卡的opkey。使用callback异步回调。
4223
4224**系统能力**:SystemCapability.Telephony.CoreService
4225
4226**参数:**
4227
4228| 参数名   | 类型                   | 必填 | 说明                                   |
4229| -------- | ---------------------- | ---- | -------------------------------------- |
4230| slotId   | number                 | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
4231| callback | AsyncCallback<string\> | 是   | 回调函数。                             |
4232
4233**错误码:**
4234
4235以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
4236
4237| 错误码ID |                 错误信息                     |
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**示例:**
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
4270获取指定卡槽中SIM卡的opkey。使用Promise异步回调。
4271
4272**系统能力**:SystemCapability.Telephony.CoreService
4273
4274**参数:**
4275
4276| 参数名 | 类型   | 必填 | 说明                                   |
4277| ------ | ------ | ---- | -------------------------------------- |
4278| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
4279
4280**返回值:**
4281
4282| 类型             | 说明                                      |
4283| ---------------- | ----------------------------------------- |
4284| Promise<string\> | 以Promise形式返回指定卡槽中SIM卡的opkey。 |
4285
4286**错误码:**
4287
4288以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
4289
4290| 错误码ID |                 错误信息                     |
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**示例:**
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
4317获取指定卡槽中SIM卡的opkey。
4318
4319**系统能力**:SystemCapability.Telephony.CoreService
4320
4321**参数:**
4322
4323| 参数名 | 类型   | 必填 | 说明                                   |
4324| ------ | ------ | ---- | -------------------------------------- |
4325| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
4326
4327**返回值:**
4328
4329| 类型             | 说明                                      |
4330| ---------------- | ----------------------------------------- |
4331| string | 返回指定卡槽中SIM卡的opkey。 |
4332
4333
4334**示例:**
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
4345获取指定卡槽中SIM卡的OpName。使用callback异步回调。
4346
4347**系统能力**:SystemCapability.Telephony.CoreService
4348
4349**参数:**
4350
4351| 参数名   | 类型                   | 必填 | 说明                                   |
4352| -------- | ---------------------- | ---- | -------------------------------------- |
4353| slotId   | number                 | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
4354| callback | AsyncCallback<string\> | 是   | 回调函数。                               |
4355
4356**错误码:**
4357
4358以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
4359
4360| 错误码ID |                 错误信息                     |
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**示例:**
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
4393获取指定卡槽中SIM卡的OpName。使用Promise异步回调。
4394
4395**系统能力**:SystemCapability.Telephony.CoreService
4396
4397**参数:**
4398
4399| 参数名 | 类型   | 必填 | 说明                                   |
4400| ------ | ------ | ---- | -------------------------------------- |
4401| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
4402
4403**返回值:**
4404
4405| 类型             | 说明                                       |
4406| ---------------- | ------------------------------------------ |
4407| Promise<string\> | 以Promise形式返回指定卡槽中SIM卡的OpName。 |
4408
4409**错误码:**
4410
4411以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
4412
4413| 错误码ID |                 错误信息                     |
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**示例:**
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
4440获取指定卡槽中SIM卡的OpName。
4441
4442**系统能力**:SystemCapability.Telephony.CoreService
4443
4444**参数:**
4445
4446| 参数名 | 类型   | 必填 | 说明                                   |
4447| ------ | ------ | ---- | -------------------------------------- |
4448| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
4449
4450**返回值:**
4451
4452| 类型             | 说明                                       |
4453| ---------------- | ------------------------------------------ |
4454| string | 返回指定卡槽中SIM卡的OpName。 |
4455
4456
4457**示例:**
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
4468获取默认语音业务的SIM卡ID。使用callback异步回调。
4469
4470**系统能力**:SystemCapability.Telephony.CoreService
4471
4472**参数:**
4473
4474| 参数名   | 类型                        | 必填 | 说明       |
4475| -------- | --------------------------- | ---- | ---------- |
4476| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。<br/>与SIM卡绑定,从1开始递增。 |
4477
4478**错误码:**
4479
4480以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
4481
4482| 错误码ID |                 错误信息                     |
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**示例:**
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
4507获取默认语音业务的SIM卡ID。使用Promise异步回调。
4508
4509**系统能力**:SystemCapability.Telephony.CoreService
4510
4511**返回值:**
4512
4513| 类型              | 说明                                    |
4514| ----------------- | --------------------------------------- |
4515| Promise\<number\> | 以Promise形式返回默认语音业务的SIM卡ID。<br/>与SIM卡绑定,从1开始递增。 |
4516
4517**错误码:**
4518
4519以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。
4520
4521| 错误码ID |                 错误信息                     |
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**示例:**
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
4546SIM卡状态。
4547
4548**系统能力**:SystemCapability.Telephony.CoreService
4549
4550| 名称                  | 值   | 说明                                                       |
4551| --------------------- | ---- | ---------------------------------------------------------- |
4552| SIM_STATE_UNKNOWN     | 0    | SIM卡状态未知,即无法获取准确的状态。                      |
4553| SIM_STATE_NOT_PRESENT | 1    | 表示SIM卡处于not present状态,即卡槽中没有插入SIM卡。      |
4554| SIM_STATE_LOCKED      | 2    | 表示SIM卡处于locked状态,即SIM卡被PIN、PUK或网络锁锁定。   |
4555| SIM_STATE_NOT_READY   | 3    | 表示SIM卡处于not ready状态,即SIM卡在位但无法正常工作。    |
4556| SIM_STATE_READY       | 4    | 表示SIM卡处于ready状态,即SIM卡在位且工作正常。            |
4557| SIM_STATE_LOADED      | 5    | 表示SIM卡处于loaded状态,即SIM卡在位且所有卡文件加载完毕。 |
4558
4559## CardType<sup>7+</sup>
4560
4561卡类型。
4562
4563**系统能力**:SystemCapability.Telephony.CoreService
4564
4565| 名称 | 值 | 说明 |
4566| ----- | ----- | ----- |
4567|UNKNOWN_CARD | -1 | 未知类型。 |
4568|SINGLE_MODE_SIM_CARD | 10 | 单SIM卡。 |
4569|SINGLE_MODE_USIM_CARD | 20 | 单USIM卡。 |
4570|SINGLE_MODE_RUIM_CARD | 30 | 单RUIM卡。 |
4571|DUAL_MODE_CG_CARD | 40 | 双卡模式C+G。 |
4572|CT_NATIONAL_ROAMING_CARD | 41 | 中国电信内部漫游卡。 |
4573|CU_DUAL_MODE_CARD | 42 | 中国联通双模卡。 |
4574|DUAL_MODE_TELECOM_LTE_CARD | 43 | 双模式电信LTE卡。 |
4575|DUAL_MODE_UG_CARD | 50 | 双模式UG卡。 |
4576|SINGLE_MODE_ISIM_CARD<sup>8+</sup> | 60 | 单一ISIM卡类型。 |
4577
4578## LockType<sup>8+</sup>
4579
4580锁类型。
4581
4582**系统接口:** 此接口为系统接口。
4583
4584**系统能力**:SystemCapability.Telephony.CoreService
4585
4586| 名称     | 值   | 说明        |
4587| -------- | ---- | ----------- |
4588| PIN_LOCK | 1    | SIM卡密码锁。 |
4589| FDN_LOCK | 2    | 固定拨号锁。  |
4590
4591## LockState<sup>8+</sup>
4592
4593锁状态。
4594
4595**系统接口:** 此接口为系统接口。
4596
4597**系统能力**:SystemCapability.Telephony.CoreService
4598
4599| 名称     | 值   | 说明       |
4600| -------- | ---- | ---------- |
4601| LOCK_OFF | 0    | 锁关闭状态 |
4602| LOCK_ON  | 1    | 锁开启状态 |
4603
4604## PersoLockType<sup>8+</sup>
4605
4606定制锁类型。
4607
4608**系统接口:** 此接口为系统接口。
4609
4610**系统能力**:SystemCapability.Telephony.CoreService
4611
4612| 名称         | 值   | 说明                                             |
4613| ------------ | ---- | ------------------------------------------------ |
4614| PN_PIN_LOCK  | 0    | 定制网络PIN锁(参照 3GPP TS 22.022 [33])。         |
4615| PN_PUK_LOCK  | 1    | 定制网络PUk锁。                                   |
4616| PU_PIN_LOCK  | 2    | 定制网络子集PIN锁(参照 3GPP TS 22.022 [33])。     |
4617| PU_PUK_LOCK  | 3    | 定制网络子集PUK锁。                               |
4618| PP_PIN_LOCK  | 4    | 定制服务提供者PIN锁(参照 3GPP TS 22.022 [33])。   |
4619| PP_PUK_LOCK  | 5    | 定制服务提供者PUK锁。                             |
4620| PC_PIN_LOCK  | 6    | 定制企业PIN锁(参照 3GPP TS 22.022 [33])。         |
4621| PC_PUK_LOCK  | 7    | 定制企业Puk锁。                                   |
4622| SIM_PIN_LOCK | 8    | 定制SIM的PIN锁(参照 3GPP TS 22.022 [33])。        |
4623| SIM_PUK_LOCK | 9    | 定制SIM的PUK锁。                                  |
4624
4625## LockStatusResponse<sup>7+</sup>
4626
4627锁状态响应。
4628
4629**系统接口:** 此接口为系统接口。
4630
4631**系统能力**:SystemCapability.Telephony.CoreService
4632
4633| 名称            | 类型   | 必填 | 说明                  |
4634| --------------- | ------ | ---- | --------------------- |
4635| result          | number |  是  | 当前操作的结果。      |
4636| remain?: number | number |  否  | 剩余次数(可以为空)。|
4637
4638## LockInfo<sup>8+</sup>
4639
4640锁状态响应。
4641
4642**系统接口:** 此接口为系统接口。
4643
4644**系统能力**:SystemCapability.Telephony.CoreService
4645
4646| 名称     |           类型           | 必填 |   说明   |
4647| -------- | ------------------------ | ---- | -------- |
4648| lockType | [LockType](#locktype8)   |  是  | 锁类型。 |
4649| password | string                   |  是  | 密码。   |
4650| state    | [LockState](#lockstate8) |  是  | 锁状态。 |
4651
4652## PersoLockInfo<sup>8+</sup>
4653
4654锁状态响应。
4655
4656**系统接口:** 此接口为系统接口。
4657
4658**系统能力**:SystemCapability.Telephony.CoreService
4659
4660| 名称     |               类型               | 必填 |      说明     |
4661| -------- | -------------------------------- | ---- | ------------- |
4662| lockType | [PersoLockType](#persolocktype8) |  是  | 定制锁的类型。|
4663| password | string                           |  是  | 密码。        |
4664
4665## IccAccountInfo<sup>10+</sup>
4666
4667Icc帐户信息。
4668
4669**系统能力**:SystemCapability.Telephony.CoreService
4670
4671| 名称       | 类型    | 必填 | 说明             |
4672| ---------- | ------- | ---- | ---------------- |
4673| simId      | number  |  是  | SIM卡ID。          |
4674| slotIndex  | number  |  是  | 卡槽ID。           |
4675| isEsim     | boolean |  是  | 标记卡是否是eSim。 |
4676| isActive   | boolean |  是  | 卡是否被激活。     |
4677| iccId      | string  |  是  | ICCID号码。        |
4678| showName   | string  |  是  | SIM卡显示名称。    |
4679| showNumber | string  |  是  | SIM卡显示号码。    |
4680
4681## OperatorConfig<sup>8+</sup>
4682
4683运营商配置。
4684
4685**系统接口:** 此接口为系统接口。
4686
4687**系统能力**:SystemCapability.Telephony.CoreService
4688
4689| 名称  | 类型   | 必填 | 说明 |
4690| ----- | ------ | ---- | ---- |
4691| field | string |  是  | 字段 |
4692| value | string |  是  | 值   |
4693
4694## DiallingNumbersInfo<sup>8+</sup>
4695
4696拨号号码信息。
4697
4698**系统接口:** 此接口为系统接口。
4699
4700**系统能力**:SystemCapability.Telephony.CoreService
4701
4702| 名称         | 类型   | 必填 |    说明    |
4703| ------------ | ------ | ---- | ---------- |
4704| alphaTag     | string |  是  | 标签。     |
4705| number       | string |  是  | 号码。     |
4706| recordNumber | number |  是  | 记录编号。 |
4707| pin2         | string |  是  | pin2密码。 |
4708
4709## ContactType<sup>8+</sup>
4710
4711联系人类型。
4712
4713**系统接口:** 此接口为系统接口。
4714
4715**系统能力**:SystemCapability.Telephony.CoreService
4716
4717| 名称            | 值   | 说明       |
4718| --------------- | ---- | ---------- |
4719| GENERAL_CONTACT | 1    | 通用联系人。 |
4720| FIXED_DIALING   | 2    | 固定拨号。   |
4721
4722## OperatorConfigKey<sup>9+</sup>
4723
4724运营商配置键。
4725
4726**系统接口:** 此接口为系统接口。
4727
4728**系统能力**:SystemCapability.Telephony.CoreService
4729
4730|                             名称                        |                             值                         |         说明         |
4731| ------------------------------------------------------- | ------------------------------------------------------ | -------------------- |
4732| KEY_VOICE_MAIL_NUMBER_STRING                            | "voice_mail_number_string"                             | 语音邮件号码。       |
4733| KEY_IMS_SWITCH_ON_BY_DEFAULT_BOOL                       | "ims_switch_on_by_default_bool"                        | 固定拨号。           |
4734| KEY_HIDE_IMS_SWITCH_BOOL                                | "hide_ims_switch_bool"                                 | 是否隐藏ims开关。    |
4735| KEY_VOLTE_SUPPORTED_BOOL                                | "volte_supported_bool"                                 | 是否支持volte模式。  |
4736| KEY_NR_MODE_SUPPORTED_LIST_INT_ARRAY                    | "nr_mode_supported_list_int_array"                     | nr模式支持的列表。   |
4737| KEY_VOLTE_PROVISIONING_SUPPORTED_BOOL                   | "volte_provisioning_supported_bool"                    | 是否支持配置VOLTE。  |
4738| KEY_SS_OVER_UT_SUPPORTED_BOOL                           | "ss_over_ut_supported_bool"                            | SS服务是否支持UT。   |
4739| KEY_IMS_GBA_REQUIRED_BOOL                               | "ims_gba_required_bool"                                | IMS是否需要GBA。     |
4740| KEY_UT_PROVISIONING_SUPPORTED_BOOL                      | "ut_provisioning_supported_bool"                       | 是否支持UT配置。     |
4741| KEY_IMS_PREFER_FOR_EMERGENCY_BOOL                       | "ims_prefer_for_emergency_bool"                        | IMS紧急首选项。      |
4742| KEY_CALL_WAITING_SERVICE_CLASS_INT                      | "call_waiting_service_class_int"                       | 呼叫等待服务。       |
4743| KEY_CALL_TRANSFER_VISIBILITY_BOOL                       | "call_transfer_visibility_bool"                        | 呼叫转移可见性。     |
4744| KEY_IMS_CALL_DISCONNECT_REASON_INFO_MAPPING_STRING_ARRAY| "ims_call_disconnect_reason_info_mapping_string_array" | IMS呼叫结束原因列表。|
4745| KEY_FORCE_VOLTE_SWITCH_ON_BOOL                          | "force_volte_switch_on_bool"                           | 强制VOLTE开关。      |
4746| KEY_ENABLE_OPERATOR_NAME_CUST_BOOL                      | "enable_operator_name_cust_bool"                       | 是否显示运营商名称。 |
4747| KEY_OPERATOR_NAME_CUST_STRING                           | "operator_name_cust_string"                            | 运营商名称。         |
4748| KEY_SPN_DISPLAY_CONDITION_CUST_INT                      | "spn_display_condition_cust_int"                       | SPN显示规则。        |
4749| KEY_PNN_CUST_STRING_ARRAY                               | "pnn_cust_string_array"                                | PLMN名称。           |
4750| KEY_OPL_CUST_STRING_ARRAY                               | "opl_cust_string_array"                                | 运营商PLMN信息。     |
4751| KEY_EMERGENCY_CALL_STRING_ARRAY                         | "emergency_call_string_array"                          | 紧急呼叫列表。       |
4752