Go to file
openharmony_ci cabc72810a
!1713 vcard tdd failed
Merge pull request !1713 from Aurora/master
2024-01-25 03:36:19 +00:00
figures update framework chart of coreservice 2022-03-02 14:55:55 +08:00
frameworks 增加切主卡之后的卡账户更新 2024-01-19 14:56:57 +08:00
interfaces !1679 SIM卡名称多语言适配 2024-01-16 09:16:43 +00:00
sa_profile xml改成json 2023-05-23 03:22:18 +00:00
services sim卡联系人ucs协议解析 2024-01-25 09:16:37 +08:00
telephonyres check bundleName in siguature file 2022-12-12 18:44:25 +08:00
test !1713 vcard tdd failed 2024-01-25 03:36:19 +00:00
utils fix vcard tdd failed 2024-01-24 15:57:38 +08:00
BUILD.gn remove timezone 2024-01-15 13:32:59 +08:00
bundle.json telephony ffrt 2023-12-21 21:17:02 +08:00
hisysevent.yaml IssueNo: 新增VONR开关状态打点 2023-06-30 18:48:46 +08:00
LICENSE zhanghaifeng11@huawei.com 2021-09-08 00:12:23 -07:00
OAT.xml add ons.bin. 2023-04-13 09:56:19 +08:00
README_zh.md 更换GET_PHONE_NUMBERS 2023-08-01 19:18:36 +08:00
README.md 更换GET_PHONE_NUMBERS 2023-08-01 19:18:36 +08:00
telephony_core_service.gni update telephony_core_service.gni. 2023-12-04 10:25:49 +00: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 HDF (drivers_interface and drivers_peripheral), 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 getDefaultVoiceSimId(callback: AsyncCallback<number>): void; Obtains the sim id 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_PHONE_NUMBERS
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

drivers_interface

drivers_peripheral

telephony_ril_adapter