1# Telephony <a name="EN-US_TOPIC_0000001162422291"></a> 2 3- [Introduction](#section104mcpsimp) 4- [Directory Structure](#section119mcpsimp) 5- [Constraints](#section123mcpsimp) 6- [Usage Guidelines](#section128mcpsimp) 7 - [Obtaining Current Cellular Network Signal Information](#section1458213210369) 8 - [Observing Cellular Network Status Changes](#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 RIL Manager, SIM card module, and network search 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- SMS & MMS module: provides the capabilities of sending and receiving short message service \(SMS\) messages and encoding and decoding multimedia messaging service \(MMS\) messages. 22- State registry module: provides APIs to register and deregister an observer that listens for various callback events of the telephony subsystem. 23 24**Figure 1** Telephony subsystem architecture 25 26 27 28## Directory Structure<a name="section119mcpsimp"></a> 29 30``` 31base/telephony/ 32├── core_service # Core service 33├── call_manager # Call Manager module 34├── cellular_call # Cellular call module 35├── sms_mms # SMS & MMS module 36└── state_registry # State registry module 37``` 38 39## Constraints<a name="section123mcpsimp"></a> 40 411. The open-source version currently supports only the CS call and SMS services. Cellular data and dual-SIM card are not supported. 42 43## Usage Guidelines<a name="section128mcpsimp"></a> 44 45### Obtaining Current Cellular Network Signal Information<a name="section1458213210369"></a> 46 471. Import the **radio** namespace from **@ohos.telephony.radio.d.ts**. 482. Call the **getSignalInformation\(slotId: number\)** method in callback or Promise mode. This method 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 = 1; 58 59 // Call the API in callback mode. 60 radio.getSignalInformation(slotId, (err, value) => { 61 if (err) { 62 // If the API call failed, err is not empty. 63 console.error(`failed to getSignalInformation because ${err.message}`); 64 return; 65 } 66 // If the API call succeeded, 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 succeeded. 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 failed. 81 console.error(`failed to getSignalInformation because ${err.message}`); 82 }); 83 ``` 84 85 86### Observing Cellular Network Status Changes<a name="section750135512369"></a> 87 88**Adding an Observer** 89 901. Import the **observer** namespace from **@ohos.telephony.observer.d.ts**. 912. Call the **on\(type: 'networkStateChange'\)** method 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: 1}, (err, value) => { 100 if (err) { 101 // If the API call failed, err is not empty. 102 console.error(`failed, because ${err.message}`); 103 return; 104 } 105 // If the API call succeeded, err is empty. 106 console.log(`success on. network state is ` + value); 107 }); 108 ``` 109 110 111**Removing the Observer** 112 1131. Import the **observer** namespace from **@ohos.telephony.observer.d.ts**. 1142. Call the **off\(type: 'networkStateChange'\)** method with the **callback** object passed to the **observer**. 115 116 ``` 117 // Import the observer package. 118 import observer from '@ohos.telephony.observer'; 119 120 // Deregister the observer. 121 observer.off('networkStateChange', (err, value) => { 122 if (err) { 123 // If the API call failed, err is not empty. 124 console.error(`failed, because ${err.message}`); 125 return; 126 } 127 // If the API call succeeded, err is empty. 128 console.log(`success off`); 129 }); 130 ``` 131 132 133## Repositories Involved<a name="section152mcpsimp"></a> 134 135**Telephony subsystem** 136 137[telephony_core_service](https://gitee.com/openharmony/telephony_core_service/blob/master/README.md) 138 139[telephony_call_manager](https://gitee.com/openharmony/telephony_call_manager/blob/master/README.md) 140 141[telephony_cellular_call](https://gitee.com/openharmony/telephony_cellular_call/blob/master/README.md) 142 143[telephony_sms_mms](https://gitee.com/openharmony/telephony_sms_mms/blob/master/README.md) 144 145[telephony_state_registry](https://gitee.com/openharmony/telephony_state_registry/blob/master/README.md) 146 147