• 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 #include "cs_call.h"
17 
18 #include "call_manager_errors.h"
19 #include "telephony_log_wrapper.h"
20 
21 namespace OHOS {
22 namespace Telephony {
CSCall(DialParaInfo & info)23 CSCall::CSCall(DialParaInfo &info) : CarrierCall(info) {}
24 
CSCall(DialParaInfo & info,AppExecFwk::PacMap & extras)25 CSCall::CSCall(DialParaInfo &info, AppExecFwk::PacMap &extras) : CarrierCall(info, extras) {}
26 
~CSCall()27 CSCall::~CSCall() {}
28 
DialingProcess()29 int32_t CSCall::DialingProcess()
30 {
31     return CarrierDialingProcess();
32 }
33 
AnswerCall(int32_t videoState)34 int32_t CSCall::AnswerCall(int32_t videoState)
35 {
36     return CarrierAnswerCall(videoState);
37 }
38 
RejectCall()39 int32_t CSCall::RejectCall()
40 {
41     return CarrierRejectCall();
42 }
43 
HangUpCall()44 int32_t CSCall::HangUpCall()
45 {
46     return CarrierHangUpCall();
47 }
48 
HoldCall()49 int32_t CSCall::HoldCall()
50 {
51     ConferenceState conferenceState = DelayedSingleton<CsConference>::GetInstance()->GetConferenceState();
52     if (conferenceState == CONFERENCE_STATE_ACTIVE) {
53         DelayedSingleton<CsConference>::GetInstance()->SetConferenceState(CONFERENCE_STATE_HOLDING);
54     }
55     return CarrierHoldCall();
56 }
57 
UnHoldCall()58 int32_t CSCall::UnHoldCall()
59 {
60     ConferenceState conferenceState = DelayedSingleton<CsConference>::GetInstance()->GetConferenceState();
61     if (conferenceState == CONFERENCE_STATE_HOLDING) {
62         DelayedSingleton<CsConference>::GetInstance()->SetConferenceState(CONFERENCE_STATE_ACTIVE);
63     }
64     return CarrierUnHoldCall();
65 }
66 
SwitchCall()67 int32_t CSCall::SwitchCall()
68 {
69     return CarrierSwitchCall();
70 }
71 
GetCallAttributeInfo(CallAttributeInfo & info)72 void CSCall::GetCallAttributeInfo(CallAttributeInfo &info)
73 {
74     GetCallAttributeCarrierInfo(info);
75 }
76 
SetMute(int32_t mute,int32_t slotId)77 int32_t CSCall::SetMute(int32_t mute, int32_t slotId)
78 {
79     return CarrierSetMute(mute, slotId);
80 }
81 
CombineConference()82 int32_t CSCall::CombineConference()
83 {
84     int32_t ret = DelayedSingleton<CsConference>::GetInstance()->SetMainCall(GetCallID());
85     if (ret != TELEPHONY_SUCCESS) {
86         return ret;
87     }
88     return CarrierCombineConference();
89 }
90 
SeparateConference()91 int32_t CSCall::SeparateConference()
92 {
93     return CarrierSeparateConference();
94 }
95 
CanCombineConference()96 int32_t CSCall::CanCombineConference()
97 {
98     int32_t ret = IsSupportConferenceable();
99     if (ret != TELEPHONY_SUCCESS) {
100         TELEPHONY_LOGE("call unsupported conference, error%{public}d", ret);
101         return ret;
102     }
103     return DelayedSingleton<CsConference>::GetInstance()->CanCombineConference();
104 }
105 
CanSeparateConference()106 int32_t CSCall::CanSeparateConference()
107 {
108     return DelayedSingleton<CsConference>::GetInstance()->CanSeparateConference();
109 }
110 
LaunchConference()111 int32_t CSCall::LaunchConference()
112 {
113     int32_t ret = DelayedSingleton<CsConference>::GetInstance()->JoinToConference(GetCallID());
114     if (ret == TELEPHONY_SUCCESS) {
115         SetTelConferenceState(TelConferenceState::TEL_CONFERENCE_ACTIVE);
116     }
117     return ret;
118 }
119 
ExitConference()120 int32_t CSCall::ExitConference()
121 {
122     return DelayedSingleton<CsConference>::GetInstance()->LeaveFromConference(GetCallID());
123 }
124 
HoldConference()125 int32_t CSCall::HoldConference()
126 {
127     int32_t ret = DelayedSingleton<CsConference>::GetInstance()->HoldConference(GetCallID());
128     if (ret == TELEPHONY_SUCCESS) {
129         SetTelConferenceState(TelConferenceState::TEL_CONFERENCE_HOLDING);
130     }
131     return ret;
132 }
133 
GetMainCallId(int32_t & mainCallId)134 int32_t CSCall::GetMainCallId(int32_t &mainCallId)
135 {
136     mainCallId = DelayedSingleton<CsConference>::GetInstance()->GetMainCall();
137     return TELEPHONY_SUCCESS;
138 }
139 
GetSubCallIdList(std::vector<std::u16string> & callIdList)140 int32_t CSCall::GetSubCallIdList(std::vector<std::u16string> &callIdList)
141 {
142     return DelayedSingleton<CsConference>::GetInstance()->GetSubCallIdList(GetCallID(), callIdList);
143 }
144 
GetCallIdListForConference(std::vector<std::u16string> & callIdList)145 int32_t CSCall::GetCallIdListForConference(std::vector<std::u16string> &callIdList)
146 {
147     return DelayedSingleton<CsConference>::GetInstance()->GetCallIdListForConference(GetCallID(), callIdList);
148 }
149 
IsSupportConferenceable()150 int32_t CSCall::IsSupportConferenceable()
151 {
152     // get from configure file
153 #ifdef ABILIT_CONFIG_SUPPORT
154     bool carrierSupport = GetCarrierConfig(CS_SUPPORT_CONFERENCE);
155     if (!carrierSupport) {
156         return TELEPHONY_CONFERENCE_CARRIER_NOT_SUPPORT;
157     }
158 #endif
159     return CarrierCall::IsSupportConferenceable();
160 }
161 } // namespace Telephony
162 } // namespace OHOS
163