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