• 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 "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 
GetBtScoState()41 BtScoState BluetoothCallManager::GetBtScoState()
42 {
43     if (btConnection_ == nullptr) {
44         TELEPHONY_LOGE("bluetooth connection nullptr");
45         return BtScoState::SCO_STATE_UNKNOWN;
46     }
47     return btConnection_->GetBtScoState();
48 }
49 
IsBtScoConnected()50 bool BluetoothCallManager::IsBtScoConnected()
51 {
52     if (btConnection_ == nullptr) {
53         TELEPHONY_LOGE("bluetooth connection nullptr");
54         return false;
55     }
56     return btConnection_->IsBtScoConnected();
57 }
58 
IsBtAvailble()59 bool BluetoothCallManager::IsBtAvailble()
60 {
61     if (btConnection_ == nullptr) {
62         TELEPHONY_LOGE("bluetooth connection nullptr");
63         return false;
64     }
65     bool isBtAvailble = false;
66 
67 #ifdef ABILITY_BLUETOOTH_SUPPORT
68     isBtAvailble = btConnection_->IsBtAvailble();
69 #endif
70     return isBtAvailble;
71 }
72 
GetConnectedScoAddr()73 std::string BluetoothCallManager::GetConnectedScoAddr()
74 {
75     return btConnection_->GetConnectedScoAddr();
76 }
77 } // namespace Telephony
78 } // namespace OHOS