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