# Call Manager ## Introduction The Call Manager module mainly 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. The module consists of six parts: UI interaction \(CallServiceAbility\), service management \(CallManagerService\), call management \(Call Manager\), audio management \(Audio Manager\), video management \(Video Manager\), and Bluetooth management \(Bluetooth Manager\). 1. CallServiceAbility: Implements interaction with the call UI, for example, launching the keypad UI for dialup and reporting the incoming call status to the UI. 2. CallManagerService: starts and initializes the Call Manager. 3. Call Manager: processes downlink call operations \(such as dialup, answer, and onhook\) and uplink call status \(such as incoming call status and call waiting status\), and resolves conflicts that occur in a call. 4. Audio Manager: applies for audio resources for a call and releases the resources after the call ends. This part depends on the multimedia subsystem and needs to call its APIs to perform audio-related operations. 5. Video Manager: applies for video resources for a call and releases the resources after the call ends. This part depends on the multimedia subsystem and needs to call its APIs to perform video-related operations. 6. Bluetooth Manager: applies for Bluetooth resources for a call and releases the resources after the call ends. Besides, this part processes call operations initiated by Bluetooth devices, such as answering and ending calls. The following figure shows the architecture of the Call Manager module. **Figure 1** Architecture of the Call Manager module ![](figures/en-us_architecture-of-the-call-manager-module.png) ## Directory Structure ``` /base/telephony/call_manager ├─ figures # Figures of readme files ├─ frameworks # Frameworks │ ├─ js # JS code │ └─ native # Native code ├─ interfaces # APIs │ ├─ innerkits # Internal APIs │ └─ kits # External APIs (such as JS APIs) ├─ sa_profile # SA profile ├─ services # Service code │ ├─ audio # Audio management │ ├─ bluetooth # Bluetooth call management │ ├─ call # Call service │ ├─ call_manager_service # Call Manager service │ ├─ call_report # Call status reporting │ ├─ call_setting # Call setting │ ├─ telephony_interaction # Telephony core service interaction │ └─ video # Video Manager code ├─ test # Test code │ ├─ fuzztest # Fuzzy test │ ├─ mock # Simulation test │ └─ unittest # Unit test └─ utils # Utilities ``` ## Constraints - Programming language: JavaScript - In terms of software, this module needs to work with the Security subsystem, Multimedia subsystem, and Intelligent Soft Bus subsystem \(Bluetooth module\), as well as the telephony core service \(core\_service\) and cellular call module \(cellular\_call\). - In terms of hardware, the accommodating device must be equipped with a speaker or earphone, and a headset. ## Available APIs **Table 1** External API provided by the Call Manager module

Description

Description

Required Permission

function dial(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean>): void;

Performs dialup operations.

ohos.permission.PLACE_CALL

function isImsSwitchEnabledSync(slotId: number):boolean;

Checks if VoLTE HD calling is enabled(The parameter slotId represents the SIM card ID, where 0 indicates Card 1 and 1 indicates Card 2).

ohos.permission.PLACE_CALL

**Table 2** Parameters of the Dial API

Parameter

Description

phoneNumber: string

Phone number

options: DialOptions

Dialup options (For details, see the following table.)

callback: AsyncCallback<boolean>

Asynchronous execution result. Value true indicates that the dialup is successful, and value false indicates that the dialup has failed.

**Table 3** Parameter description of options: DialOptions

Parameter

Type

Description

Mandatory

Default Value

extras

boolean

false: audio; true: video

No

false

## Usage Guidelines ### Calling the dial API to Place a Call 1. Construct the **phoneNumber** and **options** parameters. 2. Call the **Dial** API in callback or Promise mode. 3. Obtain the dialup result. The **Dial** API works in asynchronous mode. The dialup result is returned through the callback. ``` import call from "@ohos.telephony.call"; let phoneNumber = "12312312312"; // Call the API in callback mode. call.dial(phoneNumber, {extras: false}, (err, value) => { if (err) { // If the API call failed, err is not empty. console.error(`failed to dial because ${err.message}`); return; } // If the API call succeeded, err is empty. console.log(`success to dial: ${value}`); }); // Call the API in Promise mode. let promise = call.dial(phoneNumber, {extras: false}); promise.then((value) => { // The API call succeeded. console.log(`success to dial: ${value}`); }).catch((err) => { // The API call failed. console.error(`failed to dial because ${err.message}`); }); ``` ### Check if VoLTE HD calling is enabled 1. You can check if VoLTE HD calling service is enabled by invoking isImsSwitchEnabledSync. 2. This interface is a synchronous interface, and theThis interface is a synchronous interface, and the returned from isImsSwitch and the relevant execution results will be returned from isImsSwitchEnabledSync. ``` import call from "@ohos.telephony.call"; try { // Call the interface [Sync method] let isEnabled: boolean = data.isImsSwitchEnabledSync(0); // Call the interface successfully console.log(`isImsSwitchEnabledSync success : ${isEnabled}`); } catch (error) { // Call the interface failed console.log(`isImsSwitchEnabledSync failed`); } ``` ## Repositories Involved [Telephony](https://gitee.com/openharmony/docs/blob/master/en/readme/telephony.md) **telephony_call_manager** [telephony_core_service](https://gitee.com/openharmony/telephony_core_service/blob/master/README.md) [telephony_cellular_call](https://gitee.com/openharmony/telephony_cellular_call/blob/master/README.md) [telephony_state_registry](https://gitee.com/openharmony/telephony_state_registry/blob/master/README.md)