1 /*
2  * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef CALL_MANAGER_CLIENT_H
17 #define CALL_MANAGER_CLIENT_H
18 
19 #include "singleton.h"
20 #include "pac_map.h"
21 
22 #include "call_manager_callback.h"
23 
24 namespace OHOS {
25 namespace Telephony {
26 class CallManagerClient : public std::enable_shared_from_this<CallManagerClient> {
27     DECLARE_DELAYED_SINGLETON(CallManagerClient)
28 
29 public:
30     void Init(int32_t systemAbilityId);
31     void UnInit();
32 
33     /**
34      * @brief Register callback
35      *
36      * @param callback[in], callback function pointer
37      * @return Returns 0 on success, others on failure.
38      */
39     int32_t RegisterCallBack(std::unique_ptr<CallManagerCallback> callback);
40 
41     /**
42      * @brief unregister callback
43      *
44      * @return Returns 0 on success, others on failure.
45      */
46     int32_t UnRegisterCallBack();
47 
48     /**
49      * @brief the application subscribe the OnCallDetailsChange event
50      *
51      * @return Returns 0 on success, others on failure.
52      */
53     int32_t ObserverOnCallDetailsChange();
54 
55     /**
56      * @brief Dial a phone call
57      *
58      * @param number[in], dial param.
59      * @param extras[in], extras date.
60      * @return Returns callId when the value is greater than zero, others on failure.
61      */
62     int32_t DialCall(std::u16string number, AppExecFwk::PacMap &extras);
63 
64     /**
65      * @brief Make a phone call
66      *
67      * @param number[in],  call param.
68      * @return Returns 0 on success, others on failure.
69      */
70     int32_t MakeCall(std::string number);
71 
72     /**
73      * @brief Answer a phone call
74      *
75      * @param callId[in], call id
76      * @param videoState[in], 0: audio, 1: video
77      * @return Returns 0 on success, others on failure.
78      */
79     int32_t AnswerCall(int32_t callId, int32_t videoState);
80 
81     /**
82      * @brief Reject a phone call
83      *
84      * @param callId[in], call id
85      * @param rejectWithMessage[in], Whether to enter the reason for rejection,true:yes false:no
86      * @param textMessage[in], The reason you reject the call
87      * @return Returns 0 on success, others on failure.
88      */
89     int32_t RejectCall(int32_t callId, bool isSendSms, std::u16string content);
90 
91     /**
92      * @brief Hang up the phone
93      *
94      * @param callId[in], call id
95      * @return Returns 0 on success, others on failure.
96      */
97     int32_t HangUpCall(int32_t callId);
98 
99     /**
100      * @brief Obtain the call status of the device
101      *
102      * @return Returns call state.
103      */
104     int32_t GetCallState();
105 
106     /**
107      * @brief Park a phone call
108      *
109      * @param callId[in], call id
110      * @return Returns 0 on success, others on failure.
111      */
112     int32_t HoldCall(int32_t callId);
113 
114     /**
115      * @brief Activate a phone call
116      *
117      * @param callId[in], call id
118      * @return Returns 0 on success, others on failure.
119      */
120     int32_t UnHoldCall(int32_t callId);
121 
122     /**
123      * @brief Switch the phone call between hold and unhold
124      *
125      * @param callId[in], call id
126      * @return Returns 0 on success, others on failure.
127      */
128     int32_t SwitchCall(int32_t callId);
129 
130     /**
131      * @brief Merge calls to form a conference
132      *
133      * @param callId[in], call id
134      * @return Returns 0 on success, others on failure.
135      */
136     int32_t CombineConference(int32_t callId);
137 
138     /**
139      * @brief Separates a specified call from a conference call
140      *
141      * @param callId[in], call id
142      * @return Returns 0 on success, others on failure.
143      */
144     int32_t SeparateConference(int32_t callId);
145 
146     /**
147      * @brief Hangup a specified call from a conference call
148      *
149      * @param callId[in], call id
150      * @return Returns 0 on success, others on failure.
151      */
152     int32_t KickOutFromConference(int32_t callId);
153 
154     /**
155      * @brief Obtain the ID of the primary call in a conference
156      *
157      * @param callId[in], Id of a call in a conference
158      * @return Returns main call id, -1 on not call id.
159      */
160     int32_t GetMainCallId(int32_t &callId, int32_t &mainCallId);
161 
162     /**
163      * @brief Obtain the list of neutron call ids
164      *
165      * @param callId[in], Id of a call in a conference
166      * @param callIdList[out], the list of neutron call ids
167      * @return Returns 0 on success, others on failure.
168      */
169     int32_t GetSubCallIdList(int32_t callId, std::vector<std::u16string> &callIdList);
170 
171     /**
172      * @brief Obtain the callId list of all calls in a conference
173      *
174      * @param callId[in], Id of a call in a conference
175      * @param callIdList[out], the callId list of all calls in a conference
176      * @return Returns 0 on success, others on failure.
177      */
178     int32_t GetCallIdListForConference(int32_t callId, std::vector<std::u16string> &callIdList);
179 
180     /**
181      * @brief Gets whether the call waiting service of the current account is enabled
182      *
183      * @param slotId[in], The slot id
184      * @return Returns 0 on success, others on failure.
185      */
186     int32_t GetCallWaiting(int32_t slotId);
187 
188     /**
189      * @brief Set the call waiting function for the current account
190      *
191      * @param slotId[in], The slot id
192      * @param activate[in], Activation of switch
193      * @return Returns 0 on success, others on failure.
194      */
195     int32_t SetCallWaiting(int32_t slotId, bool activate);
196 
197     /**
198      * @brief Gets the call restriction information of the specified account
199      *
200      * @param slotId[in], The slot id
201      * @param type[in], Call Restriction type
202      * @return Returns 0 on success, others on failure.
203      */
204     int32_t GetCallRestriction(int32_t slotId, CallRestrictionType type);
205 
206     /**
207      * @brief Set the call restriction function for the current account
208      *
209      * @param slotId[in], The slot id
210      * @param info[in], Call restriction information
211      * @return Returns 0 on success, others on failure.
212      */
213     int32_t SetCallRestriction(int32_t slotId, CallRestrictionInfo &info);
214 
215     /**
216      * @brief Set the call restriction password function for the current account
217      *
218      * @param slotId[in], The slot id
219      * @param fac[in], Call restriction type
220      * @param oldPassword[in], Old password of call restriction type
221      * @param newPassword[in], New password of call restriction type
222      * @return Returns 0 on success, others on failure.
223      */
224     int32_t SetCallRestrictionPassword(
225         int32_t slotId, CallRestrictionType fac, const char *oldPassword, const char *newPassword);
226 
227     /**
228      * @brief Gets the call transfer information of the current account
229      *
230      * @param slotId[in], The slot id
231      * @param type[in], Call Transfer Type
232      * @return Returns 0 on success, others on failure.
233      */
234     int32_t GetCallTransferInfo(int32_t slotId, CallTransferType type);
235 
236     /**
237      * @brief Set the call transfer function for the current account
238      *
239      * @param slotId[in], The slot id
240      * @param info[in], Call Transfer Information
241      * @return Returns 0 on success, others on failure.
242      */
243     int32_t SetCallTransferInfo(int32_t slotId, CallTransferInfo &info);
244 
245     /**
246      * @brief confirm whether IMS can set call transfer time.
247      *
248      * @param slotId[in], The slot id
249      * @param result[out], The result of can set or not
250      * @return Returns true on can set, others on can not set.
251      */
252     int32_t CanSetCallTransferTime(int32_t slotId, bool &result);
253 
254     /**
255      * @brief Setting the Call Type
256      *
257      * @param slotId[in], The slot id
258      * @param mode[in], Preference Mode
259      * @return Returns 0 on success, others on failure.
260      */
261     int32_t SetCallPreferenceMode(int32_t slotId, int32_t mode);
262 
263     /**
264      * @brief Enable and send DTMF
265      *
266      * @param callId[in], call id
267      * @param str[in], Characters sent
268      * @return Returns 0 on success, others on failure.
269      */
270     int32_t StartDtmf(int32_t callId, char str);
271 
272     /**
273      * @brief Stop the DTMF
274      *
275      * @param callId[in], call id
276      * @return Returns 0 on success, others on failure.
277      */
278     int32_t StopDtmf(int32_t callId);
279 
280     int32_t PostDialProceed(int32_t callId, bool proceed);
281     /**
282      * @brief Whether the ringing
283      *
284      * @param enabled[out], true on ringing, false on there is no ringing
285      * @return Returns interface processing results.
286      */
287     int32_t IsRinging(bool &enabled);
288 
289     /**
290      * @brief Is there Call
291      *
292      * @return Returns true on has call, others on there is no call.
293      */
294     bool HasCall();
295 
296     /**
297      * @brief Can I initiate a call
298      *
299      * @param enabled[out], whether allow new calls
300      * @return Returns interface processing results.
301      */
302     int32_t IsNewCallAllowed(bool &enabled);
303 
304     /**
305      * @brief Is there an emergency call
306      *
307      * @param enabled[out], true on emergency call, false on no emergency call
308      * @return Returns interface processing results.
309      */
310     int32_t IsInEmergencyCall(bool &enabled);
311 
312     /**
313      * @brief Is it an emergency call
314      *
315      * @param number[in], Phone number to be formatted
316      * @param slotId[in], The slot id
317      * @param enabled[out] result of is it an emergency call
318      * @return Returns 0 on success, others on failure.
319      */
320     int32_t IsEmergencyPhoneNumber(std::u16string &number, int32_t slotId, bool &enabled);
321 
322     /**
323      * @brief Formatting a phone number
324      *
325      * @param number[in], Phone number to be formatted
326      * @param countryCode[in], Country code of the phone number
327      * @param formatNumber[out] Formatting a phone number
328      * @return Returns 0 on success, others on failure.
329      */
330     int32_t FormatPhoneNumber(std::u16string &number, std::u16string &countryCode, std::u16string &formatNumber);
331 
332     /**
333      * @brief Formatting a phone number
334      *
335      * @param number[in]. Phone number to be formatted
336      * @param countryCode[in], Country code of the phone number
337      * @param formatNumber[out] Formatting a phone number
338      * @return Returns 0 on success, others on failure.
339      */
340     int32_t FormatPhoneNumberToE164(
341         std::u16string &number, std::u16string &countryCode, std::u16string &formatNumber);
342 
343     /**
344      * @brief Mute the Microphone
345      *
346      * @param isMute[in], mute state
347      * @return Returns 0 on success, others on failure.
348      */
349     int32_t SetMuted(bool isMute);
350 
351     /**
352      * @brief Call mute
353      *
354      * @return Returns 0 on success, others on failure.
355      */
356     int32_t MuteRinger();
357 
358     /**
359      * @brief Setting the Audio Channel
360      *
361      * @param audioDevice[in], contain audioDeviceType and address
362      * @return Returns 0 on success, others on failure.
363      */
364     int32_t SetAudioDevice(const AudioDevice &audioDevice);
365 
366     /**
367      * @brief Open or close camera
368      *
369      * @param callId[in], The call id
370      * @param cameraId[in], The camera id
371      * @return Returns 0 on success, others on failure.
372      */
373     int32_t ControlCamera(int32_t callId, std::u16string cameraId);
374 
375     /**
376      * @brief Set the location and size of the preview window for videos captured by the local camera.
377      *
378      * @param callId[in], The call id
379      * @param surfaceId[in], Window information
380      * @return Returns 0 on success, others on failure.
381      */
382     int32_t SetPreviewWindow(int32_t callId, std::string &surfaceId);
383 
384     /**
385      * @brief Sets the location and size of the remote video window.
386      *
387      * @param callId[in], The call id
388      * @param surfaceId[in], Window information
389      * @return Returns 0 on success, others on failure.
390      */
391     int32_t SetDisplayWindow(int32_t callId, std::string &surfaceId);
392 
393     /**
394      * @brief Sets the local camera zoom scale
395      *
396      * @param zoomRatio[in], Camera scale
397      * @return Returns 0 on success, others on failure.
398      */
399     int32_t SetCameraZoom(float zoomRatio);
400 
401     /**
402      * @brief APP sets the screen of the remote video freeze immediately.
403      * If the APP does not call this interface when making a video call,
404      * the last frame before the remote video freeze is displayed by default
405      *
406      * @param callId[in], The call id
407      * @param path[in], Local Picture address
408      * @return Returns 0 on success, others on failure.
409      */
410     int32_t SetPausePicture(int32_t callId, std::u16string path);
411 
412     /**
413      * @brief Set the rotation Angle of the local device. The default value is 0
414      *
415      * @param rotation[in], Rotation Angle
416      * @return Returns 0 on success, others on failure.
417      */
418     int32_t SetDeviceDirection(int32_t callId, int32_t rotation);
419 
420     /**
421      * @brief Obtain the IMS service configuration
422      *
423      * @param slotId[in], The slot id
424      * @param item[in]
425      * @return Returns 0 on success, others on failure.
426      */
427     int32_t GetImsConfig(int32_t slotId, ImsConfigItem item);
428 
429     /**
430      * @brief Example Set the IMS service configuration
431      *
432      * @param slotId[in], The slot id
433      * @param item[in]
434      * @return Returns 0 on success, others on failure.
435      */
436     int32_t SetImsConfig(int32_t slotId, ImsConfigItem item, std::u16string &value);
437 
438     /**
439      * @brief Gets the value of the IMS function item of the specified network type
440      *
441      * @param slotId[in], The slot id
442      * @param info[in], FeatureType
443      * @return Returns 0 on success, others on failure.
444      */
445     int32_t GetImsFeatureValue(int32_t slotId, FeatureType type);
446 
447     /**
448      * @brief Set the value of the IMS function item of the specified network type
449      *
450      * @param slotId[in], The slot id
451      * @param info[in], FeatureType
452      * @param value[in]
453      * @return Returns 0 on success, others on failure.
454      */
455     int32_t SetImsFeatureValue(int32_t slotId, FeatureType type, int32_t value);
456 
457     /**
458      * @brief Setting the Call Mode
459      *
460      * @param callId[in], The call id
461      * @param mode[in], Calling patterns
462      * @return Returns 0 on success, others on failure.
463      */
464     int32_t UpdateImsCallMode(int32_t callId, ImsCallMode mode);
465 
466     /**
467      * @brief Start VoLte
468      *
469      * @param slotId[in], The slot id
470      * @return Returns 0 on success, others on failure.
471      */
472     int32_t EnableImsSwitch(int32_t slotId);
473 
474     /**
475      * @brief Stop VoLte
476      *
477      * @param slotId[in], The slot id
478      * @return Returns 0 on success, others on failure.
479      */
480     int32_t DisableImsSwitch(int32_t slotId);
481 
482     /**
483      * @brief Whether to enable VoLte
484      *
485      * @param slotId[in], The slot id
486      * @param enabled[out], The result of enable or not
487      * @return Returns 0 on success, others on failure.
488      */
489     int32_t IsImsSwitchEnabled(int32_t slotId, bool &enabled);
490 
491     /**
492      * @brief Set VoNR Switch Status
493      *
494      * @param state[in] Indicates the VoNR state, 0: off, 1: on
495      * @param slotId[in] the slot id
496      * @return Returns 0 on success, others on failure.
497      */
498     int32_t SetVoNRState(int32_t slotId, int32_t state);
499 
500     /**
501      * @brief Get VoNR Switch Status
502      *
503      * @param slotId[in] the slot id
504      * @param state[out] Indicates the VoNR state, 0: off, 1: on
505      * @return Returns 0 on success, others on failure.
506      */
507     int32_t GetVoNRState(int32_t slotId, int32_t &state);
508 
509     /**
510      * @brief Enable and send RTT information
511      *
512      * @param callId[in], The call id
513      * @param msg[in], RTT information
514      * @return Returns 0 on success, others on failure.
515      */
516     int32_t StartRtt(int32_t callId, std::u16string &msg);
517 
518     /**
519      * @brief Close the RTT
520      *
521      * @param callId[in], The call id
522      * @return Returns 0 on success, others on failure.
523      */
524     int32_t StopRtt(int32_t callId);
525 
526     /**
527      * @brief Bring someone into a meeting
528      *
529      * @param callId[in], The call id
530      * @param numberList[in], List of calls to join the conference
531      * @return Returns 0 on success, others on failure.
532      */
533     int32_t JoinConference(int32_t callId, std::vector<std::u16string> &numberList);
534 
535     /**
536      * @brief report ott call details info
537      *
538      * @param ottVec[in], ott call status detail info list
539      * @return Returns 0 on success, others on failure.
540      */
541     int32_t ReportOttCallDetailsInfo(std::vector<OttCallDetailsInfo> &ottVec);
542 
543     /**
544      * @brief report ott call event info
545      *
546      * @param eventInfo[in], ott call event detail info
547      * @return Returns 0 on success, others on failure.
548      */
549     int32_t ReportOttCallEventInfo(OttCallEventInfo &eventInfo);
550 
551     /**
552      * @brief Close Unfinished ussd function for the current account
553      *
554      * @param slotId[in], The slot id
555      * @return Returns 0 on success, others on failure.
556      */
557     int32_t CloseUnFinishedUssd(int32_t slotId);
558 
559     /**
560      * @brief Handle special code from dialer.
561      *
562      * @param specialCode[in], special code
563      * @return Returns 0 on success, others on failure.
564      */
565     int32_t InputDialerSpecialCode(const std::string &specialCode);
566 
567     /**
568      * @brief Remove missed incoming call notification.
569      *
570      * @return Returns 0 on success, others on failure.
571      */
572     int32_t RemoveMissedIncomingCallNotification();
573 
574     /**
575      * @brief Set VoIP Call state
576      *
577      * @param state[in] Indicates the VoIP Call state
578      * @return Returns 0 on success, others on failure.
579      */
580     int32_t SetVoIPCallState(int32_t state);
581 
582     /**
583      * @brief Get VoIP Call Switch Status
584      *
585      * @param state[out] Indicates the VoIP Call state
586      * @return Returns 0 on success, others on failure.
587      */
588     int32_t GetVoIPCallState(int32_t &state);
589 
590     /**
591      * @brief Checks whether a device supports voice calls
592      *
593      * @return true on support voice calls, false on not support.
594      */
595     bool HasVoiceCapability();
596 
597     /**
598      * @brief report audio device info
599      *
600      * @return Returns 0 on success, others on failure.
601      */
602     int32_t ReportAudioDeviceInfo();
603 
604     /**
605      * @brief cancel upgrade to video call
606      *
607      * @param callId[in], The call id
608      * @return Returns 0 on success, others on failure.
609      */
610     int32_t CancelCallUpgrade(int32_t callId);
611 
612     /**
613      * @brief request camera capabilities
614      *
615      * @param callId[in], The call id
616      * @return Returns 0 on success, others on failure.
617      */
618     int32_t RequestCameraCapabilities(int32_t callId);
619 
620     /**
621      * @brief notify voip register callstatus callback
622      *
623      * @return Returns 0 on success, others on failure.
624      */
625     int32_t RegisterVoipCallManagerCallback();
626 
627     /**
628      * @brief notify voip unregister callstatus callback
629      *
630      * @return Returns 0 on success, others on failure.
631      */
632     int32_t UnRegisterVoipCallManagerCallback();
633 
634     /**
635      * @brief send call ui event
636      *
637      * @return Returns 0 on success, others on failure.
638      */
639     int32_t SendCallUiEvent(int32_t callId, std::string &eventName);
640 };
641 } // namespace Telephony
642 } // namespace OHOS
643 
644 #endif
645