• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 TELEPHONY_IMS_CALL_CLIENT_H
17 #define TELEPHONY_IMS_CALL_CLIENT_H
18 
19 #include "event_runner.h"
20 #include "ims_call_interface.h"
21 #include "ims_core_service_interface.h"
22 #include "iremote_stub.h"
23 #include "rwlock.h"
24 #include "singleton.h"
25 #include "system_ability_status_change_stub.h"
26 
27 namespace OHOS {
28 namespace Telephony {
29 class ImsCallClient {
30     DECLARE_DELAYED_SINGLETON(ImsCallClient);
31 
32 public:
33     /**
34      * @brief Get ImsCall Remote Object ptr
35      *
36      * @return sptr<ImsCallInterface>
37      */
38     sptr<ImsCallInterface> GetImsCallProxy();
39 
40     /**
41      * @brief Get the remote object ptr, initiate a listener and subscribe the system ability
42      */
43     void Init();
44 
45     /**
46      * @brief Clear the listener and the remote ptr when destroy the ImsCallClient Object
47      */
48     void UnInit();
49 
50     /**
51      * @brief Register ImsCallCallback Handler, put the handler and slot id into {handlerMap_}
52      *
53      * @param slotId Indicates the card slot index number,
54      * @param handler Indicates the event handler ptr
55      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
56      */
57     int32_t RegisterImsCallCallbackHandler(int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler);
58 
59     /**
60      * @brief Get the event handler ptr from {handlerMap_}
61      *
62      * @param slotId Indicates the card slot index number,
63      * @return AppExecFwk::EventHandler
64      */
65     std::shared_ptr<AppExecFwk::EventHandler> GetHandler(int32_t slotId);
66 
67     /****************** call basic ******************/
68     /**
69      * @brief IMS dial the call interface
70      *
71      * @param ImsCallInfo Indicates the call detail information, contains phone number, slot id,
72      * video state, call index
73      * @param CLIRMode Indicates the CLIR mode, like default, transfer, inhibition
74      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
75      */
76     int32_t Dial(const ImsCallInfo &callInfo, CLIRMode mode);
77 
78     /**
79      * @brief IMS HangUp the call interface
80      *
81      * @param ImsCallInfo Indicates the call detail information, contains phone number, slot id,
82      * video state, call index
83      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
84      */
85     int32_t HangUp(const ImsCallInfo &callInfo);
86 
87     /**
88      * @brief IMS Reject the call interface
89      *
90      * @param ImsCallInfo Indicates the call detail information, contains phone number, slot id,
91      * video state, call index
92      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
93      */
94     int32_t Reject(const ImsCallInfo &callInfo);
95 
96     /**
97      * @brief IMS Reject the call with reason interface
98      *
99      * @param ImsCallInfo Indicates the call detail information, contains phone number, slot id,
100      * video state, call index
101      * @param ImsRejectReason Indicated the reject reason, like user is busy or user decline
102      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
103      */
104     int32_t RejectWithReason(const ImsCallInfo &callInfo, const ImsRejectReason &reason);
105 
106     /**
107      * @brief IMS Answer the call interface
108      *
109      * @param ImsCallInfo Indicates the call detail information, contains phone number, slot id,
110      * video state, call index
111      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
112      */
113     int32_t Answer(const ImsCallInfo &callInfo);
114 
115     /**
116      * @brief Hold the Call
117      *
118      * @param slotId Indicates the card slot index number,
119      * @param callType Indicates the call type,
120      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
121      */
122     int32_t HoldCall(int32_t slotId, int32_t callType);
123 
124     /**
125      * @brief UnHold the Call
126      *
127      * @param slotId Indicates the card slot index number,
128      * @param callType Indicates the type of video state, 0: voice, 1: video
129      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
130      */
131     int32_t UnHoldCall(int32_t slotId, int32_t callType);
132 
133     /**
134      * @brief Switch the phone call between hold and unhold
135      *
136      * @param slotId Indicates the card slot index number,
137      * @param callType Indicates the type of video state, 0: voice, 1: video
138      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
139      */
140     int32_t SwitchCall(int32_t slotId, int32_t callType);
141 
142     /**
143      * @brief Merge calls to form a conference
144      *
145      * @param slotId Indicates the card slot index number,
146      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
147      */
148     int32_t CombineConference(int32_t slotId);
149 
150     /**
151      * @brief Invite someone to conference
152      *
153      * @param slotId Indicates the card slot index number,
154      * @param numberList phone number list which will be invited to the conference call
155      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
156      */
157     int32_t InviteToConference(int32_t slotId, const std::vector<std::string> &numberList);
158 
159     /**
160      * @brief Kick out someone from conference
161      *
162      * @param slotId Indicates the card slot index number,
163      * @param index which will be kicked out from the conference call
164      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
165      */
166     int32_t KickOutFromConference(int32_t slotId, int32_t index);
167 
168     /**
169      * @brief IMS UpdateImsCallMode interface
170      *
171      * @param ImsCallInfo Indicates the call detail information, contains phone number, slot id,
172      * video state, call index
173      * @param ImsCallMode Indicates the call media mode, like audio only, send only .etc.
174      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
175      */
176     int32_t UpdateImsCallMode(const ImsCallInfo &callInfo, ImsCallMode mode);
177 
178     /**
179      * @brief Get Ims Calls Data Request
180      *
181      * @param slotId Indicates the card slot index number,
182      * @param lastCallsDataFlag The ims call data id, is a number in milliseconds
183      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
184      */
185     int32_t GetImsCallsDataRequest(int32_t slotId, int64_t lastCallsDataFlag);
186 
187     /**
188      * @brief Get Last Call Fail Reason
189      *
190      * @param slotId Indicates the card slot index number,
191      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
192      */
193     int32_t GetLastCallFailReason(int32_t slotId);
194 
195     /****************** dtmf rtt ******************/
196     /**
197      * @brief start to paly a dtmf tone
198      *
199      * @param slotId Indicates the card slot index number,
200      * @param cDTMFCode A character indicate the DTMF digit for which to play the tone. This
201      * value must be one of {0~9}, {*} or {#}.
202      * @param index Indicates the index of command.
203      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
204      */
205     int32_t StartDtmf(int32_t slotId, char cDtmfCode, int32_t index);
206 
207     /**
208      * @brief play a dtmf tone
209      *
210      * @param slotId Indicates the card slot index number,
211      * @param cDtmfCode A character indicate the DTMF digit for which to play the tone. This
212      * value must be one of {0~9}, {*} or {#}.
213      * @param index Indicates the index of command.
214      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
215      */
216     int32_t SendDtmf(int32_t slotId, char cDtmfCode, int32_t index);
217 
218     /**
219      * @brief stop the playing dtmf tone
220      *
221      * @param slotId Indicates the card slot index number,
222      * @param index Indicates the index of command.
223      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
224      */
225     int32_t StopDtmf(int32_t slotId, int32_t index);
226 
227     /**
228      * @brief Start a RTT session
229      *
230      * @param slotId Indicates the card slot index number,
231      * @param msg the specific RTT msg
232      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
233      */
234     int32_t StartRtt(int32_t slotId, const std::string &msg);
235 
236     /**
237      * @brief Terminate the current RTT session
238      *
239      * @param slotId Indicates the card slot index number,
240      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
241      */
242     int32_t StopRtt(int32_t slotId);
243 
244     /****************** ims config ******************/
245     /**
246      * @brief Set Domain Preference Mode
247      *
248      * @param slotId Indicates the card slot index number,
249      * @param mode indicate the domain preference, 1: CS only, 2: CS prefer, 3: PS prefer, 4: PS only
250      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
251      */
252     int32_t SetDomainPreferenceMode(int32_t slotId, int32_t mode);
253 
254     /**
255      * @brief Get Domain Preference Mode
256      *
257      * @param slotId Indicates the card slot index number,
258      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
259      */
260     int32_t GetDomainPreferenceMode(int32_t slotId);
261 
262     /**
263      * @brief Set the ims switch status
264      *
265      * @param slotId Indicates the card slot index number,
266      * @param active 1: enable ims, 0: disable ims
267      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
268      */
269     int32_t SetImsSwitchStatus(int32_t slotId, int32_t active);
270 
271     /**
272      * @brief IMS GetImsSwitchStatus interface
273      *
274      * @param slotId Indicates the card slot index number,
275      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
276      */
277     int32_t GetImsSwitchStatus(int32_t slotId);
278 
279     /**
280      * @brief IMS SetImsConfig interface
281      *
282      * @param ImsConfigItem Identify specific item, like ITEM_VIDEO_QUALITY, ITEM_IMS_SWITCH_STATUS
283      * @param value The specific value corresponding to the item
284      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
285      */
286     int32_t SetImsConfig(ImsConfigItem item, const std::string &value);
287 
288     /**
289      * @brief IMS SetImsConfig interface
290      *
291      * @param ImsConfigItem Identify specific item, like ITEM_VIDEO_QUALITY, ITEM_IMS_SWITCH_STATUS
292      * @param value The specific value corresponding to the item
293      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
294      */
295     int32_t SetImsConfig(ImsConfigItem item, int32_t value);
296 
297     /**
298      * @brief IMS GetImsConfig interface
299      *
300      * @param ImsConfigItem Identify specific item, like ITEM_VIDEO_QUALITY, ITEM_IMS_SWITCH_STATUS
301      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
302      */
303     int32_t GetImsConfig(ImsConfigItem item);
304 
305     /**
306      * @brief IMS SetImsFeatureValue interface
307      *
308      * @param FeatureType the ims feature item, like VoLTE, ViLTE, SS over UT
309      * @param value The specific value corresponding to the item
310      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
311      */
312     int32_t SetImsFeatureValue(FeatureType type, int32_t value);
313 
314     /**
315      * @brief IMS GetImsFeatureValue interface
316      *
317      * @param FeatureType Indicate which feature type to query.
318      * @param value Indicate the return value of the query feature type.
319      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
320      */
321     int32_t GetImsFeatureValue(FeatureType type, int32_t &value);
322 
323     /**
324      * @brief Set the mute state of the call
325      *
326      * @param mute 0: not mute, 1:mute
327      * @param slotId Indicates the card slot index number,
328      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
329      */
330     int32_t SetMute(int32_t slotId, int32_t mute);
331 
332     /**
333      * @brief IMS GetMute interface
334      *
335      * @param slotId Indicates the card slot index number,
336      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
337      */
338     int32_t GetMute(int32_t slotId);
339 
340     /****************** video settings ******************/
341     /**
342      * @brief IMS CtrlCamera interface
343      *
344      * @param cameraId The id of the camera
345      * @param callingUid the UID of call
346      * @param callingPid the PID if call
347      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
348      */
349     int32_t CtrlCamera(const std::u16string &cameraId, int32_t callingUid, int32_t callingPid);
350 
351     /**
352      * @brief Set a window which used to display a preview of camera capturing
353      *
354      * @param x X coordinate of window
355      * @param y Y coordinate of window
356      * @param z Z coordinate of window
357      * @param width the width of window
358      * @param height the height of window
359      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
360      */
361     int32_t SetPreviewWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height);
362 
363     /**
364      * @brief Set a window which used to display the viedo which is received from remote
365      *
366      * @param x X coordinate of window
367      * @param y Y coordinate of window
368      * @param z Z coordinate of window
369      * @param width the width of window
370      * @param height the height of window
371      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
372      */
373     int32_t SetDisplayWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height);
374 
375     /**
376      * @brief Set camera zoom ratio
377      *
378      * @param zoomRatio the camera zoom ratio
379      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
380      */
381     int32_t SetCameraZoom(float zoomRatio);
382 
383     /**
384      * @brief Set a image which will be displayed when the video signal is paused
385      *
386      * @param path the dispalyed image path
387      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
388      */
389     int32_t SetPauseImage(const std::u16string &path);
390 
391     /**
392      * @brief Set the device orientation
393      *
394      * @param rotation The device orientation, in degrees
395      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
396      */
397     int32_t SetDeviceDirection(int32_t rotation);
398 
399     /****************** supplement ******************/
400     /**
401      * @brief SetClip IMS SetClip interface
402      *
403      * @param slotId Indicates the card slot index number,
404      * ranging from 0 to the maximum card slot index number supported by the device.
405      * @param action Indicates the action for SetClip,
406      * 1, means turn on clip; 0, means turn off clip.
407      * @param index Indicates the index of command.
408      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
409      */
410     int32_t SetClip(int32_t slotId, int32_t action, int32_t index);
411 
412     /**
413      * @brief GetClip IMS GetClip interface
414      *
415      * @param slotId Indicates the card slot index number,
416      * ranging from 0 to the maximum card slot index number supported by the device.
417      * @param index Indicates the index of command.
418      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
419      */
420     int32_t GetClip(int32_t slotId, int32_t index);
421 
422     /**
423      * @brief SetClir IMS SetClir interface
424      *
425      * @param slotId Indicates the card slot index number,
426      * ranging from 0 to the maximum card slot index number supported by the device.
427      * @param action Indicates the action for SetClir,
428      * 1, means turn on clir; 0, means turn off clir.
429      * @param index Indicates the index of command.
430      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
431      */
432     int32_t SetClir(int32_t slotId, int32_t action, int32_t index);
433 
434     /**
435      * @brief GetClir IMS GetClir interface
436      *
437      * @param slotId Indicates the card slot index number,
438      * ranging from 0 to the maximum card slot index number supported by the device.
439      * @param index Indicates the index of command.
440      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
441      */
442     int32_t GetClir(int32_t slotId, int32_t index);
443 
444     /**
445      * @brief SetCallTransfer Set Call Transfer Request
446      *
447      * @param slotId Indicates the card slot index number,
448      * ranging from 0 to the maximum card slot index number supported by the device.
449      * @param cfInfo Indicates the reason/mode/transferNum/timer of the set call transfer.
450      * @param classType Indicates a sum of service class for setting call transfer.
451      * @param index Indicates the index of command.
452      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
453      */
454     int32_t SetCallTransfer(int32_t slotId, const CallTransferInfo &cfInfo, int32_t classType, int32_t index);
455 
456     /**
457      * @brief confirm whether IMS can set call transfer time.
458      *
459      * @param slotId Indicates the card slot index number,
460      * ranging from 0 to the maximum card slot index number supported by the device.
461      * @param result, The result of can set or not
462      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
463      */
464     int32_t CanSetCallTransferTime(int32_t slotId, bool &result);
465 
466     /**
467      * @brief GetCallTransfer IMS GetCallTransfer interface
468      *
469      * @param slotId Indicates the card slot index number,
470      * ranging from 0 to the maximum card slot index number supported by the device.
471      * @param reason Indicates the reason of the get call transfer.
472      * @param index Indicates the index of command.
473      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
474      */
475     int32_t GetCallTransfer(int32_t slotId, int32_t reason, int32_t index);
476 
477     /**
478      * @brief SetCallRestriction IMS SetCallRestriction interface
479      *
480      * @param slotId Indicates the card slot index number,
481      * ranging from 0 to the maximum card slot index number supported by the device.
482      * @param fac Indicates the facility of the set call restriction.
483      * @param mode Indicates the mode of the set call restriction.
484      * @param pw Indicates password or "" if not required.
485      * @param index Indicates the index of command.
486      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
487      */
488     int32_t SetCallRestriction(
489         int32_t slotId, const std::string &fac, int32_t mode, const std::string &pw, int32_t index);
490 
491     /**
492      * @brief GetCallRestriction IMS GetCallRestriction interface
493      *
494      * @param slotId Indicates the card slot index number,
495      * ranging from 0 to the maximum card slot index number supported by the device.
496      * @param fac Indicates the facility of the get call restriction.
497      * @param index Indicates the index of command.
498      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
499      */
500     int32_t GetCallRestriction(int32_t slotId, const std::string &fac, int32_t index);
501 
502     /**
503      * @brief SetCallWaiting IMS SetCallWaiting interface
504      *
505      * @param slotId Indicates the card slot index number,
506      * ranging from 0 to the maximum card slot index number supported by the device.
507      * @param activate Indicates the action for SetCallWaiting,
508      * true, means turn on CallWaiting; false, means turn off CallWaiting.
509      * @param classType Call waiting and conditions +CCWA,
510      * the value was {@code ServiceClassType}, See 3GPP TS 22.083.
511      * @param index Indicates the index of command.
512      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
513      */
514     int32_t SetCallWaiting(int32_t slotId, bool activate, int32_t classType, int32_t index);
515 
516     /**
517      * @brief GetCallWaiting IMS GetCallWaiting interface
518      *
519      * @param slotId Indicates the card slot index number,
520      * ranging from 0 to the maximum card slot index number supported by the device.
521      * @param index Indicates the index of command.
522      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
523      */
524     int32_t GetCallWaiting(int32_t slotId, int32_t index);
525 
526     /**
527      * @brief SetColr IMS SetColr interface
528      *
529      * @param slotId Indicates the card slot index number,
530      * ranging from 0 to the maximum card slot index number supported by the device.
531      * @param presentation Indicates the action for SetColr,
532      * 1, means turn on colr; 0, means turn off colr.
533      * @param index Indicates the index of command.
534      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
535      */
536     int32_t SetColr(int32_t slotId, int32_t presentation, int32_t index);
537 
538     /**
539      * @brief GetColr IMS GetColr interface
540      *
541      * @param slotId Indicates the card slot index number,
542      * ranging from 0 to the maximum card slot index number supported by the device.
543      * @param index Indicates the index of command.
544      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
545      */
546     int32_t GetColr(int32_t slotId, int32_t index);
547 
548     /**
549      * @brief SetColp IMS SetColp interface
550      *
551      * @param slotId Indicates the card slot index number,
552      * ranging from 0 to the maximum card slot index number supported by the device.
553      * @param action Indicates the action for SetColp,
554      * 1, means turn on colp; 0, means turn off colp.
555      * @param index Indicates the index of command.
556      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
557      */
558     int32_t SetColp(int32_t slotId, int32_t action, int32_t index);
559 
560     /**
561      * @brief GetColp IMS GetColp interface
562      *
563      * @param slotId Indicates the card slot index number,
564      * ranging from 0 to the maximum card slot index number supported by the device.
565      * @param index Indicates the index of command.
566      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
567      */
568     int32_t GetColp(int32_t slotId, int32_t index);
569 
570     /**
571      * @brief Update Ims Capabilities
572      *
573      * @param slotId Indicates the card slot index number,
574      * ranging from 0 to the maximum card slot index number supported by the device.
575      * @param imsCapabilityList Indicates the related ims capability
576      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
577      */
578     int32_t UpdateImsCapabilities(int32_t slotId, const ImsCapabilityList &imsCapabilityList);
579 
580     /**
581      * @brief Get impu which come form network
582      *
583      * @param slotId Indicates the card slot index number,
584      * ranging from 0 to the maximum card slot index number supported by the device.
585      * @param impu the result of impu
586      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
587      */
588     int32_t GetUtImpuFromNetwork(int32_t slotId, std::string &impu);
589 
590 private:
591     class SystemAbilityListener : public SystemAbilityStatusChangeStub {
592     public:
SystemAbilityListener()593         SystemAbilityListener() {}
~SystemAbilityListener()594         ~SystemAbilityListener() {}
595 
596     public:
597         void OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override;
598         void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override;
599     };
600 
601     /**
602      * Is Connect ImsCall Remote Object
603      *
604      * @return bool
605      */
606     bool IsConnect() const;
607     int32_t RegisterImsCallCallback();
608     int32_t ReConnectService();
609     void Clean();
610 
611 private:
612     sptr<ImsCoreServiceInterface> imsCoreServiceProxy_ = nullptr;
613     sptr<ImsCallInterface> imsCallProxy_ = nullptr;
614     sptr<ImsCallCallbackInterface> imsCallCallback_ = nullptr;
615     std::map<int32_t, std::shared_ptr<AppExecFwk::EventHandler>> handlerMap_;
616     Utils::RWLock rwClientLock_;
617     sptr<ISystemAbilityStatusChange> statusChangeListener_ = nullptr;
618 };
619 } // namespace Telephony
620 } // namespace OHOS
621 
622 #endif // TELEPHONY_IMS_CORE_SERVICE_CLIENT_H
623