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<boolean> | 是 | 回调函数。返回指定卡槽是否激活,如果激活返回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<boolean> | 以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.error(`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<number> | 是 | 回调函数。<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.error(`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.error(`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.error(`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.error(`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.error(`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.error(`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.error(`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<boolean> | 是 | 回调返回指定卡槽是否插卡,如果插卡返回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<boolean> | 以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.error(`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**需要权限**:ohos.permission.GET_TELEPHONY_STATE 930 931>**说明:** 932> 933>仅需获取ICCID和号码信息时需要GET_TELEPHONY_STATE权限,ICCID和号码信息为敏感数据,不向三方应用开放。调用接口时,获取到的ICCID和号码信息为空。 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**需要权限**:ohos.permission.GET_TELEPHONY_STATE 977 978>**说明:** 979> 980>仅需获取ICCID和号码信息时需要GET_TELEPHONY_STATE权限,ICCID和号码信息为敏感数据,不向三方应用开放。调用接口时,获取到的ICCID和号码信息为空。 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.error(`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**需要权限**:ohos.permission.GET_TELEPHONY_STATE 1030 1031>**说明:** 1032> 1033>仅需获取ICCID和号码信息时需要GET_TELEPHONY_STATE权限,ICCID和号码信息为敏感数据,不向三方应用开放。调用接口时,获取到的ICCID和号码信息为空。 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| 401 | Parameter error. | 1050| 8300001 | Invalid parameter value. | 1051| 8300002 | Operation failed. Cannot connect to service. | 1052| 8300003 | System internal error. | 1053| 8300004 | Do not have sim card. | 1054| 8300999 | Unknown error code. | 1055 1056**示例:** 1057 1058```ts 1059import { BusinessError } from '@ohos.base'; 1060import sim from '@ohos.telephony.sim'; 1061 1062sim.getActiveSimAccountInfoList((err: BusinessError, data: Array<sim.IccAccountInfo>) => { 1063 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 1064}); 1065``` 1066 1067 1068## sim.getActiveSimAccountInfoList<sup>10+</sup> 1069 1070getActiveSimAccountInfoList\(\): Promise\<Array\<IccAccountInfo\>\> 1071 1072获取激活SIM卡帐户信息列表。使用Promise异步回调。 1073 1074**需要权限**:ohos.permission.GET_TELEPHONY_STATE 1075 1076>**说明:** 1077> 1078>仅需获取ICCID和号码信息时需要GET_TELEPHONY_STATE权限,ICCID和号码信息为敏感数据,不向三方应用开放。调用接口时,获取到的ICCID和号码信息为空。 1079 1080**系统能力**:SystemCapability.Telephony.CoreService 1081 1082**返回值:** 1083 1084| 类型 | 说明 | 1085| ---------------------------------------------------- | ---------------------------------------------- | 1086| Promise<Array<[IccAccountInfo](#iccaccountinfo10)\>\> | 以Promise形式返回激活卡槽SIM卡的帐户信息列表。 | 1087 1088**错误码:** 1089 1090以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1091 1092| 错误码ID | 错误信息 | 1093| -------- | -------------------------------------------- | 1094| 8300002 | Operation failed. Cannot connect to service. | 1095| 8300003 | System internal error. | 1096| 8300004 | Do not have sim card. | 1097| 8300999 | Unknown error code. | 1098 1099**示例:** 1100 1101```ts 1102import { BusinessError } from '@ohos.base'; 1103import sim from '@ohos.telephony.sim'; 1104 1105sim.getActiveSimAccountInfoList().then((data: Array<sim.IccAccountInfo>) => { 1106 console.log(`getActiveSimAccountInfoList success, promise: data->${JSON.stringify(data)}`); 1107}).catch((err: BusinessError) => { 1108 console.error(`getActiveSimAccountInfoList failed, promise: err->${JSON.stringify(err)}`); 1109}); 1110``` 1111 1112## sim.setDefaultVoiceSlotId<sup>7+</sup> 1113 1114setDefaultVoiceSlotId\(slotId: number, callback: AsyncCallback\<void\>\): void 1115 1116设置默认语音业务的卡槽ID。使用callback异步回调。 1117 1118**系统接口:** 此接口为系统接口。 1119 1120**需要权限**:ohos.permission.SET_TELEPHONY_STATE 1121 1122**系统能力**:SystemCapability.Telephony.CoreService 1123 1124**参数:** 1125 1126| 参数名 | 类型 | 必填 | 说明 | 1127| -------- | ------------------------- | ---- | ------------------------------------------------------------ | 1128| slotId | number | 是 | SIM卡槽ID:<br/>- 0:卡槽1<br/>- 1:卡槽2<br/>- -1:清除默认配置 | 1129| callback | AsyncCallback<void> | 是 | 回调函数。 | 1130 1131**错误码:** 1132 1133以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1134 1135| 错误码ID | 错误信息 | 1136| -------- | -------------------------------------------- | 1137| 201 | Permission denied. | 1138| 202 | Non-system applications use system APIs. | 1139| 401 | Parameter error. | 1140| 8300001 | Invalid parameter value. | 1141| 8300002 | Operation failed. Cannot connect to service. | 1142| 8300003 | System internal error. | 1143| 8300004 | Do not have sim card. | 1144| 8300999 | Unknown error code. | 1145| 8301001 | SIM card is not activated. | 1146 1147**示例:** 1148 1149```ts 1150import { BusinessError } from '@ohos.base'; 1151import sim from '@ohos.telephony.sim'; 1152 1153sim.setDefaultVoiceSlotId(0, (err: BusinessError) => { 1154 console.log(`callback: err->${JSON.stringify(err)}`); 1155}); 1156``` 1157 1158 1159## sim.setDefaultVoiceSlotId<sup>7+</sup> 1160 1161setDefaultVoiceSlotId\(slotId: number\): Promise\<void\> 1162 1163设置默认语音业务的卡槽ID。使用Promise异步回调。 1164 1165**系统接口:** 此接口为系统接口。 1166 1167**需要权限**:ohos.permission.SET_TELEPHONY_STATE 1168 1169**系统能力**:SystemCapability.Telephony.CoreService 1170 1171**参数:** 1172 1173| 参数名 | 类型 | 必填 | 说明 | 1174| ------ | ------ | ---- | ------------------------------------------------------------ | 1175| slotId | number | 是 | SIM卡槽ID:<br/>- 0:卡槽1<br/>- 1:卡槽2<br/>- -1:清除默认配置 | 1176 1177**返回值:** 1178 1179| 类型 | 说明 | 1180| --------------- | ------------------------------- | 1181| Promise\<void\> | 以Promise形式异步返回设置结果。 | 1182 1183**错误码:** 1184 1185以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1186 1187| 错误码ID | 错误信息 | 1188| -------- | -------------------------------------------- | 1189| 201 | Permission denied. | 1190| 202 | Non-system applications use system APIs. | 1191| 401 | Parameter error. | 1192| 8300001 | Invalid parameter value. | 1193| 8300002 | Operation failed. Cannot connect to service. | 1194| 8300003 | System internal error. | 1195| 8300004 | Do not have sim card. | 1196| 8300999 | Unknown error code. | 1197| 8301001 | SIM card is not activated. | 1198 1199**示例:** 1200 1201```ts 1202import { BusinessError } from '@ohos.base'; 1203import sim from '@ohos.telephony.sim'; 1204 1205sim.setDefaultVoiceSlotId(0).then(() => { 1206 console.log(`setDefaultVoiceSlotId success.`); 1207}).catch((err: BusinessError) => { 1208 console.error(`setDefaultVoiceSlotId failed, promise: err->${JSON.stringify(err)}`); 1209}); 1210``` 1211 1212## sim.setShowName<sup>8+</sup> 1213 1214setShowName\(slotId: number, name: string, callback: AsyncCallback\<void\>\): void 1215 1216设置指定卡槽SIM卡显示的名称。使用callback异步回调。 1217 1218**系统接口:** 此接口为系统接口。 1219 1220**需要权限**:ohos.permission.SET_TELEPHONY_STATE 1221 1222**系统能力**:SystemCapability.Telephony.CoreService 1223 1224**参数:** 1225 1226| 参数名 | 类型 | 必填 | 说明 | 1227| -------- | ------------------------- | ---- | -------------------------------------- | 1228| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 1229| name | string | 是 | SIM卡名称。 | 1230| callback | AsyncCallback<void> | 是 | 回调函数。 | 1231 1232**错误码:** 1233 1234以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1235 1236| 错误码ID | 错误信息 | 1237| -------- | -------------------------------------------- | 1238| 201 | Permission denied. | 1239| 202 | Non-system applications use system APIs. | 1240| 401 | Parameter error. | 1241| 8300001 | Invalid parameter value. | 1242| 8300002 | Operation failed. Cannot connect to service. | 1243| 8300003 | System internal error. | 1244| 8300004 | Do not have sim card. | 1245| 8300999 | Unknown error code. | 1246 1247**示例:** 1248 1249```ts 1250import { BusinessError } from '@ohos.base'; 1251import sim from '@ohos.telephony.sim'; 1252 1253let name: string = "ShowName"; 1254sim.setShowName(0, name, (err: BusinessError) => { 1255 console.log(`callback: err->${JSON.stringify(err)}`); 1256}); 1257``` 1258 1259## sim.setShowName<sup>8+</sup> 1260 1261setShowName\(slotId: number, name: string\): Promise\<void\> 1262 1263设置指定卡槽SIM卡显示的名称。使用Promise异步回调。 1264 1265**系统接口:** 此接口为系统接口。 1266 1267**需要权限**:ohos.permission.SET_TELEPHONY_STATE 1268 1269**系统能力**:SystemCapability.Telephony.CoreService 1270 1271**参数:** 1272 1273| 参数名 | 类型 | 必填 | 说明 | 1274| ------ | ------ | ---- | -------------------------------------- | 1275| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 1276| name | string | 是 | SIM卡名称。 | 1277 1278**返回值:** 1279 1280| 类型 | 说明 | 1281| --------------- | ------------------------------- | 1282| Promise\<void\> | 以Promise形式异步返回设置结果。 | 1283 1284**错误码:** 1285 1286以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1287 1288| 错误码ID | 错误信息 | 1289| -------- | -------------------------------------------- | 1290| 201 | Permission denied. | 1291| 202 | Non-system applications use system APIs. | 1292| 401 | Parameter error. | 1293| 8300001 | Invalid parameter value. | 1294| 8300002 | Operation failed. Cannot connect to service. | 1295| 8300003 | System internal error. | 1296| 8300004 | Do not have sim card. | 1297| 8300999 | Unknown error code. | 1298 1299**示例:** 1300 1301```ts 1302import { BusinessError } from '@ohos.base'; 1303import sim from '@ohos.telephony.sim'; 1304 1305let name: string = "ShowName"; 1306sim.setShowName(0, name).then(() => { 1307 console.log(`setShowName success.`); 1308}).catch((err: BusinessError) => { 1309 console.error(`setShowName failed, promise: err->${JSON.stringify(err)}`); 1310}); 1311``` 1312 1313## sim.getShowName<sup>8+</sup> 1314 1315getShowName\(slotId: number, callback: AsyncCallback\<string\>\): void 1316 1317获取指定卡槽SIM卡的名称。使用callback异步回调。 1318 1319**系统接口:** 此接口为系统接口。 1320 1321**需要权限**:ohos.permission.GET_TELEPHONY_STATE 1322 1323**系统能力**:SystemCapability.Telephony.CoreService 1324 1325**参数:** 1326 1327| 参数名 | 类型 | 必填 | 说明 | 1328| -------- | --------------------------- | ---- | -------------------------------------- | 1329| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 1330| callback | AsyncCallback<string> | 是 | 回调函数。返回指定卡槽SIM卡的名称。 | 1331 1332**错误码:** 1333 1334以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1335 1336| 错误码ID | 错误信息 | 1337| -------- | -------------------------------------------- | 1338| 201 | Permission denied. | 1339| 202 | Non-system applications use system APIs. | 1340| 401 | Parameter error. | 1341| 8300001 | Invalid parameter value. | 1342| 8300002 | Operation failed. Cannot connect to service. | 1343| 8300003 | System internal error. | 1344| 8300004 | Do not have sim card. | 1345| 8300999 | Unknown error code. | 1346 1347**示例:** 1348 1349```ts 1350import { BusinessError } from '@ohos.base'; 1351import sim from '@ohos.telephony.sim'; 1352 1353sim.getShowName(0, (err: BusinessError, data: string) => { 1354 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 1355}); 1356``` 1357 1358 1359## sim.getShowName<sup>8+</sup> 1360 1361getShowName\(slotId: number\): Promise\<string\> 1362 1363获取指定卡槽SIM卡的名称。使用Promise异步回调。 1364 1365**系统接口:** 此接口为系统接口。 1366 1367**需要权限**:ohos.permission.GET_TELEPHONY_STATE 1368 1369**系统能力**:SystemCapability.Telephony.CoreService 1370 1371**参数:** 1372 1373| 参数名 | 类型 | 必填 | 说明 | 1374| ------ | ------ | ---- | -------------------------------------- | 1375| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 1376 1377**返回值:** 1378 1379| 类型 | 说明 | 1380| --------------------- | -------------------------------------- | 1381| Promise<string> | 以Promise形式返回指定卡槽SIM卡的名称。 | 1382 1383**错误码:** 1384 1385以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1386 1387| 错误码ID | 错误信息 | 1388| -------- | -------------------------------------------- | 1389| 201 | Permission denied. | 1390| 202 | Non-system applications use system APIs. | 1391| 401 | Parameter error. | 1392| 8300001 | Invalid parameter value. | 1393| 8300002 | Operation failed. Cannot connect to service. | 1394| 8300003 | System internal error. | 1395| 8300004 | Do not have sim card. | 1396| 8300999 | Unknown error code. | 1397 1398**示例:** 1399 1400```ts 1401import { BusinessError } from '@ohos.base'; 1402import sim from '@ohos.telephony.sim'; 1403 1404sim.getShowName(0).then((data: string) => { 1405 console.log(`getShowName success, promise: data->${JSON.stringify(data)}`); 1406}).catch((err: BusinessError) => { 1407 console.error(`getShowName failed, promise: err->${JSON.stringify(err)}`); 1408}); 1409``` 1410 1411## sim.setShowNumber<sup>8+</sup> 1412 1413setShowNumber\(slotId: number, number: string, callback: AsyncCallback\<void\>\): void 1414 1415设置指定卡槽SIM卡的号码。使用callback异步回调。 1416 1417**系统接口:** 此接口为系统接口。 1418 1419**需要权限**:ohos.permission.SET_TELEPHONY_STATE 1420 1421**系统能力**:SystemCapability.Telephony.CoreService 1422 1423**参数:** 1424 1425| 参数名 | 类型 | 必填 | 说明 | 1426| -------- | ------------------------- | ---- | -------------------------------------- | 1427| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 1428| number | string | 是 | SIM卡号码。 | 1429| callback | AsyncCallback<void> | 是 | 回调函数。 | 1430 1431**错误码:** 1432 1433以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1434 1435| 错误码ID | 错误信息 | 1436| -------- | -------------------------------------------- | 1437| 201 | Permission denied. | 1438| 202 | Non-system applications use system APIs. | 1439| 401 | Parameter error. | 1440| 8300001 | Invalid parameter value. | 1441| 8300002 | Operation failed. Cannot connect to service. | 1442| 8300003 | System internal error. | 1443| 8300004 | Do not have sim card. | 1444| 8300999 | Unknown error code. | 1445 1446**示例:** 1447 1448```ts 1449import { BusinessError } from '@ohos.base'; 1450import sim from '@ohos.telephony.sim'; 1451 1452let number: string = '+861xxxxxxxxxx'; 1453sim.setShowNumber(0, number, (err: BusinessError) => { 1454 console.log(`callback: err->${JSON.stringify(err)}`); 1455}); 1456``` 1457 1458 1459## sim.setShowNumber<sup>8+</sup> 1460 1461setShowNumber\(slotId: number, number: string\): Promise\<void\> 1462 1463设置指定卡槽SIM卡的号码。使用Promise异步回调。 1464 1465**系统接口:** 此接口为系统接口。 1466 1467**需要权限**:ohos.permission.SET_TELEPHONY_STATE 1468 1469**系统能力**:SystemCapability.Telephony.CoreService 1470 1471**参数:** 1472 1473| 参数名 | 类型 | 必填 | 说明 | 1474| ------ | ------ | ---- | -------------------------------------- | 1475| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 1476| number | string | 是 | SIM卡号码。 | 1477 1478**返回值:** 1479 1480| 类型 | 说明 | 1481| -------------- | ------------------------------- | 1482| Promise<void\> | 以Promise形式异步返回设置结果。 | 1483 1484**错误码:** 1485 1486以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1487 1488| 错误码ID | 错误信息 | 1489| -------- | -------------------------------------------- | 1490| 201 | Permission denied. | 1491| 202 | Non-system applications use system APIs. | 1492| 401 | Parameter error. | 1493| 8300001 | Invalid parameter value. | 1494| 8300002 | Operation failed. Cannot connect to service. | 1495| 8300003 | System internal error. | 1496| 8300004 | Do not have sim card. | 1497| 8300999 | Unknown error code. | 1498 1499**示例:** 1500 1501```ts 1502import { BusinessError } from '@ohos.base'; 1503import sim from '@ohos.telephony.sim'; 1504 1505let number: string = '+861xxxxxxxxxx'; 1506sim.setShowNumber(0, number).then(() => { 1507 console.log(`setShowNumber success.`); 1508}).catch((err: BusinessError) => { 1509 console.error(`setShowNumber failed, promise: err->${JSON.stringify(err)}`); 1510}); 1511``` 1512 1513## sim.getShowNumber<sup>8+</sup> 1514 1515getShowNumber\(slotId: number, callback: AsyncCallback\<string\>): void 1516 1517获取指定卡槽SIM卡的号码。使用callback异步回调。 1518 1519**系统接口:** 此接口为系统接口。 1520 1521**需要权限**:ohos.permission.GET_TELEPHONY_STATE 1522 1523**系统能力**:SystemCapability.Telephony.CoreService 1524 1525**参数:** 1526 1527| 参数名 | 类型 | 必填 | 说明 | 1528| -------- | --------------------------- | ---- | -------------------------------------- | 1529| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 1530| callback | AsyncCallback<string> | 是 | 回调函数。返回指定卡槽的号码。 | 1531 1532**错误码:** 1533 1534以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1535 1536| 错误码ID | 错误信息 | 1537| -------- | -------------------------------------------- | 1538| 201 | Permission denied. | 1539| 202 | Non-system applications use system APIs. | 1540| 401 | Parameter error. | 1541| 8300001 | Invalid parameter value. | 1542| 8300002 | Operation failed. Cannot connect to service. | 1543| 8300003 | System internal error. | 1544| 8300004 | Do not have sim card. | 1545| 8300999 | Unknown error code. | 1546 1547**示例:** 1548 1549```ts 1550import { BusinessError } from '@ohos.base'; 1551import sim from '@ohos.telephony.sim'; 1552 1553sim.getShowNumber(0, (err: BusinessError, data: string) => { 1554 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 1555}); 1556``` 1557 1558 1559## sim.getShowNumber<sup>8+</sup> 1560 1561getShowNumber\(slotId: number\): Promise\<string\> 1562 1563获取指定卡槽SIM卡的号码。使用Promise异步回调。 1564 1565**系统接口:** 此接口为系统接口。 1566 1567**需要权限**:ohos.permission.GET_TELEPHONY_STATE 1568 1569**系统能力**:SystemCapability.Telephony.CoreService 1570 1571**参数:** 1572 1573| 参数名 | 类型 | 必填 | 说明 | 1574| ------ | ------ | ---- | -------------------------------------- | 1575| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 1576 1577**返回值:** 1578 1579| 类型 | 说明 | 1580| --------------------- | --------------------------------- | 1581| Promise<string> | 以Promise形式返回指定卡槽的号码。 | 1582 1583**错误码:** 1584 1585以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1586 1587| 错误码ID | 错误信息 | 1588| -------- | -------------------------------------------- | 1589| 201 | Permission denied. | 1590| 202 | Non-system applications use system APIs. | 1591| 401 | Parameter error. | 1592| 8300001 | Invalid parameter value. | 1593| 8300002 | Operation failed. Cannot connect to service. | 1594| 8300003 | System internal error. | 1595| 8300004 | Do not have sim card. | 1596| 8300999 | Unknown error code. | 1597 1598**示例:** 1599 1600```ts 1601import { BusinessError } from '@ohos.base'; 1602import sim from '@ohos.telephony.sim'; 1603 1604sim.getShowNumber(0).then((data: string) => { 1605 console.log(`getShowNumber success, promise: data->${JSON.stringify(data)}`); 1606}).catch((err: BusinessError) => { 1607 console.error(`getShowNumber failed, promise: err->${JSON.stringify(err)}`); 1608}); 1609``` 1610 1611## sim.activateSim<sup>8+</sup> 1612 1613activateSim\(slotId: number, callback: AsyncCallback\<void\>\): void 1614 1615激活指定卡槽SIM卡。使用callback异步回调。 1616 1617**系统接口:** 此接口为系统接口。 1618 1619**需要权限**:ohos.permission.SET_TELEPHONY_STATE 1620 1621**系统能力**:SystemCapability.Telephony.CoreService 1622 1623**参数:** 1624 1625| 参数名 | 类型 | 必填 | 说明 | 1626| -------- | ------------------------- | ---- | -------------------------------------- | 1627| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 1628| callback | AsyncCallback<void> | 是 | 回调函数。 | 1629 1630**错误码:** 1631 1632以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1633 1634| 错误码ID | 错误信息 | 1635| -------- | -------------------------------------------- | 1636| 201 | Permission denied. | 1637| 202 | Non-system applications use system APIs. | 1638| 401 | Parameter error. | 1639| 8300001 | Invalid parameter value. | 1640| 8300002 | Operation failed. Cannot connect to service. | 1641| 8300003 | System internal error. | 1642| 8300004 | Do not have sim card. | 1643| 8300999 | Unknown error code. | 1644 1645**示例:** 1646 1647```ts 1648import { BusinessError } from '@ohos.base'; 1649import sim from '@ohos.telephony.sim'; 1650 1651sim.activateSim(0, (err: BusinessError) => { 1652 console.log(`callback: err->${JSON.stringify(err)}`); 1653}); 1654``` 1655 1656 1657## sim.activateSim<sup>8+</sup> 1658 1659activateSim\(slotId: number\): Promise\<void\> 1660 1661激活指定卡槽SIM卡。使用Promise异步回调。 1662 1663**系统接口:** 此接口为系统接口。 1664 1665**需要权限**:ohos.permission.SET_TELEPHONY_STATE 1666 1667**系统能力**:SystemCapability.Telephony.CoreService 1668 1669**参数:** 1670 1671| 参数名 | 类型 | 必填 | 说明 | 1672| ------ | ------ | ---- | -------------------------------------- | 1673| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 1674 1675**返回值:** 1676 1677| 类型 | 说明 | 1678| --------------- | ------------------------------- | 1679| Promise\<void\> | 以Promise形式异步返回设置结果。 | 1680 1681**错误码:** 1682 1683以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1684 1685| 错误码ID | 错误信息 | 1686| -------- | -------------------------------------------- | 1687| 201 | Permission denied. | 1688| 202 | Non-system applications use system APIs. | 1689| 401 | Parameter error. | 1690| 8300001 | Invalid parameter value. | 1691| 8300002 | Operation failed. Cannot connect to service. | 1692| 8300003 | System internal error. | 1693| 8300004 | Do not have sim card. | 1694| 8300999 | Unknown error code. | 1695 1696**示例:** 1697 1698```ts 1699import { BusinessError } from '@ohos.base'; 1700import sim from '@ohos.telephony.sim'; 1701 1702sim.activateSim(0).then(() => { 1703 console.log(`activateSim success.`); 1704}).catch((err: BusinessError) => { 1705 console.error(`activateSim failed, promise: err->${JSON.stringify(err)}`); 1706}); 1707``` 1708 1709## sim.deactivateSim<sup>8+</sup> 1710 1711deactivateSim\(slotId: number, callback: AsyncCallback\<void\>\): void 1712 1713禁用指定卡槽SIM卡。使用callback异步回调。 1714 1715**系统接口:** 此接口为系统接口。 1716 1717**需要权限**:ohos.permission.SET_TELEPHONY_STATE 1718 1719**系统能力**:SystemCapability.Telephony.CoreService 1720 1721**参数:** 1722 1723| 参数名 | 类型 | 必填 | 说明 | 1724| -------- | ------------------------- | ---- | -------------------------------------- | 1725| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 1726| callback | AsyncCallback<void> | 是 | 回调函数。 | 1727 1728**错误码:** 1729 1730以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1731 1732| 错误码ID | 错误信息 | 1733| -------- | -------------------------------------------- | 1734| 201 | Permission denied. | 1735| 202 | Non-system applications use system APIs. | 1736| 401 | Parameter error. | 1737| 8300001 | Invalid parameter value. | 1738| 8300002 | Operation failed. Cannot connect to service. | 1739| 8300003 | System internal error. | 1740| 8300004 | Do not have sim card. | 1741| 8300999 | Unknown error code. | 1742 1743**示例:** 1744 1745```ts 1746import { BusinessError } from '@ohos.base'; 1747import sim from '@ohos.telephony.sim'; 1748 1749sim.deactivateSim(0, (err: BusinessError) => { 1750 console.log(`callback: err->${JSON.stringify(err)}`); 1751}); 1752``` 1753 1754 1755## sim.deactivateSim<sup>8+</sup> 1756 1757deactivateSim\(slotId: number\): Promise\<void\> 1758 1759禁用指定卡槽SIM卡。使用Promise异步回调。 1760 1761**系统接口:** 此接口为系统接口。 1762 1763**需要权限**:ohos.permission.SET_TELEPHONY_STATE 1764 1765**系统能力**:SystemCapability.Telephony.CoreService 1766 1767**参数:** 1768 1769| 参数名 | 类型 | 必填 | 说明 | 1770| ------ | ------ | ---- | -------------------------------------- | 1771| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 1772 1773**返回值:** 1774 1775| 类型 | 说明 | 1776| --------------- | ------------------------------- | 1777| Promise\<void\> | 以Promise形式异步返回设置结果。 | 1778 1779**错误码:** 1780 1781以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1782 1783| 错误码ID | 错误信息 | 1784| -------- | -------------------------------------------- | 1785| 201 | Permission denied. | 1786| 202 | Non-system applications use system APIs. | 1787| 401 | Parameter error. | 1788| 8300001 | Invalid parameter value. | 1789| 8300002 | Operation failed. Cannot connect to service. | 1790| 8300003 | System internal error. | 1791| 8300004 | Do not have sim card. | 1792| 8300999 | Unknown error code. | 1793 1794**示例:** 1795 1796```ts 1797import { BusinessError } from '@ohos.base'; 1798import sim from '@ohos.telephony.sim'; 1799 1800sim.deactivateSim(0).then(() => { 1801 console.log(`deactivateSim success.`); 1802}).catch((err: BusinessError) => { 1803 console.error(`deactivateSim failed, promise: err->${JSON.stringify(err)}`); 1804}); 1805``` 1806 1807## sim.setLockState<sup>7+</sup> 1808 1809setLockState\(slotId: number, options: LockInfo, callback: AsyncCallback\<LockStatusResponse\>\): void 1810 1811设置指定卡槽SIM卡的锁状态。使用callback异步回调。 1812 1813**系统接口:** 此接口为系统接口。 1814 1815**需要权限**:ohos.permission.SET_TELEPHONY_STATE 1816 1817**系统能力**:SystemCapability.Telephony.CoreService 1818 1819**参数:** 1820 1821| 参数名 | 类型 | 必填 | 说明 | 1822| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | 1823| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 1824| callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | 是 | 回调函数。 | 1825| options | [LockInfo](#lockinfo8) | 是 | 锁信息。<br/>- lockType: [LockType](#locktype8)<br/>- password: string<br/>- state: [LockState](#lockstate8) | 1826 1827**错误码:** 1828 1829以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1830 1831| 错误码ID | 错误信息 | 1832| -------- | -------------------------------------------- | 1833| 201 | Permission denied. | 1834| 202 | Non-system applications use system APIs. | 1835| 401 | Parameter error. | 1836| 8300001 | Invalid parameter value. | 1837| 8300002 | Operation failed. Cannot connect to service. | 1838| 8300003 | System internal error. | 1839| 8300004 | Do not have sim card. | 1840| 8300999 | Unknown error code. | 1841| 8301002 | SIM card operation error. | 1842 1843**示例:** 1844 1845```ts 1846import { BusinessError } from '@ohos.base'; 1847import sim from '@ohos.telephony.sim'; 1848 1849let lockInfo: sim.LockInfo = { 1850 lockType: sim.LockType.PIN_LOCK, 1851 password: "1234", 1852 state: sim.LockState.LOCK_OFF 1853}; 1854sim.setLockState(0, lockInfo, (err: BusinessError, data: sim.LockStatusResponse) => { 1855 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 1856}); 1857``` 1858 1859 1860## sim.setLockState<sup>7+</sup> 1861 1862setLockState\(slotId: number, options: LockInfo\): Promise\<LockStatusResponse\> 1863 1864设置指定卡槽SIM卡的锁状态。使用Promise异步回调。 1865 1866**系统接口:** 此接口为系统接口。 1867 1868**需要权限**:ohos.permission.SET_TELEPHONY_STATE 1869 1870**系统能力**:SystemCapability.Telephony.CoreService 1871 1872**参数:** 1873 1874| 参数名 | 类型 | 必填 | 说明 | 1875| ------- | ---------------------- | ---- | ------------------------------------------------------------ | 1876| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 1877| options | [LockInfo](#lockinfo8) | 是 | 锁信息。<br/>- lockType: [LockType](#locktype8)<br/>- password: string<br/>- state: [LockState](#lockstate8) | 1878 1879**返回值:** 1880 1881| 类型 | 说明 | 1882| ---------------------------------------------------- | -------------------------------------------- | 1883| Promise<[LockStatusResponse](#lockstatusresponse7)\> | 以Promise形式返回获取指定卡槽SIM卡的锁状态。 | 1884 1885**错误码:** 1886 1887以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1888 1889| 错误码ID | 错误信息 | 1890| -------- | -------------------------------------------- | 1891| 201 | Permission denied. | 1892| 202 | Non-system applications use system APIs. | 1893| 401 | Parameter error. | 1894| 8300001 | Invalid parameter value. | 1895| 8300002 | Operation failed. Cannot connect to service. | 1896| 8300003 | System internal error. | 1897| 8300004 | Do not have sim card. | 1898| 8300999 | Unknown error code. | 1899| 8301002 | SIM card operation error. | 1900 1901**示例:** 1902 1903```ts 1904import { BusinessError } from '@ohos.base'; 1905import sim from '@ohos.telephony.sim'; 1906 1907let lockInfo: sim.LockInfo = { 1908 lockType: sim.LockType.PIN_LOCK, 1909 password: "1234", 1910 state: sim.LockState.LOCK_OFF 1911}; 1912sim.setLockState(0, lockInfo).then((data: sim.LockStatusResponse) => { 1913 console.log(`setLockState success, promise: data->${JSON.stringify(data)}`); 1914}).catch((err: BusinessError) => { 1915 console.error(`setLockState failed, promise: err->${JSON.stringify(err)}`); 1916}); 1917``` 1918 1919## sim.getLockState<sup>8+</sup> 1920 1921getLockState\(slotId: number, lockType: LockType, callback: AsyncCallback\<LockState\>\): void 1922 1923获取指定卡槽SIM卡的锁状态。使用callback异步回调。 1924 1925**系统接口:** 此接口为系统接口。 1926 1927**需要权限**:ohos.permission.GET_TELEPHONY_STATE 1928 1929**系统能力**:SystemCapability.Telephony.CoreService 1930 1931**参数:** 1932 1933| 参数名 | 类型 | 必填 | 说明 | 1934| -------- | ----------------------------------------- | ---- | --------------------------------------- | 1935| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 1936| callback | AsyncCallback\<[LockState](#lockstate8)\> | 是 | 回调函数。 | 1937| options | [LockType](#locktype8) | 是 | 锁类型。<br/>- 1: PIN锁<br/>- 2: PIN2锁 | 1938 1939**错误码:** 1940 1941以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1942 1943| 错误码ID | 错误信息 | 1944| -------- | -------------------------------------------- | 1945| 201 | Permission denied. | 1946| 202 | Non-system applications use system APIs. | 1947| 401 | Parameter error. | 1948| 8300001 | Invalid parameter value. | 1949| 8300002 | Operation failed. Cannot connect to service. | 1950| 8300003 | System internal error. | 1951| 8300004 | Do not have sim card. | 1952| 8300999 | Unknown error code. | 1953| 8301002 | SIM card operation error. | 1954 1955**示例:** 1956 1957```ts 1958import { BusinessError } from '@ohos.base'; 1959import sim from '@ohos.telephony.sim'; 1960 1961sim.getLockState(0, 1, (err: BusinessError, data: sim.LockState) => { 1962 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 1963}); 1964``` 1965 1966 1967## sim.getLockState<sup>8+</sup> 1968 1969getLockState\(slotId: number, lockType: LockType\): Promise\<LockState\> 1970 1971获取指定卡槽SIM卡的锁状态。使用Promise异步回调。 1972 1973**系统接口:** 此接口为系统接口。 1974 1975**需要权限**:ohos.permission.GET_TELEPHONY_STATE 1976 1977**系统能力**:SystemCapability.Telephony.CoreService 1978 1979**参数:** 1980 1981| 参数名 | 类型 | 必填 | 说明 | 1982| ------- | ---------------------- | ---- | --------------------------------------- | 1983| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 1984| options | [LockType](#locktype8) | 是 | 锁类型。<br/>- 1: PIN锁<br/>- 2: PIN2锁 | 1985 1986**返回值:** 1987 1988| 类型 | 说明 | 1989| ---------------------------------- | -------------------------------------------- | 1990| Promise<[LockState](#lockstate8)\> | 以Promise形式返回获取指定卡槽SIM卡的锁状态。 | 1991 1992**错误码:** 1993 1994以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 1995 1996| 错误码ID | 错误信息 | 1997| -------- | -------------------------------------------- | 1998| 201 | Permission denied. | 1999| 202 | Non-system applications use system APIs. | 2000| 401 | Parameter error. | 2001| 8300001 | Invalid parameter value. | 2002| 8300002 | Operation failed. Cannot connect to service. | 2003| 8300003 | System internal error. | 2004| 8300004 | Do not have sim card. | 2005| 8300999 | Unknown error code. | 2006| 8301002 | SIM card operation error. | 2007 2008**示例:** 2009 2010```ts 2011import { BusinessError } from '@ohos.base'; 2012import sim from '@ohos.telephony.sim'; 2013 2014sim.getLockState(0, 1).then((data: sim.LockState) => { 2015 console.log(`getLockState success, promise: data->${JSON.stringify(data)}`); 2016}).catch((err: BusinessError) => { 2017 console.error(`getLockState failed, promise: err->${JSON.stringify(err)}`); 2018}); 2019``` 2020 2021## sim.alterPin<sup>7+</sup> 2022 2023alterPin\(slotId: number, newPin: string, oldPin: string, callback: AsyncCallback\<LockStatusResponse\>\): void 2024 2025更改Pin密码。使用callback异步回调。 2026 2027**系统接口:** 此接口为系统接口。 2028 2029**需要权限**:ohos.permission.SET_TELEPHONY_STATE 2030 2031**系统能力**:SystemCapability.Telephony.CoreService 2032 2033**参数:** 2034 2035| 参数名 | 类型 | 必填 | 说明 | 2036| -------- | ----------------------------------------------------------- | ---- | -------------------------------------- | 2037| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2038| callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | 是 | 回调函数。 | 2039| newPin | string | 是 | 新密码。 | 2040| oldPin | string | 是 | 旧密码。 | 2041 2042**错误码:** 2043 2044以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2045 2046| 错误码ID | 错误信息 | 2047| -------- | -------------------------------------------- | 2048| 201 | Permission denied. | 2049| 202 | Non-system applications use system APIs. | 2050| 401 | Parameter error. | 2051| 8300001 | Invalid parameter value. | 2052| 8300002 | Operation failed. Cannot connect to service. | 2053| 8300003 | System internal error. | 2054| 8300004 | Do not have sim card. | 2055| 8300999 | Unknown error code. | 2056| 8301002 | SIM card operation error. | 2057 2058**示例:** 2059 2060```ts 2061import { BusinessError } from '@ohos.base'; 2062import sim from '@ohos.telephony.sim'; 2063 2064sim.alterPin(0, "1234", "0000", (err: BusinessError, data: sim.LockStatusResponse) => { 2065 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 2066}); 2067``` 2068 2069 2070## sim.alterPin<sup>7+</sup> 2071 2072alterPin\(slotId: number, newPin: string, oldPin: string\): Promise\<LockStatusResponse\> 2073 2074更改Pin密码。使用Promise异步回调。 2075 2076**系统接口:** 此接口为系统接口。 2077 2078**需要权限**:ohos.permission.SET_TELEPHONY_STATE 2079 2080**系统能力**:SystemCapability.Telephony.CoreService 2081 2082**参数:** 2083 2084| 参数名 | 类型 | 必填 | 说明 | 2085| ------ | ------ | ---- | -------------------------------------- | 2086| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2087| newPin | string | 是 | 新密码。 | 2088| oldPin | string | 是 | 旧密码。 | 2089 2090**返回值:** 2091 2092| 类型 | 说明 | 2093| ---------------------------------------------------- | --------------------------------------------- | 2094| Promise<[LockStatusResponse](#lockstatusresponse7)\> | 以Promise形式返回指定卡槽SIM卡的Pin是否成功。 | 2095 2096**错误码:** 2097 2098以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2099 2100| 错误码ID | 错误信息 | 2101| -------- | -------------------------------------------- | 2102| 201 | Permission denied. | 2103| 202 | Non-system applications use system APIs. | 2104| 401 | Parameter error. | 2105| 8300001 | Invalid parameter value. | 2106| 8300002 | Operation failed. Cannot connect to service. | 2107| 8300003 | System internal error. | 2108| 8300004 | Do not have sim card. | 2109| 8300999 | Unknown error code. | 2110| 8301002 | SIM card operation error. | 2111 2112**示例:** 2113 2114```ts 2115import { BusinessError } from '@ohos.base'; 2116import sim from '@ohos.telephony.sim'; 2117 2118sim.alterPin(0, "1234", "0000").then((data: sim.LockStatusResponse) => { 2119 console.log(`alterPin success, promise: data->${JSON.stringify(data)}`); 2120}).catch((err: BusinessError) => { 2121 console.error(`alterPin failed, promise: err->${JSON.stringify(err)}`); 2122}); 2123``` 2124 2125## sim.alterPin2<sup>8+</sup> 2126 2127alterPin2\(slotId: number, newPin2: string, oldPin2: string, callback: AsyncCallback\<LockStatusResponse\>\): void 2128 2129更改Pin2密码。使用callback异步回调。 2130 2131**系统接口:** 此接口为系统接口。 2132 2133**需要权限**:ohos.permission.SET_TELEPHONY_STATE 2134 2135**系统能力**:SystemCapability.Telephony.CoreService 2136 2137**参数:** 2138 2139| 参数名 | 类型 | 必填 | 说明 | 2140| -------- | ----------------------------------------------------------- | ---- | -------------------------------------- | 2141| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2142| callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | 是 | 回调函数。 | 2143| newPin2 | string | 是 | 新密码。 | 2144| oldPin2 | string | 是 | 旧密码。 | 2145 2146**错误码:** 2147 2148以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2149 2150| 错误码ID | 错误信息 | 2151| -------- | -------------------------------------------- | 2152| 201 | Permission denied. | 2153| 202 | Non-system applications use system APIs. | 2154| 401 | Parameter error. | 2155| 8300001 | Invalid parameter value. | 2156| 8300002 | Operation failed. Cannot connect to service. | 2157| 8300003 | System internal error. | 2158| 8300004 | Do not have sim card. | 2159| 8300999 | Unknown error code. | 2160| 8301002 | SIM card operation error. | 2161 2162**示例:** 2163 2164```ts 2165import { BusinessError } from '@ohos.base'; 2166import sim from '@ohos.telephony.sim'; 2167 2168sim.alterPin2(0, "1234", "0000", (err: BusinessError, data: sim.LockStatusResponse) => { 2169 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 2170}); 2171``` 2172 2173 2174## sim.alterPin2<sup>8+</sup> 2175 2176alterPin2\(slotId: number, newPin2: string, oldPin2: string\): Promise\<LockStatusResponse\> 2177 2178更改Pin2密码。使用Promise异步回调。 2179 2180**系统接口:** 此接口为系统接口。 2181 2182**需要权限**:ohos.permission.SET_TELEPHONY_STATE 2183 2184**系统能力**:SystemCapability.Telephony.CoreService 2185 2186**参数:** 2187 2188| 参数名 | 类型 | 必填 | 说明 | 2189| ------- | ------ | ---- | -------------------------------------- | 2190| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2191| newPin2 | string | 是 | 新密码。 | 2192| oldPin2 | string | 是 | 旧密码。 | 2193 2194**返回值:** 2195 2196| 类型 | 说明 | 2197| ---------------------------------------------------- | --------------------------------------------- | 2198| Promise<[LockStatusResponse](#lockstatusresponse7)\> | 以Promise形式返回指定卡槽SIM卡的Pin是否成功。 | 2199 2200**错误码:** 2201 2202以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2203 2204| 错误码ID | 错误信息 | 2205| -------- | -------------------------------------------- | 2206| 201 | Permission denied. | 2207| 202 | Non-system applications use system APIs. | 2208| 401 | Parameter error. | 2209| 8300001 | Invalid parameter value. | 2210| 8300002 | Operation failed. Cannot connect to service. | 2211| 8300003 | System internal error. | 2212| 8300004 | Do not have sim card. | 2213| 8300999 | Unknown error code. | 2214| 8301002 | SIM card operation error. | 2215 2216**示例:** 2217 2218```ts 2219import { BusinessError } from '@ohos.base'; 2220import sim from '@ohos.telephony.sim'; 2221 2222sim.alterPin2(0, "1234", "0000").then((data: sim.LockStatusResponse) => { 2223 console.log(`alterPin2 success, promise: data->${JSON.stringify(data)}`); 2224}).catch((err: BusinessError) => { 2225 console.error(`alterPin2 failed, promise: err->${JSON.stringify(err)}`); 2226}); 2227``` 2228 2229## sim.unlockPin<sup>7+</sup> 2230 2231unlockPin\(slotId: number, pin: string, callback: AsyncCallback\<LockStatusResponse\>\): void 2232 2233解锁指定卡槽SIM卡密码。使用callback异步回调。 2234 2235**系统接口:** 此接口为系统接口。 2236 2237**需要权限**:ohos.permission.SET_TELEPHONY_STATE 2238 2239**系统能力**:SystemCapability.Telephony.CoreService 2240 2241**参数:** 2242 2243| 参数名 | 类型 | 必填 | 说明 | 2244| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | 2245| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2246| pin | string | 是 | SIM卡的密码。 | 2247| callback | AsyncCallback<[LockStatusResponse](#lockstatusresponse7)> | 是 | 回调函数。 | 2248 2249**错误码:** 2250 2251以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2252 2253| 错误码ID | 错误信息 | 2254| -------- | -------------------------------------------- | 2255| 201 | Permission denied. | 2256| 202 | Non-system applications use system APIs. | 2257| 401 | Parameter error. | 2258| 8300001 | Invalid parameter value. | 2259| 8300002 | Operation failed. Cannot connect to service. | 2260| 8300003 | System internal error. | 2261| 8300004 | Do not have sim card. | 2262| 8300999 | Unknown error code. | 2263| 8301002 | SIM card operation error. | 2264 2265**示例:** 2266 2267```ts 2268import { BusinessError } from '@ohos.base'; 2269import sim from '@ohos.telephony.sim'; 2270 2271let pin: string = '1234'; 2272sim.unlockPin(0, pin, (err: BusinessError, data: sim.LockStatusResponse) => { 2273 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 2274}); 2275``` 2276 2277 2278## sim.unlockPin<sup>7+</sup> 2279 2280unlockPin\(slotId: number, pin: string\): Promise\<LockStatusResponse\> 2281 2282解锁指定卡槽SIM卡密码。使用Promise异步回调。 2283 2284**系统接口:** 此接口为系统接口。 2285 2286**需要权限**:ohos.permission.SET_TELEPHONY_STATE 2287 2288**系统能力**:SystemCapability.Telephony.CoreService 2289 2290**参数:** 2291 2292| 参数名 | 类型 | 必填 | 说明 | 2293| ------ | ------ | ---- | -------------------------------------- | 2294| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2295| pin | string | 是 | SIM卡的密码。 | 2296 2297**返回值:** 2298 2299| 类型 | 说明 | 2300| ---------------------------------------------------- | -------------------------------------------------- | 2301| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | 以Promise形式返回获取指定卡槽的SIM卡锁状态的响应。 | 2302 2303**错误码:** 2304 2305以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2306 2307| 错误码ID | 错误信息 | 2308| -------- | -------------------------------------------- | 2309| 201 | Permission denied. | 2310| 202 | Non-system applications use system APIs. | 2311| 401 | Parameter error. | 2312| 8300001 | Invalid parameter value. | 2313| 8300002 | Operation failed. Cannot connect to service. | 2314| 8300003 | System internal error. | 2315| 8300004 | Do not have sim card. | 2316| 8300999 | Unknown error code. | 2317| 8301002 | SIM card operation error. | 2318 2319**示例:** 2320 2321```ts 2322import { BusinessError } from '@ohos.base'; 2323import sim from '@ohos.telephony.sim'; 2324 2325let pin: string = '1234'; 2326sim.unlockPin(0, pin).then((data: sim.LockStatusResponse) => { 2327 console.log(`unlockPin success, promise: data->${JSON.stringify(data)}`); 2328}).catch((err: BusinessError) => { 2329 console.error(`unlockPin failed, promise: err->${JSON.stringify(err)}`); 2330}); 2331``` 2332 2333## sim.unlockPuk<sup>7+</sup> 2334 2335unlockPuk\(slotId: number, newPin: string, puk: string, callback: AsyncCallback\<LockStatusResponse\>\): void 2336 2337解锁指定卡槽SIM卡密码的解锁密码。使用callback异步回调。 2338 2339**系统接口:** 此接口为系统接口。 2340 2341**需要权限**:ohos.permission.SET_TELEPHONY_STATE 2342 2343**系统能力**:SystemCapability.Telephony.CoreService 2344 2345**参数:** 2346 2347| 参数名 | 类型 | 必填 | 说明 | 2348| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | 2349| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2350| newPin | string | 是 | 重置SIM卡的密码。 | 2351| puk | string | 是 | SIM卡密码的解锁密码。 | 2352| callback | AsyncCallback<[LockStatusResponse](#lockstatusresponse7)> | 是 | 回调函数。 | 2353 2354**错误码:** 2355 2356以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2357 2358| 错误码ID | 错误信息 | 2359| -------- | -------------------------------------------- | 2360| 201 | Permission denied. | 2361| 202 | Non-system applications use system APIs. | 2362| 401 | Parameter error. | 2363| 8300001 | Invalid parameter value. | 2364| 8300002 | Operation failed. Cannot connect to service. | 2365| 8300003 | System internal error. | 2366| 8300004 | Do not have sim card. | 2367| 8300999 | Unknown error code. | 2368| 8301002 | SIM card operation error. | 2369 2370**示例:** 2371 2372```ts 2373import { BusinessError } from '@ohos.base'; 2374import sim from '@ohos.telephony.sim'; 2375 2376let puk: string = '1xxxxxxx'; 2377let newPin: string = '1235'; 2378sim.unlockPuk(0, newPin, puk, (err: BusinessError, data: sim.LockStatusResponse) => { 2379 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 2380}); 2381``` 2382 2383 2384## sim.unlockPuk<sup>7+</sup> 2385 2386unlockPuk\(slotId: number, newPin: string, puk: string\): Promise\<LockStatusResponse\> 2387 2388解锁指定卡槽SIM卡密码的解锁密码。使用Promise异步回调。 2389 2390**系统接口:** 此接口为系统接口。 2391 2392**需要权限**:ohos.permission.SET_TELEPHONY_STATE 2393 2394**系统能力**:SystemCapability.Telephony.CoreService 2395 2396**参数:** 2397 2398| 参数名 | 类型 | 必填 | 说明 | 2399| ------ | ------ | ---- | -------------------------------------- | 2400| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2401| newPin | string | 是 | 重置SIM卡的密码。 | 2402| puk | string | 是 | SIM卡密码的解锁密码。 | 2403 2404**返回值:** 2405 2406| 类型 | 说明 | 2407| ---------------------------------------------------- | -------------------------------------------------- | 2408| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | 以Promise形式返回获取指定卡槽的SIM卡锁状态的响应。 | 2409 2410**错误码:** 2411 2412以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2413 2414| 错误码ID | 错误信息 | 2415| -------- | -------------------------------------------- | 2416| 201 | Permission denied. | 2417| 202 | Non-system applications use system APIs. | 2418| 401 | Parameter error. | 2419| 8300001 | Invalid parameter value. | 2420| 8300002 | Operation failed. Cannot connect to service. | 2421| 8300003 | System internal error. | 2422| 8300004 | Do not have sim card. | 2423| 8300999 | Unknown error code. | 2424| 8301002 | SIM card operation error. | 2425 2426**示例:** 2427 2428```ts 2429import { BusinessError } from '@ohos.base'; 2430import sim from '@ohos.telephony.sim'; 2431 2432let puk: string = '1xxxxxxx'; 2433let newPin: string = '1235'; 2434sim.unlockPuk(0, newPin, puk).then((data: sim.LockStatusResponse) => { 2435 console.log(`unlockPuk success, promise: data->${JSON.stringify(data)}`); 2436}).catch((err: BusinessError) => { 2437 console.error(`unlockPuk failed, promise: err->${JSON.stringify(err)}`); 2438}); 2439``` 2440 2441## sim.unlockPin2<sup>8+</sup> 2442 2443unlockPin2\(slotId: number, pin2: string, callback: AsyncCallback\<LockStatusResponse\>\): void 2444 2445解锁指定卡槽SIM卡密码。使用callback异步回调。 2446 2447**系统接口:** 此接口为系统接口。 2448 2449**需要权限**:ohos.permission.SET_TELEPHONY_STATE 2450 2451**系统能力**:SystemCapability.Telephony.CoreService 2452 2453**参数:** 2454 2455| 参数名 | 类型 | 必填 | 说明 | 2456| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | 2457| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2458| pin2 | string | 是 | SIM卡的密码。 | 2459| callback | AsyncCallback<[LockStatusResponse](#lockstatusresponse7)> | 是 | 回调函数。 | 2460 2461**错误码:** 2462 2463以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2464 2465| 错误码ID | 错误信息 | 2466| -------- | -------------------------------------------- | 2467| 201 | Permission denied. | 2468| 202 | Non-system applications use system APIs. | 2469| 401 | Parameter error. | 2470| 8300001 | Invalid parameter value. | 2471| 8300002 | Operation failed. Cannot connect to service. | 2472| 8300003 | System internal error. | 2473| 8300004 | Do not have sim card. | 2474| 8300999 | Unknown error code. | 2475| 8301002 | SIM card operation error. | 2476 2477**示例:** 2478 2479```ts 2480import { BusinessError } from '@ohos.base'; 2481import sim from '@ohos.telephony.sim'; 2482 2483let pin2: string = '1234'; 2484sim.unlockPin2(0, pin2, (err: BusinessError, data: sim.LockStatusResponse) => { 2485 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 2486}); 2487``` 2488 2489 2490## sim.unlockPin2<sup>8+</sup> 2491 2492unlockPin2\(slotId: number, pin2: string\): Promise\<LockStatusResponse\> 2493 2494解锁指定卡槽SIM卡密码。使用Promise异步回调。 2495 2496**系统接口:** 此接口为系统接口。 2497 2498**需要权限**:ohos.permission.SET_TELEPHONY_STATE 2499 2500**系统能力**:SystemCapability.Telephony.CoreService 2501 2502**参数:** 2503 2504| 参数名 | 类型 | 必填 | 说明 | 2505| ------ | ------ | ---- | -------------------------------------- | 2506| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2507| pin2 | string | 是 | SIM卡的密码。 | 2508 2509**返回值:** 2510 2511| 类型 | 说明 | 2512| ----------------------------------------------------- | -------------------------------------------------- | 2513| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | 以Promise形式返回获取指定卡槽的SIM卡锁状态的响应。 | 2514 2515**错误码:** 2516 2517以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2518 2519| 错误码ID | 错误信息 | 2520| -------- | -------------------------------------------- | 2521| 201 | Permission denied. | 2522| 202 | Non-system applications use system APIs. | 2523| 401 | Parameter error. | 2524| 8300001 | Invalid parameter value. | 2525| 8300002 | Operation failed. Cannot connect to service. | 2526| 8300003 | System internal error. | 2527| 8300004 | Do not have sim card. | 2528| 8300999 | Unknown error code. | 2529| 8301002 | SIM card operation error. | 2530 2531**示例:** 2532 2533```ts 2534import { BusinessError } from '@ohos.base'; 2535import sim from '@ohos.telephony.sim'; 2536 2537let pin2: string = '1234'; 2538sim.unlockPin2(0, pin2).then((data: sim.LockStatusResponse) => { 2539 console.log(`unlockPin2 success, promise: data->${JSON.stringify(data)}`); 2540}).catch((err: BusinessError) => { 2541 console.error(`unlockPin2 failed, promise: err->${JSON.stringify(err)}`); 2542}); 2543``` 2544 2545## sim.unlockPuk2<sup>8+</sup> 2546 2547unlockPuk2\(slotId: number, newPin2: string, puk2: string, callback: AsyncCallback\<LockStatusResponse\>\): void 2548 2549解锁指定卡槽SIM卡密码的解锁密码。使用callback异步回调。 2550 2551**系统接口:** 此接口为系统接口。 2552 2553**需要权限**:ohos.permission.SET_TELEPHONY_STATE 2554 2555**系统能力**:SystemCapability.Telephony.CoreService 2556 2557**参数:** 2558 2559| 参数名 | 类型 | 必填 | 说明 | 2560| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | 2561| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2562| newPin2 | string | 是 | 重置SIM卡的密码。 | 2563| puk2 | string | 是 | SIM卡密码的解锁密码。 | 2564| callback | AsyncCallback<[LockStatusResponse](#lockstatusresponse7)> | 是 | 回调函数。 | 2565 2566**错误码:** 2567 2568以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2569 2570| 错误码ID | 错误信息 | 2571| -------- | -------------------------------------------- | 2572| 201 | Permission denied. | 2573| 202 | Non-system applications use system APIs. | 2574| 401 | Parameter error. | 2575| 8300001 | Invalid parameter value. | 2576| 8300002 | Operation failed. Cannot connect to service. | 2577| 8300003 | System internal error. | 2578| 8300004 | Do not have sim card. | 2579| 8300999 | Unknown error code. | 2580| 8301002 | SIM card operation error. | 2581 2582**示例:** 2583 2584```ts 2585import { BusinessError } from '@ohos.base'; 2586import sim from '@ohos.telephony.sim'; 2587 2588let puk2: string = '1xxxxxxx'; 2589let newPin2: string = '1235'; 2590sim.unlockPuk2(0, newPin2, puk2, (err: BusinessError, data: sim.LockStatusResponse) => { 2591 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 2592}); 2593``` 2594 2595 2596## sim.unlockPuk2<sup>8+</sup> 2597 2598unlockPuk2\(slotId: number, newPin2: string, puk2: string\): Promise\<LockStatusResponse\> 2599 2600解锁指定卡槽SIM卡密码的解锁密码。使用Promise异步回调。 2601 2602**系统接口:** 此接口为系统接口。 2603 2604**需要权限**:ohos.permission.SET_TELEPHONY_STATE 2605 2606**系统能力**:SystemCapability.Telephony.CoreService 2607 2608**参数:** 2609 2610| 参数名 | 类型 | 必填 | 说明 | 2611| ------- | ------ | ---- | -------------------------------------- | 2612| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2613| newPin2 | string | 是 | 重置SIM卡的密码。 | 2614| puk2 | string | 是 | SIM卡密码的解锁密码。 | 2615 2616**返回值:** 2617 2618| 类型 | 说明 | 2619| ---------------------------------------------------- | -------------------------------------------------- | 2620| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | 以Promise形式返回获取指定卡槽的SIM卡锁状态的响应。 | 2621 2622**错误码:** 2623 2624以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2625 2626| 错误码ID | 错误信息 | 2627| -------- | -------------------------------------------- | 2628| 201 | Permission denied. | 2629| 202 | Non-system applications use system APIs. | 2630| 401 | Parameter error. | 2631| 8300001 | Invalid parameter value. | 2632| 8300002 | Operation failed. Cannot connect to service. | 2633| 8300003 | System internal error. | 2634| 8300004 | Do not have sim card. | 2635| 8300999 | Unknown error code. | 2636| 8301002 | SIM card operation error. | 2637 2638**示例:** 2639 2640```ts 2641import { BusinessError } from '@ohos.base'; 2642import sim from '@ohos.telephony.sim'; 2643 2644let puk2: string = '1xxxxxxx'; 2645let newPin2: string = '1235'; 2646sim.unlockPuk2(0, newPin2, puk2).then((data: sim.LockStatusResponse) => { 2647 console.log(`unlockPuk2 success, promise: data->${JSON.stringify(data)}`); 2648}).catch((err: BusinessError) => { 2649 console.error(`unlockPuk2 failed, promise: err->${JSON.stringify(err)}`); 2650}); 2651``` 2652 2653## sim.getMaxSimCount<sup>7+</sup> 2654 2655getMaxSimCount\(\): number 2656 2657获取卡槽数量。 2658 2659**系统能力**:SystemCapability.Telephony.CoreService 2660 2661**返回值:** 2662 2663| 类型 | 说明 | 2664| ----------------- | ------------------------------------------------------------ | 2665| number | 卡槽数量。 | 2666 2667**示例:** 2668 2669```ts 2670import sim from '@ohos.telephony.sim'; 2671 2672console.log("Result: "+ sim.getMaxSimCount()); 2673``` 2674 2675## sim.getSimIccId<sup>7+</sup> 2676 2677getSimIccId\(slotId: number, callback: AsyncCallback\<string\>\): void 2678 2679获取指定卡槽SIM卡的ICCID。使用callback异步回调。 2680 2681**系统接口:** 此接口为系统接口。 2682 2683**需要权限**:ohos.permission.GET_TELEPHONY_STATE 2684 2685**系统能力**:SystemCapability.Telephony.CoreService 2686 2687**参数:** 2688 2689| 参数名 | 类型 | 必填 | 说明 | 2690| -------- | ---------------------- | ---- | -------------------------------------- | 2691| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2692| callback | AsyncCallback<string\> | 是 | 回调函数。 | 2693 2694**错误码:** 2695 2696以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2697 2698| 错误码ID | 错误信息 | 2699| -------- | -------------------------------------------- | 2700| 201 | Permission denied. | 2701| 202 | Non-system applications use system APIs. | 2702| 401 | Parameter error. | 2703| 8300001 | Invalid parameter value. | 2704| 8300002 | Operation failed. Cannot connect to service. | 2705| 8300003 | System internal error. | 2706| 8300004 | Do not have sim card. | 2707| 8300999 | Unknown error code. | 2708 2709**示例:** 2710 2711```ts 2712import { BusinessError } from '@ohos.base'; 2713import sim from '@ohos.telephony.sim'; 2714 2715sim.getSimIccId(0, (err: BusinessError, data: string) => { 2716 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 2717}); 2718``` 2719 2720 2721## sim.getSimIccId<sup>7+</sup> 2722 2723getSimIccId\(slotId: number\): Promise\<string\> 2724 2725获取指定卡槽SIM卡的ICCID。使用Promise异步回调。 2726 2727**系统接口:** 此接口为系统接口。 2728 2729**需要权限**:ohos.permission.GET_TELEPHONY_STATE 2730 2731**系统能力**:SystemCapability.Telephony.CoreService 2732 2733**参数:** 2734 2735| 参数名 | 类型 | 必填 | 说明 | 2736| ------ | ------ | ---- | -------------------------------------- | 2737| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2738 2739**返回值:** 2740 2741| 类型 | 说明 | 2742| ---------------- | ------------------------------------------- | 2743| Promise<string\> | 以Promise形式返回获取指定卡槽SIM卡的ICCID。 | 2744 2745**错误码:** 2746 2747以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2748 2749| 错误码ID | 错误信息 | 2750| -------- | -------------------------------------------- | 2751| 201 | Permission denied. | 2752| 202 | Non-system applications use system APIs. | 2753| 401 | Parameter error. | 2754| 8300001 | Invalid parameter value. | 2755| 8300002 | Operation failed. Cannot connect to service. | 2756| 8300003 | System internal error. | 2757| 8300004 | Do not have sim card. | 2758| 8300999 | Unknown error code. | 2759 2760**示例:** 2761 2762```ts 2763import { BusinessError } from '@ohos.base'; 2764import sim from '@ohos.telephony.sim'; 2765 2766sim.getSimIccId(0).then((data:string) => { 2767 console.log(`getSimIccId success, promise: data->${JSON.stringify(data)}`); 2768}).catch((err: BusinessError) => { 2769 console.error(`getSimIccId failed, promise: err->${JSON.stringify(err)}`); 2770}); 2771``` 2772 2773## sim.getVoiceMailIdentifier<sup>8+</sup> 2774 2775getVoiceMailIdentifier\(slotId: number, callback: AsyncCallback\<string\>\): void 2776 2777获取指定卡槽中SIM卡语音信箱的alpha标识符。使用callback异步回调。 2778 2779**系统接口:** 此接口为系统接口。 2780 2781**需要权限**:ohos.permission.GET_TELEPHONY_STATE 2782 2783**系统能力**:SystemCapability.Telephony.CoreService 2784 2785**参数:** 2786 2787| 参数名 | 类型 | 必填 | 说明 | 2788| -------- | ---------------------- | ---- | -------------------------------------- | 2789| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2790| callback | AsyncCallback<string\> | 是 | 回调函数。 | 2791 2792**错误码:** 2793 2794以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2795 2796| 错误码ID | 错误信息 | 2797| -------- | -------------------------------------------- | 2798| 201 | Permission denied. | 2799| 202 | Non-system applications use system APIs. | 2800| 401 | Parameter error. | 2801| 8300001 | Invalid parameter value. | 2802| 8300002 | Operation failed. Cannot connect to service. | 2803| 8300003 | System internal error. | 2804| 8300004 | Do not have sim card. | 2805| 8300999 | Unknown error code. | 2806 2807**示例:** 2808 2809```ts 2810import { BusinessError } from '@ohos.base'; 2811import sim from '@ohos.telephony.sim'; 2812 2813sim.getVoiceMailIdentifier(0, (err: BusinessError, data: string) => { 2814 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 2815}); 2816``` 2817 2818 2819## sim.getVoiceMailIdentifier<sup>8+</sup> 2820 2821getVoiceMailIdentifier\(slotId: number\): Promise\<string\> 2822 2823获取指定卡槽中SIM卡语音信箱的alpha标识符。使用Promise异步回调。 2824 2825**系统接口:** 此接口为系统接口。 2826 2827**需要权限**:ohos.permission.GET_TELEPHONY_STATE 2828 2829**系统能力**:SystemCapability.Telephony.CoreService 2830 2831**参数:** 2832 2833| 参数名 | 类型 | 必填 | 说明 | 2834| ------ | ------ | ---- | -------------------------------------- | 2835| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2836 2837**返回值:** 2838 2839| 类型 | 说明 | 2840| ---------------- | ------------------------------------------------- | 2841| Promise<string\> | 以Promise形式返回获取指定卡槽SIM卡的alpha标识符。 | 2842 2843**错误码:** 2844 2845以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2846 2847| 错误码ID | 错误信息 | 2848| -------- | -------------------------------------------- | 2849| 201 | Permission denied. | 2850| 202 | Non-system applications use system APIs. | 2851| 401 | Parameter error. | 2852| 8300001 | Invalid parameter value. | 2853| 8300002 | Operation failed. Cannot connect to service. | 2854| 8300003 | System internal error. | 2855| 8300004 | Do not have sim card. | 2856| 8300999 | Unknown error code. | 2857 2858**示例:** 2859 2860```ts 2861import { BusinessError } from '@ohos.base'; 2862import sim from '@ohos.telephony.sim'; 2863 2864sim.getVoiceMailIdentifier(0).then((data: string) => { 2865 console.log(`getVoiceMailIdentifier success, promise: data->${JSON.stringify(data)}`); 2866}).catch((err: BusinessError) => { 2867 console.error(`getVoiceMailIdentifier failed, promise: err->${JSON.stringify(err)}`); 2868}); 2869``` 2870 2871## sim.getVoiceMailNumber<sup>8+</sup> 2872 2873getVoiceMailNumber\(slotId: number, callback: AsyncCallback\<string\>): void 2874 2875获取指定卡槽中SIM卡的语音信箱号。使用callback异步回调。 2876 2877**系统接口:** 此接口为系统接口。 2878 2879**需要权限**:ohos.permission.GET_TELEPHONY_STATE 2880 2881**系统能力**:SystemCapability.Telephony.CoreService 2882 2883**参数:** 2884 2885| 参数名 | 类型 | 必填 | 说明 | 2886| -------- | ---------------------- | ---- | -------------------------------------- | 2887| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2888| callback | AsyncCallback<string\> | 是 | 回调函数。 | 2889 2890**错误码:** 2891 2892以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2893 2894| 错误码ID | 错误信息 | 2895| -------- | -------------------------------------------- | 2896| 201 | Permission denied. | 2897| 202 | Non-system applications use system APIs. | 2898| 401 | Parameter error. | 2899| 8300001 | Invalid parameter value. | 2900| 8300002 | Operation failed. Cannot connect to service. | 2901| 8300003 | System internal error. | 2902| 8300004 | Do not have sim card. | 2903| 8300999 | Unknown error code. | 2904 2905**示例:** 2906 2907```ts 2908import { BusinessError } from '@ohos.base'; 2909import sim from '@ohos.telephony.sim'; 2910 2911sim.getVoiceMailNumber(0, (err: BusinessError, data: string) => { 2912 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 2913}); 2914``` 2915 2916 2917## sim.getVoiceMailNumber<sup>8+</sup> 2918 2919getVoiceMailNumber\(slotId: number\): Promise\<string\> 2920 2921获取指定卡槽中SIM卡的语音信箱号。使用Promise异步回调。 2922 2923**系统接口:** 此接口为系统接口。 2924 2925**需要权限**:ohos.permission.GET_TELEPHONY_STATE 2926 2927**系统能力**:SystemCapability.Telephony.CoreService 2928 2929**参数:** 2930 2931| 参数名 | 类型 | 必填 | 说明 | 2932| ------ | ------ | ---- | -------------------------------------- | 2933| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2934 2935**返回值:** 2936 2937| 类型 | 说明 | 2938| ---------------- | ------------------------------------------------ | 2939| Promise<string\> | 以Promise形式返回获取指定卡槽SIM卡的语音信箱号。 | 2940 2941**错误码:** 2942 2943以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2944 2945| 错误码ID | 错误信息 | 2946| -------- | -------------------------------------------- | 2947| 201 | Permission denied. | 2948| 202 | Non-system applications use system APIs. | 2949| 401 | Parameter error. | 2950| 8300001 | Invalid parameter value. | 2951| 8300002 | Operation failed. Cannot connect to service. | 2952| 8300003 | System internal error. | 2953| 8300004 | Do not have sim card. | 2954| 8300999 | Unknown error code. | 2955 2956**示例:** 2957 2958```ts 2959import { BusinessError } from '@ohos.base'; 2960import sim from '@ohos.telephony.sim'; 2961 2962sim.getVoiceMailNumber(0).then((data: string) => { 2963 console.log(`getVoiceMailNumber success, promise: data->${JSON.stringify(data)}`); 2964}).catch((err: BusinessError) => { 2965 console.error(`getVoiceMailNumber failed, promise: err->${JSON.stringify(err)}`); 2966}); 2967``` 2968 2969 2970## sim.setVoiceMailInfo<sup>8+</sup> 2971 2972setVoiceMailInfo\(slotId: number, mailName: string, mailNumber: string, callback: AsyncCallback\<void\>\): void 2973 2974设置语音邮件信息。使用callback异步回调。 2975 2976**系统接口:** 此接口为系统接口。 2977 2978**需要权限**:ohos.permission.SET_TELEPHONY_STATE 2979 2980**系统能力**:SystemCapability.Telephony.CoreService 2981 2982**参数:** 2983 2984| 参数名 | 类型 | 必填 | 说明 | 2985| ---------- | -------------------- | ---- | -------------------------------------- | 2986| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 2987| mailName | string | 是 | 邮件名字 | 2988| mailNumber | string | 是 | 邮件号码 | 2989| callback | AsyncCallback<void\> | 是 | 回调函数。 | 2990 2991**错误码:** 2992 2993以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 2994 2995| 错误码ID | 错误信息 | 2996| -------- | -------------------------------------------- | 2997| 201 | Permission denied. | 2998| 202 | Non-system applications use system APIs. | 2999| 401 | Parameter error. | 3000| 8300001 | Invalid parameter value. | 3001| 8300002 | Operation failed. Cannot connect to service. | 3002| 8300003 | System internal error. | 3003| 8300004 | Do not have sim card. | 3004| 8300999 | Unknown error code. | 3005| 8301002 | SIM card operation error. | 3006 3007**示例:** 3008 3009```ts 3010import { BusinessError } from '@ohos.base'; 3011import sim from '@ohos.telephony.sim'; 3012 3013sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com", (err: BusinessError) => { 3014 console.log(`callback: err->${JSON.stringify(err)}`); 3015}); 3016``` 3017 3018 3019## sim.setVoiceMailInfo<sup>8+</sup> 3020 3021setVoiceMailInfo\(slotId: number, mailName: string, mailNumber: string\): Promise\<void\> 3022 3023设置语音邮件信息。使用Promise异步回调。 3024 3025**系统接口:** 此接口为系统接口。 3026 3027**需要权限**:ohos.permission.SET_TELEPHONY_STATE 3028 3029**系统能力**:SystemCapability.Telephony.CoreService 3030 3031**参数:** 3032 3033| 参数名 | 类型 | 必填 | 说明 | 3034| ---------- | ------ | ---- | -------------------------------------- | 3035| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3036| mailName | string | 是 | 邮件名字。 | 3037| mailNumber | string | 是 | 邮件号码。 | 3038 3039**返回值:** 3040 3041| 类型 | 说明 | 3042| -------------- | ----------------------- | 3043| Promise<void\> | 以Promise形式返回结果。 | 3044 3045**错误码:** 3046 3047以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3048 3049| 错误码ID | 错误信息 | 3050| -------- | -------------------------------------------- | 3051| 201 | Permission denied. | 3052| 202 | Non-system applications use system APIs. | 3053| 401 | Parameter error. | 3054| 8300001 | Invalid parameter value. | 3055| 8300002 | Operation failed. Cannot connect to service. | 3056| 8300003 | System internal error. | 3057| 8300004 | Do not have sim card. | 3058| 8300999 | Unknown error code. | 3059| 8301002 | SIM card operation error. | 3060 3061**示例:** 3062 3063```ts 3064import { BusinessError } from '@ohos.base'; 3065import sim from '@ohos.telephony.sim'; 3066 3067sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com").then(() => { 3068 console.log(`setVoiceMailInfo success.`); 3069}).catch((err: BusinessError) => { 3070 console.error(`setVoiceMailInfo failed, promise: err->${JSON.stringify(err)}`); 3071}); 3072``` 3073 3074## sim.getSimTelephoneNumber<sup>8+</sup> 3075 3076getSimTelephoneNumber\(slotId: number, callback: AsyncCallback\<string\>\): void 3077 3078获取指定卡槽中SIM卡的MSISDN。使用callback异步回调。 3079 3080**系统接口:** 此接口为系统接口。 3081 3082**需要权限**:ohos.permission.GET_PHONE_NUMBERS 3083 3084**系统能力**:SystemCapability.Telephony.CoreService 3085 3086**参数:** 3087 3088| 参数名 | 类型 | 必填 | 说明 | 3089| -------- | ---------------------- | ---- | -------------------------------------- | 3090| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3091| callback | AsyncCallback<string\> | 是 | 回调函数。 | 3092 3093**错误码:** 3094 3095以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3096 3097| 错误码ID | 错误信息 | 3098| -------- | -------------------------------------------- | 3099| 201 | Permission denied. | 3100| 202 | Non-system applications use system APIs. | 3101| 401 | Parameter error. | 3102| 8300001 | Invalid parameter value. | 3103| 8300002 | Operation failed. Cannot connect to service. | 3104| 8300003 | System internal error. | 3105| 8300004 | Do not have sim card. | 3106| 8300999 | Unknown error code. | 3107 3108**示例:** 3109 3110```ts 3111import { BusinessError } from '@ohos.base'; 3112import sim from '@ohos.telephony.sim'; 3113 3114sim.getSimTelephoneNumber(0, (err: BusinessError, data: string) => { 3115 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 3116}); 3117``` 3118 3119 3120## sim.getSimTelephoneNumber<sup>8+</sup> 3121 3122getSimTelephoneNumber\(slotId: number\): Promise\<string\> 3123 3124获取指定卡槽中SIM卡的MSISDN。使用Promise异步回调。 3125 3126**系统接口:** 此接口为系统接口。 3127 3128**需要权限**:ohos.permission.GET_PHONE_NUMBERS 3129 3130**系统能力**:SystemCapability.Telephony.CoreService 3131 3132**参数:** 3133 3134| 参数名 | 类型 | 必填 | 说明 | 3135| ------ | ------ | ---- | -------------------------------------- | 3136| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3137 3138**返回值:** 3139 3140| 类型 | 说明 | 3141| ---------------- | -------------------------------------------- | 3142| Promise<string\> | 以Promise形式返回获取指定卡槽SIM卡的MSISDN。 | 3143 3144**错误码:** 3145 3146以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3147 3148| 错误码ID | 错误信息 | 3149| -------- | -------------------------------------------- | 3150| 201 | Permission denied. | 3151| 202 | Non-system applications use system APIs. | 3152| 401 | Parameter error. | 3153| 8300001 | Invalid parameter value. | 3154| 8300002 | Operation failed. Cannot connect to service. | 3155| 8300003 | System internal error. | 3156| 8300004 | Do not have sim card. | 3157| 8300999 | Unknown error code. | 3158 3159**示例:** 3160 3161```ts 3162import { BusinessError } from '@ohos.base'; 3163import sim from '@ohos.telephony.sim'; 3164 3165sim.getSimTelephoneNumber(0).then((data: string) => { 3166 console.log(`getSimTelephoneNumber success, promise: data->${JSON.stringify(data)}`); 3167}).catch((err: BusinessError) => { 3168 console.error(`getSimTelephoneNumber failed, promise: err->${JSON.stringify(err)}`); 3169}); 3170``` 3171 3172## sim.getSimGid1<sup>7+</sup> 3173 3174getSimGid1\(slotId: number, callback: AsyncCallback\<string\>\): void 3175 3176获取指定卡槽中SIM卡的组标识符级别1(GID1)。使用callback异步回调。 3177 3178**系统接口:** 此接口为系统接口。 3179 3180**需要权限**:ohos.permission.GET_TELEPHONY_STATE 3181 3182**系统能力**:SystemCapability.Telephony.CoreService 3183 3184**参数:** 3185 3186| 参数名 | 类型 | 必填 | 说明 | 3187| -------- | ----------------------- | ---- | -------------------------------------- | 3188| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3189| callback | AsyncCallback\<string\> | 是 | 回调函数。 | 3190 3191**错误码:** 3192 3193以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3194 3195| 错误码ID | 错误信息 | 3196| -------- | -------------------------------------------- | 3197| 201 | Permission denied. | 3198| 202 | Non-system applications use system APIs. | 3199| 401 | Parameter error. | 3200| 8300001 | Invalid parameter value. | 3201| 8300002 | Operation failed. Cannot connect to service. | 3202| 8300003 | System internal error. | 3203| 8300004 | Do not have sim card. | 3204| 8300999 | Unknown error code. | 3205 3206**示例:** 3207 3208```ts 3209import { BusinessError } from '@ohos.base'; 3210import sim from '@ohos.telephony.sim'; 3211 3212sim.getSimGid1(0, (err: BusinessError, data: string) => { 3213 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 3214}); 3215``` 3216 3217 3218## sim.getSimGid1<sup>7+</sup> 3219 3220getSimGid1\(slotId: number\): Promise\<string\> 3221 3222获取指定卡槽中SIM卡的组标识符级别1(GID1)。使用Promise异步回调。 3223 3224**系统接口:** 此接口为系统接口。 3225 3226**需要权限**:ohos.permission.GET_TELEPHONY_STATE 3227 3228**系统能力**:SystemCapability.Telephony.CoreService 3229 3230**参数:** 3231 3232| 参数名 | 类型 | 必填 | 说明 | 3233| ------ | ------ | ---- | -------------------------------------- | 3234| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3235 3236**返回值:** 3237 3238| 类型 | 说明 | 3239| ---------------- | ------------------------------------------------- | 3240| Promise<string\> | 以Promise形式返回获取指定卡槽SIM卡的标识符级别1。 | 3241 3242**错误码:** 3243 3244以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3245 3246| 错误码ID | 错误信息 | 3247| -------- | -------------------------------------------- | 3248| 201 | Permission denied. | 3249| 202 | Non-system applications use system APIs. | 3250| 401 | Parameter error. | 3251| 8300001 | Invalid parameter value. | 3252| 8300002 | Operation failed. Cannot connect to service. | 3253| 8300003 | System internal error. | 3254| 8300004 | Do not have sim card. | 3255| 8300999 | Unknown error code. | 3256 3257**示例:** 3258 3259```ts 3260import { BusinessError } from '@ohos.base'; 3261import sim from '@ohos.telephony.sim'; 3262 3263sim.getSimGid1(0).then((data: string) => { 3264 console.log(`getSimGid1 success, promise: data->${JSON.stringify(data)}`); 3265}).catch((err: BusinessError) => { 3266 console.error(`getSimGid1 failed, promise: err->${JSON.stringify(err)}`); 3267}); 3268``` 3269 3270## sim.getIMSI 3271 3272getIMSI\(slotId: number, callback: AsyncCallback\<string\>\): void 3273 3274获取国际移动用户识别码。使用callback异步回调。 3275 3276**系统接口:** 此接口为系统接口。 3277 3278**需要权限**:ohos.permission.GET_TELEPHONY_STATE 3279 3280**系统能力**:SystemCapability.Telephony.CoreService 3281 3282**参数:** 3283 3284| 参数名 | 类型 | 必填 | 说明 | 3285| -------- | ----------------------- | ---- | -------------------------------------- | 3286| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3287| callback | AsyncCallback\<string\> | 是 | 回调函数。 | 3288 3289**错误码:** 3290 3291以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3292 3293| 错误码ID | 错误信息 | 3294| -------- | -------------------------------------------- | 3295| 201 | Permission denied. | 3296| 202 | Non-system applications use system APIs. | 3297| 401 | Parameter error. | 3298| 8300001 | Invalid parameter value. | 3299| 8300002 | Operation failed. Cannot connect to service. | 3300| 8300003 | System internal error. | 3301| 8300004 | Do not have sim card. | 3302| 8300999 | Unknown error code. | 3303 3304**示例:** 3305 3306```ts 3307import { BusinessError } from '@ohos.base'; 3308import sim from '@ohos.telephony.sim'; 3309 3310sim.getIMSI(0, (err: BusinessError, data: string) => { 3311 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 3312}); 3313``` 3314 3315 3316## sim.getIMSI 3317 3318getIMSI\(slotId: number\): Promise\<string\> 3319 3320获取国际移动用户识别码。使用Promise异步回调。 3321 3322**系统接口:** 此接口为系统接口。 3323 3324**需要权限**:ohos.permission.GET_TELEPHONY_STATE 3325 3326**系统能力**:SystemCapability.Telephony.CoreService 3327 3328**参数:** 3329 3330| 参数名 | 类型 | 必填 | 说明 | 3331| ------ | ------ | ---- | -------------------------------------- | 3332| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3333 3334**返回值:** 3335 3336| 类型 | 说明 | 3337| ---------------- | ------------------------------------------- | 3338| Promise<string\> | 以Promise形式返回获取的国际移动用户识别码。 | 3339 3340**错误码:** 3341 3342以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3343 3344| 错误码ID | 错误信息 | 3345| -------- | -------------------------------------------- | 3346| 201 | Permission denied. | 3347| 202 | Non-system applications use system APIs. | 3348| 401 | Parameter error. | 3349| 8300001 | Invalid parameter value. | 3350| 8300002 | Operation failed. Cannot connect to service. | 3351| 8300003 | System internal error. | 3352| 8300004 | Do not have sim card. | 3353| 8300999 | Unknown error code. | 3354 3355**示例:** 3356 3357```ts 3358import { BusinessError } from '@ohos.base'; 3359import sim from '@ohos.telephony.sim'; 3360 3361sim.getIMSI(0).then((data: string) => { 3362 console.log(`getIMSI success, promise: data->${JSON.stringify(data)}`); 3363}).catch((err: BusinessError) => { 3364 console.error(`getIMSI failed, promise: err->${JSON.stringify(err)}`); 3365}); 3366``` 3367 3368## sim.getOperatorConfigs<sup>8+</sup> 3369 3370getOperatorConfigs\(slotId: number, callback: AsyncCallback\<Array\<OperatorConfig\>\>\): void 3371 3372获取运营商配置。使用callback异步回调。 3373 3374**系统接口:** 此接口为系统接口。 3375 3376**需要权限**:ohos.permission.GET_TELEPHONY_STATE 3377 3378**系统能力**:SystemCapability.Telephony.CoreService 3379 3380**参数:** 3381 3382| 参数名 | 类型 | 必填 | 说明 | 3383| -------- | --------------------------------------------------------- | ---- | -------------------------------------- | 3384| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3385| callback | AsyncCallback<Array<[OperatorConfig](#operatorconfig8)\>> | 是 | 回调函数。 | 3386 3387**错误码:** 3388 3389以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3390 3391| 错误码ID | 错误信息 | 3392| -------- | -------------------------------------------- | 3393| 201 | Permission denied. | 3394| 202 | Non-system applications use system APIs. | 3395| 401 | Parameter error. | 3396| 8300001 | Invalid parameter value. | 3397| 8300002 | Operation failed. Cannot connect to service. | 3398| 8300003 | System internal error. | 3399| 8300999 | Unknown error code. | 3400 3401**示例:** 3402 3403```ts 3404import { BusinessError } from '@ohos.base'; 3405import sim from '@ohos.telephony.sim'; 3406 3407sim.getOperatorConfigs(0, (err: BusinessError, data: Array<sim.OperatorConfig>) => { 3408 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 3409}); 3410``` 3411 3412 3413## sim.getOperatorConfigs<sup>8+</sup> 3414 3415getOperatorConfigs\(slotId: number\): Promise\<Array\<OperatorConfig\>\> 3416 3417获取运营商配置。使用Promise异步回调。 3418 3419**系统接口:** 此接口为系统接口。 3420 3421**需要权限**:ohos.permission.GET_TELEPHONY_STATE 3422 3423**系统能力**:SystemCapability.Telephony.CoreService 3424 3425**参数:** 3426 3427| 参数名 | 类型 | 必填 | 说明 | 3428| ------ | ------ | ---- | -------------------------------------- | 3429| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3430 3431**返回值:** 3432 3433| 类型 | 说明 | 3434| --------------------------------------------------- | ----------------------------- | 3435| Promise<Array<[OperatorConfig](#operatorconfig8)\>> | 以Promise形式返回运营商配置。 | 3436 3437**错误码:** 3438 3439以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3440 3441| 错误码ID | 错误信息 | 3442| -------- | -------------------------------------------- | 3443| 201 | Permission denied. | 3444| 202 | Non-system applications use system APIs. | 3445| 401 | Parameter error. | 3446| 8300001 | Invalid parameter value. | 3447| 8300002 | Operation failed. Cannot connect to service. | 3448| 8300003 | System internal error. | 3449| 8300999 | Unknown error code. | 3450 3451**示例:** 3452 3453```ts 3454import { BusinessError } from '@ohos.base'; 3455import sim from '@ohos.telephony.sim'; 3456 3457sim.getOperatorConfigs(0).then((data: Array<sim.OperatorConfig>) => { 3458 console.log(`getOperatorConfigs success, promise: data->${JSON.stringify(data)}`); 3459}).catch((err: BusinessError) => { 3460 console.error(`getOperatorConfigs failed, promise: err->${JSON.stringify(err)}`); 3461}); 3462``` 3463 3464## sim.queryIccDiallingNumbers<sup>8+</sup> 3465 3466queryIccDiallingNumbers\(slotId: number, type: ContactType, callback: AsyncCallback\<Array\<DiallingNumbersInfo\>\>\): void 3467 3468查询SIM卡联系人号码。使用callback异步回调。 3469 3470>**说明:** 3471> 3472>SIM卡联系人存在缓存机制,对联系人进行增删改操作时会维护一套由卡槽slotId和联系人类型type对应的SIM卡联系人缓存,所以需要先调用sim.queryIccDiallingNumbers接口传入所需的slotId和type查询SIM卡联系人,生成缓存数据,在没有缓存的情况下直接调用sim.addIccDiallingNumbers、sim.delIccDiallingNumbers、sim.updateIccDiallingNumbers等接口会失败。 3473> 3474 3475**系统接口:** 此接口为系统接口。 3476 3477**需要权限**:ohos.permission.READ_CONTACTS 3478 3479**系统能力**:SystemCapability.Telephony.CoreService 3480 3481**参数:** 3482 3483| 参数名 | 类型 | 必填 | 说明 | 3484| -------- | ------------------------------------------------------------ | ---- | ---------------------------------------------------------- | 3485| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3486| type | [ContactType](#contacttype8) | 是 | 联系人类型。<br/>- 1 : GENERAL_CONTACT<br/>- 2 : FIXED_DIALING | 3487| callback | AsyncCallback<Array<[DiallingNumbersInfo](#diallingnumbersinfo8)\>> | 是 | 回调函数。 | 3488 3489**错误码:** 3490 3491以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3492 3493| 错误码ID | 错误信息 | 3494| -------- | -------------------------------------------- | 3495| 201 | Permission denied. | 3496| 202 | Non-system applications use system APIs. | 3497| 401 | Parameter error. | 3498| 8300001 | Invalid parameter value. | 3499| 8300002 | Operation failed. Cannot connect to service. | 3500| 8300003 | System internal error. | 3501| 8300004 | Do not have sim card. | 3502| 8300999 | Unknown error code. | 3503| 8301002 | SIM card operation error. | 3504 3505**示例:** 3506 3507```ts 3508import { BusinessError } from '@ohos.base'; 3509import sim from '@ohos.telephony.sim'; 3510 3511sim.queryIccDiallingNumbers(0, 1, (err: BusinessError, data: Array<sim.DiallingNumbersInfo>) => { 3512 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 3513}); 3514``` 3515 3516 3517## sim.queryIccDiallingNumbers<sup>8+</sup> 3518 3519queryIccDiallingNumbers\(slotId: number, type: ContactType\): Promise\<Array\<DiallingNumbersInfo\>\> 3520 3521查询SIM卡联系人号码。使用Promise异步回调。 3522 3523>**说明:** 3524> 3525>SIM卡联系人存在缓存机制,对联系人进行增删改操作时会维护一套由卡槽slotId和联系人类型type对应的SIM卡联系人缓存,所以需要先调用sim.queryIccDiallingNumbers接口传入所需的slotId和type查询SIM卡联系人,生成缓存数据,在没有缓存的情况下直接调用sim.addIccDiallingNumbers、sim.delIccDiallingNumbers、sim.updateIccDiallingNumbers等接口会失败。 3526> 3527 3528**系统接口:** 此接口为系统接口。 3529 3530**需要权限**:ohos.permission.READ_CONTACTS 3531 3532**系统能力**:SystemCapability.Telephony.CoreService 3533 3534**参数:** 3535 3536| 参数名 | 类型 | 必填 | 说明 | 3537| ------ | ----------- | ---- | ---------------------------------------------------------- | 3538| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3539| type | [ContactType](#contacttype8) | 是 | 联系人类型。<br/>- 1 : GENERAL_CONTACT<br/>- 2 : FIXED_DIALING | 3540 3541**返回值:** 3542 3543| 类型 | 说明 | 3544| ------------------------------------------------------------ | ------------------------------ | 3545| Promise<Array<[DiallingNumbersInfo](#diallingnumbersinfo8)\>> | 以Promise形式返回Icc拨号号码。| 3546 3547**错误码:** 3548 3549以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3550 3551| 错误码ID | 错误信息 | 3552| -------- | -------------------------------------------- | 3553| 201 | Permission denied. | 3554| 202 | Non-system applications use system APIs. | 3555| 401 | Parameter error. | 3556| 8300001 | Invalid parameter value. | 3557| 8300002 | Operation failed. Cannot connect to service. | 3558| 8300003 | System internal error. | 3559| 8300004 | Do not have sim card. | 3560| 8300999 | Unknown error code. | 3561| 8301002 | SIM card operation error. | 3562 3563**示例:** 3564 3565```ts 3566import { BusinessError } from '@ohos.base'; 3567import sim from '@ohos.telephony.sim'; 3568 3569sim.queryIccDiallingNumbers(0, 1).then((data: Array<sim.DiallingNumbersInfo>) => { 3570 console.log(`queryIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); 3571}).catch((err: BusinessError) => { 3572 console.error(`queryIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`); 3573}); 3574``` 3575 3576## sim.addIccDiallingNumbers<sup>8+</sup> 3577 3578addIccDiallingNumbers\(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback\<void\>\): void 3579 3580添加SIM卡联系人号码。使用callback异步回调。 3581 3582>**说明:** 3583> 3584>SIM卡联系人存在缓存机制,对联系人进行增删改操作时会维护一套由卡槽slotId和联系人类型type对应的SIM卡联系人缓存,所以需要先调用sim.queryIccDiallingNumbers接口传入所需的slotId和type查询SIM卡联系人,生成缓存数据,在没有缓存的情况下直接调用sim.addIccDiallingNumbers、sim.delIccDiallingNumbers、sim.updateIccDiallingNumbers等接口会失败。 3585> 3586 3587**系统接口:** 此接口为系统接口。 3588 3589**需要权限**:ohos.permission.WRITE_CONTACTS 3590 3591**系统能力**:SystemCapability.Telephony.CoreService 3592 3593**参数:** 3594 3595| 参数名 | 类型 | 必填 | 说明 | 3596| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- | 3597| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3598| type | [ContactType](#contacttype8) | 是 | 联系人类型。<br/>- 1 : GENERAL_CONTACT<br/>- 2 : FIXED_DIALING | 3599| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是 | 拨号号码信息。 | 3600| callback | AsyncCallback<void\> | 是 | 回调函数。 | 3601 3602**错误码:** 3603 3604以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3605 3606| 错误码ID | 错误信息 | 3607| -------- | -------------------------------------------- | 3608| 201 | Permission denied. | 3609| 202 | Non-system applications use system APIs. | 3610| 401 | Parameter error. | 3611| 8300001 | Invalid parameter value. | 3612| 8300002 | Operation failed. Cannot connect to service. | 3613| 8300003 | System internal error. | 3614| 8300004 | Do not have sim card. | 3615| 8300999 | Unknown error code. | 3616| 8301002 | SIM card operation error. | 3617 3618**示例:** 3619 3620```ts 3621import { BusinessError } from '@ohos.base'; 3622import sim from '@ohos.telephony.sim'; 3623 3624let diallingNumbersInof: sim.DiallingNumbersInfo = { 3625 alphaTag: "alpha", 3626 number: "138xxxxxxxx", 3627 pin2: "1234" 3628}; 3629sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err: BusinessError) => { 3630 console.log(`callback: err->${JSON.stringify(err)}`); 3631}); 3632``` 3633 3634 3635## sim.addIccDiallingNumbers<sup>8+</sup> 3636 3637addIccDiallingNumbers\(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo\): Promise\<void\> 3638 3639添加SIM卡联系人号码。使用Promise异步回调。 3640 3641>**说明:** 3642> 3643>SIM卡联系人存在缓存机制,对联系人进行增删改操作时会维护一套由卡槽slotId和联系人类型type对应的SIM卡联系人缓存,所以需要先调用sim.queryIccDiallingNumbers接口传入所需的slotId和type查询SIM卡联系人,生成缓存数据,在没有缓存的情况下直接调用sim.addIccDiallingNumbers、sim.delIccDiallingNumbers、sim.updateIccDiallingNumbers等接口会失败。 3644> 3645 3646**系统接口:** 此接口为系统接口。 3647 3648**需要权限**:ohos.permission.WRITE_CONTACTS 3649 3650**系统能力**:SystemCapability.Telephony.CoreService 3651 3652**参数:** 3653 3654| 参数名 | 类型 | 必填 | 说明 | 3655| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- | 3656| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3657| type | [ContactType](#contacttype8) | 是 | 联系人类型。<br/>- 1 : GENERAL_CONTACT<br/>- 2 : FIXED_DIALING | 3658| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是 | 拨号号码信息。 | 3659 3660**返回值:** 3661 3662| 类型 | 说明 | 3663| -------------- | --------------------------- | 3664| Promise<void\> | 以Promise形式返回添加结果。 | 3665 3666**错误码:** 3667 3668以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3669 3670| 错误码ID | 错误信息 | 3671| -------- | -------------------------------------------- | 3672| 201 | Permission denied. | 3673| 202 | Non-system applications use system APIs. | 3674| 401 | Parameter error. | 3675| 8300001 | Invalid parameter value. | 3676| 8300002 | Operation failed. Cannot connect to service. | 3677| 8300003 | System internal error. | 3678| 8300004 | Do not have sim card. | 3679| 8300999 | Unknown error code. | 3680| 8301002 | SIM card operation error. | 3681 3682**示例:** 3683 3684```ts 3685import { BusinessError } from '@ohos.base'; 3686import sim from '@ohos.telephony.sim'; 3687 3688let diallingNumbersInof: sim.DiallingNumbersInfo = { 3689 alphaTag: "alpha", 3690 number: "138xxxxxxxx" 3691}; 3692sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof).then(() => { 3693 console.log(`addIccDiallingNumbers success.`); 3694}).catch((err: BusinessError) => { 3695 console.error(`addIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`); 3696}); 3697``` 3698 3699## sim.delIccDiallingNumbers<sup>8+</sup> 3700 3701delIccDiallingNumbers\(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback\<void\>\): void 3702 3703删除SIM卡联系人号码。使用callback异步回调。 3704 3705>**说明:** 3706> 3707>SIM卡联系人存在缓存机制,对联系人进行增删改操作时会维护一套由卡槽slotId和联系人类型type对应的SIM卡联系人缓存,所以需要先调用sim.queryIccDiallingNumbers接口传入所需的slotId和type查询SIM卡联系人,生成缓存数据,在没有缓存的情况下直接调用sim.addIccDiallingNumbers、sim.delIccDiallingNumbers、sim.updateIccDiallingNumbers等接口会失败。 3708> 3709 3710**系统接口:** 此接口为系统接口。 3711 3712**需要权限**:ohos.permission.WRITE_CONTACTS 3713 3714**系统能力**:SystemCapability.Telephony.CoreService 3715 3716**参数:** 3717 3718| 参数名 | 类型 | 必填 | 说明 | 3719| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- | 3720| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3721| type | [ContactType](#contacttype8) | 是 | 联系人类型。<br/>- 1 : GENERAL_CONTACT<br/>- 2 : FIXED_DIALING | 3722| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是 | 拨号号码信息。 | 3723| callback | AsyncCallback<void\> | 是 | 回调函数。 | 3724 3725**错误码:** 3726 3727以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3728 3729| 错误码ID | 错误信息 | 3730| -------- | -------------------------------------------- | 3731| 201 | Permission denied. | 3732| 202 | Non-system applications use system APIs. | 3733| 401 | Parameter error. | 3734| 8300001 | Invalid parameter value. | 3735| 8300002 | Operation failed. Cannot connect to service. | 3736| 8300003 | System internal error. | 3737| 8300004 | Do not have sim card. | 3738| 8300999 | Unknown error code. | 3739| 8301002 | SIM card operation error. | 3740 3741**示例:** 3742 3743```ts 3744import { BusinessError } from '@ohos.base'; 3745import sim from '@ohos.telephony.sim'; 3746 3747let diallingNumbersInof: sim.DiallingNumbersInfo = { 3748 alphaTag: "alpha", 3749 number: "138xxxxxxxx", 3750 recordNumber: 123, 3751 pin2: "1234" 3752}; 3753sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err: BusinessError) => { 3754 console.log(`callback: err->${JSON.stringify(err)}`); 3755}); 3756``` 3757 3758 3759## sim.delIccDiallingNumbers<sup>8+</sup> 3760 3761delIccDiallingNumbers\(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo\): Promise\<void\> 3762 3763删除SIM卡联系人号码。使用Promise异步回调。 3764 3765>**说明:** 3766> 3767>SIM卡联系人存在缓存机制,对联系人进行增删改操作时会维护一套由卡槽slotId和联系人类型type对应的SIM卡联系人缓存,所以需要先调用sim.queryIccDiallingNumbers接口传入所需的slotId和type查询SIM卡联系人,生成缓存数据,在没有缓存的情况下直接调用sim.addIccDiallingNumbers、sim.delIccDiallingNumbers、sim.updateIccDiallingNumbers等接口会失败。 3768> 3769 3770**系统接口:** 此接口为系统接口。 3771 3772**需要权限**:ohos.permission.WRITE_CONTACTS 3773 3774**系统能力**:SystemCapability.Telephony.CoreService 3775 3776**参数:** 3777 3778| 参数名 | 类型 | 必填 | 说明 | 3779| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- | 3780| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3781| type | [ContactType](#contacttype8) | 是 | 联系人类型。<br/>- 1 : GENERAL_CONTACT<br/>- 2 : FIXED_DIALING | 3782| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是 | 拨号号码信息。 | 3783 3784**返回值:** 3785 3786| 类型 | 说明 | 3787| -------------- | --------------------------- | 3788| Promise<void\> | 以Promise形式返回删除结果。 | 3789 3790**错误码:** 3791 3792以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3793 3794| 错误码ID | 错误信息 | 3795| -------- | -------------------------------------------- | 3796| 201 | Permission denied. | 3797| 202 | Non-system applications use system APIs. | 3798| 401 | Parameter error. | 3799| 8300001 | Invalid parameter value. | 3800| 8300002 | Operation failed. Cannot connect to service. | 3801| 8300003 | System internal error. | 3802| 8300004 | Do not have sim card. | 3803| 8300999 | Unknown error code. | 3804| 8301002 | SIM card operation error. | 3805 3806**示例:** 3807 3808```ts 3809import { BusinessError } from '@ohos.base'; 3810import sim from '@ohos.telephony.sim'; 3811 3812let diallingNumbersInof: sim.DiallingNumbersInfo = { 3813 alphaTag: "alpha", 3814 number: "138xxxxxxxx" 3815}; 3816sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof).then(() => { 3817 console.log(`delIccDiallingNumbers success.`); 3818}).catch((err: BusinessError) => { 3819 console.error(`delIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`); 3820}); 3821``` 3822 3823## sim.updateIccDiallingNumbers<sup>8+</sup> 3824 3825updateIccDiallingNumbers\(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback\<void\>\): void 3826 3827更新SIM卡联系人号码。使用callback异步回调。 3828 3829>**说明:** 3830> 3831>SIM卡联系人存在缓存机制,对联系人进行增删改操作时会维护一套由卡槽slotId和联系人类型type对应的SIM卡联系人缓存,所以需要先调用sim.queryIccDiallingNumbers接口传入所需的slotId和type查询SIM卡联系人,生成缓存数据,在没有缓存的情况下直接调用sim.addIccDiallingNumbers、sim.delIccDiallingNumbers、sim.updateIccDiallingNumbers等接口会失败。 3832> 3833 3834**系统接口:** 此接口为系统接口。 3835 3836**需要权限**:ohos.permission.WRITE_CONTACTS 3837 3838**系统能力**:SystemCapability.Telephony.CoreService 3839 3840**参数:** 3841 3842| 参数名 | 类型 | 必填 | 说明 | 3843| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- | 3844| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3845| type | [ContactType](#contacttype8) | 是 | 联系人类型。<br/>- 1 : GENERAL_CONTACT<br/>- 2 : FIXED_DIALING | 3846| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是 | 拨号号码信息。 | 3847| callback | AsyncCallback<void\> | 是 | 回调函数。 | 3848 3849**错误码:** 3850 3851以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3852 3853| 错误码ID | 错误信息 | 3854| -------- | -------------------------------------------- | 3855| 201 | Permission denied. | 3856| 202 | Non-system applications use system APIs. | 3857| 401 | Parameter error. | 3858| 8300001 | Invalid parameter value. | 3859| 8300002 | Operation failed. Cannot connect to service. | 3860| 8300003 | System internal error. | 3861| 8300004 | Do not have sim card. | 3862| 8300999 | Unknown error code. | 3863| 8301002 | SIM card operation error. | 3864 3865**示例:** 3866 3867```ts 3868import { BusinessError } from '@ohos.base'; 3869import sim from '@ohos.telephony.sim'; 3870 3871let diallingNumbersInof: sim.DiallingNumbersInfo = { 3872 alphaTag: "alpha", 3873 number: "138xxxxxxxx", 3874 recordNumber: 123, 3875 pin2: "1234" 3876}; 3877sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err: BusinessError) => { 3878 console.log(`callback: err->${JSON.stringify(err)}`); 3879}); 3880``` 3881 3882 3883## sim.updateIccDiallingNumbers<sup>8+</sup> 3884 3885updateIccDiallingNumbers\(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo\): Promise\<void\> 3886 3887更新SIM卡联系人号码。使用Promise异步回调。 3888 3889>**说明:** 3890> 3891>SIM卡联系人存在缓存机制,对联系人进行增删改操作时会维护一套由卡槽slotId和联系人类型type对应的SIM卡联系人缓存,所以需要先调用sim.queryIccDiallingNumbers接口传入所需的slotId和type查询SIM卡联系人,生成缓存数据,在没有缓存的情况下直接调用sim.addIccDiallingNumbers、sim.delIccDiallingNumbers、sim.updateIccDiallingNumbers等接口会失败。 3892> 3893 3894**系统接口:** 此接口为系统接口。 3895 3896**需要权限**:ohos.permission.WRITE_CONTACTS 3897 3898**系统能力**:SystemCapability.Telephony.CoreService 3899 3900**参数:** 3901 3902| 参数名 | 类型 | 必填 | 说明 | 3903| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- | 3904| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3905| type | [ContactType](#contacttype8) | 是 | 联系人类型。<br/>- 1 : GENERAL_CONTACT<br/>- 2 : FIXED_DIALING | 3906| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是 | 拨号号码信息。 | 3907 3908**返回值:** 3909 3910| 类型 | 说明 | 3911| -------------- | ----------------------------- | 3912| Promise<void\> | 以Promise形式返回更新的结果。 | 3913 3914**错误码:** 3915 3916以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3917 3918| 错误码ID | 错误信息 | 3919| -------- | -------------------------------------------- | 3920| 201 | Permission denied. | 3921| 202 | Non-system applications use system APIs. | 3922| 401 | Parameter error. | 3923| 8300001 | Invalid parameter value. | 3924| 8300002 | Operation failed. Cannot connect to service. | 3925| 8300003 | System internal error. | 3926| 8300004 | Do not have sim card. | 3927| 8300999 | Unknown error code. | 3928| 8301002 | SIM card operation error. | 3929 3930**示例:** 3931 3932```ts 3933import { BusinessError } from '@ohos.base'; 3934import sim from '@ohos.telephony.sim'; 3935 3936let diallingNumbersInof: sim.DiallingNumbersInfo = { 3937 alphaTag: "alpha", 3938 number: "138xxxxxxxx", 3939 recordNumber: 123 3940}; 3941sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof).then(() => { 3942 console.log(`updateIccDiallingNumbers success.`); 3943}).catch((err: BusinessError) => { 3944 console.error(`updateIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`); 3945}); 3946``` 3947 3948## sim.sendEnvelopeCmd<sup>8+</sup> 3949 3950sendEnvelopeCmd\(slotId: number, cmd: string, callback: AsyncCallback\<void\>\): void 3951 3952发送信封命令。使用callback异步回调。 3953 3954**系统接口:** 此接口为系统接口。 3955 3956**需要权限**:ohos.permission.SET_TELEPHONY_STATE 3957 3958**系统能力**:SystemCapability.Telephony.CoreService 3959 3960**参数:** 3961 3962| 参数名 | 类型 | 必填 | 说明 | 3963| -------- | -------------------- | ---- | -------------------------------------- | 3964| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 3965| cmd | string | 是 | 命令。 | 3966| callback | AsyncCallback<void\> | 是 | 回调函数。 | 3967 3968**错误码:** 3969 3970以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 3971 3972| 错误码ID | 错误信息 | 3973| -------- | -------------------------------------------- | 3974| 201 | Permission denied. | 3975| 202 | Non-system applications use system APIs. | 3976| 401 | Parameter error. | 3977| 8300001 | Invalid parameter value. | 3978| 8300002 | Operation failed. Cannot connect to service. | 3979| 8300003 | System internal error. | 3980| 8300004 | Do not have sim card. | 3981| 8300999 | Unknown error code. | 3982 3983**示例:** 3984 3985```ts 3986import { BusinessError } from '@ohos.base'; 3987import sim from '@ohos.telephony.sim'; 3988 3989sim.sendEnvelopeCmd(0, "ls", (err: BusinessError) => { 3990 console.log(`callback: err->${JSON.stringify(err)}`); 3991}); 3992``` 3993 3994 3995## sim.sendEnvelopeCmd<sup>8+</sup> 3996 3997sendEnvelopeCmd\(slotId: number, cmd: string\): Promise\<void\> 3998 3999发送信封命令。使用Promise异步回调。 4000 4001**系统接口:** 此接口为系统接口。 4002 4003**需要权限**:ohos.permission.SET_TELEPHONY_STATE 4004 4005**系统能力**:SystemCapability.Telephony.CoreService 4006 4007**参数:** 4008 4009| 参数名 | 类型 | 必填 | 说明 | 4010| ------ | ------ | ---- | -------------------------------------- | 4011| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 4012| cmd | string | 是 | 命令。 | 4013 4014**返回值:** 4015 4016| 类型 | 说明 | 4017| -------------- | --------------------------- | 4018| Promise<void\> | 以Promise形式返回发送结果。 | 4019 4020**错误码:** 4021 4022以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 4023 4024| 错误码ID | 错误信息 | 4025| -------- | -------------------------------------------- | 4026| 201 | Permission denied. | 4027| 202 | Non-system applications use system APIs. | 4028| 401 | Parameter error. | 4029| 8300001 | Invalid parameter value. | 4030| 8300002 | Operation failed. Cannot connect to service. | 4031| 8300003 | System internal error. | 4032| 8300004 | Do not have sim card. | 4033| 8300999 | Unknown error code. | 4034 4035**示例:** 4036 4037```ts 4038import { BusinessError } from '@ohos.base'; 4039import sim from '@ohos.telephony.sim'; 4040 4041sim.sendEnvelopeCmd(0, "ls").then(() => { 4042 console.log(`sendEnvelopeCmd success.`); 4043}).catch((err: BusinessError) => { 4044 console.error(`sendEnvelopeCmd failed, promise: err->${JSON.stringify(err)}`); 4045}); 4046``` 4047 4048## sim.sendTerminalResponseCmd<sup>8+</sup> 4049 4050sendTerminalResponseCmd\(slotId: number, cmd: string, callback: AsyncCallback\<void\>\): void 4051 4052发送终端响应命令。使用callback异步回调。 4053 4054**系统接口:** 此接口为系统接口。 4055 4056**需要权限**:ohos.permission.SET_TELEPHONY_STATE 4057 4058**系统能力**:SystemCapability.Telephony.CoreService 4059 4060**参数:** 4061 4062| 参数名 | 类型 | 必填 | 说明 | 4063| -------- | -------------------- | ---- | -------------------------------------- | 4064| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 4065| cmd | string | 是 | 命令。 | 4066| callback | AsyncCallback<void\> | 是 | 回调函数。 | 4067 4068**错误码:** 4069 4070以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 4071 4072| 错误码ID | 错误信息 | 4073| -------- | -------------------------------------------- | 4074| 201 | Permission denied. | 4075| 202 | Non-system applications use system APIs. | 4076| 401 | Parameter error. | 4077| 8300001 | Invalid parameter value. | 4078| 8300002 | Operation failed. Cannot connect to service. | 4079| 8300003 | System internal error. | 4080| 8300004 | Do not have sim card. | 4081| 8300999 | Unknown error code. | 4082 4083**示例:** 4084 4085```ts 4086import { BusinessError } from '@ohos.base'; 4087import sim from '@ohos.telephony.sim'; 4088 4089sim.sendTerminalResponseCmd(0, "ls", (err: BusinessError) => { 4090 console.log(`callback: err->${JSON.stringify(err)}`); 4091}); 4092``` 4093 4094 4095## sim.sendTerminalResponseCmd<sup>8+</sup> 4096 4097sendTerminalResponseCmd\(slotId: number, cmd: string\): Promise\<void\> 4098 4099发送终端响应命令。使用Promise异步回调。 4100 4101**系统接口:** 此接口为系统接口。 4102 4103**需要权限**:ohos.permission.SET_TELEPHONY_STATE 4104 4105**系统能力**:SystemCapability.Telephony.CoreService 4106 4107**参数:** 4108 4109| 参数名 | 类型 | 必填 | 说明 | 4110| ------ | ------ | ---- | -------------------------------------- | 4111| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 4112| cmd | string | 是 | 命令。 | 4113 4114**返回值:** 4115 4116| 类型 | 说明 | 4117| -------------- | --------------------------- | 4118| Promise<void\> | 以Promise形式返回发送结果。 | 4119 4120**错误码:** 4121 4122以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 4123 4124| 错误码ID | 错误信息 | 4125| -------- | -------------------------------------------- | 4126| 201 | Permission denied. | 4127| 202 | Non-system applications use system APIs. | 4128| 401 | Parameter error. | 4129| 8300001 | Invalid parameter value. | 4130| 8300002 | Operation failed. Cannot connect to service. | 4131| 8300003 | System internal error. | 4132| 8300004 | Do not have sim card. | 4133| 8300999 | Unknown error code. | 4134 4135**示例:** 4136 4137```ts 4138import { BusinessError } from '@ohos.base'; 4139import sim from '@ohos.telephony.sim'; 4140 4141sim.sendTerminalResponseCmd(0, "ls").then(() => { 4142 console.log(`sendTerminalResponseCmd success.`); 4143}).catch((err: BusinessError) => { 4144 console.error(`sendTerminalResponseCmd failed, promise: err->${JSON.stringify(err)}`); 4145}); 4146``` 4147 4148 4149## sim.unlockSimLock<sup>8+</sup> 4150 4151unlockSimLock\(slotId: number, lockInfo: PersoLockInfo, callback: AsyncCallback\<LockStatusResponse\>\): void 4152 4153解锁SIM卡锁。使用callback异步回调。 4154 4155**系统接口:** 此接口为系统接口。 4156 4157**需要权限**:ohos.permission.SET_TELEPHONY_STATE 4158 4159**系统能力**:SystemCapability.Telephony.CoreService 4160 4161**参数:** 4162 4163| 参数名 | 类型 | 必填 | 说明 | 4164| -------- | ---------------------------------------------------------- | ---- | -------------------------------------- | 4165| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 4166| lockInfo | [PersoLockInfo](#persolockinfo8) | 是 | 定制锁类型信息。 | 4167| callback | AsyncCallback<[LockStatusResponse](#lockstatusresponse7)\> | 是 | 回调函数。 | 4168 4169**错误码:** 4170 4171以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 4172 4173| 错误码ID | 错误信息 | 4174| -------- | -------------------------------------------- | 4175| 201 | Permission denied. | 4176| 202 | Non-system applications use system APIs. | 4177| 401 | Parameter error. | 4178| 8300001 | Invalid parameter value. | 4179| 8300002 | Operation failed. Cannot connect to service. | 4180| 8300003 | System internal error. | 4181| 8300004 | Do not have sim card. | 4182| 8300999 | Unknown error code. | 4183| 8301002 | SIM card operation error. | 4184 4185**示例:** 4186 4187```ts 4188import { BusinessError } from '@ohos.base'; 4189import sim from '@ohos.telephony.sim'; 4190 4191let persoLockInfo: sim.PersoLockInfo = { 4192 lockType: sim.PersoLockType.PN_PIN_LOCK, 4193 password: "1234" 4194}; 4195sim.unlockSimLock(0, persoLockInfo, (err: BusinessError, data: sim.LockStatusResponse) => { 4196 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 4197}); 4198``` 4199 4200 4201## sim.unlockSimLock<sup>8+</sup> 4202 4203unlockSimLock\(slotId: number, lockInfo: PersoLockInfo\): Promise\<LockStatusResponse\> 4204 4205解锁SIM卡锁。使用Promise异步回调。 4206 4207**系统接口:** 此接口为系统接口。 4208 4209**需要权限**:ohos.permission.SET_TELEPHONY_STATE 4210 4211**系统能力**:SystemCapability.Telephony.CoreService 4212 4213**参数:** 4214 4215| 参数名 | 类型 | 必填 | 说明 | 4216| -------- | -------------------------------- | ---- | -------------------------------------- | 4217| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 4218| lockInfo | [PersoLockInfo](#persolockinfo8) | 是 | 定制锁类型信息。 | 4219 4220**返回值:** 4221 4222| 类型 | 说明 | 4223| ---------------------------------------------------- | ------------------------- | 4224| Promise<[LockStatusResponse](#lockstatusresponse7)\> | 以Promise形式返回锁状态。 | 4225 4226**错误码:** 4227 4228以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 4229 4230| 错误码ID | 错误信息 | 4231| -------- | -------------------------------------------- | 4232| 201 | Permission denied. | 4233| 202 | Non-system applications use system APIs. | 4234| 401 | Parameter error. | 4235| 8300001 | Invalid parameter value. | 4236| 8300002 | Operation failed. Cannot connect to service. | 4237| 8300003 | System internal error. | 4238| 8300004 | Do not have sim card. | 4239| 8300999 | Unknown error code. | 4240| 8301002 | SIM card operation error. | 4241 4242**示例:** 4243 4244```ts 4245import { BusinessError } from '@ohos.base'; 4246import sim from '@ohos.telephony.sim'; 4247 4248let persoLockInfo: sim.PersoLockInfo = { 4249 lockType: sim.PersoLockType.PN_PIN_LOCK, 4250 password: "1234" 4251}; 4252sim.unlockSimLock(0, persoLockInfo).then((data: sim.LockStatusResponse) => { 4253 console.log(`unlockSimLock success, promise: data->${JSON.stringify(data)}`); 4254}).catch((err: BusinessError) => { 4255 console.error(`unlockSimLock failed, promise: err->${JSON.stringify(err)}`); 4256}); 4257``` 4258 4259## sim.getOpKey<sup>9+</sup> 4260 4261getOpKey\(slotId: number, callback: AsyncCallback\<string\>): void 4262 4263获取指定卡槽中SIM卡的opkey。使用callback异步回调。 4264 4265**系统能力**:SystemCapability.Telephony.CoreService 4266 4267**参数:** 4268 4269| 参数名 | 类型 | 必填 | 说明 | 4270| -------- | ---------------------- | ---- | -------------------------------------- | 4271| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 4272| callback | AsyncCallback<string\> | 是 | 回调函数。 | 4273 4274**错误码:** 4275 4276以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 4277 4278| 错误码ID | 错误信息 | 4279| -------- | -------------------------------------------- | 4280| 401 | Parameter error. | 4281| 801 | Capability not supported. | 4282| 8300001 | Invalid parameter value. | 4283| 8300002 | Operation failed. Cannot connect to service. | 4284| 8300003 | System internal error. | 4285| 8300999 | Unknown error code. | 4286 4287**示例:** 4288 4289```ts 4290import { BusinessError } from '@ohos.base'; 4291import sim from '@ohos.telephony.sim'; 4292 4293try { 4294 sim.getOpKey(0, (err: BusinessError, data: string) => { 4295 if (err) { 4296 console.error("getOpKey failed, err: " + JSON.stringify(err)); 4297 } else { 4298 console.log('getOpKey successfully, data: ' + JSON.stringify(data)); 4299 } 4300 }); 4301} catch (err) { 4302 console.error("getOpKey err: " + JSON.stringify(err)); 4303} 4304``` 4305 4306 4307## sim.getOpKey<sup>9+</sup> 4308 4309getOpKey\(slotId: number\): Promise\<string\> 4310 4311获取指定卡槽中SIM卡的opkey。使用Promise异步回调。 4312 4313**系统能力**:SystemCapability.Telephony.CoreService 4314 4315**参数:** 4316 4317| 参数名 | 类型 | 必填 | 说明 | 4318| ------ | ------ | ---- | -------------------------------------- | 4319| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 4320 4321**返回值:** 4322 4323| 类型 | 说明 | 4324| ---------------- | ----------------------------------------- | 4325| Promise<string\> | 以Promise形式返回指定卡槽中SIM卡的opkey。 | 4326 4327**错误码:** 4328 4329以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 4330 4331| 错误码ID | 错误信息 | 4332| -------- | -------------------------------------------- | 4333| 401 | Parameter error. | 4334| 801 | Capability not supported. | 4335| 8300001 | Invalid parameter value. | 4336| 8300002 | Operation failed. Cannot connect to service. | 4337| 8300003 | System internal error. | 4338| 8300999 | Unknown error code. | 4339 4340**示例:** 4341 4342```ts 4343import { BusinessError } from '@ohos.base'; 4344import sim from '@ohos.telephony.sim'; 4345 4346sim.getOpKey(0).then((data: string) => { 4347 console.log(`getOpKey success, promise: data->${JSON.stringify(data)}`); 4348}).catch((err: BusinessError) => { 4349 console.error(`getOpKey failed, promise: err->${JSON.stringify(err)}`); 4350}); 4351``` 4352 4353## sim.getOpKeySync<sup>10+</sup> 4354 4355getOpKeySync\(slotId: number\): string 4356 4357获取指定卡槽中SIM卡的opkey。 4358 4359**系统能力**:SystemCapability.Telephony.CoreService 4360 4361**参数:** 4362 4363| 参数名 | 类型 | 必填 | 说明 | 4364| ------ | ------ | ---- | -------------------------------------- | 4365| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 4366 4367**返回值:** 4368 4369| 类型 | 说明 | 4370| ---------------- | ----------------------------------------- | 4371| string | 返回指定卡槽中SIM卡的opkey。 | 4372 4373 4374**示例:** 4375 4376```js 4377let data = sim.getOpKeySync(0); 4378console.log(`getOpKey success, promise: data->${JSON.stringify(data)}`); 4379``` 4380 4381## sim.getOpName<sup>9+</sup> 4382 4383getOpName\(slotId: number, callback: AsyncCallback\<string\>\): void 4384 4385获取指定卡槽中SIM卡的OpName。使用callback异步回调。 4386 4387**系统能力**:SystemCapability.Telephony.CoreService 4388 4389**参数:** 4390 4391| 参数名 | 类型 | 必填 | 说明 | 4392| -------- | ---------------------- | ---- | -------------------------------------- | 4393| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 4394| callback | AsyncCallback<string\> | 是 | 回调函数。 | 4395 4396**错误码:** 4397 4398以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 4399 4400| 错误码ID | 错误信息 | 4401| -------- | -------------------------------------------- | 4402| 401 | Parameter error. | 4403| 801 | Capability not supported. | 4404| 8300001 | Invalid parameter value. | 4405| 8300002 | Operation failed. Cannot connect to service. | 4406| 8300003 | System internal error. | 4407| 8300999 | Unknown error code. | 4408 4409**示例:** 4410 4411```ts 4412import { BusinessError } from '@ohos.base'; 4413import sim from '@ohos.telephony.sim'; 4414 4415try { 4416 sim.getOpName(0, (err: BusinessError, data: string) => { 4417 if (err) { 4418 console.error("getOpName failed, err: " + JSON.stringify(err)); 4419 } else { 4420 console.log('getOpName successfully, data: ' + JSON.stringify(data)); 4421 } 4422 }); 4423} catch (err) { 4424 console.error("getOpName err: " + JSON.stringify(err)); 4425} 4426``` 4427 4428 4429## sim.getOpName<sup>9+</sup> 4430 4431getOpName\(slotId: number\): Promise\<string\> 4432 4433获取指定卡槽中SIM卡的OpName。使用Promise异步回调。 4434 4435**系统能力**:SystemCapability.Telephony.CoreService 4436 4437**参数:** 4438 4439| 参数名 | 类型 | 必填 | 说明 | 4440| ------ | ------ | ---- | -------------------------------------- | 4441| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 4442 4443**返回值:** 4444 4445| 类型 | 说明 | 4446| ---------------- | ------------------------------------------ | 4447| Promise<string\> | 以Promise形式返回指定卡槽中SIM卡的OpName。 | 4448 4449**错误码:** 4450 4451以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 4452 4453| 错误码ID | 错误信息 | 4454| -------- | -------------------------------------------- | 4455| 401 | Parameter error. | 4456| 801 | Capability not supported. | 4457| 8300001 | Invalid parameter value. | 4458| 8300002 | Operation failed. Cannot connect to service. | 4459| 8300003 | System internal error. | 4460| 8300999 | Unknown error code. | 4461 4462**示例:** 4463 4464```ts 4465import { BusinessError } from '@ohos.base'; 4466import sim from '@ohos.telephony.sim'; 4467 4468sim.getOpName(0).then((data: string) => { 4469 console.log(`getOpName success, promise: data->${JSON.stringify(data)}`); 4470}).catch((err: BusinessError) => { 4471 console.error(`getOpName failed, promise: err->${JSON.stringify(err)}`); 4472}); 4473``` 4474 4475## sim.getOpNameSync<sup>10+</sup> 4476 4477getOpNameSync\(slotId: number\): string 4478 4479获取指定卡槽中SIM卡的OpName。 4480 4481**系统能力**:SystemCapability.Telephony.CoreService 4482 4483**参数:** 4484 4485| 参数名 | 类型 | 必填 | 说明 | 4486| ------ | ------ | ---- | -------------------------------------- | 4487| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 4488 4489**返回值:** 4490 4491| 类型 | 说明 | 4492| ---------------- | ------------------------------------------ | 4493| string | 返回指定卡槽中SIM卡的OpName。 | 4494 4495 4496**示例:** 4497 4498```js 4499let data = sim.getOpNameSync(0); 4500console.log(`getOpName success, promise: data->${JSON.stringify(data)}`); 4501``` 4502 4503## sim.getDefaultVoiceSimId<sup>10+</sup> 4504 4505getDefaultVoiceSimId\(callback: AsyncCallback\<number\>\): void 4506 4507获取默认语音业务的SIM卡ID。使用callback异步回调。 4508 4509**系统能力**:SystemCapability.Telephony.CoreService 4510 4511**参数:** 4512 4513| 参数名 | 类型 | 必填 | 说明 | 4514| -------- | --------------------------- | ---- | ---------- | 4515| callback | AsyncCallback<number> | 是 | 回调函数。<br/>与SIM卡绑定,从1开始递增。 | 4516 4517**错误码:** 4518 4519以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 4520 4521| 错误码ID | 错误信息 | 4522| -------- | -------------------------------------------- | 4523| 401 | Parameter error. | 4524| 8300001 | Invalid parameter value. | 4525| 8300002 | Operation failed. Cannot connect to service. | 4526| 8300003 | System internal error. | 4527| 8300004 | Do not have sim card. | 4528| 8300999 | Unknown error code. | 4529| 8301001 | SIM card is not activated. | 4530 4531**示例:** 4532 4533```ts 4534import { BusinessError } from '@ohos.base'; 4535import sim from '@ohos.telephony.sim'; 4536 4537sim.getDefaultVoiceSimId((err: BusinessError, data: number) => { 4538 console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 4539}); 4540``` 4541 4542## sim.getDefaultVoiceSimId<sup>10+</sup> 4543 4544getDefaultVoiceSimId\(\): Promise\<number\> 4545 4546获取默认语音业务的SIM卡ID。使用Promise异步回调。 4547 4548**系统能力**:SystemCapability.Telephony.CoreService 4549 4550**返回值:** 4551 4552| 类型 | 说明 | 4553| ----------------- | --------------------------------------- | 4554| Promise\<number\> | 以Promise形式返回默认语音业务的SIM卡ID。<br/>与SIM卡绑定,从1开始递增。 | 4555 4556**错误码:** 4557 4558以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)。 4559 4560| 错误码ID | 错误信息 | 4561| -------- | -------------------------------------------- | 4562| 8300001 | Invalid parameter value. | 4563| 8300002 | Operation failed. Cannot connect to service. | 4564| 8300003 | System internal error. | 4565| 8300004 | Do not have sim card. | 4566| 8300999 | Unknown error code. | 4567| 8301001 | SIM card is not activated. | 4568 4569**示例:** 4570 4571```ts 4572import { BusinessError } from '@ohos.base'; 4573import sim from '@ohos.telephony.sim'; 4574 4575let promise = sim.getDefaultVoiceSimId(); 4576promise.then((data: number) => { 4577 console.log(`getDefaultVoiceSimId success, promise: data->${JSON.stringify(data)}`); 4578}).catch((err: BusinessError) => { 4579 console.error(`getDefaultVoiceSimId failed, promise: err->${JSON.stringify(err)}`); 4580}); 4581``` 4582 4583## SimState 4584 4585SIM卡状态。 4586 4587**系统能力**:SystemCapability.Telephony.CoreService 4588 4589| 名称 | 值 | 说明 | 4590| --------------------- | ---- | ---------------------------------------------------------- | 4591| SIM_STATE_UNKNOWN | 0 | SIM卡状态未知,即无法获取准确的状态。 | 4592| SIM_STATE_NOT_PRESENT | 1 | 表示SIM卡处于not present状态,即卡槽中没有插入SIM卡。 | 4593| SIM_STATE_LOCKED | 2 | 表示SIM卡处于locked状态,即SIM卡被PIN、PUK或网络锁锁定。 | 4594| SIM_STATE_NOT_READY | 3 | 表示SIM卡处于not ready状态,即SIM卡在位但无法正常工作。 | 4595| SIM_STATE_READY | 4 | 表示SIM卡处于ready状态,即SIM卡在位且工作正常。 | 4596| SIM_STATE_LOADED | 5 | 表示SIM卡处于loaded状态,即SIM卡在位且所有卡文件加载完毕。 | 4597 4598## CardType<sup>7+</sup> 4599 4600卡类型。 4601 4602**系统能力**:SystemCapability.Telephony.CoreService 4603 4604| 名称 | 值 | 说明 | 4605| ----- | ----- | ----- | 4606|UNKNOWN_CARD | -1 | 未知类型。 | 4607|SINGLE_MODE_SIM_CARD | 10 | 单SIM卡。 | 4608|SINGLE_MODE_USIM_CARD | 20 | 单USIM卡。 | 4609|SINGLE_MODE_RUIM_CARD | 30 | 单RUIM卡。 | 4610|DUAL_MODE_CG_CARD | 40 | 双卡模式C+G。 | 4611|CT_NATIONAL_ROAMING_CARD | 41 | 中国电信内部漫游卡。 | 4612|CU_DUAL_MODE_CARD | 42 | 中国联通双模卡。 | 4613|DUAL_MODE_TELECOM_LTE_CARD | 43 | 双模式电信LTE卡。 | 4614|DUAL_MODE_UG_CARD | 50 | 双模式UG卡。 | 4615|SINGLE_MODE_ISIM_CARD<sup>8+</sup> | 60 | 单一ISIM卡类型。 | 4616 4617## LockType<sup>8+</sup> 4618 4619锁类型。 4620 4621**系统接口:** 此接口为系统接口。 4622 4623**系统能力**:SystemCapability.Telephony.CoreService 4624 4625| 名称 | 值 | 说明 | 4626| -------- | ---- | ----------- | 4627| PIN_LOCK | 1 | SIM卡密码锁。 | 4628| FDN_LOCK | 2 | 固定拨号锁。 | 4629 4630## LockState<sup>8+</sup> 4631 4632锁状态。 4633 4634**系统接口:** 此接口为系统接口。 4635 4636**系统能力**:SystemCapability.Telephony.CoreService 4637 4638| 名称 | 值 | 说明 | 4639| -------- | ---- | ---------- | 4640| LOCK_OFF | 0 | 锁关闭状态 | 4641| LOCK_ON | 1 | 锁开启状态 | 4642 4643## PersoLockType<sup>8+</sup> 4644 4645定制锁类型。 4646 4647**系统接口:** 此接口为系统接口。 4648 4649**系统能力**:SystemCapability.Telephony.CoreService 4650 4651| 名称 | 值 | 说明 | 4652| ------------ | ---- | ------------------------------------------------ | 4653| PN_PIN_LOCK | 0 | 定制网络PIN锁(参照 3GPP TS 22.022 [33])。 | 4654| PN_PUK_LOCK | 1 | 定制网络PUk锁。 | 4655| PU_PIN_LOCK | 2 | 定制网络子集PIN锁(参照 3GPP TS 22.022 [33])。 | 4656| PU_PUK_LOCK | 3 | 定制网络子集PUK锁。 | 4657| PP_PIN_LOCK | 4 | 定制服务提供者PIN锁(参照 3GPP TS 22.022 [33])。 | 4658| PP_PUK_LOCK | 5 | 定制服务提供者PUK锁。 | 4659| PC_PIN_LOCK | 6 | 定制企业PIN锁(参照 3GPP TS 22.022 [33])。 | 4660| PC_PUK_LOCK | 7 | 定制企业Puk锁。 | 4661| SIM_PIN_LOCK | 8 | 定制SIM的PIN锁(参照 3GPP TS 22.022 [33])。 | 4662| SIM_PUK_LOCK | 9 | 定制SIM的PUK锁。 | 4663 4664## LockStatusResponse<sup>7+</sup> 4665 4666锁状态响应。 4667 4668**系统接口:** 此接口为系统接口。 4669 4670**系统能力**:SystemCapability.Telephony.CoreService 4671 4672| 名称 | 类型 | 必填 | 说明 | 4673| --------------- | ------ | ---- | --------------------- | 4674| result | number | 是 | 当前操作的结果。 | 4675| remain | number | 否 | 剩余次数(可以为空)。| 4676 4677## LockInfo<sup>8+</sup> 4678 4679锁状态响应。 4680 4681**系统接口:** 此接口为系统接口。 4682 4683**系统能力**:SystemCapability.Telephony.CoreService 4684 4685| 名称 | 类型 | 必填 | 说明 | 4686| -------- | ------------------------ | ---- | -------- | 4687| lockType | [LockType](#locktype8) | 是 | 锁类型。 | 4688| password | string | 是 | 密码。 | 4689| state | [LockState](#lockstate8) | 是 | 锁状态。 | 4690 4691## PersoLockInfo<sup>8+</sup> 4692 4693锁状态响应。 4694 4695**系统接口:** 此接口为系统接口。 4696 4697**系统能力**:SystemCapability.Telephony.CoreService 4698 4699| 名称 | 类型 | 必填 | 说明 | 4700| -------- | -------------------------------- | ---- | ------------- | 4701| lockType | [PersoLockType](#persolocktype8) | 是 | 定制锁的类型。| 4702| password | string | 是 | 密码。 | 4703 4704## IccAccountInfo<sup>10+</sup> 4705 4706Icc帐户信息。 4707 4708**系统能力**:SystemCapability.Telephony.CoreService 4709 4710| 名称 | 类型 | 必填 | 说明 | 4711| ---------- | ------- | ---- | ---------------- | 4712| simId | number | 是 | SIM卡ID。 | 4713| slotIndex | number | 是 | 卡槽ID。 | 4714| isEsim | boolean | 是 | 标记卡是否是eSim。 | 4715| isActive | boolean | 是 | 卡是否被激活。 | 4716| iccId | string | 是 | ICCID号码。 | 4717| showName | string | 是 | SIM卡显示名称。 | 4718| showNumber | string | 是 | SIM卡显示号码。 | 4719 4720## OperatorConfig<sup>8+</sup> 4721 4722运营商配置。 4723 4724**系统接口:** 此接口为系统接口。 4725 4726**系统能力**:SystemCapability.Telephony.CoreService 4727 4728| 名称 | 类型 | 必填 | 说明 | 4729| ----- | ------ | ---- | ---- | 4730| field | string | 是 | 字段 | 4731| value | string | 是 | 值 | 4732 4733## DiallingNumbersInfo<sup>8+</sup> 4734 4735拨号号码信息。 4736 4737**系统接口:** 此接口为系统接口。 4738 4739**系统能力**:SystemCapability.Telephony.CoreService 4740 4741| 名称 | 类型 | 必填 | 说明 | 4742| ------------ | ------ | ---- | ---------- | 4743| alphaTag | string | 是 | 标签。 | 4744| number | string | 是 | 号码。 | 4745| recordNumber | number | 否 | 记录编号。 | 4746| pin2 | string | 否 | pin2密码。 | 4747 4748## ContactType<sup>8+</sup> 4749 4750联系人类型。 4751 4752**系统接口:** 此接口为系统接口。 4753 4754**系统能力**:SystemCapability.Telephony.CoreService 4755 4756| 名称 | 值 | 说明 | 4757| --------------- | ---- | ---------- | 4758| GENERAL_CONTACT | 1 | 通用联系人。 | 4759| FIXED_DIALING | 2 | 固定拨号。 | 4760 4761## OperatorConfigKey<sup>9+</sup> 4762 4763运营商配置键。 4764 4765**系统接口:** 此接口为系统接口。 4766 4767**系统能力**:SystemCapability.Telephony.CoreService 4768 4769| 名称 | 值 | 说明 | 4770| ------------------------------------------------------- | ------------------------------------------------------ | -------------------- | 4771| KEY_VOICE_MAIL_NUMBER_STRING | "voice_mail_number_string" | 语音邮件号码。 | 4772| KEY_IMS_SWITCH_ON_BY_DEFAULT_BOOL | "ims_switch_on_by_default_bool" | 固定拨号。 | 4773| KEY_HIDE_IMS_SWITCH_BOOL | "hide_ims_switch_bool" | 是否隐藏ims开关。 | 4774| KEY_VOLTE_SUPPORTED_BOOL | "volte_supported_bool" | 是否支持volte模式。 | 4775| KEY_NR_MODE_SUPPORTED_LIST_INT_ARRAY | "nr_mode_supported_list_int_array" | nr模式支持的列表。 | 4776| KEY_VOLTE_PROVISIONING_SUPPORTED_BOOL | "volte_provisioning_supported_bool" | 是否支持配置VOLTE。 | 4777| KEY_SS_OVER_UT_SUPPORTED_BOOL | "ss_over_ut_supported_bool" | SS服务是否支持UT。 | 4778| KEY_IMS_GBA_REQUIRED_BOOL | "ims_gba_required_bool" | IMS是否需要GBA。 | 4779| KEY_UT_PROVISIONING_SUPPORTED_BOOL | "ut_provisioning_supported_bool" | 是否支持UT配置。 | 4780| KEY_IMS_PREFER_FOR_EMERGENCY_BOOL | "ims_prefer_for_emergency_bool" | IMS紧急首选项。 | 4781| KEY_CALL_WAITING_SERVICE_CLASS_INT | "call_waiting_service_class_int" | 呼叫等待服务。 | 4782| KEY_CALL_TRANSFER_VISIBILITY_BOOL | "call_transfer_visibility_bool" | 呼叫转移可见性。 | 4783| KEY_IMS_CALL_DISCONNECT_REASON_INFO_MAPPING_STRING_ARRAY| "ims_call_disconnect_reason_info_mapping_string_array" | IMS呼叫结束原因列表。| 4784| KEY_FORCE_VOLTE_SWITCH_ON_BOOL | "force_volte_switch_on_bool" | 强制VOLTE开关。 | 4785| KEY_ENABLE_OPERATOR_NAME_CUST_BOOL | "enable_operator_name_cust_bool" | 是否显示运营商名称。 | 4786| KEY_OPERATOR_NAME_CUST_STRING | "operator_name_cust_string" | 运营商名称。 | 4787| KEY_SPN_DISPLAY_CONDITION_CUST_INT | "spn_display_condition_cust_int" | SPN显示规则。 | 4788| KEY_PNN_CUST_STRING_ARRAY | "pnn_cust_string_array" | PLMN名称。 | 4789| KEY_OPL_CUST_STRING_ARRAY | "opl_cust_string_array" | 运营商PLMN信息。 | 4790| KEY_EMERGENCY_CALL_STRING_ARRAY | "emergency_call_string_array" | 紧急呼叫列表。 | 4791