Go to file
dingxiaochen f2e2a0e721 fix js docs.
Signed-off-by: dingxiaochen <dingxiaochen@huawei.com>
2022-12-01 20:04:00 +08:00
figures update framework chart of coreservice 2022-03-02 14:55:55 +08:00
frameworks fix js docs. 2022-12-01 14:29:44 +08:00
interfaces fix js docs. 2022-12-01 20:04:00 +08:00
sa_profile go back sandbox 2022-09-05 21:13:09 +08:00
services !934 修改cppcheck告警 2022-11-29 08:29:32 +00:00
telephonyres add 2022-11-07 11:13:56 +08:00
test fix tdd test. 2022-11-30 11:30:54 +08:00
utils replace HiSysEvent::Write to HiSysEventWrite 2022-11-24 17:16:01 +08:00
BUILD.gn replace time_service with time_client 2022-11-07 17:16:59 +08:00
bundle.json !708 修复 destPath 字段的路径为相对路径。 2022-10-12 13:22:23 +00:00
core_service_aafwk.gni aafwk->ability_runtime 2022-06-28 14:05:58 +08:00
hisysevent.yaml foundation 2022-09-28 21:44:12 +08:00
LICENSE zhanghaifeng11@huawei.com 2021-09-08 00:12:23 -07:00
README_zh.md fix js docs. 2022-12-01 14:29:44 +08:00
README.md fix js docs. 2022-12-01 14:29:44 +08:00
telephony.gni zhanghaifeng11@huawei.com 2022-02-19 15:45:55 +08:00

Telephony Core Service

Introduction

The telephony core service initializes the SimManager, NetworkSearchManager, and TelRilManager modules, 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 following:

  • 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.
  • 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.
  • TelRilManager: provides the proactive callback service and query result callback service.

Directory Structure

/base/telphony/core_service
├── figures                       # Figures of readme files
├── frameworks                    # Framework layer
│   ├── js
│   └── native
├── interfaces                    # APIs
│   ├── innerkits                 # Internal APIs
|   |    ├── ims                  # IMS network status reporting APIs
│   └── kits                      # External APIs \(such as JS APIs\)
├── sa_profile                    # SA profile
├── services                      # Implementation of the telephony core service
│   ├── etc                       # Telephony core service driver scripts
|   ├── ims_service_interaction   # IMS service interaction (for status reporting)
│   ├── include
│   ├── network_search            # Network search service
│   ├── sim                       # SIM card service
│   ├── src
│   └── tel_ril                   # Telephony core service and RIL Adapter communication
├─ test                            # Test code
│   └── unittest
└── utils
    ├── common                    # Telephony core service log
    ├── log
    └── preferences

Constraints

  • Programming language: C++ and JavaScript.
  • Software constraints: This module must work with the RIL Adapter service ril\_adapter and state registry service state\_registry.
  • Hardware constraints: 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 and radio modules.

SimManager APIs

Name Description Required Permission
function getSimState(slotId: number, callback: AsyncCallback<SimState>): void; Obtains the state of the SIM card in a specified slot.
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
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
function getISOCountryCodeForSim(slotId: number, callback: AsyncCallback<string>): void; Obtains the ISO country code of the SIM card in the specified slot.
function getSimOperatorNumeric(slotId: number, callback: AsyncCallback<string>): void; Obtains the public land mobile network PLMN ID of the SIM card in the specified slot.
function getSimSpn(slotId: number, callback: AsyncCallback<string>): void; Obtains the service provider name SPN of the SIM card in the specified slot.
function getDefaultVoiceSlotId(callback: AsyncCallback<number>): void; Obtains the slot of the default SIM card that provides the voice service.
function isSimActive(slotId: number, callback: AsyncCallback<boolean>): void Checks whether the SIM card in the specified slot is activated.
function hasSimCard(slotId: number, callback: AsyncCallback<boolean>): void Checks whether the specified slot is populated with a SIM card.
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
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
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
function getCardType(slotId: number, callback: AsyncCallback<CardType>): void Obtains the type of the SIM card in the specified slot.
function hasOperatorPrivileges(slotId: number, callback: AsyncCallback<boolean>): void Checks whether the application (caller) has been granted the operator permission.
function getMaxSimCount(): number Obtains the maximum number of SIM cards, that is, the maximum number of SIM card slots, available on the device.

