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_BASE_H 17 #define CALL_BASE_H 18 19 #include <unistd.h> 20 #include <cstring> 21 #include <memory> 22 #include <mutex> 23 24 #include "refbase.h" 25 #include "pac_map.h" 26 27 #include "common_type.h" 28 #include "conference_base.h" 29 #include "call_manager_info.h" 30 31 /** 32 * @ClassName: CallBase 33 * @Description: an abstraction of telephone calls, provide basic call ops interfaces 34 */ 35 namespace OHOS { 36 namespace Telephony { 37 class CallBase : public virtual RefBase { 38 public: 39 explicit CallBase(DialParaInfo &info); 40 CallBase(DialParaInfo &info, AppExecFwk::PacMap &extras); 41 virtual ~CallBase(); 42 43 virtual int32_t DialingProcess() = 0; 44 virtual int32_t AnswerCall(int32_t videoState) = 0; 45 virtual int32_t RejectCall() = 0; 46 virtual int32_t HangUpCall() = 0; 47 virtual int32_t HoldCall() = 0; 48 virtual int32_t UnHoldCall() = 0; 49 virtual int32_t SwitchCall() = 0; 50 virtual void GetCallAttributeInfo(CallAttributeInfo &info) = 0; 51 virtual bool GetEmergencyState() = 0; 52 virtual int32_t StartDtmf(char str) = 0; 53 virtual int32_t StopDtmf() = 0; 54 virtual int32_t PostDialProceed(bool proceed) = 0; 55 virtual int32_t GetSlotId() = 0; 56 virtual int32_t CombineConference() = 0; 57 virtual void HandleCombineConferenceFailEvent() = 0; 58 virtual int32_t SeparateConference() = 0; 59 virtual int32_t KickOutFromConference() = 0; 60 virtual int32_t CanCombineConference() = 0; 61 virtual int32_t CanSeparateConference() = 0; 62 virtual int32_t CanKickOutFromConference() = 0; 63 virtual int32_t LaunchConference() = 0; 64 virtual int32_t ExitConference() = 0; 65 virtual int32_t HoldConference() = 0; 66 virtual int32_t GetMainCallId(int32_t &mainCallId) = 0; 67 virtual int32_t GetSubCallIdList(std::vector<std::u16string> &callIdList) = 0; 68 virtual int32_t GetCallIdListForConference(std::vector<std::u16string> &callIdList) = 0; 69 virtual int32_t IsSupportConferenceable() = 0; 70 virtual int32_t SetMute(int32_t mute, int32_t slotId) = 0; 71 int32_t DialCallBase(); 72 int32_t IncomingCallBase(); 73 int32_t AnswerCallBase(); 74 int32_t RejectCallBase(); 75 void GetCallAttributeBaseInfo(CallAttributeInfo &info); 76 int32_t GetCallID(); 77 CallType GetCallType(); 78 CallRunningState GetCallRunningState(); 79 int32_t SetTelCallState(TelCallState nextState); 80 TelCallState GetTelCallState(); 81 void SetTelConferenceState(TelConferenceState state); 82 TelConferenceState GetTelConferenceState(); 83 VideoStateType GetVideoStateType(); 84 void SetVideoStateType(VideoStateType mediaType); 85 void SetPolicyFlag(PolicyFlag flag); 86 uint64_t GetPolicyFlag(); 87 ContactInfo GetCallerInfo(); 88 void SetCallerInfo(const ContactInfo &contactInfo); 89 NumberMarkInfo GetNumberMarkInfo(); 90 void SetNumberMarkInfo(const NumberMarkInfo &numberMarkInfo); 91 void SetBlockReason(const int32_t &blockReason); 92 void SetDetectDetails(std::string detectDetails); 93 std::string GetDetectDetails(); 94 void SetCallRunningState(CallRunningState callRunningState); 95 void SetStartTime(int64_t startTime); 96 void SetCallBeginTime(time_t callBeginTime); 97 void SetCallCreateTime(time_t callCreateTime); 98 void SetCallEndTime(time_t callEndTime); 99 void SetRingBeginTime(time_t ringBeginTime); 100 void SetRingEndTime(time_t ringEndTime); 101 void SetAnswerType(CallAnswerType answerType); 102 CallAnswerType GetAnswerType(); 103 CallEndedType GetCallEndedType(); 104 int32_t SetCallEndedType(CallEndedType callEndedType); 105 void SetCallId(int32_t callId); 106 bool IsSpeakerphoneEnabled(); 107 bool IsCurrentRinging(); 108 std::string GetAccountNumber(); 109 void SetAccountNumber(const std::string accountNumber); 110 int32_t SetSpeakerphoneOn(bool speakerphoneOn); 111 bool IsSpeakerphoneOn(); 112 void SetAutoAnswerState(bool flag); 113 bool GetAutoAnswerState(); 114 void SetAnswerVideoState(int32_t videoState); 115 int32_t GetAnswerVideoState(); 116 void SetCanUnHoldState(bool flag); 117 bool GetCanUnHoldState(); 118 void SetCanSwitchCallState(bool flag); 119 bool GetCanSwitchCallState(); 120 bool CheckVoicemailNumber(std::string phoneNumber); 121 bool IsAliveState(); 122 void SetBundleName(const char *bundleName); 123 void SetCallType(CallType callType); 124 void SetCrsType(int32_t crsType); 125 int32_t GetCrsType(); 126 void SetOriginalCallType(int32_t originalCallType); 127 int32_t GetOriginalCallType(); 128 void SetNumberLocation(std::string numberLocation); 129 std::string GetNumberLocation(); SetSlotId(int32_t slotId)130 virtual void SetSlotId(int32_t slotId) {} SetCallIndex(int32_t index)131 virtual void SetCallIndex(int32_t index) {} GetCallIndex()132 virtual int32_t GetCallIndex() {return 0;} 133 int32_t SetMicPhoneState(bool isMuted); 134 bool IsMuted(); 135 void SetIsEccContact(bool isEccContact); 136 void SetCeliaCallType(int32_t celiaCallType); 137 int32_t GetCeliaCallType(); 138 void SetExtraParams(AAFwk::WantParams extraParams); 139 void SetCallDirection(CallDirection direction); 140 CallDirection GetCallDirection(); 141 int32_t GetAccountId(); 142 void SetAccountId(int32_t accountId); 143 bool IsAnsweredCall(); 144 void SetAnsweredCall(bool isAnswered); 145 AAFwk::WantParams GetExtraParams(); 146 void SetPhoneOrWatchDial(int32_t phoneOrWatch); 147 bool IsAiAutoAnswer(); 148 void SetAiAutoAnswer(bool isAiAutoAnswer); 149 bool IsForcedReportVoiceCall(); 150 void SetForcedReportVoiceCall(bool isForcedReportVoiceCall); 151 int32_t GetPhoneOrWatchDial(); 152 bool GetAnsweredByPhone(); 153 void SetIsAnsweredByPhone(bool isAnsweredByPhone); 154 void SetNewCallUseBox(int32_t newCallUseBox); 155 int32_t GetNewCallUseBox(); 156 157 protected: 158 int32_t callId_; 159 CallType callType_; 160 VideoStateType videoState_; 161 std::string accountNumber_; 162 std::string bundleName_; 163 164 private: 165 void StateChangesToDialing(); 166 void StateChangesToIncoming(); 167 void StateChangesToWaiting(); 168 void StateChangesToActive(); 169 void StateChangesToHolding(); 170 void StateChangesToDisconnected(); 171 void StateChangesToDisconnecting(); 172 void StateChangesToAlerting(); 173 void HangUpVoipCall(); 174 175 CallRunningState callRunningState_; 176 TelConferenceState conferenceState_; 177 int64_t startTime_; // Call start time 178 CallDirection direction_; 179 uint64_t policyFlag_; 180 TelCallState callState_; 181 bool autoAnswerState_; 182 bool canUnHoldState_; 183 bool canSwitchCallState_; 184 int32_t answerVideoState_; 185 bool isSpeakerphoneOn_; 186 CallEndedType callEndedType_; 187 ContactInfo contactInfo_; 188 time_t callBeginTime_; 189 time_t callCreateTime_; 190 time_t callEndTime_; 191 time_t ringBeginTime_; 192 time_t ringEndTime_; 193 CallAnswerType answerType_; 194 int32_t accountId_; 195 int32_t crsType_; 196 int32_t originalCallType_; 197 bool isMuted_; 198 std::mutex mutex_; 199 std::string numberLocation_; 200 NumberMarkInfo numberMarkInfo_; 201 int32_t blockReason_; 202 bool isEccContact_; 203 int32_t celiaCallType_; 204 AAFwk::WantParams extraParams_; 205 bool isAnswered_; 206 std::string detectDetails_; 207 int32_t phoneOrWatch_ = 0; 208 bool isAiAutoAnswer_; 209 bool isForcedReportVoiceCall_{false}; 210 bool isAnsweredByPhone_{false}; 211 int32_t newCallUseBox_ = 0; 212 }; 213 } // namespace Telephony 214 } // namespace OHOS 215 216 #endif // CALL_BASE_H 217