• 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_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     bool IsAnsweredCall();
143     void SetAnsweredCall(bool isAnswered);
144     AAFwk::WantParams GetExtraParams();
145     void SetPhoneOrWatchDial(int32_t phoneOrWatch);
146 
147 protected:
148     int32_t callId_;
149     CallType callType_;
150     VideoStateType videoState_;
151     std::string accountNumber_;
152     std::string bundleName_;
153 
154 private:
155     void StateChangesToDialing();
156     void StateChangesToIncoming();
157     void StateChangesToWaiting();
158     void StateChangesToActive();
159     void StateChangesToHolding();
160     void StateChangesToDisconnected();
161     void StateChangesToDisconnecting();
162     void StateChangesToAlerting();
163     void HangUpVoipCall();
164 
165     CallRunningState callRunningState_;
166     TelConferenceState conferenceState_;
167     int64_t startTime_; // Call start time
168     CallDirection direction_;
169     uint64_t policyFlag_;
170     TelCallState callState_;
171     bool autoAnswerState_;
172     bool canUnHoldState_;
173     bool canSwitchCallState_;
174     int32_t answerVideoState_;
175     bool isSpeakerphoneOn_;
176     CallEndedType callEndedType_;
177     ContactInfo contactInfo_;
178     time_t callBeginTime_;
179     time_t callCreateTime_;
180     time_t callEndTime_;
181     time_t ringBeginTime_;
182     time_t ringEndTime_;
183     CallAnswerType answerType_;
184     int32_t accountId_;
185     int32_t crsType_;
186     int32_t originalCallType_;
187     bool isMuted_;
188     std::mutex mutex_;
189     std::string numberLocation_;
190     NumberMarkInfo numberMarkInfo_;
191     int32_t blockReason_;
192     bool isEccContact_;
193     int32_t celiaCallType_;
194     AAFwk::WantParams extraParams_;
195     bool isAnswered_;
196     std::string detectDetails_;
197     int32_t phoneOrWatch_ = 0;
198 };
199 } // namespace Telephony
200 } // namespace OHOS
201 
202 #endif // CALL_BASE_H
203