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 "bluetooth_call_manager.h"
17
18 #include "call_manager_errors.h"
19 #include "telephony_log_wrapper.h"
20
21 #include "audio_control_manager.h"
22 #include "call_control_manager.h"
23 #include "bluetooth_connection.h"
24
25 #ifdef ABILITY_BLUETOOTH_SUPPORT
26 #include "bluetooth_mgr_client.h"
27 #include "bluetooth_remote_device.h"
28 #endif
29
30 namespace OHOS {
31 namespace Telephony {
BluetoothCallManager()32 BluetoothCallManager::BluetoothCallManager() : btConnection_(std::make_unique<BluetoothConnection>()) {}
33
~BluetoothCallManager()34 BluetoothCallManager::~BluetoothCallManager() {}
35
ConnectBtSco()36 bool BluetoothCallManager::ConnectBtSco()
37 {
38 if (btConnection_ == nullptr) {
39 TELEPHONY_LOGE("bluetooth connection nullptr");
40 return false;
41 }
42 return btConnection_->ConnectBtSco();
43 }
44
DisconnectBtSco()45 bool BluetoothCallManager::DisconnectBtSco()
46 {
47 if (btConnection_ == nullptr) {
48 TELEPHONY_LOGE("bluetooth connection nullptr");
49 return false;
50 }
51 return btConnection_->DisconnectBtSco();
52 }
53
SendBtCallState(int32_t numActive,int32_t numHeld,int32_t callState,const std::string & number)54 int32_t BluetoothCallManager::SendBtCallState(
55 int32_t numActive, int32_t numHeld, int32_t callState, const std::string &number)
56 {
57 if (btConnection_ == nullptr) {
58 TELEPHONY_LOGE("bluetooth connection nullptr");
59 return false;
60 }
61 return btConnection_->SendBtCallState(numActive, numHeld, callState, number);
62 }
63
GetBtScoState()64 BtScoState BluetoothCallManager::GetBtScoState()
65 {
66 if (btConnection_ == nullptr) {
67 TELEPHONY_LOGE("bluetooth connection nullptr");
68 return BtScoState::SCO_STATE_UNKNOWN;
69 }
70 return btConnection_->GetBtScoState();
71 }
72
IsBtScoConnected()73 bool BluetoothCallManager::IsBtScoConnected()
74 {
75 if (btConnection_ == nullptr) {
76 TELEPHONY_LOGE("bluetooth connection nullptr");
77 return false;
78 }
79 return btConnection_->IsBtScoConnected();
80 }
81 } // namespace Telephony
82 } // namespace OHOS