1 /*
2  * Copyright (C) 2021-2023 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 CELLULAR_CALL_PROXY_H
17 #define CELLULAR_CALL_PROXY_H
18 
19 #include "cellular_call_interface.h"
20 #include "cellular_call_ipc_interface_code.h"
21 #include "iremote_proxy.h"
22 
23 namespace OHOS {
24 namespace Telephony {
25 class CellularCallProxy : public IRemoteProxy<CellularCallInterface> {
26 public:
27     /**
28      * @brief Construct a new Cellular Call Proxy object
29      *
30      * @param impl
31      */
CellularCallProxy(const sptr<IRemoteObject> & impl)32     explicit CellularCallProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<CellularCallInterface>(impl) {}
33 
34     /**
35      * @brief Destroy the Cellular Call Proxy object
36      */
37     ~CellularCallProxy() = default;
38 
39     /**
40      * @brief dial a call
41      *
42      * @param callInfo[in] the call detail info which contains phone number, call type, slot id .etc
43      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
44      */
45     int32_t Dial(const CellularCallInfo &callInfo) override;
46 
47     /**
48      * @brief hang up a call
49      *
50      * @param callInfo[in] the call detail info which contains phone number, call type, slot id .etc
51      * @param type[in] Indicates the +CHLD related supplementary services.
52      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
53      */
54     int32_t HangUp(const CellularCallInfo &callInfo, CallSupplementType type) override;
55 
56     /**
57      * @brief reject a call
58      *
59      * @param callInfo[in] the call detail info which contains phone number, call type, slot id .etc
60      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
61      */
62     int32_t Reject(const CellularCallInfo &callInfo) override;
63 
64     /**
65      * @brief answer a call
66      *
67      * @param callInfo[in] the call detail info which contains phone number, call type, slot id .etc
68      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
69      */
70     int32_t Answer(const CellularCallInfo &callInfo) override;
71 
72     /**
73      * @brief hold a call
74      *
75      * @param callInfo[in] the call detail info which contains phone number, call type, slot id .etc
76      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
77      */
78     int32_t HoldCall(const CellularCallInfo &callInfo) override;
79 
80     /**
81      * @brief unhold a call
82      *
83      * @param callInfo[in] the call detail info which contains phone number, call type, slot id .etc
84      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
85      */
86     int32_t UnHoldCall(const CellularCallInfo &callInfo) override;
87 
88     /**
89      * @brief switch the call
90      *
91      * @param callInfo[in] the call detail info which contains phone number, call type, slot id .etc
92      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
93      */
94     int32_t SwitchCall(const CellularCallInfo &callInfo) override;
95 
96     /**
97      * @brief Checks whether the called number is an emergency number
98      *
99      * @param slotId[in] the slot id
100      * @param phoneNum[in] the phone number
101      * @param enabled[out] if the phone number is ecc, true is yes, false is no
102      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
103      */
104     int32_t IsEmergencyPhoneNumber(int32_t slotId, const std::string &phoneNum, bool &enabled) override;
105 
106     /**
107      * @brief Merge into multiple calls
108      *
109      * @param callInfo[in] the call detail info which contains phone number, call type, slot id .etc
110      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
111      */
112     int32_t CombineConference(const CellularCallInfo &callInfo) override;
113 
114     /**
115      * @brief Separate the Conference call
116      *
117      * @param callInfo[in] the call detail info which contains phone number, call type, slot id .etc
118      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
119      */
120     int32_t SeparateConference(const CellularCallInfo &callInfo) override;
121 
122     /**
123      * @brief Invite someone to the conference call
124      *
125      * @param numberList[in] the number list to invite to conference
126      * @param slotId[in] the slot id
127      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
128      */
129     int32_t InviteToConference(int32_t slotId, const std::vector<std::string> &numberList) override;
130 
131     /**
132      * @brief Kick out someone from the conference call
133      *
134      * @param callInfo[in] the call detail info which contains phone number, call type, slot id .etc
135      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
136      */
137     int32_t KickOutFromConference(const CellularCallInfo &callInfo) override;
138 
139     /**
140      * @brief Hang Up All Connection
141      *
142      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
143      */
144     int32_t HangUpAllConnection() override;
145 
146     /**
147      * @brief Hang Up All Connection
148      *
149      * @param slotId[in] the slot id
150      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
151      */
152     int32_t HangUpAllConnection(int32_t slotId) override;
153 
154     /**
155      * @brief set whether the device can make calls
156      *
157      * @param slotId[in] the slot id
158      * @param callType[in] indicate the call type is cs or ims. 0 is cs, 1 is ims
159      * @param isReadyToCall[in] indicate whether the device can make calls
160      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
161      */
162     int32_t SetReadyToCall(int32_t slotId, int32_t callType, bool isReadyToCall) override;
163 
164     /**
165      * @brief IMS Send Call Media Mode Request
166      *
167      * @param callInfo[in] the call detail info which contains phone number, call type, slot id .etc
168      * @param mode[in] indicate the call mode just like audio only, receive only .etc
169      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
170      */
171     int32_t SendUpdateCallMediaModeRequest(const CellularCallInfo &callInfo, ImsCallMode mode) override;
172 
173     /**
174      * @brief IMS Send Call Media Mode Response
175      *
176      * @param callInfo[in] the call detail info which contains phone number, call type, slot id .etc
177      * @param mode[in] indicate the call mode just like audio only, receive only .etc
178      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
179      */
180     int32_t SendUpdateCallMediaModeResponse(const CellularCallInfo &callInfo, ImsCallMode mode) override;
181 
182     /**
183      * @brief start to paly a dtmf tone
184      *
185      * @param cDtmfCode[in] A character indicate the DTMF digit for which to play the tone. This
186      * value must be one of {0~9}, {*} or {#}.
187      * @param callInfo[in] the call detail info which contains phone number, call type, slot id .etc
188      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
189      */
190     int32_t StartDtmf(char cDtmfCode, const CellularCallInfo &callInfo) override;
191 
192     /**
193      * @brief stop the playing dtmf tone
194      *
195      * @param callInfo[in] the call detail info which contains phone number, call type, slot id .etc
196      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
197      */
198     int32_t StopDtmf(const CellularCallInfo &callInfo) override;
199 
200     int32_t PostDialProceed(const CellularCallInfo &callInfo, const bool proceed) override;
201 
202     /**
203      * @brief play a dtmf tone
204      *
205      * @param cDtmfCode[in] A character indicate the DTMF digit for which to play the tone. This
206      * value must be one of {0~9}, {*} or {#}.
207      * @param callInfo[in] the call detail info which contains phone number, call type, slot id .etc
208      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
209      */
210     int32_t SendDtmf(char cDtmfCode, const CellularCallInfo &callInfo) override;
211 
212     /**
213      * @brief Start a Rtt session
214      *
215      * @param msg the rtt message
216      * @param slotId[in] the slot id
217      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
218      */
219     int32_t StartRtt(int32_t slotId, const std::string &msg) override;
220 
221     /**
222      * @brief Terminate the current RTT session
223      *
224      * @param slotId[in] the slot id
225      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
226      */
227     int32_t StopRtt(int32_t slotId) override;
228 
229     /**
230      * @brief set call transfer for the slot id
231      *
232      * @param ctInfo[in] contains the call transfer type, enable/disable, the transfered number, the start/end time
233      * @param slotId[in] the slot id
234      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
235      */
236     int32_t SetCallTransferInfo(int32_t slotId, const CallTransferInfo &cfInfo) override;
237 
238     /**
239      * @brief confirm whether IMS can set call transfer time
240      *
241      * @param slotId[in] the slot id
242      * @param result[out] whether IMS can set call transfer time. true mean yes, false mean no
243      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
244      */
245     int32_t CanSetCallTransferTime(int32_t slotId, bool &result) override;
246 
247     /**
248      * @brief Get Call Transfer information
249      *
250      * @param type[in] indicate the call transfer type, just like CFU, CFB, CFNRy, CFNRc
251      * @param slotId[in] the slot id
252      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
253      */
254     int32_t GetCallTransferInfo(int32_t slotId, CallTransferType type) override;
255 
256     /**
257      * @brief Set Call Waiting
258      *
259      * @param activate[in] true mean activate the call waiting, false mean inactivate
260      * @param slotId[in] the slot id
261      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
262      */
263     int32_t SetCallWaiting(int32_t slotId, bool activate) override;
264 
265     /**
266      * @brief Gets whether the call waiting service of the current account is enabled
267      *
268      * @param slotId[in] the slot id
269      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
270      */
271     int32_t GetCallWaiting(int32_t slotId) override;
272 
273     /**
274      * @brief Set the call restriction function for the current account
275      *
276      * @param cRInfo[in] contains the password, call restriction type and call restriction mode
277      * @param slotId[in] the slot id
278      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
279      */
280     int32_t SetCallRestriction(int32_t slotId, const CallRestrictionInfo &crInfo) override;
281 
282     /**
283      * @brief Set the call restriction password of the specified account
284      *
285      * @param slotId[in] the slot id
286      * @param fac[in] indicate the call restriction type, just like all incoming, all outgoing .etc
287      * @param oldPassword[in] indicate the call restriction old password
288      * @param newPassword[in] indicate the call restriction new password
289      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
290      */
291     int32_t SetCallRestrictionPassword(
292         int32_t slotId, CallRestrictionType fac, const char *oldPassword, const char *newPassword) override;
293 
294     /**
295      * @brief Gets the call restriction information of the specified account
296      *
297      * @param facType[in] indicate the call restriction type, just like all incoming, all outgoing .etc
298      * @param slotId[in] the slot id
299      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
300      */
301     int32_t GetCallRestriction(int32_t slotId, CallRestrictionType facType) override;
302 
303     /**
304      * @brief Register CallManager CallBack ptr
305      *
306      * @param callback callback ptr
307      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
308      */
309     int32_t RegisterCallManagerCallBack(const sptr<ICallStatusCallback> &callback) override;
310 
311     /**
312      * @brief UnRegister CallManager CallBack ptr
313      *
314      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
315      */
316     int32_t UnRegisterCallManagerCallBack() override;
317 
318     /**
319      * @brief Set Domain Preference Mode
320      *
321      * @param mode[in] indicate the domain preference, 1: CS only, 2: CS prefer, 3: PS prefer, 4: PS only
322      * @param slotId[in] the slot id
323      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
324      */
325     int32_t SetDomainPreferenceMode(int32_t slotId, int32_t mode) override;
326 
327     /**
328      * @brief Get Domain Preference Mode
329      *
330      * @param slotId[in] the slot id
331      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
332      */
333     int32_t GetDomainPreferenceMode(int32_t slotId) override;
334 
335     /**
336      * @brief Set Ims Switch Status
337      *
338      * @param active[in] indicate the ims switch status, true is on, false is off
339      * @param slotId[in] the slot id
340      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
341      */
342     int32_t SetImsSwitchStatus(int32_t slotId, bool active) override;
343 
344     /**
345      * @brief Get Ims Switch Status
346      *
347      * @param slotId[in] the slot id
348      * @param enabled[out] indicate the ims switch status, true is on, false is off
349      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
350      */
351     int32_t GetImsSwitchStatus(int32_t slotId, bool &enabled) override;
352 
353     /**
354      * @brief Set VoNR Switch Status
355      *
356      * @param state[in] Indicates the VoNR state, 0: off, 1: on
357      * @param slotId[in] the slot id
358      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
359      */
360     int32_t SetVoNRState(int32_t slotId, int32_t state) override;
361 
362     /**
363      * @brief Get VoNR Switch Status
364      *
365      * @param slotId[in] the slot id
366      * @param state[out] Indicates the VoNR state, 0: off, 1: on
367      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
368      */
369     int32_t GetVoNRState(int32_t slotId, int32_t &state) override;
370 
371     /**
372      * @brief Set Ims Config
373      *
374      * @param item[in] Identify specific item, like ITEM_VIDEO_QUALITY, ITEM_IMS_SWITCH_STATUS
375      * @param value[in] The specific value corresponding to the item
376      * @param slotId[in] the slot id
377      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
378      */
379     int32_t SetImsConfig(int32_t slotId, ImsConfigItem item, const std::string &value) override;
380 
381     /**
382      * @brief Set Ims Config
383      *
384      * @param item[in] Identify specific item, like ITEM_VIDEO_QUALITY, ITEM_IMS_SWITCH_STATUS
385      * @param value[in] The specific value corresponding to the item
386      * @param slotId[in] the slot id
387      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
388      */
389     int32_t SetImsConfig(int32_t slotId, ImsConfigItem item, int32_t value) override;
390 
391     /**
392      * @brief Get Ims Config
393      *
394      * @param item[in] Identify specific item, like ITEM_VIDEO_QUALITY, ITEM_IMS_SWITCH_STATUS
395      * @param slotId[in] the slot id
396      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
397      */
398     int32_t GetImsConfig(int32_t slotId, ImsConfigItem item) override;
399 
400     /**
401      * @brief Set Ims Feature Value
402      *
403      * @param type[in] the ims feature item, like VoLTE, ViLTE, SS over UT
404      * @param value[in] The specific value corresponding to the item
405      * @param slotId[in] the slot id
406      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
407      */
408     int32_t SetImsFeatureValue(int32_t slotId, FeatureType type, int32_t value) override;
409 
410     /**
411      * @brief Get Ims Feature Value
412      *
413      * @param type[in] the ims feature item, like VoLTE, ViLTE, SS over UT
414      * @param slotId[in] the slot id
415      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
416      */
417     int32_t GetImsFeatureValue(int32_t slotId, FeatureType type) override;
418 
419     /**
420      * @brief set camara to be enabled for video call
421      *
422      * @param slotId[in] the slot id
423      * @param index[in] the index of call
424      * @param cameraId[in] The id of the camera
425      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
426      */
427     int32_t ControlCamera(int32_t slotId, int32_t index, const std::string &cameraId) override;
428 
429     /**
430      * @brief set a window which used to display a preview of camera capturing
431      *
432      * @param slotId[in] the slot id
433      * @param index[in] the index of call
434      * @param surfaceId[in] the window information
435      * @param surface[in] the window information
436      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
437      */
438     int32_t SetPreviewWindow(
439         int32_t slotId, int32_t index, const std::string &surfaceId, sptr<Surface> surface) override;
440 
441     /**
442      * @brief set a window which used to display the viedo which is received from remote
443      *
444      * @param slotId[in] the slot id
445      * @param index[in] the index of call
446      * @param surfaceId[in] the window information
447      * @param surface[in] the window information
448      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
449      */
450     int32_t SetDisplayWindow(
451         int32_t slotId, int32_t index, const std::string &surfaceId, sptr<Surface> surface) override;
452 
453     /**
454      * @brief set camera zoom ratio
455      *
456      * @param zoomRatio[in] the camera zoom ratio
457      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
458      */
459     int32_t SetCameraZoom(float zoomRatio) override;
460 
461     /**
462      * @brief set a image which will be displayed when the video signal is paused
463      *
464      * @param slotId[in] the slot id
465      * @param index[in] the index of call
466      * @param path[in] the dispalyed image path
467      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
468      */
469     int32_t SetPausePicture(int32_t slotId, int32_t index, const std::string &path) override;
470 
471     /**
472      * @brief set the device orientation
473      *
474      * @param slotId[in] the slot id
475      * @param index[in] the index of call
476      * @param rotation[in] The device orientation, in degrees
477      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
478      */
479     int32_t SetDeviceDirection(int32_t slotId, int32_t index, int32_t rotation) override;
480 
481     /**
482      * @brief Set the mute state of the call
483      *
484      * @param mute[in] 1 means the call could be muted
485      * @param slotId[in] the slot id
486      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
487      */
488     int32_t SetMute(int32_t mute, int32_t slotId) override;
489 
490     /**
491      * @brief Get the mute state of the call
492      *
493      * @param slotId[in] the slot id
494      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
495      */
496     int32_t GetMute(int32_t slotId) override;
497 
498     /**
499      * @brief Set emergency phone number
500      *
501      * @param eccVecr[in] ecc number info list
502      * @param slotId[in] The slot id
503      * @return Returns TELEPHONY_SUCCESS on true, others on false.
504      */
505     int32_t SetEmergencyCallList(int32_t slotId, std::vector<EmergencyCall>  &eccVec) override;
506 
507     /**
508      * @brief Close Unfinished ussd function for the current account
509      *
510      * @param slotId[in] the slot id
511      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
512      */
513     int32_t CloseUnFinishedUssd(int32_t slotId) override;
514 
515     /**
516      * @brief clear all call if cellular call service restart
517      *
518      * @param infos[in] the call detail info vector which contains phone number, call type, slot id .etc
519      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
520      */
521     int32_t ClearAllCalls(const std::vector<CellularCallInfo> &infos) override;
522 
523     /**
524      * @brief cancel call upgrade
525      *
526      * @param slotId[in] the slot id
527      * @param index[in] the index of call
528      * @return Returns 0 on success, others on failure.
529      */
530     int32_t CancelCallUpgrade(int32_t slotId, int32_t index) override;
531 
532     /**
533      * @brief request camera capabilities
534      *
535      * @param slotId[in] the slot id
536      * @param index[in] the index of call
537      * @return Returns 0 on success, others on failure.
538      */
539     int32_t RequestCameraCapabilities(int32_t slotId, int32_t index) override;
540 
541 private:
542     /**
543      * @brief SetCommonParamForMessageParcel, set common param for MessageParcel
544      *
545      * @param slotId[in] the slot id
546      * @param in[out] the MessageParcel which will contain some common parameters like slotid, token,
547      * max size while the return is success.
548      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
549      */
550     int32_t SetCommonParamForMessageParcel(int32_t slotId, MessageParcel &in);
551 
552 private:
553     static inline BrokerDelegator<CellularCallProxy> delegator_;
554 };
555 } // namespace Telephony
556 } // namespace OHOS
557 #endif // CELLULAR_CALL_PROXY_H
558