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 int32_t HasNewCall(); 46 static int32_t IsNewCallAllowedCreate(bool &enabled); 47 static int32_t GetCarrierCallList(std::list<int32_t> &list); 48 static bool HasRingingMaximum(); 49 static bool HasDialingMaximum(); 50 static int32_t HasEmergencyCall(bool &enabled); 51 static int32_t GetNewCallId(); 52 static bool IsCallExist(int32_t callId); 53 static bool IsCallExist(std::string &phoneNumber); 54 static bool HasCallExist(); 55 static int32_t HasRingingCall(bool &enabled); 56 static TelCallState GetCallState(int32_t callId); 57 static sptr<CallBase> GetOneCallObject(CallRunningState callState); 58 static bool IsCallExist(CallType type, TelCallState callState); 59 static bool IsCallExist(TelCallState callState); 60 static bool IsCallExist(TelCallState callState, int32_t &callId); 61 static bool IsConferenceCallExist(TelConferenceState state, int32_t &callId); 62 static int32_t GetCallNum(TelCallState callState); 63 static std::string GetCallNumber(TelCallState callState); 64 static std::vector<CallAttributeInfo> GetCallInfoList(int32_t slotId); 65 static sptr<CallBase> GetForegroundLiveCall(); 66 static std::vector<CallAttributeInfo> GetCarrierCallInfoList(); 67 int32_t DealFailDial(sptr<CallBase> call); 68 69 protected: 70 static std::condition_variable cv_; 71 static bool isFirstDialCallAdded_; 72 73 private: 74 static std::list<sptr<CallBase>> callObjectPtrList_; 75 static std::mutex listMutex_; 76 static int32_t callId_; 77 }; 78 } // namespace Telephony 79 } // namespace OHOS 80 81 #endif // CALL_OBJECT_MANAGER_H 82