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 namespace OHOS {
26 namespace Telephony {
BluetoothCallManager()27 BluetoothCallManager::BluetoothCallManager() : btConnection_(DelayedSingleton<BluetoothConnection>::GetInstance()) {}
28
~BluetoothCallManager()29 BluetoothCallManager::~BluetoothCallManager() {}
30
SendBtCallState(int32_t numActive,int32_t numHeld,int32_t callState,const std::string & number)31 int32_t BluetoothCallManager::SendBtCallState(
32 int32_t numActive, int32_t numHeld, int32_t callState, const std::string &number)
33 {
34 if (btConnection_ == nullptr) {
35 TELEPHONY_LOGE("bluetooth connection nullptr");
36 return false;
37 }
38 return btConnection_->SendBtCallState(numActive, numHeld, callState, number);
39 }
40
SendCallDetailsChange(int32_t callId,int32_t callState)41 int32_t BluetoothCallManager::SendCallDetailsChange(int32_t callId, int32_t callState)
42 {
43 if (btConnection_ == nullptr) {
44 TELEPHONY_LOGE("bluetooth connection nullptr");
45 return false;
46 }
47 return btConnection_->SendCallDetailsChange(callId, callState);
48 }
49
IsBtAvailble()50 bool BluetoothCallManager::IsBtAvailble()
51 {
52 if (btConnection_ == nullptr) {
53 TELEPHONY_LOGE("bluetooth connection nullptr");
54 return false;
55 }
56 bool isBtAvailble = false;
57
58 #ifdef ABILITY_BLUETOOTH_SUPPORT
59 isBtAvailble = btConnection_->IsBtAvailble();
60 #endif
61 return isBtAvailble;
62 }
63 } // namespace Telephony
64 } // namespace OHOS