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 #ifndef TELEPHONY_BLUETOOTH_CONNECTION_H 17 #define TELEPHONY_BLUETOOTH_CONNECTION_H 18 19 #include <set> 20 #include <string> 21 #include <memory> 22 23 #ifdef ABILITY_BLUETOOTH_SUPPORT 24 #include "bluetooth_hfp_ag.h" 25 #endif 26 27 namespace OHOS { 28 namespace Telephony { 29 enum BtScoState { 30 SCO_STATE_UNKNOWN = 0, 31 SCO_STATE_CONNECTED, 32 SCO_STATE_DISCONNECTED, 33 SCO_STATE_PENDING, 34 }; 35 36 class BluetoothConnection { 37 public: 38 BluetoothConnection(); 39 ~BluetoothConnection(); 40 bool ConnectBtSco(); 41 bool DisconnectBtSco(); 42 bool IsBtScoConnected(); 43 static BtScoState GetBtScoState(); 44 static void SetBtScoState(BtScoState state); 45 int32_t SendBtCallState(int32_t numActive, int32_t numHeld, int32_t callState, const std::string &number); 46 #ifdef ABILITY_BLUETOOTH_SUPPORT 47 void OnScoStateChanged(const Bluetooth::BluetoothRemoteDevice &device, int32_t state) override; 48 void OnConnectionStateChanged(const Bluetooth::BluetoothRemoteDevice &device, int32_t state) override; 49 #endif 50 51 private: 52 bool IsAudioActivated(); 53 static BtScoState btScoState_; 54 std::string connectedScoAddr_; 55 std::set<std::string> connectedBtDevices_; 56 #ifdef ABILITY_BLUETOOTH_SUPPORT 57 bool ConnectBtSco(const Bluetooth::BluetoothRemoteDevice &device); 58 bool DisconnectBtSco(const Bluetooth::BluetoothRemoteDevice &device); 59 #endif 60 }; 61 } // namespace Telephony 62 } // namespace OHOS 63 #endif