• Home
Name Date Size #Lines LOC

..--

figures/12-May-2024-

frameworks/12-May-2024-14,24012,373

interfaces/12-May-2024-5,2213,078

sa_profile/12-May-2024-4628

services/12-May-2024-38,85132,650

telephonyres/12-May-2024-7266

test/12-May-2024-5,3513,666

utils/12-May-2024-776535

BUILD.gnD12-May-20247.4 KiB169157

LICENSED12-May-20249.9 KiB177150

README.mdD12-May-202414 KiB202158

README_zh.mdD12-May-202413.5 KiB211163

bundle.jsonD12-May-20243.8 KiB104103

telephony.gniD12-May-2024695 2117

README.md

1# Telephony Core Service<a name="EN-US_TOPIC_0000001152064913"></a>
2
3-   [Introduction](#section117mcpsimp)
4-   [Directory Structure](#section129mcpsimp)
5-   [Constraints](#section133mcpsimp)
6-   [Available APIs](#section139mcpsimp)
7    -   [APIs for the SIM Card Service](#section142mcpsimp)
8    -   [APIs for the Network Search Service](#section198mcpsimp)
9
10-   [Usage Guidelines](#section370mcpsimp)
11    -   [Network Search](#section393mcpsimp)
12    -   [SIM Card](#section402mcpsimp)
13
14-   [Repositories Involved](#section409mcpsimp)
15
16## Introduction<a name="section117mcpsimp"></a>
17
18The telephony core service initializes the RIL Manager, SIM card module, and network search module, and provides access to the RIL Adapter service.
19
20You can implement communication with the RIL Adapter by registering the callback service and implement communication between modules by subscribing to callbacks.
21
22**Figure  1**  Architecture of the telephony core service<a name="fig5700192716219"></a>
23
24
25 ![](figures/en-us_architecture-of-the-core_service-module.png)
26
27As shown in the preceding figure, the telephony core service consists of the SIM card service, network search service, and RIL Manager service.
28
29-   SIM card service: Provides services including SIM card initialization, file read/write, loading status notification, and single-SIM/dual-SIM control. These services implement functions such as SIM card status query, SIM card management, SIM card control, STK, contact storage, and SMS storage.
30-   Network search service: Provides services including network registration and network status acquisition. These services offer functions such as network registration, network mode query, radio status query, network search management, signal strength query, cell management, registration status management, and time and time zone setting.
31-   RIL Manager service: Provides the proactive callback service and query result callback service.
32
33## Directory Structure<a name="section129mcpsimp"></a>
34
35```shell
36/base/telphony/core_service
37├── figures                # Resource of Readme
38├── frameworks             # Framework Level Directory
39│   ├── js
40│   └── native
41├── interfaces             # APIs
42│   ├── innerkits          # Internal APIs
43│   └── kits               # External APIs (such as JS APIs)
44├── sa_profile             # Core service startup file directory
45├── services               # Implementation of the telephony core service
46│   ├── etc                # Driver script directory for core services
47│   ├── include
48│   ├── network_search     # Search Network Service Code Directory
49│   ├── sim                # SIM card service code directory
50│   ├── src
51│   └── tel_ril            # Core service and RIL Adapter communication code directory
52├── test                   # Unit test related code
53│   └── unittest
54└── utils
55    ├── common             # Core service log print directory
56    ├── log
57    └── preferences
58```
59
60## Constraints<a name="section133mcpsimp"></a>
61
62-   Programming language: C++、JavaScript
63-   In terms of software, this module needs to work with the RIL adapter service \(ril\_adapter\) and status registration service \(state\_registry\).
64-   In terms of hardware, the accommodating device must be equipped with a modem and a SIM card capable of independent cellular communication.
65
66## Available APIs<a name="section139mcpsimp"></a>
67
68The telephony core service module needs to provide APIs for related modules, including the SIM card, network search modules.
69
70### APIs for the SIM Card Service<a name="section142mcpsimp"></a>
71
72| Interface name                                                     | Interface description                                                    | Required permissions                            |
73| ------------------------------------------------------------ | ----------------------------------------------------------- | ----------------------------------- |
74| function getSimState(slotId: number, callback: AsyncCallback\<SimState>): void; | Get the SIM card status of the specified slot                                     | None                                  |
75| function getSimGid1(slotId: number, callback: AsyncCallback\<string>): void; | Get the GID1 of the SIM card in the specified slot (Group Identifier Level 1)           | ohos.permission.GET_TELEPHONY_STATE |
76| function getSimIccId(slotId: number, callback: AsyncCallback\<string>): void; | Get the ICCID (Integrate Circuit Card Identity) of the SIM card in the specified slot | ohos.permission.GET_TELEPHONY_STATE |
77| function getISOCountryCodeForSim(slotId: number, callback: AsyncCallback\<string>): void; | Get the ISO country code of the SIM card in the specified slot                                | None                                  |
78| function getSimOperatorNumeric(slotId: number, callback: AsyncCallback\<string>): void; | Get the PLMN (Public Land Mobile Network) number of the SIM card in the specified slot | None                                  |
79| function getSimSpn(slotId: number, callback: AsyncCallback\<string>): void; | Get the SPN (Service Provider Name) of the SIM card of the specified slot       | None                                  |
80| function getDefaultVoiceSlotId(callback: AsyncCallback\<number>): void; | Get the default card slot of the voice service                                    | None                                  |
81| function isSimActive(slotId: number, callback: AsyncCallback\<boolean>): void | Check whether the SIM card in the specified slot is activated                           | None                                  |
82| function hasSimCard(slotId: number, callback: AsyncCallback\<boolean>): void  | Check whether the SIM card is inserted into the specified card slot                             | None                                  |
83| function getSimTelephoneNumber(slotId: number, callback: AsyncCallback\<string>): void | Get the MSISDN (Mobile Station Integrated Services Digital Network) of the SIM card in the specified slot|ohos.permission.GET_TELEPHONY_STATE |
84| function getVoiceMailIdentifier(slotId: number, callback: AsyncCallback\<string>): void | Get the voicemail identification of the SIM card in the specified slot | ohos.permission.GET_TELEPHONY_STATE | ohos.permission.GET_TELEPHONY_STATE |
85| function getVoiceMailNumber(slotId: number, callback: AsyncCallback\<string>): void | Get the voice mailbox number of the SIM card in the specified slot | ohos.permission.GET_TELEPHONY_STATE |
86| function getCardType(slotId: number, callback: AsyncCallback\<CardType>): void | Check whether the application (caller) has been granted operator privileges | None |
87| function hasOperatorPrivileges(slotId: number, callback: AsyncCallback\<boolean>): void | Get the type of SIM card in the specified slot | None |
88| function getMaxSimCount(): number | Get the maximum number of SIM cards that can be used simultaneously on the device, that is, the maximum number of SIM card slots. | None |
89| function getPrimarySlotId(callback: AsyncCallback\<number>): void | Get the default primary slot ID | None |
90
91
92### APIs for the Network Search Service<a name="section198mcpsimp"></a>
93
94| Interface name                                                     | Interface description                                                    | Required permissions                            |
95| ------------------------------------------------------------ | ----------------------------------------------------------- | ----------------------------------- |
96| function getRadioTech(slotId: number, callback: AsyncCallback\<{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology}>): void; | Get the current access technology of the specified card slot | ohos.permission.GET_NETWORK_INFO    |
97| function getSignalInformation(slotId: number, callback: AsyncCallback\<Array\<SignalInformation>>): void; | Get the signal list of the specified card slot     | None                                  |
98| function getNetworkState(slotId: number, callback: AsyncCallback\<NetworkState>): void; | Get the network status of the specified card slot     | ohos.permission.GET_NETWORK_INFO    |
99| function getISOCountryCodeForNetwork(slotId: number, callback: AsyncCallback\<string>): void; | Get the network country code of the specified card slot   | None                                  |
100| function getNetworkSearchInformation(slotId: number, callback: AsyncCallback\<NetworkSearchResult>): void; | Get the manual search results of the specified card slot | ohos.permission.GET_TELEPHONY_STATE |
101| function getNetworkSelectionMode(slotId: number, callback: AsyncCallback\<NetworkSelectionMode>): void; | Get the network selection mode of the specified card slot     | None                                  |
102| function setNetworkSelectionMode(options: NetworkSelectionModeOptions, callback: AsyncCallback\<void>): void; | Set the network selection mode of the specified card slot     | ohos.permission.SET_TELEPHONY_STATE |
103| function isRadioOn(callback: AsyncCallback\<boolean>): void; | Determine whether Radio is turned on          | ohos.permission.GET_NETWORK_INFO    |
104| function turnOnRadio(callback: AsyncCallback\<void>): void;  | Turn on Radio                  | ohos.permission.SET_TELEPHONY_STATE |
105| function turnOffRadio(callback: AsyncCallback\<void>): void; | Turn off Radio                  | ohos.permission.SET_TELEPHONY_STATE |
106| function getOperatorName(slotId: number, callback: AsyncCallback\<string>): void; | Get the operator name of the specified card slot   | None                                  |
107| function setPreferredNetwork(slotId: number, networkMode: PreferredNetworkMode, callback: AsyncCallback\<void>): void; | Set the preferred network mode of the specified card slot | None                                  |
108| function getPreferredNetwork(slotId: number, callback: AsyncCallback\<PreferredNetworkMode>): void; | Get the preferred network mode of the specified card slot | None                                  |
109| function getCellInformation(slotId: number, callback: AsyncCallback<Array\<CellInformation>>) | Get cell information list           | ohos.permission.LOCATION            |
110| function sendUpdateCellLocationRequest(callback: AsyncCallback\<void>) | Request cell location               | ohos.permission.LOCATION            |
111| function getIMEI(slotId: number, callback: AsyncCallback\<string>) | Get Imei                   | ohos.permission.GET_TELEPHONY_STATE |
112| function getMeId(slotId: number, callback: AsyncCallback\<string>) | Get Meid                   | ohos.permission.GET_TELEPHONY_STATE |
113| function getUniqueDeviceId(slotId: number, callback: AsyncCallback\<string>) | Get the unique identification code of the device         | ohos.permission.GET_TELEPHONY_STATE |
114| function getNrOptionMode(slotId: number, callback: AsyncCallback\<NrOptionMode>) | Get 5G mode                 | ohos.permission.GET_TELEPHONY_STATE |
115| function isNrSupported: boolean;                             | Whether to support 5g network             | None                                  |
116
117>**NOTE:**
118>The RIL Manager does not provide external APIs and can only be called by modules of the Telephony subsystem.
119
120## Usage Guidelines<a name="section370mcpsimp"></a>
121
122### Network Search<a name="section393mcpsimp"></a>
123
124The function of obtaining the network status is used as an example. The process is as follows:
125
1261.  Query the SIM card in the slot specified by  **slotId**. If  **slotId**  is not set, information about the primary card is queried by default.
1272.  Call the  **GetNetworkStatus**  method in callback or Promise mode.
1283.  Obtain the network status information. The  **GetNetworkStatus**  method works in asynchronous mode. The execution result is returned through the callback.
129
130    ```js
131    import radio from "@ohos.telephony.radio";
132
133    // Set the value of slotId.
134    let slotId = 0;
135
136    // Call the API in callback mode.
137    radio.GetNetworkStatus(slotId, (err, value) => {
138      if (err) {
139        // If the API call failed, err is not empty.
140        console.error(`failed to GetNetworkStatus because ${err.message}`);
141        return;
142      }
143      // If the API call succeeded, err is empty.
144      console.log(`success to GetNetworkStatus: ${value}`);
145    });
146
147    // Call the API in Promise mode.
148    let promise = radio.GetNetworkStatus(slotId);
149    promise.then((value) => {
150      // The API call succeeded.
151      console.log(`success to GetNetworkStatus: ${value}`);
152    }).catch((err) => {
153      // The API call failed.
154      console.error(`failed to GetNetworkStatus because ${err.message}`);
155    });
156    ```
157
158
159### SIM Card<a name="section402mcpsimp"></a>
160
161The function of querying the status of a specified SIM card is used as an example. The process is as follows:
162
1631.  Set the value of  **slotId**.
1642.  Call the  **getSimState**  method in callback or Promise mode to obtain the SIM card status information.
1653.  This method works in asynchronous mode. The execution result is returned through the callback.
166
167    ```js
168    import sim from "@ohos.telephony.sim";
169
170    // Set the value of slotId.
171    let slotId = 0;
172
173    // Call the API in callback mode.
174    sim.getSimState(slotId, (err, value) => {
175      if (err) {
176        // If the API call failed, err is not empty.
177        console.error(`failed to getSimState because ${err.message}`);
178        return;
179      }
180      // If the API call succeeded, err is empty.
181      console.log(`success to getSimState: ${value}`);
182    });
183
184    // Call the API in Promise mode.
185    let promise = sim.getSimState(slotId);
186    promise.then((value) => {
187      // The API call succeeded.
188      console.log(`success to getSimState: ${value}`);
189    }).catch((err) => {
190      // The API call failed.
191      console.error(`failed to getSimState because ${err.message}`);
192    });
193    ```
194
195
196## Repositories Involved<a name="section409mcpsimp"></a>
197
198[Telephony](https://gitee.com/openharmony/docs/blob/master/en/readme/telephony.md)
199
200**telephony_core_service**
201
202[telephony_sms_mms](https://gitee.com/openharmony/telephony_sms_mms/blob/master/README.md)

README_zh.md

1# 核心服务<a name="ZH-CN_TOPIC_0000001152064913"></a>
2
3-   [简介](#section117mcpsimp)
4-   [目录](#section129mcpsimp)
5-   [约束](#section133mcpsimp)
6-   [接口说明](#section139mcpsimp)
7    -   [SIM卡对外提供的接口](#section142mcpsimp)
8    -   [搜网服务对外提供的接口](#section198mcpsimp)
9
10-   [使用说明](#section370mcpsimp)
11    -   [搜网](#section393mcpsimp)
12    -   [SIM卡](#section402mcpsimp)
13
14-   [相关仓](#section409mcpsimp)
15
16## 简介<a name="section117mcpsimp"></a>
17
18核心服务模块主要功能是初始化SIM卡服务、搜网服务和RIL管理,以及获取RIL Adapter服务。
19
20通过注册回调服务,实现与RIL Adapter进行通信;通过发布订阅,来实现与各功能模块的通信。
21
22**图 1**  核心服务架构图<a name="fig5700192716219"></a>
23
24
25 ![](figures/zh-cn_architecture-of-the-core_service-module.png)
26
27上图示中核心服务关联的业务服务包括SIM卡服务、搜网服务、RIL通信管理。
28
29-   SIM卡服务:主要是SIM卡初始化,文件读写,加载状态通知,单双卡控制,包括SIM卡状态查询、SIM卡管理、SIM卡控制、STK、联系人存储、短信存储。
30-   搜网服务:主要是网络注册,网络状态获取,包括网络注册、网络模式查询、Radio状态查询、搜网管理、信号强度查询、小区管理、驻网管理、时间时区更新。
31-   RIL管理:提供主动回调服务,查询结果回调服务等。
32
33## 目录<a name="section129mcpsimp"></a>
34
35```sh
36/base/telphony/core_service
37├── figures                # Readme资源文件
38├── frameworks             # 框架层目录
39│   ├── js
40│   └── native
41├── interfaces             # 接口目录
42│   ├── innerkits          # 部件间的内部接口
43│   └── kits               # 对应用提供的接口(例如JS接口)
44├── sa_profile             # 核心服务的启动文件目录
45├── services               # 核心服务实现代码目录
46│   ├── etc                # 核心服务的驱动脚本目录
47│   ├── include
48│   ├── network_search     # 搜网服务代码目录
49│   ├── sim                # SIM卡服务代码目录
50│   ├── src
51│   └── tel_ril            # 核心服务与RIL Adapter通信代码目录
52├── test                   # 单元测试相关代码
53│   └── unittest
54└── utils
55    ├── common             # 核心服务日志打印目录
56    ├── log
57    └── preferences
58```
59
60## 约束<a name="section133mcpsimp"></a>
61
62-   开发语言:C++ 、Java Script。
63-   软件约束:需要与以下服务配合使用:RIL适配(ril\_adapter),状态注册服务(state\_registry)。
64-   硬件约束:需要搭载的设备支持以下硬件:可以进行独立蜂窝通信的Modem以及SIM卡。
65
66## 接口说明<a name="section139mcpsimp"></a>
67
68核心服务模块需要提供SIM卡,搜网相关模块的接口。
69
70###  SIM卡对外提供的接口<a name="section142mcpsimp"></a>
71
72| 接口名称                                                     | 接口描述                                                    | 所需权限                            |
73| ------------------------------------------------------------ | ----------------------------------------------------------- | ----------------------------------- |
74| function getSimState(slotId: number, callback: AsyncCallback\<SimState>): void; | 获取指定卡槽的SIM卡状态                                     | 无                                  |
75| function getSimGid1(slotId: number, callback: AsyncCallback\<string>): void; | 获取指定卡槽SIM卡的GID1(Group Identifier Level 1)           | ohos.permission.GET_TELEPHONY_STATE |
76| function getSimIccId(slotId: number, callback: AsyncCallback\<string>): void; | 获取指定卡槽SIM卡的ICCID(Integrate Circuit Card Identity) | ohos.permission.GET_TELEPHONY_STATE |
77| function getISOCountryCodeForSim(slotId: number, callback: AsyncCallback\<string>): void; | 获取指定卡槽SIM卡的ISO国家码                                | 无                                  |
78| function getSimOperatorNumeric(slotId: number, callback: AsyncCallback\<string>): void; | 获取指定卡槽SIM卡的归属PLMN(Public Land Mobile Network)号 | 无                                  |
79| function getSimSpn(slotId: number, callback: AsyncCallback\<string>): void; | 获取指定卡槽SIM卡的运营商SPN(Service Provider Name)       | 无                                  |
80| function getDefaultVoiceSlotId(callback: AsyncCallback\<number>): void; | 获取语音业务的默认卡卡槽                                    | 无                                  |
81| function isSimActive(slotId: number, callback: AsyncCallback\<boolean>): void | 检查指定卡槽的SIM卡是否激活                           | 无                                  |
82| function hasSimCard(slotId: number, callback: AsyncCallback\<boolean>): void  | 检查SIM卡是否插入指定卡槽                             | 无                                  |
83| function getSimTelephoneNumber(slotId: number, callback: AsyncCallback\<string>): void | 获取指定卡槽SIM卡的MSISDN(Mobile Station Integrated Services Digital Network)|ohos.permission.GET_TELEPHONY_STATE |
84| function getVoiceMailIdentifier(slotId: number, callback: AsyncCallback\<string>): void | 获取指定卡槽SIM卡语音信箱的身份标识 | ohos.permission.GET_TELEPHONY_STATE |
85| function getVoiceMailNumber(slotId: number, callback: AsyncCallback\<string>): void | 获取指定卡槽SIM卡的语音邮箱号码 | ohos.permission.GET_TELEPHONY_STATE |
86| function getCardType(slotId: number, callback: AsyncCallback\<CardType>): void | 获取指定卡槽SIM卡的类型 | 无 |
87| function hasOperatorPrivileges(slotId: number, callback: AsyncCallback\<boolean>): void | 检查应用(调用者)是否已被授予运营商权限 | 无 |
88| function getMaxSimCount(): number | 获取设备上可同时使用的最大SIM卡数,即最大SIM卡槽数。 | 无 |
89
90完整的JS API说明以及实例代码请参考:[SIM卡管理](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/js-reference/apis/js-apis-sim.md)91
92### 搜网服务对外提供的接口<a name="section198mcpsimp"></a>
93
94| 接口名称                                                     | 接口描述                      | 所需权限                            |
95| ------------------------------------------------------------ | ----------------------------- | ----------------------------------- |
96| function getRadioTech(slotId: number, callback: AsyncCallback\<{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology}>): void; | 获取指定卡槽的当前接入技术    | ohos.permission.GET_NETWORK_INFO    |
97| function getSignalInformation(slotId: number, callback: AsyncCallback\<Array\<SignalInformation>>): void; | 获取指定卡槽的信号列表        | 无                                  |
98| function getNetworkState(slotId: number, callback: AsyncCallback\<NetworkState>): void; | 获取指定卡槽的网络状态        | ohos.permission.GET_NETWORK_INFO    |
99| function getISOCountryCodeForNetwork(slotId: number, callback: AsyncCallback\<string>): void; | 获取指定卡槽的网络国家码      | 无                                  |
100| function getNetworkSearchInformation(slotId: number, callback: AsyncCallback\<NetworkSearchResult>): void; | 获取指定卡槽的手动搜网结果    | ohos.permission.GET_TELEPHONY_STATE |
101| function getNetworkSelectionMode(slotId: number, callback: AsyncCallback\<NetworkSelectionMode>): void; | 获取指定卡槽的选网模式        | 无                                  |
102| function setNetworkSelectionMode(options: NetworkSelectionModeOptions, callback: AsyncCallback\<void>): void; | 设置指定卡槽的选网模式        | ohos.permission.SET_TELEPHONY_STATE |
103| function isRadioOn(callback: AsyncCallback\<boolean>): void; | 判断主卡Radio是否打开         | ohos.permission.GET_NETWORK_INFO    |
104| function isRadioOn(slotId: number, callback: AsyncCallback\<boolean>): void; | 判断指定卡槽位的Radio是否打开 | ohos.permission.GET_NETWORK_INFO    |
105| function turnOnRadio(callback: AsyncCallback\<void>): void;  | 开启主卡Radio                 | ohos.permission.SET_TELEPHONY_STATE |
106| function turnOnRadio(slotId: number, callback: AsyncCallback\<void>): void; | 开启指定卡槽位的Radio         | ohos.permission.SET_TELEPHONY_STATE |
107| function turnOffRadio(callback: AsyncCallback\<void>): void; | 关闭主卡Radio                 | ohos.permission.SET_TELEPHONY_STATE |
108| function turnOffRadio(slotId: number, callback: AsyncCallback\<void>): void; | 关闭指定卡槽位的Radio         | ohos.permission.SET_TELEPHONY_STATE |
109| function getOperatorName(slotId: number, callback: AsyncCallback\<string>): void; | 获取指定卡槽的运营商名称      | 无                                  |
110| function setPreferredNetwork(slotId: number, networkMode: PreferredNetworkMode, callback: AsyncCallback\<void>): void; | 设置指定卡槽的优选网络模式    | 无                                  |
111| function getPreferredNetwork(slotId: number, callback: AsyncCallback\<PreferredNetworkMode>): void; | 获取指定卡槽的优选网络模式    | 无                                  |
112| function getCellInformation(slotId: number, callback: AsyncCallback<Array\<CellInformation>>) | 获取小区信息列表              | ohos.permission.LOCATION            |
113| function sendUpdateCellLocationRequest(callback: AsyncCallback\<void>) | 请求小区位置                  | ohos.permission.LOCATION            |
114| function getIMEI(slotId: number, callback: AsyncCallback\<string>) | 获取Imei                      | ohos.permission.GET_TELEPHONY_STATE |
115| function getMEID(slotId: number, callback: AsyncCallback\<string>) | 获取Meid                      | ohos.permission.GET_TELEPHONY_STATE |
116| function getUniqueDeviceId(slotId: number, callback: AsyncCallback\<string>) | 获取设备唯一标识码            | ohos.permission.GET_TELEPHONY_STATE |
117| function getNrOptionMode(slotId: number, callback: AsyncCallback\<NrOptionMode>) | 获取5G模式                    | ohos.permission.GET_TELEPHONY_STATE |
118| function isNrSupported: boolean;                             | 是否支持5g网络                | 无                                  |
119
120
121完整的JS API说明以及实例代码请参考:[网络搜索](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/js-reference/apis/js-apis-radio.md)122
123**说明:**
124
125>RIL管理不对外暴露接口,由电话服务子系统其他各个模块调用。
126
127## 使用说明<a name="section370mcpsimp"></a>
128
129### 搜网<a name="section393mcpsimp"></a>
130
131获取网络状态接口调用流程及示例代码:
132
1331.  指定查询的slotId,若不指定默认查询主卡信息。
1342.  可以通过callback或者Promise的方式调用getNetworkState方法,返回网络状态信息。
1353.  该接口为异步接口,相关执行结果会从callback中返回。
136
137    ```js
138    import radio from "@ohos.telephony.radio";
139
140    // 参数赋值
141    let slotId = 0;
142
143    // 调用接口【callback方式】
144    radio.getNetworkState(slotId, (err, value) => {
145      if (err) {
146        // 接口调用失败,err非空
147        console.error(`failed to getNetworkState because ${err.message}`);
148        return;
149      }
150      // 接口调用成功,err为空
151      console.log(`success to getNetworkState: ${value}`);
152    });
153
154    // 调用接口【Promise方式】
155    let promise = radio.getNetworkState(slotId);
156    promise.then((value) => {
157      // 接口调用成功,此处可以实现成功场景分支代码。
158      console.log(`success to getNetworkState: ${value}`);
159    }).catch((err) => {
160      // 接口调用失败,此处可以实现失败场景分支代码。
161      console.error(`failed to getNetworkState because ${err.message}`);
162    });
163    ```
164
165
166### SIM卡<a name="section402mcpsimp"></a>
167
168查询指定SIM卡的状态接口调用流程及示例代码:
169
1701.  指定查询的slotId。
1712.  可以通过callback或者Promise的方式调用getSimState方法,返回卡状态信息。
1723.  该接口为异步接口,相关执行结果会从callback中返回。
173
174    ```js
175    import sim from "@ohos.telephony.sim";
176
177    // 参数赋值
178    let slotId = 0;
179
180    // 调用接口【callback方式】
181    sim.getSimState(slotId, (err, value) => {
182      if (err) {
183        // 接口调用失败,err非空
184        console.error(`failed to getSimState because ${err.message}`);
185        return;
186      }
187      // 接口调用成功,err为空
188      console.log(`success to getSimState: ${value}`);
189    });
190
191    // 调用接口【Promise方式】
192    let promise = sim.getSimState(slotId);
193    promise.then((value) => {
194      // 接口调用成功,此处可以实现成功场景分支代码。
195      console.log(`success to getSimState: ${value}`);
196    }).catch((err) => {
197      // 接口调用失败,此处可以实现失败场景分支代码。
198      console.error(`failed to getSimState because ${err.message}`);
199    });
200    ```
201
202
203## 相关仓<a name="section409mcpsimp"></a>
204
205[电话服务子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E7%94%B5%E8%AF%9D%E6%9C%8D%E5%8A%A1%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
206
207**telephony\_core\_service**
208
209[telephony\_sms\_mms](https://gitee.com/openharmony/telephony_sms_mms/blob/master/README_zh.md)
210
211[telephony\_ril\_adapter](https://gitee.com/openharmony/telephony_ril_adapter/blob/master/README_zh.md)