1 /*
2 * Copyright (C) 2024 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 "bluetooth_call.h"
17 #include "call_control_manager.h"
18 #include "call_manager_errors.h"
19 #include "call_object_manager.h"
20 #include "telephony_log_wrapper.h"
21
22 namespace OHOS {
23 namespace Telephony {
24
BluetoothCall(DialParaInfo & info,const std::string & macAddress)25 BluetoothCall::BluetoothCall(DialParaInfo &info, const std::string &macAddress) : CarrierCall(info)
26 {
27 callId_ = info.callId;
28 macAddress_ = macAddress;
29 }
30
BluetoothCall(DialParaInfo & info,AppExecFwk::PacMap & extras,const std::string & macAddress)31 BluetoothCall::BluetoothCall(DialParaInfo &info, AppExecFwk::PacMap &extras, const std::string &macAddress)
32 : CarrierCall(info, extras)
33 {
34 callId_ = info.callId;
35 macAddress_ = macAddress;
36 if (macAddress_.empty()) {
37 TELEPHONY_LOGI("macAddress is empty");
38 }
39 }
40
~BluetoothCall()41 BluetoothCall::~BluetoothCall() {}
42
DialingProcess()43 int32_t BluetoothCall::DialingProcess()
44 {
45 TELEPHONY_LOGI("BluetoothCall DialingProcess start");
46 return TELEPHONY_SUCCESS;
47 }
48
AnswerCall(int32_t videoState)49 int32_t BluetoothCall::AnswerCall(int32_t videoState)
50 {
51 TELEPHONY_LOGI("BluetoothCall AnswerCall");
52 Bluetooth::HandsFreeUnit *profile = Bluetooth::HandsFreeUnit::GetProfile();
53 if (profile == nullptr) {
54 TELEPHONY_LOGE("profile is nullptr");
55 return CALL_ERR_ANSWER_FAILED;
56 }
57 if (macAddress_.empty()) {
58 TELEPHONY_LOGE("error: macAddress is empty");
59 }
60 Bluetooth::BluetoothRemoteDevice device(macAddress_);
61 profile->AcceptIncomingCall(device, 0);
62 return TELEPHONY_SUCCESS;
63 }
64
RejectCall()65 int32_t BluetoothCall::RejectCall()
66 {
67 TELEPHONY_LOGI("BluetoothCall RejectCall enter");
68 Bluetooth::HandsFreeUnit *profile = Bluetooth::HandsFreeUnit::GetProfile();
69 if (profile == nullptr) {
70 TELEPHONY_LOGE("profile is nullptr");
71 return CALL_ERR_REJECT_FAILED;
72 }
73 if (macAddress_.empty()) {
74 TELEPHONY_LOGE("error: macAddress is empty");
75 }
76 Bluetooth::BluetoothRemoteDevice device(macAddress_);
77 profile->RejectIncomingCall(device);
78 int32_t ret = RejectCallBase();
79 return ret;
80 }
81
HangUpCall()82 int32_t BluetoothCall::HangUpCall()
83 {
84 TELEPHONY_LOGI("BluetoothCall HangUpCall enter");
85 Bluetooth::HandsFreeUnit *profile = Bluetooth::HandsFreeUnit::GetProfile();
86 if (profile == nullptr) {
87 TELEPHONY_LOGE("profile is nullptr");
88 return CALL_ERR_HANGUP_FAILED;
89 }
90 if (macAddress_.empty()) {
91 TELEPHONY_LOGE("error: macAddress is empty");
92 }
93 Bluetooth::HandsFreeUnitCall call;
94 Bluetooth::BluetoothRemoteDevice device(macAddress_);
95 profile->FinishActiveCall(device, call);
96 return TELEPHONY_SUCCESS;
97 }
98
HoldCall()99 int32_t BluetoothCall::HoldCall()
100 {
101 return TELEPHONY_SUCCESS;
102 }
103
UnHoldCall()104 int32_t BluetoothCall::UnHoldCall()
105 {
106 return TELEPHONY_SUCCESS;
107 }
108
SwitchCall()109 int32_t BluetoothCall::SwitchCall()
110 {
111 return TELEPHONY_SUCCESS;
112 }
113
SetMute(int32_t mute,int32_t slotId)114 int32_t BluetoothCall::SetMute(int32_t mute, int32_t slotId)
115 {
116 return TELEPHONY_SUCCESS;
117 }
118
GetCallAttributeInfo(CallAttributeInfo & info)119 void BluetoothCall::GetCallAttributeInfo(CallAttributeInfo &info)
120 {
121 GetCallAttributeCarrierInfo(info);
122 info.callId = callId_;
123 return;
124 }
125
CombineConference()126 int32_t BluetoothCall::CombineConference()
127 {
128 return TELEPHONY_SUCCESS;
129 }
130
HandleCombineConferenceFailEvent()131 void BluetoothCall::HandleCombineConferenceFailEvent()
132 {
133 return;
134 }
135
SeparateConference()136 int32_t BluetoothCall::SeparateConference()
137 {
138 return TELEPHONY_SUCCESS;
139 }
140
KickOutFromConference()141 int32_t BluetoothCall::KickOutFromConference()
142 {
143 return TELEPHONY_SUCCESS;
144 }
145
CanCombineConference()146 int32_t BluetoothCall::CanCombineConference()
147 {
148 return TELEPHONY_SUCCESS;
149 }
150
CanSeparateConference()151 int32_t BluetoothCall::CanSeparateConference()
152 {
153 return TELEPHONY_SUCCESS;
154 }
155
CanKickOutFromConference()156 int32_t BluetoothCall::CanKickOutFromConference()
157 {
158 return TELEPHONY_SUCCESS;
159 }
160
GetMainCallId(int32_t & mainCallId)161 int32_t BluetoothCall::GetMainCallId(int32_t &mainCallId)
162 {
163 return TELEPHONY_SUCCESS;
164 }
165
GetSubCallIdList(std::vector<std::u16string> & callIdList)166 int32_t BluetoothCall::GetSubCallIdList(std::vector<std::u16string> &callIdList)
167 {
168 return TELEPHONY_SUCCESS;
169 }
170
GetCallIdListForConference(std::vector<std::u16string> & callIdList)171 int32_t BluetoothCall::GetCallIdListForConference(std::vector<std::u16string> &callIdList)
172 {
173 return TELEPHONY_SUCCESS;
174 }
175
IsSupportConferenceable()176 int32_t BluetoothCall::IsSupportConferenceable()
177 {
178 return TELEPHONY_SUCCESS;
179 }
180
LaunchConference()181 int32_t BluetoothCall::LaunchConference()
182 {
183 return TELEPHONY_SUCCESS;
184 }
185
ExitConference()186 int32_t BluetoothCall::ExitConference()
187 {
188 return TELEPHONY_SUCCESS;
189 }
190
HoldConference()191 int32_t BluetoothCall::HoldConference()
192 {
193 return TELEPHONY_SUCCESS;
194 }
195
StartDtmf(char str)196 int32_t BluetoothCall::StartDtmf(char str)
197 {
198 Bluetooth::HandsFreeUnit *profile = Bluetooth::HandsFreeUnit::GetProfile();
199 if (profile == nullptr) {
200 TELEPHONY_LOGE("profile is nullptr");
201 return CALL_ERR_FUNCTION_NOT_SUPPORTED;
202 }
203 if (macAddress_.empty()) {
204 TELEPHONY_LOGE("error: macAddress is empty");
205 }
206 Bluetooth::BluetoothRemoteDevice device(macAddress_);
207 uint8_t code = (uint8_t)str;
208 profile->SendDTMFTone(device, code);
209 return TELEPHONY_SUCCESS;
210 }
211 } // namespace Telephony
212 } // namespace OHOS
213