Go to file
liuxiyao223 6fe4729bdf IssueNo:Add the binary file filtering policy
Description:Add the binary file filtering policy
Sig:SIG_Telephony
Feature or Bugfix: Bugfix
Binary Source: No

Signed-off-by: liuxiyao223 <liuxiyao223@huawei.com>
2024-06-06 14:27:22 +08:00
figures fix: 根据检视意见修改 2022-03-31 09:56:55 +08:00
frameworks !582 fix cellular_data service crash 2024-05-30 03:20:08 +00:00
interfaces !582 fix cellular_data service crash 2024-05-30 03:20:08 +00:00
sa_profile xml改成json 2023-05-23 03:16:17 +00:00
services !592 updataNetworkInfo in event handler 2024-06-04 07:41:45 +00:00
test IssueNo:cellular_data fuzz失败用例修复 2024-05-20 14:05:48 +08:00
BUILD.gn fix cellular data dump code. 2024-05-21 22:32:46 +08:00
bundle.json 有上无下自愈1.0 2023-12-02 17:37:33 +08:00
LICENSE fix: 根据检视意见修改 2022-03-31 09:56:55 +08:00
OAT.xml IssueNo:Add the binary file filtering policy 2024-06-06 14:27:22 +08:00
README_zh.md 代码质量加固 2022-10-29 11:34:18 +08:00
README.md fix: 根据检视意见修改 2022-03-31 09:56:55 +08:00

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. ohos.permission.GET_NETWORK_INFO

Usage Guidelines

Checking the Cellular Data Status

  1. Call the IsCellularDataEnabled method in callback or Promise mode to check whether the cellular data is enabled.

  2. 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}`);
    });
    

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
  1. Call the getCellularDataState method in callback or Promise mode to obtain the cellular data status.

  2. 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