• 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_CONTROL_MANAGER_H
17 #define CALL_CONTROL_MANAGER_H
18 
19 #include <cstring>
20 #include <list>
21 #include <memory>
22 #include <mutex>
23 
24 #include "pac_map.h"
25 #include "singleton.h"
26 
27 #include "call_setting_manager.h"
28 #include "call_policy.h"
29 #include "call_state_listener.h"
30 #include "call_request_handler.h"
31 #include "missed_call_notification.h"
32 
33 /**
34  * Singleton
35  * @ClassName:CallControlManager
36  * @Description:CallControlManager is designed for performing dial/answer/reject etc ops
37  * on kinds of calls(ims,cs,ott). usually as a entrance for downflowed [app->ril] telephony business
38  */
39 namespace OHOS {
40 namespace Telephony {
41 class CallControlManager : public CallPolicy {
42     DECLARE_DELAYED_SINGLETON(CallControlManager)
43 public:
44     bool Init();
45     int32_t DialCall(std::u16string &number, AppExecFwk::PacMap &extras);
46     int32_t AnswerCall(int32_t callId, int32_t videoState);
47     int32_t RejectCall(int32_t callId, bool rejectWithMessage, std::u16string textMessage);
48     int32_t HangUpCall(int32_t callId);
49     int32_t GetCallState();
50     int32_t HoldCall(int32_t callId);
51     int32_t UnHoldCall(int32_t callId);
52     int32_t SwitchCall(int32_t callId);
53     bool HasCall();
54     bool IsNewCallAllowed();
55     bool IsRinging();
56     bool HasEmergency();
57     bool NotifyNewCallCreated(sptr<CallBase> &callObjectPtr);
58     bool NotifyCallDestroyed(int32_t cause);
59     bool NotifyCallStateUpdated(sptr<CallBase> &callObjectPtr, TelCallState priorState, TelCallState nextState);
60     bool NotifyIncomingCallAnswered(sptr<CallBase> &callObjectPtr);
61     bool NotifyIncomingCallRejected(sptr<CallBase> &callObjectPtr, bool isSendSms, std::string content);
62     bool NotifyCallEventUpdated(CallEventInfo &info);
63     int32_t StartDtmf(int32_t callId, char str);
64     int32_t StopDtmf(int32_t callId);
65     int32_t GetCallWaiting(int32_t slotId);
66     int32_t SetCallWaiting(int32_t slotId, bool activate);
67     int32_t GetCallRestriction(int32_t slotId, CallRestrictionType type);
68     int32_t SetCallRestriction(int32_t slotId, CallRestrictionInfo &info);
69     int32_t GetCallTransferInfo(int32_t slotId, CallTransferType type);
70     int32_t SetCallTransferInfo(int32_t slotId, CallTransferInfo &info);
71     int32_t SetCallPreferenceMode(int32_t slotId, int32_t mode);
72     // merge calls
73     int32_t CombineConference(int32_t mainCallId);
74     int32_t SeparateConference(int32_t callId);
75     int32_t GetMainCallId(int32_t callId);
76     std::vector<std::u16string> GetSubCallIdList(int32_t callId);
77     std::vector<std::u16string> GetCallIdListForConference(int32_t callId);
78     int32_t GetImsConfig(int32_t slotId, ImsConfigItem item);
79     int32_t SetImsConfig(int32_t slotId, ImsConfigItem item, std::u16string &value);
80     int32_t GetImsFeatureValue(int32_t slotId, FeatureType type);
81     int32_t SetImsFeatureValue(int32_t slotId, FeatureType type, int32_t value);
82     int32_t EnableImsSwitch(int32_t slotId);
83     int32_t DisableImsSwitch(int32_t slotId);
84     int32_t IsImsSwitchEnabled(int32_t slotId);
85     int32_t SetLteEnhanceMode(int32_t slotId, bool value);
86     int32_t GetLteEnhanceMode(int32_t slotId);
87     int32_t UpdateImsCallMode(int32_t callId, ImsCallMode mode);
88     int32_t StartRtt(int32_t callId, std::u16string &msg);
89     int32_t StopRtt(int32_t callId);
90     // invite calls to participate conference
91     int32_t JoinConference(int32_t callId, std::vector<std::u16string> &numberList);
92     int32_t SetMuted(bool isMute);
93     int32_t MuteRinger();
94     int32_t SetAudioDevice(AudioDevice deviceType);
95     int32_t ControlCamera(std::u16string cameraId, int32_t callingUid, int32_t callingPid);
96     int32_t SetPreviewWindow(VideoWindow &window);
97     int32_t SetDisplayWindow(VideoWindow &window);
98     int32_t SetCameraZoom(float zoomRatio);
99     int32_t SetPausePicture(std::u16string path);
100     int32_t SetDeviceDirection(int32_t rotation);
101     bool IsEmergencyPhoneNumber(std::u16string &number, int32_t slotId, int32_t &errorCode);
102     int32_t FormatPhoneNumber(std::u16string &number, std::u16string &countryCode, std::u16string &formatNumber);
103     int32_t FormatPhoneNumberToE164(
104         std::u16string &number, std::u16string &countryCode, std::u16string &formatNumber);
105     void GetDialParaInfo(DialParaInfo &info);
106     void GetDialParaInfo(DialParaInfo &info, AppExecFwk::PacMap &extras);
107 
108 private:
109     void CallStateObserve();
110     int32_t NumberLegalityCheck(std::string &number);
111     int32_t BroadcastSubscriber();
112 
113 private:
114     std::unique_ptr<CallStateListener> callStateListenerPtr_;
115     std::unique_ptr<CallRequestHandlerService> callRequestHandlerServicePtr_;
116     // notify when incoming calls are ignored, not rejected or answered
117     std::unique_ptr<MissedCallNotification> missedCallNotification_;
118     std::unique_ptr<CallSettingManager> callSettingManagerPtr_;
119     DialParaInfo dialSrcInfo_;
120     AppExecFwk::PacMap extras_;
121     std::mutex mutex_;
122 };
123 } // namespace Telephony
124 } // namespace OHOS
125 #endif // CALL_CONTROL_MANAGER_H
126