harmony 鸿蒙@ohos.telephony.esim (eSIM卡管理)

  • 2025-06-16
  • 浏览 (3)

@ohos.telephony.esim (eSIM卡管理)

eSIM卡管理模块提供了eSIM卡管理的基础能力,包括获取指定卡槽是否支持eSIM功能,如果支持则允许用户添加单个配置文件。

说明:

本模块首批接口从API version 18开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。

导入模块

import { eSIM } from '@kit.TelephonyKit';

eSIM.isSupported18+

isSupported(slotId: number): boolean

获取指定卡槽是否支持eSIM功能。

系统能力:SystemCapability.Telephony.CoreService.Esim

参数:

参数名 类型 必填 说明
slotId number 卡槽ID。
- 0:卡槽1。
- 1:卡槽2。

返回值:

类型 说明
boolean 返回指定卡槽是否支持eSIM功能,如果支持返回true。

错误码:

以下错误码的详细介绍请参见通用错误码说明文档

错误码ID 错误信息
401 Invalid parameter value.
3120001 Service connection failed.
3120002 System internal error.

示例:

import { eSIM } from '@kit.TelephonyKit';

let isSupported: boolean = eSIM.isSupported(0);
console.log(`the esim is Supported:` + isSupported);

eSIM.addProfile18+

addProfile(profile: DownloadableProfile): Promise<boolean>

通过该接口拉起下载界面,允许用户添加单个配置文件。使用Promise异步回调。

需要权限:ohos.permission.SET_TELEPHONY_ESIM_STATE_OPEN

系统能力:SystemCapability.Telephony.CoreService.Esim

参数:

参数名 类型 必填 说明
profile DownloadableProfile 可下载的配置文件信息。

返回值:

类型 说明
Promise<boolean> 以Promise形式返回最终用户添加单个配置文件的结果。返回true为成功,false为失败。

错误码:

以下错误码的详细介绍请参见通用错误码说明文档

错误码ID 错误信息
201 Permission denied.
401 Invalid parameter value.
801 Capability not supported.
3120001 Service connection failed.
3120002 System internal error.

示例:

import { BusinessError } from '@kit.BasicServicesKit';
import { eSIM } from '@kit.TelephonyKit';

let profile: eSIM.DownloadableProfile = {
  activationCode:'1',
  confirmationCode:'1',
  carrierName:'test',
  accessRules:[{
    certificateHashHexStr:'test',
    packageName:'com.example.testcoreservice',
    accessType:0
  }]
};

eSIM.addProfile(profile).then(() => {
    console.log(`addProfile invoking succeeded.`);
}).catch((err: BusinessError) => {
    console.error(`addProfile, promise: err->${JSON.stringify(err)}`);
});

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Telephony Kit(蜂窝通信服务)

harmony 鸿蒙Telephony_NetworkState

harmony 鸿蒙电话子系统错误码

harmony 鸿蒙js-apis-call-sys

harmony 鸿蒙@ohos.telephony.call (拨打电话)

harmony 鸿蒙@ohos.telephony.esim (eSIM卡管理) (系统接口)

harmony 鸿蒙@ohos.telephony.observer (observer)(系统接口)

harmony 鸿蒙@ohos.telephony.observer (observer)

harmony 鸿蒙@ohos.telephony.radio (网络搜索)(系统接口)

harmony 鸿蒙@ohos.telephony.radio (网络搜索)

0  赞