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