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