• Home
Name Date Size #Lines LOC

..--

AppScope/06-May-2025-3633

entry/06-May-2025-1,5531,383

hvigor/06-May-2025-2522

screenshots/devices/06-May-2025-

.gitignoreD06-May-2025142 1111

README.mdD06-May-20251.1 KiB2010

README_zh.mdD06-May-20253.5 KiB7652

build-profile.json5D06-May-20251 KiB4341

hvigorfile.tsD06-May-2025158 21

hvigorwD06-May-20252.1 KiB6228

hvigorw.batD06-May-20252 KiB7356

oh-package.json5D06-May-2025816 2725

ohosTest.mdD06-May-2025516 66

README.md

1# SIM Management
2
3## Introduction
4
5This sample shows how to use the SIM management service to manage SIM settings, including the ICCID, default voice service, ISO country code, home PLMN, service provider name, and GID1.
6
7### Usage
8
91. Check the SIM card area. If a SIM card is inserted into SIM card slot 1, the SIM card 1 area is displayed in blue; if no SIM card is inserted, the SIM card 1 area is displayed in white. The case is the same for SIM card 2 area.
10
112. Click the SIM card 1 area. A dialog showing the ICCID, ISO country code, home PLMN, service provider name, and GID1 of SIM card 1 will be displayed. If you click the SIM card 1 area again, the dialog disappears. The case is the same for SIM card 2 area.
12
133. Buttons for the default active SIM card are in blue background. Currently, only the default active SIM card is displayed. The function of changing the default active SIM card is not supported.
14
154. The call transfer function is not supported currently, and therefore the button is not responsive.
16
17### Constraints
18
19This sample can only be run on standard-system devices.
20

README_zh.md

1# SIM卡管理
2
3### 介绍
4
5本示例使用[sim](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-telephony-kit/js-apis-sim.md)相关接口,展示了电话服务中SIM卡相关功能,包含SIM卡的服务提供商、ISO国家码、归属PLMN号信息,以及默认语音卡功能。
6
7### 效果预览
8
9|主页|
10|--------------------------------|
11|![](screenshots/devices/main.png)|
12
13使用说明:
14
151.若SIM卡槽1插入SIM卡则SIM卡1区域显示为蓝色,否则默认为白色。
16
172.点击SIM卡1区域,弹窗显示SIM卡1的相关信息,再次点击面板消失。
18
193.默认拨号的SIM卡其按钮背景色为蓝色,目前只展示默认拨号的SIM卡,更改默认拨号卡功能暂不支持。
20
214.呼叫转移界面功能暂不支持,故点击按钮无实际操作。
22
23### 工程目录
24```
25entry/src/main/ets/
26|---common
27|   |---CallView.ets                    // 呼叫
28|   |---InfoView.ets                    // 信息
29|   |---Show.ets                        // 展示
30|   |---ShowView.ets                    // 展示页面
31|   |---SimView.ets                     // sim页面
32|---entryability
33|   |---EntryAbility.ts
34|---model
35|   |---AbilityContextController.ts     // 弹窗
36|   |---Logger.ts                       // 日志工具
37|---pages
38|   |---Index.ets                       // 首页
39```
40### 具体实现
41
42* 该示例主要通过hasSimCard方法获取指定卡槽SIM卡是否插卡,getSimState方法获取指定卡槽的SIM卡状态,SimState方法判断SIM卡状态,isSimActive方法获取指定卡槽SIM卡是否激活,getSimSpn方法获取指定卡槽SIM卡的服务提供商名称,getISOCountryCodeForSim方法获取指定卡槽SIM卡的ISO国家码,getSimOperatorNumeric方法获取指定卡槽SIM卡的归属PLMN号,getDefaultVoiceSlotId方法获取默认语音业务的卡槽ID等开发电话服务的相关功能。
43* 源码链接:[InfoView.ets](entry/src/main/ets/common/InfoView.ets),[ShowView.ets](entry/src/main/ets/common/ShowView.ets),[SimView.ets](entry/src/main/ets/common/SimView.ets)
44* 接口参考:[@ohos.telephony.sim](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-telephony-kit/js-apis-sim.md)
45
46### 相关权限
47
48电话权限:[ohos.permission.GET_TELEPHONY_STATE](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionget_telephony_state)
49
50### 依赖
51
52不涉及。
53
54### 约束与限制
55
561.本示例暂不支持双卡功能,且需要插入SIM卡,目前该功能仅支持部分机型。
57
582.本示例仅支持在标准系统上运行。
59
603.本示例已适配API version 9版本SDK,版本号:3.2.11.9。
61
624.本示例需要使用DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400, built on April 7, 2023)及以上版本才可编译运行。
63
645.本示例所配置的权限ohos.permission.GET_TELEPHONY_STATE为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md)65
66### 下载
67
68如需单独下载本工程,执行如下命令:
69```
70git init
71git config core.sparsecheckout true
72echo code/BasicFeature/Telephony/SimManager/ > .git/info/sparse-checkout
73git remote add origin https://gitee.com/openharmony/applications_app_samples.git
74git pull origin master
75
76```