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