9 Star 13 Fork 34

OpenHarmony / telephony_core_service

Gitee — Enterprise-level DevOps R&D management platform
Join Gitee
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

Telephony Core Service

Introduction

The telephony core service initializes the RIL Manager, SIM card module, and network search module, and provides access to the RIL Adapter service.

You can implement communication with the RIL Adapter by registering the callback service and implement communication between modules by subscribing to callbacks.

Figure 1 Architecture of the telephony core service

As shown in the preceding figure, the telephony core service consists of the SIM card service, network search service, and RIL Manager service.

  • 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.
  • 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.
  • RIL Manager service: Provides the proactive callback service and query result callback service.

Directory Structure

/base/telphony/core_service
├── interfaces             # APIs
│   ├── innerkits          # Internal APIs
│   └── kits               # External APIs (such as JS APIs)
├── services               # Implementation of the telephony core service
│   ├── include
│   └── src
├── etc                    # Telephony core service driver scripts
│   └── init
├── sa_profile             # SA profile
├── tel_ril                # RIL Manager service code
│   ├── include
│   ├── src
│   └── test
├── network_search         # Network search service code
│   ├── include
│   ├── src
│   └── test
├── sim                    # SIM card service code
│   ├── include
│   ├── src
│   └── test     
├── common
│   ├── log                # Core service log print directory 
│   ├── preferences
│   ├── utils
│   └── test

Constraints

  • Programming language: C++、JavaScript
  • In terms of software, this module needs to work with the RIL adapter service (ril_adapter) and status registration service (state_registry).
  • In terms of hardware, the accommodating device must be equipped with a modem and a SIM card capable of independent cellular communication.

Available APIs

The telephony core service module needs to provide APIs for related modules, including the SIM card, network search modules.

APIs for the SIM Card Service

API

Description

Required Permission

function GetSimStatus(int32_t slotId): void;

Obtains the SIM card status.

None

function GetIsoCountryCode(int32_t slotId): void;

Obtains the country code.

None

function GetSimOperator(int32_t slotId): void;

Obtains the carrier code.

None

function GetSpn(int32_t slotId): void;

Obtains the SPN information.

None

function SimStateUpdated(int32_t slotId): void;

SIM Card state update

None

function UnlockSimPin(int32_t slotId): void;

Unlock SIM Card

None

APIs for the Network Search Service

API

Description

Required Permission

function GetPsRadioTech(int32_t slotId): void;

function GetCsRadioTech(int32_t slotId): void;

Obtains the current radio access technology.

ohos.permission.GET_NETWORK_INFO

function GetSignalInfoList(int32_t slotId): void;

Obtains the signal information.

None

function GetNetworkStatus(slotId: number, callback: AsyncCallback<GetNetworkStatus>): void;

Obtains the network status.

ohos.permission.GET_NETWORK_INFO

function getNetworkSelectionMode(slotId: number, callback: AsyncCallback): void;

Obtains the current network mode.

None

function setNetworkSelectionMode(options: NetworkSelectionModeOptions, callback: AsyncCallback): void;

Set the current network mode.

None

function getNetworkSearchInformation(slotId: number, callback: AsyncCallback): void;

Obtains the results of manual networksearch.

None

function isRadioOn(slotId: number, callback: AsyncCallback): void;

Determine that the radio is on.

None

function turnOnRadio(callback: AsyncCallback): void;

Open the radio.

None

function turnOffRadio(callback: AsyncCallback): void;

Close the radio.

None

function getISOCountryCodeForNetwork(slotId: number, callback: AsyncCallback): void;

Obtains the ISOCountryCode.

None

function setPreferredNetworkPara(slotId: number, networkMode: NetworkMode, callback: AsyncCallback): void;

Set the Preferred Network Mode.

None

function getPreferredNetworkPara(slotId: number, callback: AsyncCallback): void;

Obtains the Preferred Network Mode.

None

function GetSignalStrength(slotId: number, callback: AsyncCallback): void;

Get signal strength

None

function GetOperatorInfo(slotId: number, callback: AsyncCallback): void;

Get operator information

None

NOTE: The RIL Manager does not provide external APIs and can only be called by modules of the Telephony subsystem.

Usage Guidelines

Network Search

The function of obtaining the network status is used as an example. The process is as follows:

  1. Query the SIM card in the slot specified by slotId. If slotId is not set, information about the primary card is queried by default.

  2. Call the GetNetworkStatus method in callback or Promise mode.

  3. Obtain the network status information. The GetNetworkStatus method works in asynchronous mode. The execution result is returned through the callback.

    import radio from "@ohos.telephony.radio";
    
    // Set the value of slotId.
    let slotId = 1;
    
    // Call the API in callback mode.
    radio.GetNetworkStatus(slotId, (err, value) => {
      if (err) {
        // If the API call failed, err is not empty.
        console.error(`failed to GetNetworkStatus because ${err.message}`);
        return;
      }
      // If the API call succeeded, err is empty.
      console.log(`success to GetNetworkStatus: ${value}`);
    });
    
    // Call the API in Promise mode.
    let promise = radio.GetNetworkStatus(slotId);
    promise.then((value) => {
      // The API call succeeded.
      console.log(`success to GetNetworkStatus: ${value}`);
    }).catch((err) => {
      // The API call failed.
      console.error(`failed to GetNetworkStatus because ${err.message}`);
    });

SIM Card

The function of querying the status of a specified SIM card is used as an example. The process is as follows:

  1. Set the value of slotId.

  2. Call the getSimState method in callback or Promise mode to obtain the SIM card status information.

  3. This method works in asynchronous mode. The execution result is returned through the callback.

    import sim from "@ohos.telephony.sim";
    
    // Set the value of slotId.
    let slotId = 1;
    
    // Call the API in callback mode.
    sim.getSimState(slotId, (err, value) => {
      if (err) {
        // If the API call failed, err is not empty.
        console.error(`failed to getSimState because ${err.message}`);
        return;
      }
      // If the API call succeeded, err is empty.
      console.log(`success to getSimState: ${value}`);
    });
    
    // Call the API in Promise mode.
    let promise = sim.getSimState(slotId);
    promise.then((value) => {
      // The API call succeeded.
      console.log(`success to getSimState: ${value}`);
    }).catch((err) => {
      // The API call failed.
      console.error(`failed to getSimState because ${err.message}`);
    });

Repositories Involved

Telephony

telephony_core_service

telephony_sms_mms

Repository Comments ( 0 )

Sign in for post a comment

About

Establishing communication with RIL Adapter | 电话基础服务模块主要功能实现与RIL Adapter进行通信 expand collapse
C++ and 2 more languages
Apache-2.0
Cancel

Releases

No release

OpenHarmony

Contributors

All

Activities

load more
can not load any more
1
https://gitee.com/openharmony/telephony_core_service.git
git@gitee.com:openharmony/telephony_core_service.git
openharmony
telephony_core_service
telephony_core_service
master

Search

181749 a2d7925e 1850385 181749 9f8568a7 1850385