• 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 DeleteOneCallObject(int32_t callId);
41     static void DeleteOneCallObject(sptr<CallBase> &call);
42     static sptr<CallBase> GetOneCallObject(int32_t callId);
43     static sptr<CallBase> GetOneCallObject(std::string &phoneNumber);
44     static sptr<CallBase> GetOneCallObjectByIndex(int32_t index);
45     static sptr<CallBase> GetOneCallObjectByIndexAndSlotId(int32_t index, int32_t slotId);
46     static sptr<CallBase> GetOneCallObjectByVoipCallId(std::string voipCallId);
47     static int32_t HasNewCall();
48     static int32_t IsNewCallAllowedCreate(bool &enabled);
49     static int32_t GetCurrentCallNum();
50     static int32_t GetCarrierCallList(std::list<int32_t> &list);
51     static bool HasRingingMaximum();
52     static bool HasDialingMaximum();
53     static int32_t HasEmergencyCall(bool &enabled);
54     static int32_t GetNewCallId();
55     static bool IsCallExist(int32_t callId);
56     static bool IsCallExist(std::string &phoneNumber);
57     static bool HasCallExist();
58     static int32_t HasRingingCall(bool &enabled);
59     static TelCallState GetCallState(int32_t callId);
60     static sptr<CallBase> GetOneCallObject(CallRunningState callState);
61     static bool IsCallExist(CallType type, TelCallState callState);
62     static bool IsCallExist(TelCallState callState);
63     static bool IsCallExist(TelCallState callState, int32_t &callId);
64     static bool IsConferenceCallExist(TelConferenceState state, int32_t &callId);
65     static int32_t GetCallNum(TelCallState callState);
66     static std::string GetCallNumber(TelCallState callState);
67     static std::vector<CallAttributeInfo> GetCallInfoList(int32_t slotId);
68     static sptr<CallBase> GetForegroundLiveCall();
69     static std::vector<CallAttributeInfo> GetAllCallInfoList();
70     int32_t DealFailDial(sptr<CallBase> call);
71     static bool HasVideoCall();
72     static std::list<sptr<CallBase>> GetAllCallList();
73     static bool HasCellularCallExist();
74     static bool HasVoipCallExist();
75     static CellularCallInfo GetDialCallInfo();
76 
77 protected:
78     static std::condition_variable cv_;
79     static bool isFirstDialCallAdded_;
80     static bool needWaitHold_;
81     static CellularCallInfo dialCallInfo_;
82 
83 private:
84     static std::list<sptr<CallBase>> callObjectPtrList_;
85     static std::mutex listMutex_;
86     static int32_t callId_;
87 };
88 } // namespace Telephony
89 } // namespace OHOS
90 
91 #endif // CALL_OBJECT_MANAGER_H
92