• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Telephony
2
3## Introduction
4
5The Telephony subsystem provides APIs for obtaining information about the wireless cellular network and SIM card. Applications can call these APIs to obtain information such as the name of the currently registered network, network service status, signal strength, and SIM card information.
6
7The Telephony subsystem consists of the following modules:
8
9-   Telephony core service: initializes the Radio Interface Layer (RIL) Manager, SIM card module, and radio module.
10-   Call Manager module: manages three types of calls – circuit switched \(CS\), IP multimedia subsystem \(IMS\), and over the top \(OTT\) calls. It is responsible for applying for the audio and video resources required for a call and resolving conflicts in a multi-channel call.
11-   Cellular call module: implements basic calls over carrier networks.
12-   Cellular data module: implements cellular data services over carrier networks.
13-   SMS & MMS module: provides the capabilities of sending and receiving short message service \(SMS\) messages and encoding and decoding multimedia messaging service \(MMS\) messages.
14-   State registry module: provides APIs to register and deregister an observer that listens for various callback events of the telephony subsystem.
15-   Data storage module: stores persistent data and provides **DataAbility** access APIs.
16-   RIL Adapter module: implements adaptation of the modem communication interfaces.
17
18**Figure 1** Telephony subsystem architecture
19
20![](figures/en-us_architecture-of-telephony-subsystem.png)
21
22## Directory Structure
23
24```
25base/telephony/
26├── core_service            # Telephony core service
27├── call_manager            # Call Manager module
28├── cellular_call           # Cellular call module
29├── cellular_data           # Cellular data module
30├── sms_mms                 # SMS & MMS module
31├── state_registry          # State registry module
32├── data_storage            # Data storage module
33└── ril_adapter             # RIL Adapter module
34```
35
36## Constraints
37
381.  The open-source version currently provides the cellular call (CS call only), SMS & MMS, and cellular data services and supports the dual-SIM framework.
392.  The Hardware Device Interface (HDI) support is subject to the chip vendors' adaptation capability. For details, see [Telephony Development](../device-dev/subsystems/subsys-tel-overview.md).
40
41## Usage Guidelines
42
43To learn more about the usage of each subsystem module, refer to the respective README. The following illustrates API usage by exemplifying how to obtain the current cellular network signal information and observe the cellular network status changes.
44
45### Obtaining the Current Cellular Network Signal Information
46
471.  Import the **radio** namespace from **@ohos.telephony.radio.d.ts**.
482.  Call the **getSignalInformation\(slotId: number\)** function via callback or promise. This function works in asynchronous mode.
493.  Obtain the result from the **SignalInformation** array in the callback.
504.  Traverse the **SignalInformation** array to obtain the **signalLevel** (signal strength) for each **signalType** (radio access technology).
51
52    ```
53    // Import the radio package.
54    import radio from "@ohos.telephony.radio";
55
56    // Set the value of slotId.
57    let slotId = 0;
58
59    // Call the API in callback mode.
60    radio.getSignalInformation(slotId, (err, value) => {
61      if (err) {
62        // If the API call fails, err is not empty.
63        console.error(`failed to getSignalInformation because ${err.message}`);
64        return;
65      }
66      // If the API call is successful, err is empty.
67      for (let i = 0; i < value.length; i++) {
68        console.log(`success to getSignalInformation: type is ${value[i].signalType}, level is ${value[i].signalLevel}`);
69      }
70    });
71
72    // Call the API in promise mode.
73    let promise = radio.getSignalInformation(slotId);
74    promise.then((value) => {
75      // The API call is successful.
76      for (let i = 0; i < value.length; i++) {
77        console.log(`success to getSignalInformation: type is ${value[i].signalType}, level is ${value[i].signalLevel}`);
78      }
79    }).catch((err) => {
80      // The API call fails.
81      console.error(`failed to getSignalInformation because ${err.message}`);
82    });
83    ```
84
85
86### Observing Cellular Network Status Changes
87
88Adding an Observer
89
901.  Import the **observer** namespace from **@ohos.telephony.observer.d.ts**.
912.  Call the **on\(type:'networkStateChange'\)** function with **slotId** (slot ID, optional) and **callback** (callback processing function) passed in.
923.  Register an **observer** instance for callback events of network status changes.
93
94    ```
95    // Import the observer package.
96    import observer from '@ohos.telephony.observer';
97
98    // Registers an observer.
99    observer.on('networkStateChange', {slotId: 0}, (value) => {
100      console.log(`network state is ` + value);
101    });
102    ```
103
104
105Removing the Observer
106
1071.  Import the **observer** namespace from **@ohos.telephony.observer.d.ts**.
1082.  Call the **off\(type: 'networkStateChange'\)** function with the **callback** object passed to **observer**.
109
110    ```
111    // Import the observer package.
112    import observer from '@ohos.telephony.observer';
113
114    // Unregister the observer.
115    observer.off('networkStateChange');
116    ```
117
118
119## Repositories Involved
120
121**Telephony Subsystem**
122
123[telephony\_core\_service](https://gitee.com/openharmony/telephony_core_service/blob/master/README.md)
124
125[telephony\_call\_manager](https://gitee.com/openharmony/telephony_call_manager/blob/master/README.md)
126
127[telephony\_cellular\_call](https://gitee.com/openharmony/telephony_cellular_call/blob/master/README.md)
128
129[telephony\_cellular\_data](https://gitee.com/openharmony/telephony_cellular_data/blob/master/README.md)
130
131[telephony\_sms\_mms](https://gitee.com/openharmony/telephony_sms_mms/blob/master/README.md)
132
133[telephony\_state\_registry](https://gitee.com/openharmony/telephony_state_registry/blob/master/README.md)
134
135[telephony\_data\_storage](https://gitee.com/openharmony/telephony_data_storage)
136
137[telephony\_ril\_adapter](https://gitee.com/openharmony/telephony_ril_adapter/blob/master/README.md)
138