• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Telephony <a name="EN-US_TOPIC_0000001162422291"></a>
2
3-   [Introduction](#section104mcpsimp)
4-   [Directory Structure](#section119mcpsimp)
5-   [Constraints](#section123mcpsimp)
6-   [Usage](#section128mcpsimp)
7    -   [Obtaining the Current Cellular Network Signal Information](#section1458213210369)
8    -   [Observing Changes to the Cellular Network Status](#section750135512369)
9
10-   [Repositories Involved](#section152mcpsimp)
11
12## Introduction<a name="section104mcpsimp"></a>
13
14The 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.
15
16The Telephony subsystem consists of the following modules:
17
18-   Telephony core service: initializes the Radio Interface Layer (RIL) Manager, SIM card module, and radio module.
19-   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.
20-   Cellular call module: implements basic calls over carrier networks.
21-   Cellular data module: implements cellular data services over carrier networks.
22-   SMS & MMS module: provides the capabilities of sending and receiving short message service \(SMS\) messages and encoding and decoding multimedia messaging service \(MMS\) messages.
23-   State registry module: provides APIs to register and deregister an observer that listens for various callback events of the telephony subsystem.
24-   Data storage module: stores persistent data and provides **DataAbility** access APIs.
25-   RIL Adapter module: implements adaptation of the modem communication interfaces.
26
27**Figure 1** Architecture of the network management subsystem
28
29![](figures/en-us_architecture-of-telephony-subsystem.png)
30
31## Directory Structure<a name="section119mcpsimp"></a>
32
33```
34base/telephony/
35├── core_service            # Telephony core service
36├── call_manager            # Call Manager module
37├── cellular_call           # Cellular call module
38├── cellular_data           # Cellular data module
39├── sms_mms                 # SMS & MMS module
40├── state_registry          # State registry module
41├── data_storage            # Data storage module
42└── ril_adapter             # RIL Adapter
43```
44
45## Constraints<a name="section123mcpsimp"></a>
46
471.  The open-source version currently provides the cellular call (CS call only), SMS & MMS, and cellular data services and supports the dual-SIM framework.
482.  The southbound HDI depends on the chip vendor. For details, see [Telephony Service Southbound Development Guide](../device-dev/subsystems/subsys-tel-overview.md).
49
50## Usage<a name="section128mcpsimp"></a>
51
52To 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.
53
54### Obtaining the Current Cellular Network Signal Information<a name="section1458213210369"></a>
55
561.  Import the **radio** namespace from **@ohos.telephony.radio.d.ts**.
572.  Call [getSignalInformation\(slotId: number\)](../application-dev/reference/apis-telephony-kit/js-apis-radio.md#radiogetsignalinformation7) in callback mode or call [getSignalInformation\(slotId: number\)](../application-dev/reference/apis-telephony-kit/js-apis-radio.md#radiogetsignalinformation7-1) in promise mode.
583.  Obtain the result from the **SignalInformation** array in the callback.
594.  Traverse the **SignalInformation** array to obtain the **signalLevel** (signal strength) for each **signalType** (radio access technology).
60
61    ```
62    // Import the http namespace.
63    import radio from "@ohos.telephony.radio";
64
65    // Set the value of slotId.
66    let slotId = 0;
67
68    // Call the API in callback mode.
69    radio.getSignalInformation(slotId, (err, value) => {
70      if (err) {
71        // If the API call fails, err is not empty.
72        console.error(`failed to getSignalInformation because ${err.message}`);
73        return;
74      }
75      // If the API call is successful, err is empty.
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    });
80
81    // Call the API in promise mode.
82    let promise = radio.getSignalInformation(slotId);
83    promise.then((value) => {
84      // The API call is successful.
85      for (let i = 0; i < value.length; i++) {
86        console.log(`success to getSignalInformation: type is ${value[i].signalType}, level is ${value[i].signalLevel}`);
87      }
88    }).catch((err) => {
89      // The API call fails.
90      console.error(`failed to getSignalInformation because ${err.message}`);
91    });
92    ```
93
94
95### Observing Cellular Network Status Changes<a name="section750135512369"></a>
96
97**Adding an Observer**
98
991.  Import the **observer** namespace from **@ohos.telephony.observer.d.ts**.
1002.  Call [on\(type:'networkStateChange'\)](../application-dev/reference/apis-telephony-kit/js-apis-observer.md#observeronnetworkstatechange-1) with **slotId** (optional) and **callback** specified.
1013.  Register an **observer** instance for callback events of network status changes.
102
103    ```
104    // Import the http namespace.
105    import observer from '@ohos.telephony.observer';
106
107    // Registers an observer.
108    observer.on('networkStateChange', {slotId: 0}, (value) => {
109      console.log(`network state is ` + value);
110    });
111    ```
112
113
114**Removing the Observer**
115
1161.  Import the **observer** namespace from **@ohos.telephony.observer.d.ts**.
1172.  Call [off\(type: 'networkStateChange'\)](../application-dev/reference/apis-telephony-kit/js-apis-observer.md#observeroffnetworkstatechange) with **callback** (optional) specified for a certain type of event.
118
119    ```
120    // Import the http namespace.
121    import observer from '@ohos.telephony.observer';
122
123    // Unregister the observer.
124    observer.off('networkStateChange');
125    ```
126
127
128## Repositories Involved<a name="section152mcpsimp"></a>
129
130**Telephony**
131
132[telephony\_core\_service](https://gitee.com/openharmony/telephony_core_service/blob/master/README.md)
133
134[telephony\_call\_manager](https://gitee.com/openharmony/telephony_call_manager/blob/master/README.md)
135
136[telephony\_cellular\_call](https://gitee.com/openharmony/telephony_cellular_call/blob/master/README.md)
137
138[telephony\_cellular\_data](https://gitee.com/openharmony/telephony_cellular_data/blob/master/README.md)
139
140[telephony\_sms\_mms](https://gitee.com/openharmony/telephony_sms_mms/blob/master/README.md)
141
142[telephony\_state\_registry](https://gitee.com/openharmony/telephony_state_registry/blob/master/README.md)
143
144[telephony\_data\_storage](https://gitee.com/openharmony/telephony_data_storage/blob/master/README.md)
145
146[telephony\_ril\_adapter](https://gitee.com/openharmony/telephony_ril_adapter/blob/master/README.md)
147