• 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 
30 /**
31  * @ClassName: CallBase
32  * @Description: an abstraction  of telephone calls, provide basic call ops interfaces
33  */
34 namespace OHOS {
35 namespace Telephony {
36 class CallBase : public virtual RefBase {
37 public:
38     explicit CallBase(DialParaInfo &info);
39     CallBase(DialParaInfo &info, AppExecFwk::PacMap &extras);
40     virtual ~CallBase();
41 
42     virtual int32_t DialingProcess() = 0;
43     virtual int32_t AnswerCall(int32_t videoState) = 0;
44     virtual int32_t RejectCall() = 0;
45     virtual int32_t HangUpCall() = 0;
46     virtual int32_t HoldCall() = 0;
47     virtual int32_t UnHoldCall() = 0;
48     virtual int32_t SwitchCall() = 0;
49     virtual void GetCallAttributeInfo(CallAttributeInfo &info) = 0;
50     virtual bool GetEmergencyState() = 0;
51     virtual int32_t StartDtmf(char str) = 0;
52     virtual int32_t StopDtmf() = 0;
53     virtual int32_t PostDialProceed(bool proceed) = 0;
54     virtual int32_t GetSlotId() = 0;
55     virtual int32_t CombineConference() = 0;
56     virtual int32_t SeparateConference() = 0;
57     virtual int32_t KickOutFromConference() = 0;
58     virtual int32_t CanCombineConference() = 0;
59     virtual int32_t CanSeparateConference() = 0;
60     virtual int32_t CanKickOutFromConference() = 0;
61     virtual int32_t LaunchConference() = 0;
62     virtual int32_t ExitConference() = 0;
63     virtual int32_t HoldConference() = 0;
64     virtual int32_t GetMainCallId(int32_t &mainCallId) = 0;
65     virtual int32_t GetSubCallIdList(std::vector<std::u16string> &callIdList) = 0;
66     virtual int32_t GetCallIdListForConference(std::vector<std::u16string> &callIdList) = 0;
67     virtual int32_t IsSupportConferenceable() = 0;
68     virtual int32_t SetMute(int32_t mute, int32_t slotId) = 0;
69     int32_t DialCallBase();
70     int32_t IncomingCallBase();
71     int32_t AnswerCallBase();
72     int32_t RejectCallBase();
73     void GetCallAttributeBaseInfo(CallAttributeInfo &info);
74     int32_t GetCallID();
75     CallType GetCallType();
76     CallRunningState GetCallRunningState();
77     int32_t SetTelCallState(TelCallState nextState);
78     TelCallState GetTelCallState();
79     void SetTelConferenceState(TelConferenceState state);
80     TelConferenceState GetTelConferenceState();
81     VideoStateType GetVideoStateType();
82     void SetVideoStateType(VideoStateType mediaType);
83     void SetPolicyFlag(PolicyFlag flag);
84     uint64_t GetPolicyFlag();
85     ContactInfo GetCallerInfo();
86     void SetCallerInfo(const ContactInfo &contactInfo);
87     void SetCallRunningState(CallRunningState callRunningState);
88     void SetStartTime(int64_t startTime);
89     void SetCallBeginTime(time_t callBeginTime);
90     void SetCallEndTime(time_t callEndTime);
91     void SetRingBeginTime(time_t ringBeginTime);
92     void SetRingEndTime(time_t ringEndTime);
93     void SetAnswerType(CallAnswerType answerType);
94     CallEndedType GetCallEndedType();
95     int32_t SetCallEndedType(CallEndedType callEndedType);
96     void SetCallId(int32_t callId);
97     bool IsSpeakerphoneEnabled();
98     bool IsCurrentRinging();
99     std::string GetAccountNumber();
100     int32_t SetSpeakerphoneOn(bool speakerphoneOn);
101     bool IsSpeakerphoneOn();
102     void SetAudio();
103     bool CheckVoicemailNumber(std::string phoneNumber);
104     bool IsAliveState();
105     void SetBundleName(const char *bundleName);
106     void SetCallType(CallType callType);
SetSlotId(int32_t slotId)107     virtual void SetSlotId(int32_t slotId) {}
SetCallIndex(int32_t index)108     virtual void SetCallIndex(int32_t index) {}
GetCallIndex()109     virtual int32_t GetCallIndex() {return 0;}
110 
111 protected:
112     int32_t callId_;
113     CallType callType_;
114     VideoStateType videoState_;
115     std::string accountNumber_;
116     std::string bundleName_;
117 
118 private:
119     void StateChangesToDialing();
120     void StateChangesToIncoming();
121     void StateChangesToWaiting();
122     void StateChangesToActive();
123     void StateChangesToHolding();
124     void StateChangesToDisconnected();
125     void StateChangesToDisconnecting();
126     void StateChangesToAlerting();
127 
128     CallRunningState callRunningState_;
129     TelConferenceState conferenceState_;
130     int64_t startTime_; // Call start time
131     CallDirection direction_;
132     uint64_t policyFlag_;
133     TelCallState callState_;
134     bool isSpeakerphoneOn_;
135     CallEndedType callEndedType_;
136     ContactInfo contactInfo_;
137     time_t callBeginTime_;
138     time_t callEndTime_;
139     time_t ringBeginTime_;
140     time_t ringEndTime_;
141     CallAnswerType answerType_;
142     int32_t accountId_;
143     std::mutex mutex_;
144 };
145 } // namespace Telephony
146 } // namespace OHOS
147 
148 #endif // CALL_BASE_H
149