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_OBJECT_MANAGER_H
17e1c44949Sopenharmony_ci#define CALL_OBJECT_MANAGER_H
18e1c44949Sopenharmony_ci
19e1c44949Sopenharmony_ci#include <condition_variable>
20e1c44949Sopenharmony_ci#include <cstdio>
21e1c44949Sopenharmony_ci#include <cstdlib>
22e1c44949Sopenharmony_ci#include <list>
23e1c44949Sopenharmony_ci#include <memory>
24e1c44949Sopenharmony_ci#include <mutex>
25e1c44949Sopenharmony_ci
26e1c44949Sopenharmony_ci#include "refbase.h"
27e1c44949Sopenharmony_ci
28e1c44949Sopenharmony_ci#include "call_base.h"
29e1c44949Sopenharmony_ci#include "common_type.h"
30e1c44949Sopenharmony_ci#include "call_manager_inner_type.h"
31e1c44949Sopenharmony_ci
32e1c44949Sopenharmony_cinamespace OHOS {
33e1c44949Sopenharmony_cinamespace Telephony {
34e1c44949Sopenharmony_ciclass CallObjectManager {
35e1c44949Sopenharmony_cipublic:
36e1c44949Sopenharmony_ci    CallObjectManager();
37e1c44949Sopenharmony_ci    virtual ~CallObjectManager();
38e1c44949Sopenharmony_ci
39e1c44949Sopenharmony_ci    static int32_t AddOneCallObject(sptr<CallBase> &call);
40e1c44949Sopenharmony_ci    static void DelayedDisconnectCallConnectAbility();
41e1c44949Sopenharmony_ci    static int32_t DeleteOneCallObject(int32_t callId);
42e1c44949Sopenharmony_ci    static void DeleteOneCallObject(sptr<CallBase> &call);
43e1c44949Sopenharmony_ci    static sptr<CallBase> GetOneCallObject(int32_t callId);
44e1c44949Sopenharmony_ci    static sptr<CallBase> GetOneCallObject(std::string &phoneNumber);
45e1c44949Sopenharmony_ci    static sptr<CallBase> GetOneCallObjectByIndex(int32_t index);
46e1c44949Sopenharmony_ci    static sptr<CallBase> GetOneCallObjectByIndexAndSlotId(int32_t index, int32_t slotId);
47e1c44949Sopenharmony_ci    static sptr<CallBase> GetOneCallObjectByVoipCallId(std::string voipCallId, std::string bundleName, int32_t uid);
48e1c44949Sopenharmony_ci    static void UpdateOneCallObjectByCallId(int32_t callId, TelCallState nextCallState);
49e1c44949Sopenharmony_ci    static int32_t HasNewCall();
50e1c44949Sopenharmony_ci    static int32_t IsNewCallAllowedCreate(bool &enabled);
51e1c44949Sopenharmony_ci    static int32_t GetCurrentCallNum();
52e1c44949Sopenharmony_ci    static int32_t GetCarrierCallList(std::list<int32_t> &list);
53e1c44949Sopenharmony_ci    static int32_t GetVoipCallNum();
54e1c44949Sopenharmony_ci    static int32_t GetVoipCallList(std::list<int32_t> &list);
55e1c44949Sopenharmony_ci    static bool HasRingingMaximum();
56e1c44949Sopenharmony_ci    static bool HasDialingMaximum();
57e1c44949Sopenharmony_ci    static int32_t HasEmergencyCall(bool &enabled);
58e1c44949Sopenharmony_ci    static int32_t GetNewCallId();
59e1c44949Sopenharmony_ci    static bool IsCallExist(int32_t callId);
60e1c44949Sopenharmony_ci    static bool IsCallExist(std::string &phoneNumber);
61e1c44949Sopenharmony_ci    static bool HasCallExist();
62e1c44949Sopenharmony_ci    static int32_t HasRingingCall(bool &hasRingingCall);
63e1c44949Sopenharmony_ci    static int32_t HasHoldCall(bool &hasHoldCall);
64e1c44949Sopenharmony_ci    static TelCallState GetCallState(int32_t callId);
65e1c44949Sopenharmony_ci    static sptr<CallBase> GetOneCallObject(CallRunningState callState);
66e1c44949Sopenharmony_ci    static bool IsCallExist(CallType type, TelCallState callState);
67e1c44949Sopenharmony_ci    static bool IsCallExist(TelCallState callState);
68e1c44949Sopenharmony_ci    static bool IsCallExist(TelCallState callState, int32_t &callId);
69e1c44949Sopenharmony_ci    static bool IsConferenceCallExist(TelConferenceState state, int32_t &callId);
70e1c44949Sopenharmony_ci    static int32_t GetCallNum(TelCallState callState, bool isIncludeVoipCall = true);
71e1c44949Sopenharmony_ci    static std::string GetCallNumber(TelCallState callState, bool isIncludeVoipCall = true);
72e1c44949Sopenharmony_ci    static std::vector<CallAttributeInfo> GetCallInfoList(int32_t slotId);
73e1c44949Sopenharmony_ci    static sptr<CallBase> GetForegroundCall(bool isIncludeVoipCall = true);
74e1c44949Sopenharmony_ci    static sptr<CallBase> GetForegroundLiveCall();
75e1c44949Sopenharmony_ci    static std::vector<CallAttributeInfo> GetAllCallInfoList();
76e1c44949Sopenharmony_ci    int32_t DealFailDial(sptr<CallBase> call);
77e1c44949Sopenharmony_ci    static bool HasVideoCall();
78e1c44949Sopenharmony_ci    static std::list<sptr<CallBase>> GetAllCallList();
79e1c44949Sopenharmony_ci    static bool HasCellularCallExist();
80e1c44949Sopenharmony_ci    static bool HasVoipCallExist();
81e1c44949Sopenharmony_ci    static bool HasIncomingCallCrsType();
82e1c44949Sopenharmony_ci    static CellularCallInfo GetDialCallInfo();
83e1c44949Sopenharmony_ci    static bool HasSatelliteCallExist();
84e1c44949Sopenharmony_ci    static int32_t GetSatelliteCallList(std::list<int32_t> &list);
85e1c44949Sopenharmony_ci    static int32_t GetCallNumByRunningState(CallRunningState callState);
86e1c44949Sopenharmony_ci
87e1c44949Sopenharmony_ciprotected:
88e1c44949Sopenharmony_ci    static std::condition_variable cv_;
89e1c44949Sopenharmony_ci    static bool isFirstDialCallAdded_;
90e1c44949Sopenharmony_ci    static bool needWaitHold_;
91e1c44949Sopenharmony_ci    static CellularCallInfo dialCallInfo_;
92e1c44949Sopenharmony_ci
93e1c44949Sopenharmony_ciprivate:
94e1c44949Sopenharmony_ci    static std::list<sptr<CallBase>> callObjectPtrList_;
95e1c44949Sopenharmony_ci    static std::mutex listMutex_;
96e1c44949Sopenharmony_ci    static int32_t callId_;
97e1c44949Sopenharmony_ci};
98e1c44949Sopenharmony_ci} // namespace Telephony
99e1c44949Sopenharmony_ci} // namespace OHOS
100e1c44949Sopenharmony_ci
101e1c44949Sopenharmony_ci#endif // CALL_OBJECT_MANAGER_H
102