调整分布式蜂窝激活条件 Created-by: yyxnju Commit-by: yyxnju Merged-by: openharmony_ci Description: ### 一、内容说明(相关的Issue) https://gitcode.com/openharmony/telephony_cellular_data/issues/716 ### 二、建议测试周期和提测地址 建议测试完成时间:xxxx.xx.xx 投产上线时间:xxxx.xx.xx 提测地址:CI环境/压测环境 测试账号: ### 三、变更内容 * 3.1 关联PR列表 * 3.2 数据库和部署说明 1. 常规更新 2. 重启unicorn 3. 重启sidekiq 4. 迁移任务:是否有迁移任务,没有写 "无" 5. rake脚本:`bundle exec xxx RAILS_ENV = production`;没有写 "无" * 3.4 其他技术优化内容(做了什么,变更了什么) - 重构了 xxxx 代码 - xxxx 算法优化 * 3.5 废弃通知(什么字段、方法弃用?) * 3.6 后向不兼容变更(是否有无法向后兼容的变更?) ### 四、研发自测点(自测哪些?冒烟用例全部自测?) 自测测试结论: ### 五、测试关注点(需要提醒QA重点关注的、可能会忽略的地方) 检查点: | 需求名称 | 是否影响xx公共模块 | 是否需要xx功能 | 需求升级是否依赖其他子产品 | |------|------------|----------|---------------| | xxx | 否 | 需要 | 不需要 | | | | | | 接口测试: 性能测试: 并发测试: 其他: See merge request: openharmony/telephony_cellular_data!1264
Cellular Data
Introduction
The cellular data module is a tailorable component of the Telephony subsystem. It depends on the telephony core service (core_service) and RIL Adapter (ril_adapter). The module provides functions such as cellular data activation, cellular data fault detection and rectification, cellular data status management, cellular data switch management, cellular data roaming management, APN management, and network management and interaction.
Figure 1 Architecture of the cellular data module

Directory Structure
base/telephony/cellular_data/
├── figures
├── frameworks
│ ├── js
│ │ └── napi
│ │ ├── include # js head files
│ │ └── src # js source files
│ └── native
├── interfaces # externally exposed interface
│ ├── innerkits
│ └── kits
│ └── js
│ └── declaration # external JS API interfaces
├── sa_profile # SA profiles
├── services
│ ├── include # head files
│ │ ├── apn_manager
│ │ ├── common
│ │ ├── state_machine
│ │ └── utils
│ └── src # source files
│ ├── apn_manager
│ ├── state_machine
│ └── utils
└── test
└── unit_test # unit test code
Constraints
- Programming language: JavaScript
- In terms of software, this module needs to work with the telephony core service (core_service) and RIL Adapter (call_manger).
- In terms of hardware, the accommodating device must be equipped with a modem and a SIM card capable of independent cellular communication.
Available APIs
Table 1 External APIs provided by the cellular data module
| API | Description | Required Permission |
|---|---|---|
| function isCellularDataEnabled(callback: AsyncCallback<boolean>): void; | Checks whether the cellular data is enabled | ohos.permission.GET_NETWORK_INFO |
| function getCellularDataState(callback: AsyncCallback<DataConnectState>): void; | Obtains the cellular data status. | None |
| function isCellularDataEnabledSync(): boolean; | Checks if cellular mobile data service is enabled. | ohos.permission.GET_NETWORK_INFO |
| function isCellularDataRoamingEnabledSync(slotId: number): boolean; | Checks if cellular data roaming is enabled(The parameter slotId is the SIM card id, 0 represents card one, and 1 represents card two). | ohos.permission.GET_NETWORK_INFO |
Usage Guidelines
Checking the Cellular Data Status
-
Call the IsCellularDataEnabled method in callback or Promise mode to check whether the cellular data is enabled.
-
This method works in asynchronous mode. The execution result is returned through the callback.
import data from "@ohos.telephony.data"; // Call the API in callback mode. data.isCellularDataEnabled((err, value) => { if (err) { // If the API call failed, err is not empty. console.error(`failed to isCellularDataEnabled because ${err.message}`); return; } // If the API call succeeded, err is empty. console.log(`success to isCellularDataEnabled: ${value}`); }); // Call the API in Promise mode. let promise = data.isCellularDataEnabled(); promise.then((value) => { // The API call succeeded. console.log(`success to isCellularDataEnabled: ${value}`); }).catch((err) => { // The API call failed. console.error(`failed to isCellularDataEnabled because ${err.message}`); });
Check if cellular mobile data service is enabled
-
You can determine if cellular data services are enabled by calling isCellularDataEnabledSync.
-
This interface is synchronous, and the relevant execution results will be returned from isCellularDataEnabledSync.
import data from "@ohos.telephony.data"; try { // Call the interface [Sync method] let isEnabled: boolean = data.isCellularDataEnabledSync(); // Call the interface successfully console.log(`isCellularDataEnabledSync success : ${isEnabled}`); } catch (error) { // Call the interface failed console.log(`isCellularDataEnabledSync failed`); }
Check if cellular data roaming is enabled
-
You can determine if cellular data roaming services are enabled by calling isCellularDataRoamingEnabledSync.
-
This interface is synchronous, and the relevant execution results will be returned from isCellularDataRoamingEnabledSync.
import data from "@ohos.telephony.data"; try { // Call the interface [Sync method] let isEnabled: boolean = data.isCellularDataRoamingEnabledSync(0); // Call the interface successfully console.log(`isCellularDataRoamingEnabledSync success : ${isEnabled}`); } catch (error) { // Call the interface failed console.log(`isCellularDataRoamingEnabledSync failed`); }
Obtaining the Cellular Data Status
Table 2 Description of DataConnectState enum values
| Name | ValueDescription | |
|---|---|---|
| DATA_STATE_UNKNOWN | -1 | Unknown |
| DATA_STATE_DISCONNECTED | 0 | Disconnected |
| DATA_STATE_CONNECTING | 1 | Connecting |
| DATA_STATE_CONNECTED | 2 | Connected |
| DATA_STATE_SUSPENDED | 3 | Suspended |
-
Call the getCellularDataState method in callback or Promise mode to obtain the cellular data status.
-
This method works in asynchronous mode. The execution result is returned through the callback.
import data from "@ohos.telephony.data"; // Call the API in callback mode. data.getCellularDataState((err, value) => { if (err) { // If the API call failed, err is not empty. console.error(`failed to getCellularDataState because ${err.message}`); return; } // If the API call succeeded, err is empty. console.log(`success to getCellularDataState: ${value}`); }); // Call the API in Promise mode. let promise = data.getCellularDataState(); promise.then((value) => { // The API call succeeded. console.log(`success to getCellularDataState: ${value}`); }).catch((err) => { // The API call failed. console.error(`failed to getCellularDataState because ${err.message}`); });
Repositories Involved
Telephony
telephony_cellular_data
telephony_core_service
telephony_ril_adapter