1 /* 2 * Copyright 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <android/hardware/bluetooth/audio/2.1/IBluetoothAudioProvidersFactory.h> 20 #include <android/hardware/bluetooth/audio/2.1/types.h> 21 22 namespace bluetooth { 23 namespace audio { 24 25 using ::android::hardware::hidl_vec; 26 27 using IBluetoothAudioProvidersFactory_2_0 = ::android::hardware::bluetooth:: 28 audio::V2_0::IBluetoothAudioProvidersFactory; 29 using IBluetoothAudioProvidersFactory_2_1 = ::android::hardware::bluetooth:: 30 audio::V2_1::IBluetoothAudioProvidersFactory; 31 32 constexpr char kFullyQualifiedInterfaceName_2_0[] = 33 "android.hardware.bluetooth.audio@2.0::IBluetoothAudioProvidersFactory"; 34 constexpr char kFullyQualifiedInterfaceName_2_1[] = 35 "android.hardware.bluetooth.audio@2.1::IBluetoothAudioProvidersFactory"; 36 37 enum class BluetoothAudioHalVersion : uint8_t { 38 VERSION_UNAVAILABLE = 0, 39 VERSION_2_0, 40 VERSION_2_1, 41 VERSION_AIDL_V1, 42 }; 43 44 enum class BluetoothAudioHalTransport : uint8_t { 45 // Uninit, default value 46 UNKNOWN, 47 // No HAL available after init or force disabled 48 DISABLED, 49 AIDL, 50 HIDL, 51 }; 52 53 class HalVersionManager { 54 public: 55 static BluetoothAudioHalVersion GetHalVersion(); 56 57 static BluetoothAudioHalTransport GetHalTransport(); 58 59 static android::sp<IBluetoothAudioProvidersFactory_2_1> 60 GetProvidersFactory_2_1(); 61 62 static android::sp<IBluetoothAudioProvidersFactory_2_0> 63 GetProvidersFactory_2_0(); 64 65 HalVersionManager(); 66 67 private: 68 static std::unique_ptr<HalVersionManager> instance_ptr; 69 std::mutex mutex_; 70 71 BluetoothAudioHalVersion hal_version_; 72 }; 73 74 } // namespace audio 75 } // namespace bluetooth 76