1 // 2 // Copyright 2017 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/1.0/IBluetoothHci.h> 20 21 #include <hidl/MQDescriptor.h> 22 23 #include "hci_packetizer.h" 24 25 #include "async_manager.h" 26 #include "dual_mode_controller.h" 27 #include "test_channel_transport.h" 28 29 namespace android { 30 namespace hardware { 31 namespace bluetooth { 32 namespace V1_0 { 33 namespace sim { 34 35 class BluetoothDeathRecipient; 36 37 class BluetoothHci : public IBluetoothHci { 38 public: 39 BluetoothHci(); 40 41 ::android::hardware::Return<void> initialize( 42 const sp<IBluetoothHciCallbacks>& cb) override; 43 44 ::android::hardware::Return<void> sendHciCommand( 45 const ::android::hardware::hidl_vec<uint8_t>& packet) override; 46 47 ::android::hardware::Return<void> sendAclData( 48 const ::android::hardware::hidl_vec<uint8_t>& packet) override; 49 50 ::android::hardware::Return<void> sendScoData( 51 const ::android::hardware::hidl_vec<uint8_t>& packet) override; 52 53 ::android::hardware::Return<void> close() override; 54 55 static void OnPacketReady(); 56 57 static BluetoothHci* get(); 58 59 private: 60 sp<BluetoothDeathRecipient> death_recipient_; 61 62 std::function<void(sp<BluetoothDeathRecipient>&)> unlink_cb_; 63 64 void HandleIncomingPacket(); 65 66 test_vendor_lib::AsyncManager async_manager_; 67 68 void SetUpTestChannel(int port); 69 70 test_vendor_lib::DualModeController controller_; 71 72 test_vendor_lib::TestChannelTransport test_channel_transport_; 73 }; 74 75 extern "C" IBluetoothHci* HIDL_FETCH_IBluetoothHci(const char* name); 76 77 } // namespace sim 78 } // namespace V1_0 79 } // namespace bluetooth 80 } // namespace hardware 81 } // namespace android 82