1e1c44949Sopenharmony_ci/*
2e1c44949Sopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd.
3e1c44949Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e1c44949Sopenharmony_ci * you may not use this file except in compliance with the License.
5e1c44949Sopenharmony_ci * You may obtain a copy of the License at
6e1c44949Sopenharmony_ci *
7e1c44949Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e1c44949Sopenharmony_ci *
9e1c44949Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e1c44949Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e1c44949Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e1c44949Sopenharmony_ci * See the License for the specific language governing permissions and
13e1c44949Sopenharmony_ci * limitations under the License.
14e1c44949Sopenharmony_ci */
15e1c44949Sopenharmony_ci
16e1c44949Sopenharmony_ci#ifndef CALL_BASE_H
17e1c44949Sopenharmony_ci#define CALL_BASE_H
18e1c44949Sopenharmony_ci
19e1c44949Sopenharmony_ci#include <unistd.h>
20e1c44949Sopenharmony_ci#include <cstring>
21e1c44949Sopenharmony_ci#include <memory>
22e1c44949Sopenharmony_ci#include <mutex>
23e1c44949Sopenharmony_ci
24e1c44949Sopenharmony_ci#include "refbase.h"
25e1c44949Sopenharmony_ci#include "pac_map.h"
26e1c44949Sopenharmony_ci
27e1c44949Sopenharmony_ci#include "common_type.h"
28e1c44949Sopenharmony_ci#include "conference_base.h"
29e1c44949Sopenharmony_ci#include "call_manager_info.h"
30e1c44949Sopenharmony_ci
31e1c44949Sopenharmony_ci/**
32e1c44949Sopenharmony_ci * @ClassName: CallBase
33e1c44949Sopenharmony_ci * @Description: an abstraction  of telephone calls, provide basic call ops interfaces
34e1c44949Sopenharmony_ci */
35e1c44949Sopenharmony_cinamespace OHOS {
36e1c44949Sopenharmony_cinamespace Telephony {
37e1c44949Sopenharmony_ciclass CallBase : public virtual RefBase {
38e1c44949Sopenharmony_cipublic:
39e1c44949Sopenharmony_ci    explicit CallBase(DialParaInfo &info);
40e1c44949Sopenharmony_ci    CallBase(DialParaInfo &info, AppExecFwk::PacMap &extras);
41e1c44949Sopenharmony_ci    virtual ~CallBase();
42e1c44949Sopenharmony_ci
43e1c44949Sopenharmony_ci    virtual int32_t DialingProcess() = 0;
44e1c44949Sopenharmony_ci    virtual int32_t AnswerCall(int32_t videoState) = 0;
45e1c44949Sopenharmony_ci    virtual int32_t RejectCall() = 0;
46e1c44949Sopenharmony_ci    virtual int32_t HangUpCall() = 0;
47e1c44949Sopenharmony_ci    virtual int32_t HoldCall() = 0;
48e1c44949Sopenharmony_ci    virtual int32_t UnHoldCall() = 0;
49e1c44949Sopenharmony_ci    virtual int32_t SwitchCall() = 0;
50e1c44949Sopenharmony_ci    virtual void GetCallAttributeInfo(CallAttributeInfo &info) = 0;
51e1c44949Sopenharmony_ci    virtual bool GetEmergencyState() = 0;
52e1c44949Sopenharmony_ci    virtual int32_t StartDtmf(char str) = 0;
53e1c44949Sopenharmony_ci    virtual int32_t StopDtmf() = 0;
54e1c44949Sopenharmony_ci    virtual int32_t PostDialProceed(bool proceed) = 0;
55e1c44949Sopenharmony_ci    virtual int32_t GetSlotId() = 0;
56e1c44949Sopenharmony_ci    virtual int32_t CombineConference() = 0;
57e1c44949Sopenharmony_ci    virtual void HandleCombineConferenceFailEvent() = 0;
58e1c44949Sopenharmony_ci    virtual int32_t SeparateConference() = 0;
59e1c44949Sopenharmony_ci    virtual int32_t KickOutFromConference() = 0;
60e1c44949Sopenharmony_ci    virtual int32_t CanCombineConference() = 0;
61e1c44949Sopenharmony_ci    virtual int32_t CanSeparateConference() = 0;
62e1c44949Sopenharmony_ci    virtual int32_t CanKickOutFromConference() = 0;
63e1c44949Sopenharmony_ci    virtual int32_t LaunchConference() = 0;
64e1c44949Sopenharmony_ci    virtual int32_t ExitConference() = 0;
65e1c44949Sopenharmony_ci    virtual int32_t HoldConference() = 0;
66e1c44949Sopenharmony_ci    virtual int32_t GetMainCallId(int32_t &mainCallId) = 0;
67e1c44949Sopenharmony_ci    virtual int32_t GetSubCallIdList(std::vector<std::u16string> &callIdList) = 0;
68e1c44949Sopenharmony_ci    virtual int32_t GetCallIdListForConference(std::vector<std::u16string> &callIdList) = 0;
69e1c44949Sopenharmony_ci    virtual int32_t IsSupportConferenceable() = 0;
70e1c44949Sopenharmony_ci    virtual int32_t SetMute(int32_t mute, int32_t slotId) = 0;
71e1c44949Sopenharmony_ci    int32_t DialCallBase();
72e1c44949Sopenharmony_ci    int32_t IncomingCallBase();
73e1c44949Sopenharmony_ci    int32_t AnswerCallBase();
74e1c44949Sopenharmony_ci    int32_t RejectCallBase();
75e1c44949Sopenharmony_ci    void GetCallAttributeBaseInfo(CallAttributeInfo &info);
76e1c44949Sopenharmony_ci    int32_t GetCallID();
77e1c44949Sopenharmony_ci    CallType GetCallType();
78e1c44949Sopenharmony_ci    CallRunningState GetCallRunningState();
79e1c44949Sopenharmony_ci    int32_t SetTelCallState(TelCallState nextState);
80e1c44949Sopenharmony_ci    TelCallState GetTelCallState();
81e1c44949Sopenharmony_ci    void SetTelConferenceState(TelConferenceState state);
82e1c44949Sopenharmony_ci    TelConferenceState GetTelConferenceState();
83e1c44949Sopenharmony_ci    VideoStateType GetVideoStateType();
84e1c44949Sopenharmony_ci    void SetVideoStateType(VideoStateType mediaType);
85e1c44949Sopenharmony_ci    void SetPolicyFlag(PolicyFlag flag);
86e1c44949Sopenharmony_ci    uint64_t GetPolicyFlag();
87e1c44949Sopenharmony_ci    ContactInfo GetCallerInfo();
88e1c44949Sopenharmony_ci    void SetCallerInfo(const ContactInfo &contactInfo);
89e1c44949Sopenharmony_ci    NumberMarkInfo GetNumberMarkInfo();
90e1c44949Sopenharmony_ci    void SetNumberMarkInfo(const NumberMarkInfo &numberMarkInfo);
91e1c44949Sopenharmony_ci    void SetBlockReason(const int32_t &blockReason);
92e1c44949Sopenharmony_ci    void SetCallRunningState(CallRunningState callRunningState);
93e1c44949Sopenharmony_ci    void SetStartTime(int64_t startTime);
94e1c44949Sopenharmony_ci    void SetCallBeginTime(time_t callBeginTime);
95e1c44949Sopenharmony_ci    void SetCallCreateTime(time_t callCreateTime);
96e1c44949Sopenharmony_ci    void SetCallEndTime(time_t callEndTime);
97e1c44949Sopenharmony_ci    void SetRingBeginTime(time_t ringBeginTime);
98e1c44949Sopenharmony_ci    void SetRingEndTime(time_t ringEndTime);
99e1c44949Sopenharmony_ci    void SetAnswerType(CallAnswerType answerType);
100e1c44949Sopenharmony_ci    CallEndedType GetCallEndedType();
101e1c44949Sopenharmony_ci    int32_t SetCallEndedType(CallEndedType callEndedType);
102e1c44949Sopenharmony_ci    void SetCallId(int32_t callId);
103e1c44949Sopenharmony_ci    bool IsSpeakerphoneEnabled();
104e1c44949Sopenharmony_ci    bool IsCurrentRinging();
105e1c44949Sopenharmony_ci    std::string GetAccountNumber();
106e1c44949Sopenharmony_ci    void SetAccountNumber(const std::string accountNumber);
107e1c44949Sopenharmony_ci    int32_t SetSpeakerphoneOn(bool speakerphoneOn);
108e1c44949Sopenharmony_ci    bool IsSpeakerphoneOn();
109e1c44949Sopenharmony_ci    void SetAutoAnswerState(bool flag);
110e1c44949Sopenharmony_ci    bool GetAutoAnswerState();
111e1c44949Sopenharmony_ci    void SetAnswerVideoState(int32_t videoState);
112e1c44949Sopenharmony_ci    int32_t GetAnswerVideoState();
113e1c44949Sopenharmony_ci    void SetCanUnHoldState(bool flag);
114e1c44949Sopenharmony_ci    bool GetCanUnHoldState();
115e1c44949Sopenharmony_ci    void SetCanSwitchCallState(bool flag);
116e1c44949Sopenharmony_ci    bool GetCanSwitchCallState();
117e1c44949Sopenharmony_ci    bool CheckVoicemailNumber(std::string phoneNumber);
118e1c44949Sopenharmony_ci    bool IsAliveState();
119e1c44949Sopenharmony_ci    void SetBundleName(const char *bundleName);
120e1c44949Sopenharmony_ci    void SetCallType(CallType callType);
121e1c44949Sopenharmony_ci    void SetCrsType(int32_t crsType);
122e1c44949Sopenharmony_ci    int32_t GetCrsType();
123e1c44949Sopenharmony_ci    void SetOriginalCallType(int32_t originalCallType);
124e1c44949Sopenharmony_ci    int32_t GetOriginalCallType();
125e1c44949Sopenharmony_ci    void SetNumberLocation(std::string numberLocation);
126e1c44949Sopenharmony_ci    std::string GetNumberLocation();
127e1c44949Sopenharmony_ci    virtual void SetSlotId(int32_t slotId) {}
128e1c44949Sopenharmony_ci    virtual void SetCallIndex(int32_t index) {}
129e1c44949Sopenharmony_ci    virtual int32_t GetCallIndex() {return 0;}
130e1c44949Sopenharmony_ci    int32_t SetMicPhoneState(bool isMuted);
131e1c44949Sopenharmony_ci    bool IsMuted();
132e1c44949Sopenharmony_ci    void SetIsEccContact(bool isEccContact);
133e1c44949Sopenharmony_ci    void SetCeliaCallType(int32_t celiaCallType);
134e1c44949Sopenharmony_ci    void SetCallDirection(CallDirection direction);
135e1c44949Sopenharmony_ci    CallDirection GetCallDirection();
136e1c44949Sopenharmony_ci    int32_t GetAccountId();
137e1c44949Sopenharmony_ci    void SetExtraParams(AAFwk::WantParams extraParams);
138e1c44949Sopenharmony_ci    bool IsAnsweredCall();
139e1c44949Sopenharmony_ci    void SetAnsweredCall(bool isAnswered);
140e1c44949Sopenharmony_ci
141e1c44949Sopenharmony_ciprotected:
142e1c44949Sopenharmony_ci    int32_t callId_;
143e1c44949Sopenharmony_ci    CallType callType_;
144e1c44949Sopenharmony_ci    VideoStateType videoState_;
145e1c44949Sopenharmony_ci    std::string accountNumber_;
146e1c44949Sopenharmony_ci    std::string bundleName_;
147e1c44949Sopenharmony_ci
148e1c44949Sopenharmony_ciprivate:
149e1c44949Sopenharmony_ci    void StateChangesToDialing();
150e1c44949Sopenharmony_ci    void StateChangesToIncoming();
151e1c44949Sopenharmony_ci    void StateChangesToWaiting();
152e1c44949Sopenharmony_ci    void StateChangesToActive();
153e1c44949Sopenharmony_ci    void StateChangesToHolding();
154e1c44949Sopenharmony_ci    void StateChangesToDisconnected();
155e1c44949Sopenharmony_ci    void StateChangesToDisconnecting();
156e1c44949Sopenharmony_ci    void StateChangesToAlerting();
157e1c44949Sopenharmony_ci    void HangUpVoipCall();
158e1c44949Sopenharmony_ci
159e1c44949Sopenharmony_ci    CallRunningState callRunningState_;
160e1c44949Sopenharmony_ci    TelConferenceState conferenceState_;
161e1c44949Sopenharmony_ci    int64_t startTime_; // Call start time
162e1c44949Sopenharmony_ci    CallDirection direction_;
163e1c44949Sopenharmony_ci    uint64_t policyFlag_;
164e1c44949Sopenharmony_ci    TelCallState callState_;
165e1c44949Sopenharmony_ci    bool autoAnswerState_;
166e1c44949Sopenharmony_ci    bool canUnHoldState_;
167e1c44949Sopenharmony_ci    bool canSwitchCallState_;
168e1c44949Sopenharmony_ci    int32_t answerVideoState_;
169e1c44949Sopenharmony_ci    bool isSpeakerphoneOn_;
170e1c44949Sopenharmony_ci    CallEndedType callEndedType_;
171e1c44949Sopenharmony_ci    ContactInfo contactInfo_;
172e1c44949Sopenharmony_ci    time_t callBeginTime_;
173e1c44949Sopenharmony_ci    time_t callCreateTime_;
174e1c44949Sopenharmony_ci    time_t callEndTime_;
175e1c44949Sopenharmony_ci    time_t ringBeginTime_;
176e1c44949Sopenharmony_ci    time_t ringEndTime_;
177e1c44949Sopenharmony_ci    CallAnswerType answerType_;
178e1c44949Sopenharmony_ci    int32_t accountId_;
179e1c44949Sopenharmony_ci    int32_t crsType_;
180e1c44949Sopenharmony_ci    int32_t originalCallType_;
181e1c44949Sopenharmony_ci    bool isMuted_;
182e1c44949Sopenharmony_ci    std::mutex mutex_;
183e1c44949Sopenharmony_ci    std::string numberLocation_;
184e1c44949Sopenharmony_ci    NumberMarkInfo numberMarkInfo_;
185e1c44949Sopenharmony_ci    int32_t blockReason_;
186e1c44949Sopenharmony_ci    bool isEccContact_;
187e1c44949Sopenharmony_ci    int32_t celiaCallType_;
188e1c44949Sopenharmony_ci    AAFwk::WantParams extraParams_;
189e1c44949Sopenharmony_ci    bool isAnswered_;
190e1c44949Sopenharmony_ci};
191e1c44949Sopenharmony_ci} // namespace Telephony
192e1c44949Sopenharmony_ci} // namespace OHOS
193e1c44949Sopenharmony_ci
194e1c44949Sopenharmony_ci#endif // CALL_BASE_H
195