For details about the complete description of JavaScript APIs and sample code, see SIM Card Management.

NetworkSearchManager APIs

Name Description Required Permission
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
function getSignalInformation(slotId: number, callback: AsyncCallback<Array<SignalInformation>>): void; Obtains the signal information of the SIM card in the specified slot.
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
function getISOCountryCodeForNetwork(slotId: number, callback: AsyncCallback<string>): void; Obtains the ISO country code of the SIM card in the specified slot.
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
function getNetworkSelectionMode(slotId: number, callback: AsyncCallback<NetworkSelectionMode>): void; Obtains the network selection mode of the SIM card in the specified slot.
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
function isRadioOn(callback: AsyncCallback<boolean>): void; Checks whether the radio service is enabled on the primary SIM card. ohos.permission.GET_NETWORK_INFO
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
function turnOnRadio(callback: AsyncCallback<void>): void; Enables the radio service on the primary SIM card. ohos.permission.SET_TELEPHONY_STATE
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
function turnOffRadio(callback: AsyncCallback<void>): void; Disables the radio service on the primary SIM card. ohos.permission.SET_TELEPHONY_STATE
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
function getOperatorName(slotId: number, callback: AsyncCallback<string>): void; Obtains the carrier name of the SIM card in the specified slot.
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
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
function getCellInformation(slotId: number, callback: AsyncCallback<Array<CellInformation>>) Obtains the cell information list. ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
function sendUpdateCellLocationRequest(slotId: number, callback: AsyncCallback<void>) Requests for a cell location update. ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
function getIMEI(slotId: number, callback: AsyncCallback<string>) Obtains the international mobile equipment identity (IMEI). ohos.permission.GET_TELEPHONY_STATE
function getMEID(slotId: number, callback: AsyncCallback<string>) Obtains the mobile equipment identifier (MEID). ohos.permission.GET_TELEPHONY_STATE
function getUniqueDeviceId(slotId: number, callback: AsyncCallback<string>) Obtains the unique ID of a device. ohos.permission.GET_TELEPHONY_STATE
function getNrOptionMode(slotId: number, callback: AsyncCallback<NrOptionMode>) Obtains the 5G mode.
function isNrSupported: boolean; Checks whether 5G is supported.
function getImsRegInfo(slotId: number, imsType: ImsServiceType, callback: AsyncCallback<ImsRegInfo>): void; Gets IMS register status info ohos.permission.GET_TELEPHONY_STATE
function on(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback: Callback<ImsRegInfo>): void; Registers IMS network status callback ohos.permission.GET_TELEPHONY_STATE
function off(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback?: Callback<ImsRegInfo>): void; Unregisters IMS network status callback ohos.permission.GET_TELEPHONY_STATE

For details about the complete description of JavaScript APIs and sample code, see Radio.

NOTE

The RIL Manager does not provide external APIs. It 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 getNetworkState method in callback or promise mode to obtain the network status.

  3. Obtain the SIM card status information. The getNetworkState 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 = 0;
    
    // Call the API in callback mode.
    radio.getNetworkState(slotId, (err, value) => {
      if (err) {
        // If the API call fails, err is not empty.
        console.error(`failed to getNetworkState because ${err.message}`);
        return;
      }
      // If the API call is successful, err is empty.
      console.log(`success to getNetworkState: ${value}`);
    });
    
    // Call the API in promise mode.
    let promise = radio.getNetworkState(slotId);
    promise.then((value) => {
      // The API call is successful.
      console.log(`success to getNetworkState: ${value}`);
    }).catch((err) => {
      // The API call fails.
      console.error(`failed to getNetworkState because ${err.message}`);
    });
    

SIM Card Management

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.

  3. Obtain the SIM card status information. The getSimState 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 = 0;
    
    // Call the API in callback mode.
    sim.getSimState(slotId, (err, value) => {
      if (err) {
        // If the API call fails, err is not empty.
        console.error(`failed to getSimState because ${err.message}`);
        return;
      }
      // If the API call is successful, 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 is successful.
      console.log(`success to getSimState: ${value}`);
    }).catch((err) => {
      // The API call fails.
      console.error(`failed to getSimState because ${err.message}`);
    });
    

Repositories Involved

Telephony Subsystem

telephony_core_service

telephony_sms_mms

telephony_ril_adapter