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