• 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_OBJECT_MANAGER_H
17 #define CALL_OBJECT_MANAGER_H
18 
19 #include <condition_variable>
20 #include <cstdio>
21 #include <cstdlib>
22 #include <list>
23 #include <memory>
24 #include <mutex>
25 
26 #include "refbase.h"
27 
28 #include "call_base.h"
29 #include "common_type.h"
30 #include "call_manager_inner_type.h"
31 
32 namespace OHOS {
33 namespace Telephony {
34 class CallObjectManager {
35 public:
36     CallObjectManager();
37     virtual ~CallObjectManager();
38 
39     static int32_t AddOneCallObject(sptr<CallBase> &call);
40     static int32_t AddOneVoipCallObject(CallAttributeInfo info);
41     static void DelayedDisconnectCallConnectAbility(uint64_t time);
42     static int32_t DeleteOneCallObject(int32_t callId);
43     static int32_t DeleteOneVoipCallObject(int32_t callId);
44     static void DeleteOneCallObject(sptr<CallBase> &call);
45     static sptr<CallBase> GetOneCallObject(int32_t callId);
46     static sptr<CallBase> GetOneCallObject(std::string &phoneNumber);
47     static sptr<CallBase> GetOneCallObjectByIndex(int32_t index);
48     static sptr<CallBase> GetOneCallObjectByIndexAndSlotId(int32_t index, int32_t slotId);
49     static sptr<CallBase> GetOneCallObjectByIndexSlotIdAndCallType(int32_t index, int32_t slotId, CallType callType);
50     static sptr<CallBase> GetOneCallObjectByVoipCallId(std::string voipCallId, std::string bundleName, int32_t uid);
51     static void UpdateOneCallObjectByCallId(int32_t callId, TelCallState nextCallState);
52     static int32_t UpdateOneVoipCallObjectByCallId(int32_t callId, TelCallState nextCallState);
53     static int32_t HasNewCall();
54     static int32_t IsNewCallAllowedCreate(bool &enabled);
55     static int32_t GetCurrentCallNum();
56     static int32_t GetCarrierCallList(std::list<int32_t> &list);
57     static int32_t GetVoipCallNum();
58     static int32_t GetVoipCallList(std::list<int32_t> &list);
59     static bool HasRingingMaximum();
60     static bool HasDialingMaximum();
61     static int32_t HasEmergencyCall(bool &enabled);
62     static int32_t GetNewCallId();
63     static bool IsCallExist(int32_t callId);
64     static bool IsCallExist(std::string &phoneNumber);
65     static bool HasCallExist();
66     static bool HasActivedCallExist(int32_t &callId, bool isIncludeCallServiceKitCall);
67     static int32_t HasRingingCall(bool &hasRingingCall);
68     static int32_t HasHoldCall(bool &hasHoldCall);
69     static TelCallState GetCallState(int32_t callId);
70     static sptr<CallBase> GetOneCallObject(CallRunningState callState);
71     static sptr<CallBase> GetOneCarrierCallObject(CallRunningState callState);
72     static bool IsCallExist(CallType type, TelCallState callState);
73     static bool IsCallExist(TelCallState callState);
74     static bool IsCallExist(TelCallState callState, int32_t &callId);
75     static bool IsConferenceCallExist(TelConferenceState state, int32_t &callId);
76     static int32_t GetCallNum(TelCallState callState, bool isIncludeVoipCall = true);
77     static std::string GetCallNumber(TelCallState callState, bool isIncludeVoipCall = true);
78     static CallAttributeInfo GetVoipCallInfo();
79     static CallAttributeInfo GetActiveVoipCallInfo();
80     static void ClearVoipList();
81     static std::vector<CallAttributeInfo> GetCallInfoList(int32_t slotId, bool isIncludeVoipCall = true);
82     static sptr<CallBase> GetForegroundCall(bool isIncludeVoipCall = true);
83     static sptr<CallBase> GetForegroundLiveCall(bool isIncludeVoipCall = true);
84     static sptr<CallBase> GetIncomingCall(bool isIncludeVoipCall = true);
85     static sptr<CallBase> GetAudioLiveCall();
86     static std::vector<CallAttributeInfo> GetAllCallInfoList(bool isIncludeVoipCall = true);
87     static std::vector<CallAttributeInfo> GetVoipCallInfoList();
88     int32_t DealFailDial(sptr<CallBase> call);
89     static bool HasVideoCall();
90     static std::list<sptr<CallBase>> GetAllCallList();
91     static bool HasCellularCallExist();
92     static bool HasVoipCallExist();
93     static bool IsVoipCallExist();
94     static bool IsVoipCallExist(TelCallState callState, int32_t &callId);
95     static bool HasIncomingCallCrsType();
96     static bool HasIncomingCallVideoRingType();
97     static CellularCallInfo GetDialCallInfo();
98     static bool HasSatelliteCallExist();
99     static int32_t GetSatelliteCallList(std::list<int32_t> &list);
100     static int32_t GetCallNumByRunningState(CallRunningState callState);
101     static sptr<CallBase> GetForegroundLiveCallByCallId(int32_t callId);
102     static bool IsNeedSilentInDoNotDisturbMode();
103     static bool IsVideoRing(const std::string &personalNotificationRingtone, const std::string &ringtonePath);
104 #ifdef NOT_SUPPORT_MULTICALL
105     static bool IsTwoCallBtCallAndESIM();
106     static bool IsTwoCallBtCall();
107     static bool IsTwoCallESIMCall();
108     static bool IsOneNumberDualTerminal();
109 #endif
110 protected:
111     static std::condition_variable cv_;
112     static bool isFirstDialCallAdded_;
113     static bool needWaitHold_;
114     static CellularCallInfo dialCallInfo_;
115 
116 private:
117     static std::list<sptr<CallBase>> callObjectPtrList_;
118     static std::map<int32_t, CallAttributeInfo> voipCallObjectList_;
119     static std::mutex listMutex_;
120     static int32_t callId_;
121 };
122 } // namespace Telephony
123 } // namespace OHOS
124 
125 #endif // CALL_OBJECT_MANAGER_H
126