1 /* 2 * Copyright (C) 2022 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 <aidl/android/hardware/audio/core/BnBluetooth.h> 20 #include <aidl/android/hardware/audio/core/BnBluetoothA2dp.h> 21 #include <aidl/android/hardware/audio/core/BnBluetoothLe.h> 22 23 namespace aidl::android::hardware::audio::core { 24 25 class ParamChangeHandler { 26 public: 27 ParamChangeHandler() = default; registerHandler(std::function<ndk::ScopedAStatus ()> handler)28 void registerHandler(std::function<ndk::ScopedAStatus()> handler) { mHandler = handler; } 29 30 protected: 31 std::function<ndk::ScopedAStatus()> mHandler = nullptr; 32 }; 33 34 class Bluetooth : public BnBluetooth { 35 public: 36 Bluetooth(); 37 38 private: 39 ndk::ScopedAStatus setScoConfig(const ScoConfig& in_config, ScoConfig* _aidl_return) override; 40 ndk::ScopedAStatus setHfpConfig(const HfpConfig& in_config, HfpConfig* _aidl_return) override; 41 42 ScoConfig mScoConfig; 43 HfpConfig mHfpConfig; 44 }; 45 46 class BluetoothA2dp : public BnBluetoothA2dp, public ParamChangeHandler { 47 public: 48 BluetoothA2dp() = default; 49 ndk::ScopedAStatus isEnabled(bool* _aidl_return) override; 50 51 private: 52 ndk::ScopedAStatus setEnabled(bool in_enabled) override; 53 ndk::ScopedAStatus supportsOffloadReconfiguration(bool* _aidl_return) override; 54 ndk::ScopedAStatus reconfigureOffload( 55 const std::vector<::aidl::android::hardware::audio::core::VendorParameter>& 56 in_parameters) override; 57 58 bool mEnabled = false; 59 }; 60 61 class BluetoothLe : public BnBluetoothLe, public ParamChangeHandler { 62 public: 63 BluetoothLe() = default; 64 ndk::ScopedAStatus isEnabled(bool* _aidl_return) override; 65 66 private: 67 ndk::ScopedAStatus setEnabled(bool in_enabled) override; 68 ndk::ScopedAStatus supportsOffloadReconfiguration(bool* _aidl_return) override; 69 ndk::ScopedAStatus reconfigureOffload( 70 const std::vector<::aidl::android::hardware::audio::core::VendorParameter>& 71 in_parameters) override; 72 73 bool mEnabled = false; 74 }; 75 76 } // namespace aidl::android::hardware::audio::core 77