1# @ohos.telephony.esim (eSIM卡管理) (系统接口) 2 3穿戴设备支持eSIM,电话服务提供API给eSIM卡管理和eSIM卡服务使用。 4 5>**说明:** 6> 7>本模块首批接口从API version 14开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 8> 当前页面仅包含本模块的系统接口,其他公开接口参见[@ohos.telephony.esim (eSIM卡管理)](js-apis-esim.md) 9 10## 导入模块 11 12```ts 13import { eSIM } from '@kit.TelephonyKit'; 14``` 15 16## eSIM.getEid<sup>14+</sup> 17 18getEid\(slotId: number\): string 19 20获取指定卡槽标识eUICC硬件的EID。 21 22**系统接口:** 此接口为系统接口。 23 24**需要权限**: ohos.permission.GET_TELEPHONY_ESIM_STATE 25 26**系统能力**:SystemCapability.Telephony.CoreService.Esim 27 28**参数:** 29 30| 参数名 | 类型 | 必填 | 说明 | 31| ------ | ------ | ---- | -------------------------------------- | 32| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 33 34**返回值:** 35 36| 类型 | 说明 | 37| --------------------- | ---------------------------------- | 38| string | 返回指定卡槽标识eUICC硬件的EID。 | 39**错误码:** 40 41| 错误码ID | 错误信息 | 42| --------------------- | ---------------------------------- | 43| 201 | Permission denied. | 44| 202 | Non-system applications use system APIs. | 45| 401 | Parameter error. Possible causes: <br/>1. Mandatory parameters are left unspecified. <br/> 2. Incorrect parameter types. <br/>3. Invalid parameter value.| 46| 801 | Capability not supported. | 47|3120001| Service connection failed. | 48|3120002| System internal error. | 49**示例:** 50 51```ts 52import { eSIM } from '@kit.TelephonyKit'; 53 54let eid: string = eSIM.getEid(0); 55console.log(`the EID is:` + eid); 56``` 57 58## eSIM.getOsuStatus<sup>14+</sup> 59 60getOsuStatus\(slotId: number\): Promise\<OsuStatus\> 61 62获取指定卡槽操作系统升级的状态。使用Promise异步回调。 63 64**系统接口:** 此接口为系统接口。 65 66**需要权限**: ohos.permission.GET_TELEPHONY_ESIM_STATE 67 68**系统能力**:SystemCapability.Telephony.CoreService.Esim 69 70**参数:** 71 72| 参数名 | 类型 | 必填 | 说明 | 73| ------ | ------ | ---- | -------------------------------------- | 74| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 75 76**返回值:** 77 78| 类型 | 说明 | 79| --------------------- | ---------------------------------- | 80| Promise\<[OsuStatus](#osustatus14)\> | Promise对象,返回操作系统升级的状态。<br/> 1.正在升级 <br/> 2. 升级失败<br/> 3.升级成功<br/> 4.当前版本是最新版本<br/> 5.升级服务不可用 | 81 82**错误码:** 83 84| 错误码ID | 错误信息 | 85| --------------------- | ---------------------------------- | 86| 201 | Permission denied. | 87| 202 | Non-system applications use system APIs. | 88| 401 | Parameter error. Possible causes: <br/>1. Mandatory parameters are left unspecified. <br/> 2. Incorrect parameter types. <br/>3. Invalid parameter value.| 89| 801 | Capability not supported. | 90|3120001| Service connection failed. | 91|3120002| System internal error. | 92 93**示例:** 94 95```ts 96import { BusinessError } from '@kit.BasicServicesKit'; 97import { eSIM } from '@kit.TelephonyKit'; 98 99eSIM.getOsuStatus(0).then(() => { 100 console.log(`getOsuStatus invoking succeeded.`); 101}).catch((err: BusinessError) => { 102 console.error(`getOsuStatus, promise: err->${JSON.stringify(err)}`); 103}); 104``` 105 106## eSIM.startOsu<sup>14+</sup> 107 108startOsu\(slotId: number\): Promise\<OsuStatus\> 109 110如果指定卡槽的操作系统不是最新的,则执行操作系统升级。使用Promise异步回调。 111 112**系统接口:** 此接口为系统接口。 113 114**需要权限**: ohos.permission.SET_TELEPHONY_ESIM_STATE 115 116**系统能力**:SystemCapability.Telephony.CoreService.Esim 117 118**参数:** 119 120| 参数名 | 类型 | 必填 | 说明 | 121| ------ | ------ | ---- | -------------------------------------- | 122| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 123 124**返回值:** 125 126| 类型 | 说明 | 127| --------------------- | ---------------------------------- | 128| Promise\<[OsuStatus](#osustatus14)\> | Promise对象,返回操作系统升级的状态。<br/> 1.正在升级 <br/> 2. 升级失败<br/> 3.升级成功<br/> 4.当前版本是最新版本<br/> 5.升级服务不可用 | 129 130**错误码:** 131| 错误码ID | 错误信息 | 132| --------------------- | ---------------------------------- | 133| 201 | Permission denied. | 134| 202 | Non-system applications use system APIs. | 135| 401 | Parameter error. Possible causes: <br/>1. Mandatory parameters are left unspecified. <br/> 2. Incorrect parameter types. <br/>3. Invalid parameter value.| 136| 801 | Capability not supported. | 137|3120001| Service connection failed. | 138|3120002| System internal error. | 139 140 141**示例:** 142 143```ts 144import { BusinessError } from '@kit.BasicServicesKit'; 145import { eSIM } from '@kit.TelephonyKit'; 146 147eSIM.startOsu(0).then(() => { 148 console.log(`startOsu invoking succeeded.`); 149}).catch((err: BusinessError) => { 150 console.error(`startOsu, ErrorState: err->${JSON.stringify(err)}`); 151}); 152``` 153 154## eSIM.getDownloadableProfileMetadata<sup>14+</sup> 155 156getDownloadableProfileMetadata\(slotId: number, portIndex: number, 157 profile: DownloadableProfile, forceDisableProfile: boolean\): Promise\<GetDownloadableProfileMetadataResult\> 158 159填充可下载配置文件的元数据。使用Promise异步回调。 160 161**系统接口:** 此接口为系统接口。 162 163**需要权限**: ohos.permission.SET_TELEPHONY_ESIM_STATE 164 165**系统能力**:SystemCapability.Telephony.CoreService.Esim 166 167**参数:** 168 169| 参数名 | 类型 | 必填 | 说明 | 170| ------ | ------ | ----- | ----- | 171| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 172| portIndex | number | 是 | 插槽的端口索引。 | 173| profile | [DownloadableProfile](#downloadableprofile14) | 是 | 可下载的配置文件信息。| 174| forceDisableProfile | boolean | 是 | 如果值为true,则必须停用活动SIM才能执行操作。如果值为false,则提示用户首先同意此操作。| 175 176**返回值:** 177 178| 类型 | 说明 | 179| --------------------- | ---------------------------------- | 180| Promise\<[GetDownloadableProfileMetadataResult](#getdownloadableprofilemetadataresult14)\> | Promise对象,返回填充可下载配置文件的元数据。 | 181 182**错误码:** 183 184| 错误码ID | 错误信息 | 185| --------------------- | ---------------------------------- | 186| 201 | Permission denied. | 187| 202 | Non-system applications use system APIs. | 188| 401 | Parameter error. Possible causes: <br/>1. Mandatory parameters are left unspecified. <br/> 2. Incorrect parameter types. <br/>3. Invalid parameter value.| 189| 801 | Capability not supported. | 190|3120001| Service connection failed. | 191|3120002| System internal error. | 192 193**示例:** 194 195```ts 196import { BusinessError } from '@kit.BasicServicesKit'; 197import { eSIM } from '@kit.TelephonyKit'; 198 199let profile: eSIM.DownloadableProfile={ 200 activationCode:'1', 201 confirmationCode:'1', 202 carrierName:'test', 203 accessRules:[{ 204 certificateHashHexStr:'test', 205 packageName:'com.example.testcoreservice', 206 accessType:0 207 }] 208}; 209 210eSIM.getDownloadableProfileMetadata(0, 0, profile, true).then((data: eSIM.GetDownloadableProfileMetadataResult) => { 211 console.log(`getDownloadableProfileMetadata, GetDownloadableProfileMetadataResult: data->${JSON.stringify(data)}`); 212}).catch((err: BusinessError) => { 213 console.error(`getDownloadableProfileMetadata, GetDownloadableProfileMetadataResult: err->${JSON.stringify(err)}`); 214}); 215``` 216 217## eSIM.getDownloadableProfiles<sup>14+</sup> 218 219getDownloadableProfiles\(slotId: number, portIndex: number, 220 forceDisableProfile: boolean\): Promise\<GetDownloadableProfilesResult\> 221 222获取可用的可下载配置文件列表。使用Promise异步回调。 223 224**系统接口:** 此接口为系统接口。 225 226**需要权限**: ohos.permission.GET_TELEPHONY_ESIM_STATE 227 228**系统能力**:SystemCapability.Telephony.CoreService.Esim 229 230**参数:** 231 232| 参数名 | 类型 | 必填 | 说明 | 233| ------ | ------ | ----- | ----- | 234| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 235| portIndex | number | 是 | 插槽的端口索引。 | 236| forceDisableProfile | boolean | 是 | 如果值为true,则必须停用活动SIM才能执行操作。如果值为false,则提示用户首先同意此操作。| 237 238**返回值:** 239 240| 类型 | 说明 | 241| --------------------- | ---------------------------------- | 242| Promise\<[GetDownloadableProfilesResult](#getdownloadableprofilesresult14)\> | Promise对象,返回可下载配置文件列表。 | 243 244**错误码:** 245 246| 错误码ID | 错误信息 | 247| --------------------- | ---------------------------------- | 248| 201 | Permission denied. | 249| 202 | Non-system applications use system APIs. | 250| 401 | Parameter error. Possible causes: <br/>1. Mandatory parameters are left unspecified. <br/> 2. Incorrect parameter types. <br/>3. Invalid parameter value.| 251| 801 | Capability not supported. | 252|3120001| Service connection failed. | 253|3120002| System internal error. | 254 255**示例:** 256 257```ts 258import { BusinessError } from '@kit.BasicServicesKit'; 259import { eSIM } from '@kit.TelephonyKit'; 260 261eSIM.getDownloadableProfiles(0, 0, true).then((data: eSIM.GetDownloadableProfilesResult) => { 262 console.log(`getDownloadableProfiles, GetDownloadableProfilesResult: data->${JSON.stringify(data)}`); 263}).catch((err: BusinessError) => { 264 console.error(`getDownloadableProfiles, GetDownloadableProfilesResult: err->${JSON.stringify(err)}`); 265}); 266``` 267 268## eSIM.downloadProfile<sup>14+</sup> 269 270downloadProfile\(slotId: number, portIndex: number, profile: DownloadableProfile, 271 configuration: DownloadConfiguration\): Promise\<DownloadProfileResult\>; 272 273下载配置文件。使用Promise异步回调。 274 275**系统接口:** 此接口为系统接口。 276 277**需要权限**: ohos.permission.SET_TELEPHONY_ESIM_STATE 278 279**系统能力**:SystemCapability.Telephony.CoreService.Esim 280 281**参数:** 282 283| 参数名 | 类型 | 必填 | 说明 | 284| ------ | ------ | ----- | ----- | 285| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 286| portIndex | number | 是 | 插槽的端口索引。 | 287| profile | [DownloadableProfile](#downloadableprofile14) | 是 | 可下载的配置文件信息。 | 288| configuration | [DownloadConfiguration](#downloadconfiguration14) | 是 | 下载的配置信息。 | 289 290**返回值:** 291 292| 类型 | 说明 | 293| --------------------- | ---------------------------------- | 294| Promise\<[DownloadProfileResult](#downloadprofileresult14)\> | Promise对象,返回下载配置文件的结果。 | 295 296**错误码:** 297 298| 错误码ID | 错误信息 | 299| --------------------- | ---------------------------------- | 300| 201 | Permission denied. | 301| 202 | Non-system applications use system APIs. | 302| 401 | Parameter error. Possible causes: <br/>1. Mandatory parameters are left unspecified. <br/> 2. Incorrect parameter types. <br/>3. Invalid parameter value.| 303| 801 | Capability not supported. | 304|3120001| Service connection failed. | 305|3120002| System internal error. | 306 307**示例:** 308 309```ts 310import { BusinessError } from '@kit.BasicServicesKit'; 311import { eSIM } from '@kit.TelephonyKit'; 312 313let profile: eSIM.DownloadableProfile={ 314 activationCode:'1', 315 confirmationCode:'1', 316 carrierName:'test', 317 accessRules:[{ 318 certificateHashHexStr:'test', 319 packageName:'com.example.testcoreservice', 320 accessType:0 321 }] 322}; 323 324let configuration: eSIM.DownloadConfiguration = { 325 switchAfterDownload: true, 326 forceDisableProfile: true, 327 isAlowPpr: true, 328}; 329 330eSIM.downloadProfile(0, 0, profile, configuration).then((data: eSIM.DownloadProfileResult) => { 331 console.log(`downloadProfile, DownloadProfileResult: data->${JSON.stringify(data)}`); 332}).catch((err: BusinessError) => { 333 console.error(`downloadProfile, DownloadProfileResult: err->${JSON.stringify(err)}`); 334}); 335``` 336 337## eSIM.getEuiccProfileInfoList<sup>14+</sup> 338 339getEuiccProfileInfoList\(slotId: number\): Promise\<GetEuiccProfileInfoListResult\> 340 341获取配置文件信息列表。使用Promise异步回调。 342 343**系统接口:** 此接口为系统接口。 344 345**需要权限**: ohos.permission.GET_TELEPHONY_ESIM_STATE 346 347**系统能力**:SystemCapability.Telephony.CoreService.Esim 348 349**参数:** 350 351| 参数名 | 类型 | 必填 | 说明 | 352| ------ | ------ | ----- | ----- | 353| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 354 355**返回值:** 356 357| 类型 | 说明 | 358| --------------------- | ---------------------------------- | 359| Promise\<[GetEuiccProfileInfoListResult](#geteuiccprofileinfolistresult14)\> | Promise对象,返回配置文件信息列表。 | 360 361**错误码:** 362 363| 错误码ID | 错误信息 | 364| --------------------- | ---------------------------------- | 365| 201 | Permission denied. | 366| 202 | Non-system applications use system APIs. | 367| 401 | Parameter error. Possible causes: <br/>1. Mandatory parameters are left unspecified. <br/> 2. Incorrect parameter types. <br/>3. Invalid parameter value.| 368| 801 | Capability not supported. | 369|3120001| Service connection failed. | 370|3120002| System internal error. | 371 372**示例:** 373 374```ts 375import { BusinessError } from '@kit.BasicServicesKit'; 376import { eSIM } from '@kit.TelephonyKit'; 377 378eSIM.getEuiccProfileInfoList(0).then((data: eSIM.GetEuiccProfileInfoListResult) => { 379 console.log(`getEuiccProfileInfoList, GetEuiccProfileInfoListResult: data->${JSON.stringify(data)}`); 380}).catch((err: BusinessError) => { 381 console.error(`getEuiccProfileInfoList, GetEuiccProfileInfoListResult: err->${JSON.stringify(err)}`); 382}); 383``` 384 385## eSIM.getEuiccInfo<sup>14+</sup> 386 387getEuiccInfo\(slotId: number\): Promise\<EuiccInfo\>; 388 389获取eUICC信息。使用Promise异步回调。 390 391**系统接口:** 此接口为系统接口。 392 393**需要权限**: ohos.permission.GET_TELEPHONY_ESIM_STATE 394 395**系统能力**:SystemCapability.Telephony.CoreService.Esim 396 397**参数:** 398 399| 参数名 | 类型 | 必填 | 说明 | 400| ------ | ------ | ----- | ----- | 401| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 402 403**返回值:** 404 405| 类型 | 说明 | 406| --------------------- | ---------------------------------- | 407| Promise\<[EuiccInfo](#euiccinfo14)\> | Promise对象,返回eUicc信息。 | 408 409**错误码:** 410 411| 错误码ID | 错误信息 | 412| --------------------- | ---------------------------------- | 413| 201 | Permission denied. | 414| 202 | Non-system applications use system APIs. | 415| 401 | Parameter error. Possible causes: <br/>1. Mandatory parameters are left unspecified. <br/> 2. Incorrect parameter types. <br/>3. Invalid parameter value.| 416| 801 | Capability not supported. | 417|3120001| Service connection failed. | 418|3120002| System internal error. | 419 420**示例:** 421 422```ts 423import { BusinessError } from '@kit.BasicServicesKit'; 424import { eSIM } from '@kit.TelephonyKit'; 425 426eSIM.getEuiccInfo(0).then((data: eSIM.EuiccInfo) => { 427 console.log(`getEuiccInfo, EuiccInfo: data->${JSON.stringify(data)}`); 428}).catch((err: BusinessError) => { 429 console.error(`getEuiccInfo, EuiccInfo: err->${JSON.stringify(err)}`); 430}); 431``` 432 433## eSIM.deleteProfile<sup>14+</sup> 434 435deleteProfile\(slotId: number, iccid: string\): Promise\<ResultCode\>; 436 437删除配置文件。使用Promise异步回调。 438 439**系统接口:** 此接口为系统接口。 440 441**需要权限**: ohos.permission.SET_TELEPHONY_ESIM_STATE 442 443**系统能力**:SystemCapability.Telephony.CoreService.Esim 444 445**参数:** 446 447| 参数名 | 类型 | 必填 | 说明 | 448| ------ | ------ | ----- | ----- | 449| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 450| iccid | string | 是 | 配置文件的Id | 451 452**返回值:** 453 454| 类型 | 说明 | 455| --------------------- | ---------------------------------- | 456| Promise\<[ResultCode](#resultcode14)\> | Promise对象,返回删除配置文件的结果码。 | 457 458**错误码:** 459 460| 错误码ID | 错误信息 | 461| --------------------- | ---------------------------------- | 462| 201 | Permission denied. | 463| 202 | Non-system applications use system APIs. | 464| 401 | Parameter error. Possible causes: <br/>1. Mandatory parameters are left unspecified. <br/> 2. Incorrect parameter types. <br/>3. Invalid parameter value.| 465| 801 | Capability not supported. | 466|3120001| Service connection failed. | 467|3120002| System internal error. | 468 469**示例:** 470 471```ts 472import { BusinessError } from '@kit.BasicServicesKit'; 473import { eSIM } from '@kit.TelephonyKit'; 474 475eSIM.deleteProfile(0, testId).then(() => { 476 console.log(`deleteProfile invoking succeeded.`); 477}).catch((err: BusinessError) => { 478 console.error(`deleteProfile, ErrorState: err->${JSON.stringify(err)}`); 479}); 480``` 481 482## eSIM.switchToProfile<sup>14+</sup> 483 484switchToProfile\(slotId: number, portIndex: number, iccid: string, 485 forceDisableProfile: boolean\): Promise\<ResultCode\>; 486 487切换到(启用)给定的配置文件。使用Promise异步回调。 488 489**系统接口:** 此接口为系统接口。 490 491**需要权限**: ohos.permission.SET_TELEPHONY_ESIM_STATE 492 493**系统能力**:SystemCapability.Telephony.CoreService.Esim 494 495**参数:** 496 497| 参数名 | 类型 | 必填 | 说明 | 498| ------ | ------ | ----- | ----- | 499| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 500| portIndex | number | 是 | 插槽的端口索引。 | 501| iccid | string | 是 | 配置文件的Id。 | 502| forceDisableProfile | boolean | 是 | 如果值为true,则必须停用活动SIM才能执行操作。如果值为false,则提示用户首先同意此操作。| 503 504**返回值:** 505 506| 类型 | 说明 | 507| --------------------- | ---------------------------------- | 508| Promise\<[ResultCode](#resultcode14)\> | Promise对象,返回切换配置文件的结果码。 | 509 510**错误码:** 511 512| 错误码ID | 错误信息 | 513| --------------------- | ---------------------------------- | 514| 201 | Permission denied. | 515| 202 | Non-system applications use system APIs. | 516| 401 | Parameter error. Possible causes: <br/>1. Mandatory parameters are left unspecified. <br/> 2. Incorrect parameter types. <br/>3. Invalid parameter value.| 517| 801 | Capability not supported. | 518|3120001| Service connection failed. | 519|3120002| System internal error. | 520 521**示例:** 522 523```ts 524import { BusinessError } from '@kit.BasicServicesKit'; 525import { eSIM } from '@kit.TelephonyKit'; 526 527eSIM.switchToProfile(0, 0, testId, true).then(() => { 528 console.log(`switchToProfile invoking succeeded.`); 529}).catch((err: BusinessError) => { 530 console.error(`switchToProfile, ErrorState: err->${JSON.stringify(err)}`); 531}); 532``` 533 534## eSIM.setProfileNickname<sup>14+</sup> 535 536setProfileNickname\(slotId: number, iccid: string, nickname: string\): Promise\<ResultCode\>; 537 538设置给定配置文件的昵称。使用Promise异步回调。 539 540**系统接口:** 此接口为系统接口。 541 542**需要权限**: ohos.permission.SET_TELEPHONY_ESIM_STATE 543 544**系统能力**:SystemCapability.Telephony.CoreService.Esim 545 546**参数:** 547 548| 参数名 | 类型 | 必填 | 说明 | 549| ------ | ------ | ----- | ----- | 550| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 551| iccid | string | 是 | 配置文件的Id。 | 552| nickname | string | 是 | 昵称。 | 553 554**返回值:** 555 556| 类型 | 说明 | 557| --------------------- | ---------------------------------- | 558| Promise\<[ResultCode](#resultcode14)\> | Promise对象,返回设置昵称的结果码。 | 559 560**错误码:** 561 562| 错误码ID | 错误信息 | 563| --------------------- | ---------------------------------- | 564| 201 | Permission denied. | 565| 202 | Non-system applications use system APIs. | 566| 401 | Parameter error. Possible causes: <br/>1. Mandatory parameters are left unspecified. <br/> 2. Incorrect parameter types. <br/>3. Invalid parameter value.| 567| 801 | Capability not supported. | 568|3120001| Service connection failed. | 569|3120002| System internal error. | 570 571**示例:** 572 573```ts 574import { BusinessError } from '@kit.BasicServicesKit'; 575import { eSIM } from '@kit.TelephonyKit'; 576 577eSIM.setProfileNickname(0, testId, testName).then(() => { 578 console.log(`setProfileNickname invoking succeeded.`); 579}).catch((err: BusinessError) => { 580 console.error(`setProfileNickname, ErrorState: err->${JSON.stringify(err)}`); 581}); 582``` 583 584## eSIM.resetMemory<sup>14+</sup> 585 586resetMemory\(slotId: number, options?: ResetOption\): Promise\<ResultCode\>; 587 588清除所有特定配置文件并重置eUICC。使用Promise异步回调。 589 590**系统接口:** 此接口为系统接口。 591 592**需要权限**: ohos.permission.SET_TELEPHONY_ESIM_STATE 593 594**系统能力**:SystemCapability.Telephony.CoreService.Esim 595 596**参数:** 597 598| 参数名 | 类型 | 必填 | 说明 | 599| ------ | ------ | ----- | ----- | 600| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 601| options | [ResetOption](#resetoption14) | 否 | 重置状态。 | 602 603**返回值:** 604 605| 类型 | 说明 | 606| --------------------- | ---------------------------------- | 607| Promise\<[ResultCode](#resultcode14)\> | Promise对象,返回重置的结果码。 | 608 609**错误码:** 610 611| 错误码ID | 错误信息 | 612| --------------------- | ---------------------------------- | 613| 201 | Permission denied. | 614| 202 | Non-system applications use system APIs. | 615| 401 | Parameter error. Possible causes: <br/>1. Mandatory parameters are left unspecified. <br/> 2. Incorrect parameter types. <br/>3. Invalid parameter value.| 616| 801 | Capability not supported. | 617|3120001| Service connection failed. | 618|3120002| System internal error. | 619 620**示例:** 621 622```ts 623import { BusinessError } from '@kit.BasicServicesKit'; 624import { eSIM } from '@kit.TelephonyKit'; 625 626eSIM.resetMemory(0).then(() => { 627 console.log(`resetMemory invoking succeeded.`); 628}).catch((err: BusinessError) => { 629 console.error(`resetMemory, ErrorState: err->${JSON.stringify(err)}`); 630}); 631``` 632 633## eSIM.reserveProfilesForFactoryRestore<sup>14+</sup> 634 635reserveProfilesForFactoryRestore\(slotId: number\): Promise\<ResultCode\>; 636 637恢复出厂设置,并保留profiles。使用Promise异步回调。 638 639**系统接口:** 此接口为系统接口。 640 641**需要权限**: ohos.permission.SET_TELEPHONY_ESIM_STATE 642 643**系统能力**:SystemCapability.Telephony.CoreService.Esim 644 645**参数:** 646 647| 参数名 | 类型 | 必填 | 说明 | 648| ------ | ------ | ----- | ----- | 649| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 650 651**返回值:** 652 653| 类型 | 说明 | 654| --------------------- | ---------------------------------- | 655| Promise\<[ResultCode](#resultcode14)\> | Promise对象,返回恢复出厂设置的结果码。 | 656 657**错误码:** 658 659| 错误码ID | 错误信息 | 660| --------------------- | ---------------------------------- | 661| 201 | Permission denied. | 662| 202 | Non-system applications use system APIs. | 663| 401 | Parameter error. Possible causes: <br/>1. Mandatory parameters are left unspecified. <br/> 2. Incorrect parameter types. <br/>3. Invalid parameter value.| 664| 801 | Capability not supported. | 665|3120001| Service connection failed. | 666|3120002| System internal error. | 667 668**示例:** 669 670```ts 671import { BusinessError } from '@kit.BasicServicesKit'; 672import { eSIM } from '@kit.TelephonyKit'; 673 674eSIM.reserveProfilesForFactoryRestore(0).then(() => { 675 console.log(`reserveProfilesForFactoryRestore invoking succeeded.`); 676}).catch((err: BusinessError) => { 677 console.error(`reserveProfilesForFactoryRestore, ErrorState: err->${JSON.stringify(err)}`); 678}); 679``` 680 681## eSIM.setDefaultSmdpAddress<sup>14+</sup> 682 683setDefaultSmdpAddress\(slotId: number, address: string\): Promise\<ResultCode\>; 684 685设置或更新eUICC中存储的默认SM-DP+地址。使用Promise异步回调。 686 687**系统接口:** 此接口为系统接口。 688 689**需要权限**: ohos.permission.SET_TELEPHONY_ESIM_STATE 690 691**系统能力**:SystemCapability.Telephony.CoreService.Esim 692 693**参数:** 694 695| 参数名 | 类型 | 必填 | 说明 | 696| ------ | ------ | ----- | ----- | 697| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 698| address | string | 是 | 要设置的默认SM-DP+地址。 | 699 700**返回值:** 701 702| 类型 | 说明 | 703| --------------------- | ---------------------------------- | 704| Promise\<[ResultCode](#resultcode14)\> | Promise对象,返回设置默认SM-DP+地址的结果码。 | 705 706**错误码:** 707 708| 错误码ID | 错误信息 | 709| --------------------- | ---------------------------------- | 710| 201 | Permission denied. | 711| 202 | Non-system applications use system APIs. | 712| 401 | Parameter error. Possible causes: <br/>1. Mandatory parameters are left unspecified. <br/> 2. Incorrect parameter types. <br/>3. Invalid parameter value.| 713| 801 | Capability not supported. | 714|3120001| Service connection failed. | 715|3120002| System internal error. | 716 717**示例:** 718 719```ts 720import { BusinessError } from '@kit.BasicServicesKit'; 721import { eSIM } from '@kit.TelephonyKit'; 722 723eSIM.setDefaultSmdpAddress(0, testAddress).then(() => { 724 console.log(`setDefaultSmdpAddress invoking succeeded.`); 725}).catch((err: BusinessError) => { 726 console.error(`setDefaultSmdpAddress, ErrorState: err->${JSON.stringify(err)}`); 727}); 728``` 729 730## eSIM.getDefaultSmdpAddress<sup>14+</sup> 731 732getDefaultSmdpAddress\(slotId: number\): Promise\<string\>; 733 734获取存储在eUICC中的默认SM-DP+地址。使用Promise异步回调。 735 736**系统接口:** 此接口为系统接口。 737 738**需要权限**: ohos.permission.GET_TELEPHONY_ESIM_STATE 739 740**系统能力**:SystemCapability.Telephony.CoreService.Esim 741 742**参数:** 743 744| 参数名 | 类型 | 必填 | 说明 | 745| ------ | ------ | ----- | ----- | 746| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 747 748**返回值:** 749 750| 类型 | 说明 | 751| --------------------- | ---------------------------------- | 752| Promise\<string\> | Promise对象,返回SM-DP+地址。 | 753 754**错误码:** 755 756| 错误码ID | 错误信息 | 757| --------------------- | ---------------------------------- | 758| 201 | Permission denied. | 759| 202 | Non-system applications use system APIs. | 760| 401 | Parameter error. Possible causes: <br/>1. Mandatory parameters are left unspecified. <br/> 2. Incorrect parameter types. <br/>3. Invalid parameter value.| 761| 801 | Capability not supported. | 762|3120001| Service connection failed. | 763|3120002| System internal error. | 764 765**示例:** 766 767```ts 768import { BusinessError } from '@kit.BasicServicesKit'; 769import { eSIM } from '@kit.TelephonyKit'; 770 771eSIM.getDefaultSmdpAddress(0).then((data: string) => { 772 console.log(`getDefaultSmdpAddress, result: data->${JSON.stringify(data)}`); 773}).catch((err: BusinessError) => { 774 console.error(`getDefaultSmdpAddress, ErrorState: err->${JSON.stringify(err)}`); 775}); 776``` 777 778## eSIM.cancelSession<sup>14+</sup> 779 780cancelSession\(slotId: number, transactionId: string, cancelReason: CancelReason\): Promise\<ResultCode\>; 781 782取消会话。使用Promise异步回调。 783 784**系统接口:** 此接口为系统接口。 785 786**需要权限**: ohos.permission.SET_TELEPHONY_ESIM_STATE 787 788**系统能力**:SystemCapability.Telephony.CoreService.Esim 789 790**参数:** 791 792| 参数名 | 类型 | 必填 | 说明 | 793| ------ | ------ | ----- | ----- | 794| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | 795| transactionId | string | 是 | 业务ID。| 796| cancelReason | [CancelReason](#cancelreason14) | 是 | 取消会话的原因。| 797 798**返回值:** 799 800| 类型 | 说明 | 801| --------------------- | ---------------------------------- | 802| Promise\<[ResultCode](#resultcode14)\> | Promise对象,返回取消会话的结果码。 | 803 804**错误码:** 805 806| 错误码ID | 错误信息 | 807| --------------------- | ---------------------------------- | 808| 201 | Permission denied. | 809| 202 | Non-system applications use system APIs. | 810| 401 | Parameter error. Possible causes: <br/>1. Mandatory parameters are left unspecified. <br/> 2. Incorrect parameter types. <br/>3. Invalid parameter value.| 811| 801 | Capability not supported. | 812|3120001| Service connection failed. | 813|3120002| System internal error. | 814 815**示例:** 816 817```ts 818import { BusinessError } from '@kit.BasicServicesKit'; 819import { eSIM } from '@kit.TelephonyKit'; 820 821eSIM.cancelSession(0, testId, CancelReason::CANCEL_REASON_END_USER_REJECTION).then((data: string) => { 822 console.log(`cancelSession, result: data->${JSON.stringify(data)}`); 823}).catch((err: BusinessError) => { 824 console.error(`cancelSession execution failed: err->${JSON.stringify(err)}`); 825}); 826``` 827 828## AccessRule<sup>14+</sup> 829 830访问规则。 831 832**系统接口:** 此接口为系统接口。 833 834**系统能力**:SystemCapability.Telephony.CoreService.Esim 835 836| 名称 | 类型 | 必填 | 说明 | 837| ----- | ----- | ----- | -----| 838| certificateHashHexStr | string | 是 | 证书哈希的十六进制字符串。 | 839| packageName | string | 是 | 规则适用的程序包名称。 | 840| accessType | number | 是 | 规则的类型。 | 841 842## DownloadableProfile<sup>14+</sup> 843 844可下载的配置文件。 845 846**系统接口:** 此接口为系统接口。 847 848**系统能力**:SystemCapability.Telephony.CoreService.Esim 849 850| 名称 | 类型 | 必填 | 说明 | 851| ----- | ----- | ----- | -----| 852| activationCode | string | 是 | 激活码,对于不基于激活码的配置文件,可能为空。 | 853| confirmationCode | string | 否 | 确认码。 | 854| carrierName | string | 否 | 订阅名称。 | 855| accessRules | Array\<AccessRule> | 否 | 访问规则数组。 | 856 857## GetDownloadableProfileMetadataResult<sup>14+</sup> 858 859获取可下载配置文件的元数据。 860 861**系统接口:** 此接口为系统接口。 862 863**系统能力**:SystemCapability.Telephony.CoreService.Esim 864 865| 名称 | 类型 | 必填 | 说明 | 866| ----- | ----- | ----- | -----| 867| downloadableProfile | DownloadableProfile | 是 | 可下载的配置文件信息。 | 868| pprType | number | 是 | 配置文件策略规则类型。 | 869| pprFlag | boolean | 是 | 配置文件策略规则标记。 | 870| iccid | string | 是 | 配置文件的iccId。 | 871| serviceProviderName | string | 是 | 配置文件的服务提供商名称。 | 872| profileName | string | 是 | 配置文件名称。 | 873| profileClass | ProfileClass | 是 | 配置文件类。 | 874| solvableErrors | SolvableErrors | 是 | 可解决的错误。 | 875| responseResult | ResultCode | 是 | 操作结果码。 | 876 877## GetDownloadableProfilesResult<sup>14+</sup> 878 879获取默认可下载配置文件的列表。 880 881**系统接口:** 此接口为系统接口。 882 883**系统能力**:SystemCapability.Telephony.CoreService.Esim 884 885| 名称 | 类型 | 必填 | 说明 | 886| ----- | ----- | ----- | -----| 887| responseResult | ResultCode | 是 | 返回操作结果码。 | 888| downloadableProfiles | Array\<DownloadableProfile> | 是 | 可下载配置文件数组。 | 889 890## DownloadProfileResult<sup>14+</sup> 891 892下载配置文件的结果。 893 894**系统接口:** 此接口为系统接口。 895 896**系统能力**:SystemCapability.Telephony.CoreService.Esim 897 898| 名称 | 类型 | 必填 | 说明 | 899| ----- | ----- | ----- | -----| 900| responseResult | ResultCode | 是 | 操作结果码。 | 901| solvableErrors | SolvableErrors | 是 | 可解决错误。 | 902| cardId | number | 是 | 获取卡Id。 | 903 904## GetEuiccProfileInfoListResult<sup>14+</sup> 905 906获取配置文件信息列表。 907 908**系统接口:** 此接口为系统接口。 909 910**系统能力**:SystemCapability.Telephony.CoreService.Esim 911 912| 名称 | 类型 | 必填 | 说明 | 913| ----- | ----- | ----- | -----| 914| responseResult |ResultCode | 是 | 返回操作结果码。 | 915| profiles | Array\<EuiccProfile> | 是 | 配置文件数组。 | 916| isRemovable | boolean | 是 | 获取eUICC是否可移除。| 917 918## OperatorId<sup>14+</sup> 919 920获取eUICC芯片/设备的相关信息。 921 922**系统接口:** 此接口为系统接口。 923 924**系统能力**:SystemCapability.Telephony.CoreService.Esim 925 926| 名称 | 类型 | 必填 | 说明 | 927| ----- | ----- | ----- | -----| 928| mcc | string | 是 | 移动国家代码。 | 929| mnc | string | 是 | 网络代码。 | 930| gid1 | string | 是 | 组id级别1。 | 931| gid2 | string | 是 | 组id级别2。 | 932 933## EuiccProfile<sup>14+</sup> 934 935配置文件信息。 936 937**系统接口:** 此接口为系统接口。 938 939**系统能力**:SystemCapability.Telephony.CoreService.Esim 940 941| 名称 | 类型 | 必填 | 说明 | 942| ----- | ----- | ----- | -----| 943| iccid | string | 是 | 配置文件的iccId。 | 944| nickName | string | 是 | 昵称。 | 945| serviceProviderName | string | 是 | 配置文件的服务提供商名称。 | 946| profileName | string | 是 | 配置文件名称。 | 947| state | ProfileState | 是 | 配置文件的状态。 | 948| profileClass | ProfileClass | 是 | 配置文件类。 | 949| operatorId | OperatorId | 是 | 配置文件的操作ID。| 950| policyRules | PolicyRules | 是 | 配置文件策略。 | 951| accessRules | Array\<AccessRule> | 是 | 配置文件规则。 | 952 953## EuiccInfo<sup>14+</sup> 954 955euicc信息。 956 957**系统接口:** 此接口为系统接口。 958 959**系统能力**:SystemCapability.Telephony.CoreService.Esim 960 961| 名称 | 类型 | 必填 | 说明 | 962| ----- | ----- | ----- | -----| 963| osVersion | string | 是 | 系统版本。 | 964 965## ResetOption<sup>14+</sup> 966 967重置状态。 968 969**系统接口:** 此接口为系统接口。 970 971**系统能力**:SystemCapability.Telephony.CoreService.Esim 972 973| 名称 | 值 | 说明 | 974| ----- | ----- | ----- | 975|DELETE_OPERATIONAL_PROFILES | 1 | 删除所有操作配置文件。 | 976|DELETE_FIELD_LOADED_TEST_PROFILES | 1 << 1 | 删除所有字段加载的测试配置文件。 | 977|RESET_DEFAULT_SMDP_ADDRESS | 1 << 2 | 重置默认SM-DP+地址。 | 978 979## OsuStatus<sup>14+</sup> 980 981操作系统升级状态。 982 983**系统接口:** 此接口为系统接口。 984 985**系统能力**:SystemCapability.Telephony.CoreService.Esim 986 987| 名称 | 值 | 说明 | 988| ----- | ----- | ----- | 989|EUICC_UPGRADE_IN_PROGRESS | 1 | 升级中。 | 990|EUICC_UPGRADE_FAILED | 2 | 升级失败。 | 991|EUICC_UPGRADE_SUCCESSFUL | 3 | 升级成功。 | 992|EUICC_UPGRADE_ALREADY_LATEST | 4 | 当前为最新版本,无需升级 。| 993|EUICC_UPGRADE_SERVICE_UNAVAILABLE | 5 | 升级服务不可用。 | 994 995## ResultCode<sup>14+</sup> 996 997结果码。 998 999**系统接口:** 此接口为系统接口。 1000 1001**系统能力**:SystemCapability.Telephony.CoreService.Esim 1002 1003| 名称 | 值 | 说明 | 1004| ----- | ----- | ----- | 1005| RESULT_SOLVABLE_ERRORS | -2 | 用户必须解决可解决的错误。 | 1006| RESULT_MUST_DISABLE_PROFILE | -1 | 必须禁用活动配置文件才能执行操作。 | 1007| RESULT_OK | 0 | 成功。 | 1008| RESULT_GET_EID_FAILED | 201 | 获取EID失败。 | 1009| RESULT_ACTIVATION_CODE_CHANGED | 203 | 最终用户确认后,激活码将被更改。 | 1010| RESULT_ACTIVATION_CODE_INVALID | 204 | 激活码无效。 | 1011| RESULT_SMDP_ADDRESS_INVALID | 205 | SM-DP+服务器地址非法。 | 1012| RESULT_EUICC_INFO_INVALID | 206 | 无效的eUICC信息。 | 1013| RESULT_TLS_HANDSHAKE_FAILED | 207 | TLS握手失败。 | 1014| RESULT_CERTIFICATE_IO_ERROR | 208 | 证书网络连接错误。 | 1015| RESULT_CERTIFICATE_RESPONSE_TIMEOUT | 209 | 证书地址无效或响应超时。 | 1016| RESULT_AUTHENTICATION_FAILED | 210 | 鉴权失败。 | 1017| RESULT_RESPONSE_HTTP_FAILED | 211 | HTTP响应失败。 | 1018| RESULT_CONFIRMATION_CODE_INCORRECT | 212 | 确认码不正确。 | 1019| RESULT_EXCEEDED_CONFIRMATION_CODE_TRY_LIMIT | 213 | 已达到最大确认码尝试次数。 | 1020| RESULT_NO_PROFILE_ON_SERVER | 214 | 服务器上没有可供下载的配置文件。 | 1021| RESULT_TRANSACTION_ID_INVALID | 215 | 事务ID无效。 | 1022| RESULT_SERVER_ADDRESS_INVALID | 216 | 服务器地址无效。 | 1023| RESULT_GET_BOUND_PROFILE_PACKAGE_FAILED | 217 | 获取BPP失败。 | 1024| RESULT_USER_CANCEL_DOWNLOAD | 218 | 最终用户取消下载。 | 1025| RESULT_SERVER_UNAVAILABLE | 220 | 运营商服务器不可用。 | 1026| RESULT_PROFILE_NON_DELETE | 223 | PPR禁止删除文件。 | 1027| RESULT_SMDP_ADDRESS_INCORRECT | 226 | 认证响应服务器地址不匹配。 | 1028| RESULT_ANALYZE_AUTHENTICATION_SERVER_RESPONSE_FAILED | 228 | 解析服务器身份验证响应错误。 | 1029| RESULT_ANALYZE_AUTHENTICATION_CLIENT_RESPONSE_FAILED | 229 | 解析客户端身份验证响应错误。 | 1030| RESULT_ANALYZE_AUTHENTICATION_CLIENT_MATCHING_ID_REFUSED | 231 | 由于匹配ID被拒绝,解析客户端身份验证响应错误。 | 1031| RESULT_PROFILE_TYPE_ERROR_AUTHENTICATION_STOPPED | 233 | 由于配置文件类型中的错误,身份验证已停止。 | 1032| RESULT_CARRIER_SERVER_REFUSED_ERRORS | 249 | 运营商服务器拒绝原因码为3.8的错误。 | 1033| RESULT_CERTIFICATE_INVALID | 251 | 证书无效。 | 1034| RESULT_OUT_OF_MEMORY | 263 | 由于内存不足,配置文件安装失败。 | 1035| RESULT_PPR_FORBIDDEN | 268 | PPR规则禁止此操作。 | 1036| RESULT_PPR_NOT_MATCH | 276 | 与PPR约束不匹配。 | 1037| RESULT_PROFILE_EID_INVALID | 284 | 此eSIM配置文件已被使用或无效。 | 1038| RESULT_DOWNLOAD_TIMEOUT | 287 | 下载超时。 | 1039| RESULT_SGP_22_OTHER | 400 | SGP.22中定义的其他错误。 | 1040 1041## CancelReason<sup>14+</sup> 1042 1043取消会话的原因。 1044 1045**系统接口:** 此接口为系统接口。 1046 1047**系统能力**:SystemCapability.Telephony.CoreService.Esim 1048 1049| 名称 | 值 | 说明 | 1050| ----- | ----- | ----- | 1051|CANCEL_REASON_END_USER_REJECTION | 0 | 最终用户已拒绝下载。 | 1052|CANCEL_REASON_POSTPONED | 1 | 下载已推迟,稍后可以重新启动。 | 1053|CANCEL_REASON_TIMEOUT | 2 | 下载已超时,稍后可以重新启动。 | 1054|CANCEL_REASON_PPR_NOT_ALLOWED | 3 | 由于eUICC上的授权表或其他已安装的配置文件不允许其策略规则,因此无法安装。 | 1055 1056## ProfileState<sup>14+</sup> 1057 1058配置文件状态。 1059 1060**系统接口:** 此接口为系统接口。 1061 1062**系统能力**:SystemCapability.Telephony.CoreService.Esim 1063 1064| 名称 | 值 | 说明 | 1065| ----- | ----- | ----- | 1066|PROFILE_STATE_UNSPECIFIED | -1 | 未设置配置文件状态。 | 1067|PROFILE_STATE_DISABLED | 0 | 禁用配置文件。 | 1068|PROFILE_STATE_ENABLED | 1 | 已启用配置文件。 | 1069 1070## ProfileClass<sup>14+</sup> 1071 1072配置文件类。 1073 1074**系统接口:** 此接口为系统接口。 1075 1076**系统能力**:SystemCapability.Telephony.CoreService.Esim 1077 1078| 名称 | 值 | 说明 | 1079| ----- | ----- | ----- | 1080|PROFILE_CLASS_UNSPECIFIED | -1 | 未设置配置文件类。 | 1081|PROFILE_CLASS_TEST | 0 | 测试配置文件。 | 1082|PROFILE_CLASS_PROVISIONING | 1 | 预加载在eUICC上的配置文件。 | 1083|PROFILE_CLASS_OPERATIONAL | 2 | 可预加载或下载的操作配置文件。 | 1084 1085## PolicyRules<sup>14+</sup> 1086 1087配置文件的策略规则。 1088 1089**系统接口:** 此接口为系统接口。 1090 1091**系统能力**:SystemCapability.Telephony.CoreService.Esim 1092 1093| 名称 | 值 | 说明 | 1094| ----- | ----- | ----- | 1095|POLICY_RULE_DISABLE_NOT_ALLOWED | 1 | 启用此配置文件后,将无法禁用。 | 1096|POLICY_RULE_DELETE_NOT_ALLOWED | 1 << 1 | 无法删除此配置文件。 | 1097|POLICY_RULE_DISABLE_AND_DELETE | 1 << 2 | 禁用后应删除此配置文件。 | 1098 1099## SolvableErrors<sup>14+</sup> 1100 1101可解决错误码。 1102 1103**系统接口:** 此接口为系统接口。 1104 1105**系统能力**:SystemCapability.Telephony.CoreService.Esim 1106 1107| 名称 | 值 | 说明 | 1108| ----- | ----- | ----- | 1109|SOLVABLE_ERROR_NEED_CONFIRMATION_CODE | 1 << 0 | 下载过程需要用户输入确认码。 | 1110|SOLVABLE_ERROR_NEED_POLICY_RULE | 1 << 1 | 下载过程需要用户同意才能允许配置文件策略规则。| 1111 1112## DownloadConfiguration<sup>14+</sup> 1113 1114下载过程中的属性配置。 1115 1116**系统接口:** 此接口为系统接口。 1117 1118**系统能力**:SystemCapability.Telephony.CoreService.Esim 1119 1120| 名称 | 类型 | 必填 | 说明 | 1121| ----- | ----- | ----- | -----| 1122|switchAfterDownload | boolean | 是 | 下载成功后是否启用配置文件。| 1123|forceDisableProfile | boolean | 是 | 是否强制禁用模板。 | 1124|isPprAllowed | boolean | 是 | 指定用户是否允许服务提供商在被告知其限制后实施此配置文件策略规则。| 1125