Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
figures/ | 12-May-2024 | - | ||||
frameworks/ | 12-May-2024 | - | 18,630 | 16,314 | ||
interfaces/ | 12-May-2024 | - | 7,245 | 3,900 | ||
sa_profile/ | 12-May-2024 | - | 46 | 28 | ||
services/ | 12-May-2024 | - | 43,609 | 36,957 | ||
telephonyres/ | 12-May-2024 | - | 430 | 423 | ||
test/ | 12-May-2024 | - | 18,756 | 13,513 | ||
utils/ | 12-May-2024 | - | 1,436 | 1,069 | ||
BUILD.gn | D | 12-May-2024 | 7.9 KiB | 181 | 170 | |
LICENSE | D | 12-May-2024 | 9.9 KiB | 177 | 150 | |
README.md | D | 12-May-2024 | 16.2 KiB | 217 | 168 | |
README_zh.md | D | 12-May-2024 | 14.8 KiB | 220 | 169 | |
bundle.json | D | 12-May-2024 | 5.4 KiB | 137 | 136 | |
core_service_aafwk.gni | D | 12-May-2024 | 869 | 18 | 16 | |
hisysevent.yaml | D | 12-May-2024 | 6.8 KiB | 158 | 121 | |
telephony.gni | D | 12-May-2024 | 695 | 21 | 17 |
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 - [SimManager APIs](#section142mcpsimp) 8 - [NetworkSearchManager APIs](#section198mcpsimp) 9 10- [Usage Guidelines](#section370mcpsimp) 11 - [Network Search](#section393mcpsimp) 12 - [SIM Card Management](#section402mcpsimp) 13 14- [Repositories Involved](#section409mcpsimp) 15 16## Introduction<a name="section117mcpsimp"></a> 17 18The telephony core service initializes the SimManager, NetworkSearchManager, and TelRilManager modules, 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  26 27As shown in the preceding figure, the telephony core service consists of the following: 28 29- SimManager: 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- NetworkSearchManager: provides services including network registration and network status acquisition. These services offer functions such as network registration, network mode query, IMS network status reporting, radio service status query, radio service management, signal strength query, cell management, registration status management, and time and time zone setting. 31- TelRilManager: provides the proactive callback service and query result callback service. 32 33## Directory Structure<a name="section129mcpsimp"></a> 34 35```sh 36/base/telphony/core_service 37├── figures # Figures of readme files 38├── frameworks # Framework layer 39│ ├── js 40│ └── native 41├── interfaces # APIs 42│ ├── innerkits # Internal APIs 43| | ├── ims # IMS network status reporting APIs 44│ └── kits # External APIs \(such as JS APIs\) 45├── sa_profile # SA profile 46├── services # Implementation of the telephony core service 47│ ├── etc # Telephony core service driver scripts 48| ├── ims_service_interaction # IMS service interaction (for status reporting) 49│ ├── include 50│ ├── network_search # Network search service 51│ ├── sim # SIM card service 52│ ├── src 53│ └── tel_ril # Telephony core service and RIL Adapter communication 54├─ test # Test code 55│ └── unittest 56└── utils 57 ├── common # Telephony core service log 58 ├── log 59 └── preferences 60``` 61 62## Constraints<a name="section133mcpsimp"></a> 63 64- Programming language: C++ and JavaScript. 65- Software constraints: This module must work with the RIL Adapter service \(ril\_adapter\) and state registry service \(state\_registry\). 66- Hardware constraints: The accommodating device must be equipped with a modem and a SIM card capable of independent cellular communication. 67 68## Available APIs<a name="section139mcpsimp"></a> 69 70The telephony core service module needs to provide APIs for related modules, including the SIM card and radio modules. 71 72### SimManager APIs<a name="section142mcpsimp"></a> 73 74| Name | Description | Required Permission | 75| ------------------------------------------------------------ | ----------------------------------------------------------- | ----------------------------------- | 76| function getSimState(slotId: number, callback: AsyncCallback\<SimState>): void; | Obtains the state of the SIM card in a specified slot. | – | 77| function getSimGid1(slotId: number, callback: AsyncCallback\<string>): void; | Obtains the group identifier level 1 \(GID1\) of the SIM card in the specified slot. | ohos.permission.GET_TELEPHONY_STATE | 78| function getSimIccId(slotId: number, callback: AsyncCallback\<string>): void; | Obtains the integrated circuit card identity \(ICCID\) of the SIM card in the specified slot.| ohos.permission.GET_TELEPHONY_STATE | 79| function getISOCountryCodeForSim(slotId: number, callback: AsyncCallback\<string>): void; | Obtains the ISO country code of the SIM card in the specified slot. | – | 80| function getSimOperatorNumeric(slotId: number, callback: AsyncCallback\<string>): void; | Obtains the public land mobile network \(PLMN\) ID of the SIM card in the specified slot. | – | 81| function getSimSpn(slotId: number, callback: AsyncCallback\<string>): void; | Obtains the service provider name \(SPN\) of the SIM card in the specified slot. | – | 82| function getDefaultVoiceSlotId(callback: AsyncCallback\<number>): void; | Obtains the slot of the default SIM card that provides the voice service. | – | 83| function isSimActive(slotId: number, callback: AsyncCallback\<boolean>): void | Checks whether the SIM card in the specified slot is activated. | – | 84| function hasSimCard(slotId: number, callback: AsyncCallback\<boolean>): void | Checks whether the specified slot is populated with a SIM card. | – | 85| function getSimTelephoneNumber(slotId: number, callback: AsyncCallback\<string>): void | Obtains the mobile station integrated services digital network (MSISDN) of the SIM card in the specified slot.|ohos.permission.GET_TELEPHONY_STATE | 86| function getVoiceMailIdentifier(slotId: number, callback: AsyncCallback\<string>): void | Obtains the voice mailbox identifier of the SIM card in the specified slot.| ohos.permission.GET_TELEPHONY_STATE | 87| function getVoiceMailNumber(slotId: number, callback: AsyncCallback\<string>): void | Obtains the voice mailbox number of the SIM card in the specified slot.| ohos.permission.GET_TELEPHONY_STATE | 88| function getCardType(slotId: number, callback: AsyncCallback\<CardType>): void | Obtains the type of the SIM card in the specified slot. | –| 89| function hasOperatorPrivileges(slotId: number, callback: AsyncCallback\<boolean>): void | Checks whether the application (caller) has been granted the operator permission.| –| 90| function getMaxSimCount(): number | Obtains the maximum number of SIM cards, that is, the maximum number of SIM card slots, available on the device.| –| 91 92For details about the complete description of JavaScript APIs and sample code, see [SIM Card Management](https://gitee.com/openharmony/docs/blob/master/en/application-dev/js-reference/apis/js-apis-sim.md). 93 94### NetworkSearchManager APIs<a name="section198mcpsimp"></a> 95 96| Name | Description | Required Permission | 97| ------------------------------------------------------------ | ----------------------------- | ----------------------------------- | 98| function getRadioTech(slotId: number, callback: AsyncCallback\<{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology}>): void; | Obtains the current radio access technology of the SIM card in the specified slot. | ohos.permission.GET_NETWORK_INFO | 99| function getSignalInformation(slotId: number, callback: AsyncCallback\<Array\<SignalInformation>>): void; | Obtains the signal information of the SIM card in the specified slot. | – | 100| function getNetworkState(slotId: number, callback: AsyncCallback\<NetworkState>): void; | Obtains the network status of the SIM card in the specified slot. | ohos.permission.GET_NETWORK_INFO | 101| function getISOCountryCodeForNetwork(slotId: number, callback: AsyncCallback\<string>): void; | Obtains the ISO country code of the SIM card in the specified slot. | – | 102| function getNetworkSearchInformation(slotId: number, callback: AsyncCallback\<NetworkSearchResult>): void; | Obtains the manual network search result of the SIM card in the specified slot. | ohos.permission.GET_TELEPHONY_STATE | 103| function getNetworkSelectionMode(slotId: number, callback: AsyncCallback\<NetworkSelectionMode>): void; | Obtains the network selection mode of the SIM card in the specified slot. | – | 104| function setNetworkSelectionMode(options: NetworkSelectionModeOptions, callback: AsyncCallback\<void>): void; | Sets the network selection mode of the SIM card in the specified slot. | ohos.permission.SET_TELEPHONY_STATE | 105| function isRadioOn(callback: AsyncCallback\<boolean>): void; | Checks whether the radio service is enabled on the primary SIM card. | ohos.permission.GET_NETWORK_INFO | 106| function isRadioOn(slotId: number, callback: AsyncCallback\<boolean>): void; | Checks whether the radio service is enabled on the SIM card in the specified slot.| ohos.permission.GET_NETWORK_INFO | 107| function turnOnRadio(callback: AsyncCallback\<void>): void; | Enables the radio service on the primary SIM card. | ohos.permission.SET_TELEPHONY_STATE | 108| function turnOnRadio(slotId: number, callback: AsyncCallback\<void>): void; | Enables the radio service on the SIM card in the specified slot. | ohos.permission.SET_TELEPHONY_STATE | 109| function turnOffRadio(callback: AsyncCallback\<void>): void; | Disables the radio service on the primary SIM card. | ohos.permission.SET_TELEPHONY_STATE | 110| function turnOffRadio(slotId: number, callback: AsyncCallback\<void>): void; | Disables the radio service on the SIM card in the specified slot. | ohos.permission.SET_TELEPHONY_STATE | 111| function getOperatorName(slotId: number, callback: AsyncCallback\<string>): void; | Obtains the carrier name of the SIM card in the specified slot. | – | 112| function setPreferredNetwork(slotId: number, networkMode: PreferredNetworkMode, callback: AsyncCallback\<void>): void; | Sets the preferred network of the SIM card in the specified slot. | ohos.permission.SET_TELEPHONY_STATE | 113| function getPreferredNetwork(slotId: number, callback: AsyncCallback\<PreferredNetworkMode>): void; | Obtains the preferred network of the SIM card in the specified slot. | ohos.permission.GET_TELEPHONY_STATE | 114| function getCellInformation(slotId: number, callback: AsyncCallback<Array\<CellInformation>>) | Obtains the cell information list. | ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION | 115| function sendUpdateCellLocationRequest(slotId: number, callback: AsyncCallback\<void>) | Requests for a cell location update. | ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION | 116| function getIMEI(slotId: number, callback: AsyncCallback\<string>) | Obtains the international mobile equipment identity (IMEI). | ohos.permission.GET_TELEPHONY_STATE | 117| function getMEID(slotId: number, callback: AsyncCallback\<string>)| Obtains the mobile equipment identifier (MEID). | ohos.permission.GET_TELEPHONY_STATE | 118| function getUniqueDeviceId(slotId: number, callback: AsyncCallback\<string>)| Obtains the unique ID of a device. | ohos.permission.GET_TELEPHONY_STATE | 119| function getNrOptionMode(slotId: number, callback: AsyncCallback\<NrOptionMode>)| Obtains the 5G mode. | – | 120| function isNrSupported: boolean; | Checks whether 5G is supported. | – | 121| function getImsRegInfo(slotId: number, imsType: ImsServiceType, callback: AsyncCallback\<ImsRegInfo>): void; | Gets IMS register status info | ohos.permission.GET_TELEPHONY_STATE | 122| function on(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback: Callback\<ImsRegInfo>): void; | Registers IMS network status callback | ohos.permission.GET_TELEPHONY_STATE | 123| function off(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback?: Callback\<ImsRegInfo>): void; | Unregisters IMS network status callback | ohos.permission.GET_TELEPHONY_STATE | 124 125 126For details about the complete description of JavaScript APIs and sample code, see [Radio](https://gitee.com/openharmony/docs/blob/master/en/application-dev/js-reference/apis/js-apis-radio.md). 127 128**NOTE** 129 130>The RIL Manager does not provide external APIs. It can only be called by modules of the Telephony subsystem. 131 132## Usage Guidelines<a name="section370mcpsimp"></a> 133 134### Network Search<a name="section393mcpsimp"></a> 135 136The function of obtaining the network status is used as an example. The process is as follows: 137 1381. Query the SIM card in the slot specified by **slotId**. If **slotId** is not set, information about the primary card is queried by default. 1392. Call the **getNetworkState** method in callback or promise mode to obtain the network status. 1403. Obtain the SIM card status information. The **getNetworkState** method works in asynchronous mode. The execution result is returned through the callback. 141 142 ```js 143 import radio from "@ohos.telephony.radio"; 144 145 // Set the value of slotId. 146 let slotId = 0; 147 148 // Call the API in callback mode. 149 radio.getNetworkState(slotId, (err, value) => { 150 if (err) { 151 // If the API call fails, err is not empty. 152 console.error(`failed to getNetworkState because ${err.message}`); 153 return; 154 } 155 // If the API call is successful, err is empty. 156 console.log(`success to getNetworkState: ${value}`); 157 }); 158 159 // Call the API in promise mode. 160 let promise = radio.getNetworkState(slotId); 161 promise.then((value) => { 162 // The API call is successful. 163 console.log(`success to getNetworkState: ${value}`); 164 }).catch((err) => { 165 // The API call fails. 166 console.error(`failed to getNetworkState because ${err.message}`); 167 }); 168 ``` 169 170 171### SIM Card Management<a name="section402mcpsimp"></a> 172 173The function of querying the status of a specified SIM card is used as an example. The process is as follows: 174 1751. Set the value of **slotId**. 1762. Call the **getSimState** method in callback or promise mode to obtain the SIM card status. 1773. Obtain the SIM card status information. The **getSimState** method works in asynchronous mode. The execution result is returned through the callback. 178 179 ```js 180 import sim from "@ohos.telephony.sim"; 181 182 // Set the value of slotId. 183 let slotId = 0; 184 185 // Call the API in callback mode. 186 sim.getSimState(slotId, (err, value) => { 187 if (err) { 188 // If the API call fails, err is not empty. 189 console.error(`failed to getSimState because ${err.message}`); 190 return; 191 } 192 // If the API call is successful, err is empty. 193 console.log(`success to getSimState: ${value}`); 194 }); 195 196 // Call the API in promise mode. 197 let promise = sim.getSimState(slotId); 198 promise.then((value) => { 199 // The API call is successful. 200 console.log(`success to getSimState: ${value}`); 201 }).catch((err) => { 202 // The API call fails. 203 console.error(`failed to getSimState because ${err.message}`); 204 }); 205 ``` 206 207 208## Repositories Involved<a name="section409mcpsimp"></a> 209 210[Telephony Subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/%E7%94%B5%E8%AF%9D%E6%9C%8D%E5%8A%A1%E5%AD%90%E7%B3%BB%E7%BB%9F.md) 211 212**telephony\_core\_service** 213 214[telephony\_sms\_mms](https://gitee.com/openharmony/telephony_sms_mms/blob/master/README.md) 215 216[telephony\_ril\_adapter](https://gitee.com/openharmony/telephony_ril_adapter/blob/master/README.md) 217
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  26 27上图示中核心服务关联的业务服务包括SIM卡服务、搜网服务、RIL通信管理。 28 29- SIM卡服务:主要是SIM卡初始化,文件读写,加载状态通知,单双卡控制,包括SIM卡状态查询、SIM卡管理、SIM卡控制、STK、联系人存储、短信存储。 30- 搜网服务:主要是网络注册,网络状态获取,包括网络注册、网络模式查询、IMS网络状态上报、Radio状态查询、搜网管理、信号强度查询、小区管理、驻网管理、时间时区更新。 31- RIL管理:提供主动回调服务,查询结果回调服务等。 32 33## 目录<a name="section129mcpsimp"></a> 34 35```sh 36/base/telephony/core_service 37├── figures # Readme资源文件 38├── frameworks # 框架层目录 39│ ├── js # js相关代码 40│ └── native # native相关代码 41├── interfaces # 接口目录 42│ ├── innerkits # 部件间的内部接口 43│ └── kits # 对应用提供的接口(例如JS接口) 44├── sa_profile # 核心服务的启动文件目录 45├── services # 核心服务实现代码目录 46│ ├── core # 核心服务的核心文件目录 47│ ├── etc # 核心服务的驱动脚本目录 48| ├── ims_service_interaction # IMS网络状态上报实现代码目录 49│ ├── network_search # 搜网服务代码目录 50│ ├── sim # SIM卡服务代码目录 51│ └── tel_ril # 核心服务与RIL Adapter通信代码目录 52├── test # 核心服务测试代码目录 53│ ├── fuzztest # 模糊测试相关代码 54│ └── unittest # 单元测试相关代码 55└── utils # 核心服务工具代码目录 56 ├── common # 核心服务通用工具目录 57 ├── log # 核心服务日志工具目录 58 └── preferences # 核心服务属性偏好工具目录 59``` 60 61## 约束<a name="section133mcpsimp"></a> 62 63- 开发语言:C++ 、Java Script。 64- 软件约束:需要与以下服务配合使用:HDF(drivers\_interface,drivers\_peripheral),RIL适配(ril\_adapter),状态注册服务(state\_registry)。 65- 硬件约束:需要搭载的设备支持以下硬件:可以进行独立蜂窝通信的Modem以及SIM卡。 66 67## 接口说明<a name="section139mcpsimp"></a> 68 69核心服务模块需要提供SIM卡,搜网相关模块的接口。 70 71### SIM卡对外提供的接口<a name="section142mcpsimp"></a> 72 73| 接口名称 | 接口描述 | 所需权限 | 74| ------------------------------------------------------------ | ----------------------------------------------------------- | ----------------------------------- | 75| function getSimState(slotId: number, callback: AsyncCallback\<SimState>): void; | 获取指定卡槽的SIM卡状态 | 无 | 76| function getSimGid1(slotId: number, callback: AsyncCallback\<string>): void; | 获取指定卡槽SIM卡的GID1(Group Identifier Level 1) | ohos.permission.GET_TELEPHONY_STATE | 77| function getSimIccId(slotId: number, callback: AsyncCallback\<string>): void; | 获取指定卡槽SIM卡的ICCID(Integrate Circuit Card Identity) | ohos.permission.GET_TELEPHONY_STATE | 78| function getISOCountryCodeForSim(slotId: number, callback: AsyncCallback\<string>): void; | 获取指定卡槽SIM卡的ISO国家码 | 无 | 79| function getSimOperatorNumeric(slotId: number, callback: AsyncCallback\<string>): void; | 获取指定卡槽SIM卡的归属PLMN(Public Land Mobile Network)号 | 无 | 80| function getSimSpn(slotId: number, callback: AsyncCallback\<string>): void; | 获取指定卡槽SIM卡的运营商SPN(Service Provider Name) | 无 | 81| function getDefaultVoiceSlotId(callback: AsyncCallback\<number>): void; | 获取语音业务的默认卡卡槽 | 无 | 82| function isSimActive(slotId: number, callback: AsyncCallback\<boolean>): void | 检查指定卡槽的SIM卡是否激活 | 无 | 83| function hasSimCard(slotId: number, callback: AsyncCallback\<boolean>): void | 检查SIM卡是否插入指定卡槽 | 无 | 84| function getSimTelephoneNumber(slotId: number, callback: AsyncCallback\<string>): void | 获取指定卡槽SIM卡的MSISDN(Mobile Station Integrated Services Digital Network)|ohos.permission.GET_TELEPHONY_STATE | 85| function getVoiceMailIdentifier(slotId: number, callback: AsyncCallback\<string>): void | 获取指定卡槽SIM卡语音信箱的身份标识 | ohos.permission.GET_TELEPHONY_STATE | 86| function getVoiceMailNumber(slotId: number, callback: AsyncCallback\<string>): void | 获取指定卡槽SIM卡的语音邮箱号码 | ohos.permission.GET_TELEPHONY_STATE | 87| function getCardType(slotId: number, callback: AsyncCallback\<CardType>): void | 获取指定卡槽SIM卡的类型 | 无 | 88| function hasOperatorPrivileges(slotId: number, callback: AsyncCallback\<boolean>): void | 检查应用(调用者)是否已被授予运营商权限 | 无 | 89| function getMaxSimCount(): number | 获取设备上可同时使用的最大SIM卡数,即最大SIM卡槽数。 | 无 | 90 91完整的JS API说明以及实例代码请参考:[SIM卡管理](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-sim.md)。 92 93### 搜网服务对外提供的接口<a name="section198mcpsimp"></a> 94 95| 接口名称 | 接口描述 | 所需权限 | 96| ------------------------------------------------------------ | ----------------------------- | ----------------------------------- | 97| function getRadioTech(slotId: number, callback: AsyncCallback\<{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology}>): void; | 获取指定卡槽的当前接入技术 | ohos.permission.GET_NETWORK_INFO | 98| function getSignalInformation(slotId: number, callback: AsyncCallback\<Array\<SignalInformation>>): void; | 获取指定卡槽的信号列表 | 无 | 99| function getNetworkState(slotId: number, callback: AsyncCallback\<NetworkState>): void; | 获取指定卡槽的网络状态 | ohos.permission.GET_NETWORK_INFO | 100| function getISOCountryCodeForNetwork(slotId: number, callback: AsyncCallback\<string>): void; | 获取指定卡槽的网络国家码 | 无 | 101| function getNetworkSearchInformation(slotId: number, callback: AsyncCallback\<NetworkSearchResult>): void; | 获取指定卡槽的手动搜网结果 | ohos.permission.GET_TELEPHONY_STATE | 102| function getNetworkSelectionMode(slotId: number, callback: AsyncCallback\<NetworkSelectionMode>): void; | 获取指定卡槽的选网模式 | 无 | 103| function setNetworkSelectionMode(options: NetworkSelectionModeOptions, callback: AsyncCallback\<void>): void; | 设置指定卡槽的选网模式 | ohos.permission.SET_TELEPHONY_STATE | 104| function isRadioOn(callback: AsyncCallback\<boolean>): void; | 判断主卡Radio是否打开 | ohos.permission.GET_NETWORK_INFO | 105| function isRadioOn(slotId: number, callback: AsyncCallback\<boolean>): void; | 判断指定卡槽位的Radio是否打开 | ohos.permission.GET_NETWORK_INFO | 106| function turnOnRadio(callback: AsyncCallback\<void>): void; | 开启主卡Radio | ohos.permission.SET_TELEPHONY_STATE | 107| function turnOnRadio(slotId: number, callback: AsyncCallback\<void>): void; | 开启指定卡槽位的Radio | ohos.permission.SET_TELEPHONY_STATE | 108| function turnOffRadio(callback: AsyncCallback\<void>): void; | 关闭主卡Radio | ohos.permission.SET_TELEPHONY_STATE | 109| function turnOffRadio(slotId: number, callback: AsyncCallback\<void>): void; | 关闭指定卡槽位的Radio | ohos.permission.SET_TELEPHONY_STATE | 110| function getOperatorName(slotId: number, callback: AsyncCallback\<string>): void; | 获取指定卡槽的运营商名称 | 无 | 111| function setPreferredNetwork(slotId: number, networkMode: PreferredNetworkMode, callback: AsyncCallback\<void>): void; | 设置指定卡槽的优选网络模式 | ohos.permission.SET_TELEPHONY_STATE | 112| function getPreferredNetwork(slotId: number, callback: AsyncCallback\<PreferredNetworkMode>): void; | 获取指定卡槽的优选网络模式 | ohos.permission.GET_TELEPHONY_STATE | 113| function getCellInformation(slotId: number, callback: AsyncCallback<Array\<CellInformation>>) | 获取小区信息列表 | ohos.permission.LOCATION 和 ohos.permission.APPROXIMATELY_LOCATION | 114| function sendUpdateCellLocationRequest(slotId: number, callback: AsyncCallback\<void>) | 请求小区位置 | ohos.permission.LOCATION 和 ohos.permission.APPROXIMATELY_LOCATION | 115| function getIMEI(slotId: number, callback: AsyncCallback\<string>) | 获取Imei | ohos.permission.GET_TELEPHONY_STATE | 116| function getMEID(slotId: number, callback: AsyncCallback\<string>) | 获取Meid | ohos.permission.GET_TELEPHONY_STATE | 117| function getUniqueDeviceId(slotId: number, callback: AsyncCallback\<string>) | 获取设备唯一标识码 | ohos.permission.GET_TELEPHONY_STATE | 118| function getNrOptionMode(slotId: number, callback: AsyncCallback\<NrOptionMode>) | 获取5G模式 | 无 | 119| function isNrSupported: boolean; | 是否支持5g网络 | 无 | 120| function getImsRegInfo(slotId: number, imsType: ImsServiceType, callback: AsyncCallback\<ImsRegInfo>): void; | 获取IMS注册测状态信息 | ohos.permission.GET_TELEPHONY_STATE | 121| function on(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback: Callback\<ImsRegInfo>): void; | 注册IMS网络状态变化回调 | ohos.permission.GET_TELEPHONY_STATE | 122| function off(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback?: Callback\<ImsRegInfo>): void; | 反注册IMS网络状态变化回调 | ohos.permission.GET_TELEPHONY_STATE | 123 124 125完整的JS API说明以及实例代码请参考:[网络搜索](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-radio.md)。 126 127**说明:** 128 129>RIL管理不对外暴露接口,由电话服务子系统其他各个模块调用。 130 131## 使用说明<a name="section370mcpsimp"></a> 132 133### 搜网<a name="section393mcpsimp"></a> 134 135获取网络状态接口调用流程及示例代码: 136 1371. 指定查询的slotId,若不指定默认查询主卡信息。 1382. 可以通过callback或者Promise的方式调用getNetworkState方法,返回网络状态信息。 1393. 该接口为异步接口,相关执行结果会从callback中返回。 140 141 ```js 142 import radio from "@ohos.telephony.radio"; 143 144 // 参数赋值 145 let slotId = 0; 146 147 // 调用接口【callback方式】 148 radio.getNetworkState(slotId, (err, value) => { 149 if (err) { 150 // 接口调用失败,err非空 151 console.error(`failed to getNetworkState because ${err.message}`); 152 return; 153 } 154 // 接口调用成功,err为空 155 console.log(`success to getNetworkState: ${value}`); 156 }); 157 158 // 调用接口【Promise方式】 159 let promise = radio.getNetworkState(slotId); 160 promise.then((value) => { 161 // 接口调用成功,此处可以实现成功场景分支代码。 162 console.log(`success to getNetworkState: ${value}`); 163 }).catch((err) => { 164 // 接口调用失败,此处可以实现失败场景分支代码。 165 console.error(`failed to getNetworkState because ${err.message}`); 166 }); 167 ``` 168 169 170### SIM卡<a name="section402mcpsimp"></a> 171 172查询指定SIM卡的状态接口调用流程及示例代码: 173 1741. 指定查询的slotId。 1752. 可以通过callback或者Promise的方式调用getSimState方法,返回卡状态信息。 1763. 该接口为异步接口,相关执行结果会从callback中返回。 177 178 ```js 179 import sim from "@ohos.telephony.sim"; 180 181 // 参数赋值 182 let slotId = 0; 183 184 // 调用接口【callback方式】 185 sim.getSimState(slotId, (err, value) => { 186 if (err) { 187 // 接口调用失败,err非空 188 console.error(`failed to getSimState because ${err.message}`); 189 return; 190 } 191 // 接口调用成功,err为空 192 console.log(`success to getSimState: ${value}`); 193 }); 194 195 // 调用接口【Promise方式】 196 let promise = sim.getSimState(slotId); 197 promise.then((value) => { 198 // 接口调用成功,此处可以实现成功场景分支代码。 199 console.log(`success to getSimState: ${value}`); 200 }).catch((err) => { 201 // 接口调用失败,此处可以实现失败场景分支代码。 202 console.error(`failed to getSimState because ${err.message}`); 203 }); 204 ``` 205 206 207## 相关仓<a name="section409mcpsimp"></a> 208 209[电话服务子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/电话服务子系统.md) 210 211**telephony\_core\_service** 212 213[telephony\_sms\_mms](https://gitee.com/openharmony/telephony_sms_mms/blob/master/README_zh.md) 214 215[drivers_interface](https://gitee.com/openharmony/drivers_interface) 216 217[drivers_peripheral](https://gitee.com/openharmony/drivers_peripheral) 218 219[telephony\_ril\_adapter](https://gitee.com/openharmony/telephony_ril_adapter/blob/master/README_zh.md) 220