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