OSDN Git Service

Add AclCommands for LE and BR/EDR
authorMyles Watson <mylesgw@google.com>
Tue, 17 Nov 2020 05:24:21 +0000 (21:24 -0800)
committerMyles Watson <mylesgw@google.com>
Tue, 17 Nov 2020 15:46:04 +0000 (07:46 -0800)
Bug: 172725986
Test: atest bluetooth_test_gd
Tag: #gd-refactor
Change-Id: I822ce0751be08a98a30c219853e1540e2e461a08

16 files changed:
gd/hci/acl_connection_interface.h
gd/hci/acl_manager_test.cc
gd/hci/facade/acl_manager_facade.cc
gd/hci/facade/le_acl_manager_facade.cc
gd/hci/fuzz/fuzz_hci_layer.h
gd/hci/fuzz/hci_layer_fuzz_client.cc
gd/hci/hci_layer.cc
gd/hci/hci_layer.h
gd/hci/hci_layer_test.cc
gd/hci/hci_packets.pdl
gd/hci/hci_packets_test.cc
gd/hci/le_acl_connection_interface.h
gd/hci/le_address_manager_test.cc
gd/hci/le_advertising_manager_test.cc
gd/hci/le_scanning_manager_test.cc
vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.cc

index 5b2564b..eb8b12b 100644 (file)
@@ -40,7 +40,7 @@ constexpr EventCode AclConnectionEvents[] = {
     EventCode::LINK_SUPERVISION_TIMEOUT_CHANGED,
 };
 
-typedef CommandInterface<ConnectionManagementCommandBuilder> AclConnectionInterface;
+typedef CommandInterface<AclCommandBuilder> AclConnectionInterface;
 
 }  // namespace hci
 }  // namespace bluetooth
index a9de6a2..79e9e22 100644 (file)
@@ -156,11 +156,12 @@ class TestHciLayer : public HciLayer {
       EXPECT_NE(std::future_status::timeout, result);
     }
     if (command_queue_.empty()) {
-      return ConnectionManagementCommandView::Create(
-          CommandPacketView::Create(PacketView<kLittleEndian>(std::make_shared<std::vector<uint8_t>>())));
+      return ConnectionManagementCommandView::Create(AclCommandView::Create(
+          CommandPacketView::Create(PacketView<kLittleEndian>(std::make_shared<std::vector<uint8_t>>()))));
     }
     CommandPacketView command_packet_view = GetLastCommand();
-    ConnectionManagementCommandView command = ConnectionManagementCommandView::Create(command_packet_view);
+    ConnectionManagementCommandView command =
+        ConnectionManagementCommandView::Create(AclCommandView::Create(command_packet_view));
     EXPECT_TRUE(command.IsValid());
     EXPECT_EQ(command.GetOpCode(), op_code);
 
@@ -176,11 +177,12 @@ class TestHciLayer : public HciLayer {
       EXPECT_NE(std::future_status::timeout, result);
     }
     if (command_queue_.empty()) {
-      return ConnectionManagementCommandView::Create(
-          CommandPacketView::Create(PacketView<kLittleEndian>(std::make_shared<std::vector<uint8_t>>())));
+      return ConnectionManagementCommandView::Create(AclCommandView::Create(
+          CommandPacketView::Create(PacketView<kLittleEndian>(std::make_shared<std::vector<uint8_t>>()))));
     }
     CommandPacketView command_packet_view = GetLastCommand();
-    ConnectionManagementCommandView command = ConnectionManagementCommandView::Create(command_packet_view);
+    ConnectionManagementCommandView command =
+        ConnectionManagementCommandView::Create(AclCommandView::Create(command_packet_view));
     EXPECT_TRUE(command.IsValid());
     EXPECT_EQ(command.GetOpCode(), op_code);
 
@@ -582,7 +584,8 @@ class AclManagerWithLeConnectionTest : public AclManagerTest {
     test_hci_layer_->IncomingEvent(LeAddDeviceToConnectListCompleteBuilder::Create(0x01, ErrorCode::SUCCESS));
     test_hci_layer_->SetCommandFuture();
     auto packet = test_hci_layer_->GetCommandPacket(OpCode::LE_CREATE_CONNECTION);
-    auto le_connection_management_command_view = LeConnectionManagementCommandView::Create(packet);
+    auto le_connection_management_command_view =
+        LeConnectionManagementCommandView::Create(AclCommandView::Create(packet));
     auto command_view = LeCreateConnectionView::Create(le_connection_management_command_view);
     ASSERT_TRUE(command_view.IsValid());
     if (use_connect_list_) {
@@ -664,7 +667,8 @@ TEST_F(AclManagerTest, invoke_registered_callback_le_connection_complete_fail) {
   test_hci_layer_->IncomingEvent(LeAddDeviceToConnectListCompleteBuilder::Create(0x01, ErrorCode::SUCCESS));
   test_hci_layer_->SetCommandFuture();
   auto packet = test_hci_layer_->GetLastCommandPacket(OpCode::LE_CREATE_CONNECTION);
-  auto le_connection_management_command_view = LeConnectionManagementCommandView::Create(packet);
+  auto le_connection_management_command_view =
+      LeConnectionManagementCommandView::Create(AclCommandView::Create(packet));
   auto command_view = LeCreateConnectionView::Create(le_connection_management_command_view);
   ASSERT_TRUE(command_view.IsValid());
   if (use_connect_list_) {
@@ -691,7 +695,7 @@ TEST_F(AclManagerTest, invoke_registered_callback_le_connection_complete_fail) {
 
   test_hci_layer_->SetCommandFuture();
   packet = test_hci_layer_->GetLastCommandPacket(OpCode::LE_REMOVE_DEVICE_FROM_CONNECT_LIST);
-  le_connection_management_command_view = LeConnectionManagementCommandView::Create(packet);
+  le_connection_management_command_view = LeConnectionManagementCommandView::Create(AclCommandView::Create(packet));
   auto remove_command_view = LeRemoveDeviceFromConnectListView::Create(le_connection_management_command_view);
   ASSERT_TRUE(remove_command_view.IsValid());
   test_hci_layer_->IncomingEvent(LeRemoveDeviceFromConnectListCompleteBuilder::Create(0x01, ErrorCode::SUCCESS));
@@ -709,7 +713,8 @@ TEST_F(AclManagerTest, cancel_le_connection) {
   test_hci_layer_->SetCommandFuture();
   acl_manager_->CancelLeConnect(remote_with_type);
   auto packet = test_hci_layer_->GetLastCommandPacket(OpCode::LE_CREATE_CONNECTION_CANCEL);
-  auto le_connection_management_command_view = LeConnectionManagementCommandView::Create(packet);
+  auto le_connection_management_command_view =
+      LeConnectionManagementCommandView::Create(AclCommandView::Create(packet));
   auto command_view = LeCreateConnectionCancelView::Create(le_connection_management_command_view);
   ASSERT_TRUE(command_view.IsValid());
 
@@ -727,7 +732,7 @@ TEST_F(AclManagerTest, cancel_le_connection) {
 
   test_hci_layer_->SetCommandFuture();
   packet = test_hci_layer_->GetLastCommandPacket(OpCode::LE_REMOVE_DEVICE_FROM_CONNECT_LIST);
-  le_connection_management_command_view = LeConnectionManagementCommandView::Create(packet);
+  le_connection_management_command_view = LeConnectionManagementCommandView::Create(AclCommandView::Create(packet));
   auto remove_command_view = LeRemoveDeviceFromConnectListView::Create(le_connection_management_command_view);
   ASSERT_TRUE(remove_command_view.IsValid());
 
@@ -776,7 +781,8 @@ TEST_F(AclManagerWithLeConnectionTest, invoke_registered_callback_le_connection_
   connection_->LeConnectionUpdate(connection_interval_min, connection_interval_max, connection_latency,
                                   supervision_timeout, 0x10, 0x20);
   auto update_packet = test_hci_layer_->GetCommandPacket(OpCode::LE_CONNECTION_UPDATE);
-  auto update_view = LeConnectionUpdateView::Create(LeConnectionManagementCommandView::Create(update_packet));
+  auto update_view =
+      LeConnectionUpdateView::Create(LeConnectionManagementCommandView::Create(AclCommandView::Create(update_packet)));
   ASSERT_TRUE(update_view.IsValid());
   EXPECT_EQ(update_view.GetConnectionHandle(), handle_);
   EXPECT_CALL(mock_le_connection_management_callbacks_,
index 3daa037..1e0df84 100644 (file)
@@ -114,8 +114,9 @@ class AclManagerFacadeService : public AclManagerFacade::Service, public Connect
       ::grpc::ServerContext* context,
       const ConnectionCommandMsg* request,
       ::google::protobuf::Empty* response) override {
-    auto command_view = ConnectionManagementCommandView::Create(CommandPacketView::Create(PacketView<kLittleEndian>(
-        std::make_shared<std::vector<uint8_t>>(request->packet().begin(), request->packet().end()))));
+    auto command_view = ConnectionManagementCommandView::Create(
+        AclCommandView::Create(CommandPacketView::Create(PacketView<kLittleEndian>(
+            std::make_shared<std::vector<uint8_t>>(request->packet().begin(), request->packet().end())))));
     if (!command_view.IsValid()) {
       return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "Invalid command packet");
     }
index d86b377..7806b4a 100644 (file)
@@ -120,8 +120,9 @@ class LeAclManagerFacadeService : public LeAclManagerFacade::Service, public LeC
       ::grpc::ServerContext* context,
       const LeConnectionCommandMsg* request,
       ::google::protobuf::Empty* response) override {
-    auto command_view = ConnectionManagementCommandView::Create(CommandPacketView::Create(PacketView<kLittleEndian>(
-        std::make_shared<std::vector<uint8_t>>(request->packet().begin(), request->packet().end()))));
+    auto command_view = ConnectionManagementCommandView::Create(
+        AclCommandView::Create(CommandPacketView::Create(PacketView<kLittleEndian>(
+            std::make_shared<std::vector<uint8_t>>(request->packet().begin(), request->packet().end())))));
     if (!command_view.IsValid()) {
       return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "Invalid command packet");
     }
index c76956f..19d7c05 100644 (file)
@@ -155,8 +155,8 @@ class FuzzHciLayer : public HciLayer {
   os::fuzz::DevNullQueue<AclPacketBuilder>* acl_dev_null_;
   os::fuzz::FuzzInjectQueue<AclPacketView>* acl_inject_;
 
-  FuzzCommandInterface<ConnectionManagementCommandBuilder> acl_connection_interface_{};
-  FuzzCommandInterface<LeConnectionManagementCommandBuilder> le_acl_connection_interface_{};
+  FuzzCommandInterface<AclCommandBuilder> acl_connection_interface_{};
+  FuzzCommandInterface<AclCommandBuilder> le_acl_connection_interface_{};
   FuzzCommandInterface<SecurityCommandBuilder> security_interface_{};
   FuzzCommandInterface<LeSecurityCommandBuilder> le_security_interface_{};
   FuzzCommandInterface<LeAdvertisingCommandBuilder> le_advertising_interface_{};
index 607e7b5..ca58030 100644 (file)
@@ -104,12 +104,11 @@ void HciLayerFuzzClient::injectLeSecurityCommand(std::vector<uint8_t> data) {
 }
 
 void HciLayerFuzzClient::injectAclConnectionCommand(std::vector<uint8_t> data) {
-  inject_command<ConnectionManagementCommandView, ConnectionManagementCommandBuilder>(data, acl_connection_interface_);
+  inject_command<AclCommandView, AclCommandBuilder>(data, acl_connection_interface_);
 }
 
 void HciLayerFuzzClient::injectLeAclConnectionCommand(std::vector<uint8_t> data) {
-  inject_command<LeConnectionManagementCommandView, LeConnectionManagementCommandBuilder>(data,
-                                                                                          le_acl_connection_interface_);
+  inject_command<AclCommandView, AclCommandBuilder>(data, le_acl_connection_interface_);
 }
 
 void HciLayerFuzzClient::injectLeAdvertisingCommand(std::vector<uint8_t> data) {
index b187c21..1761777 100644 (file)
@@ -338,7 +338,7 @@ void HciLayer::on_read_remote_version_complete(EventPacketView event_view) {
   if (view.GetStatus() != ErrorCode::SUCCESS) {
     auto status = view.GetStatus();
     std::string error_code = ErrorCodeText(status);
-    LOG_ERROR("Received on_read_remote_version_information_complete with error code %s", error_code.c_str());
+    LOG_ERROR("Received with error code %s", error_code.c_str());
     return;
   }
   uint16_t handle = view.GetConnectionHandle();
index 462c3d6..d8a1875 100644 (file)
@@ -132,8 +132,8 @@ class HciLayer : public Module, public CommandInterface<CommandPacketBuilder> {
   void on_read_remote_version_complete(EventPacketView event_view);
 
   // Interfaces
-  CommandInterfaceImpl<ConnectionManagementCommandBuilder> acl_connection_manager_interface_{*this};
-  CommandInterfaceImpl<LeConnectionManagementCommandBuilder> le_acl_connection_manager_interface_{*this};
+  CommandInterfaceImpl<AclCommandBuilder> acl_connection_manager_interface_{*this};
+  CommandInterfaceImpl<AclCommandBuilder> le_acl_connection_manager_interface_{*this};
   CommandInterfaceImpl<SecurityCommandBuilder> security_interface{*this};
   CommandInterfaceImpl<LeSecurityCommandBuilder> le_security_interface{*this};
   CommandInterfaceImpl<LeAdvertisingCommandBuilder> le_advertising_interface{*this};
index f21a64b..e3c45ad 100644 (file)
@@ -586,8 +586,8 @@ TEST_F(HciTest, createConnectionTest) {
   // Check the command
   auto sent_command = hal->GetSentCommand();
   ASSERT_LT(0, sent_command.size());
-  CreateConnectionView view =
-      CreateConnectionView::Create(ConnectionManagementCommandView::Create(CommandPacketView::Create(sent_command)));
+  CreateConnectionView view = CreateConnectionView::Create(
+      ConnectionManagementCommandView::Create(AclCommandView::Create(CommandPacketView::Create(sent_command))));
   ASSERT_TRUE(view.IsValid());
   ASSERT_EQ(bd_addr, view.GetBdAddr());
   ASSERT_EQ(packet_type, view.GetPacketType());
index 58cf8a7..bdf482a 100644 (file)
@@ -621,12 +621,13 @@ packet CommandPacket {
 // Packets for interfaces
 
 packet DiscoveryCommand : CommandPacket { _payload_, }
-packet ConnectionManagementCommand : CommandPacket { _payload_, }
+packet AclCommand : CommandPacket { _payload_, }
+packet ConnectionManagementCommand : AclCommand { _payload_, }
 packet SecurityCommand : CommandPacket { _payload_, }
 packet ScoConnectionCommand : CommandPacket { _payload_, }
 packet LeAdvertisingCommand : CommandPacket { _payload_, }
 packet LeScanningCommand : CommandPacket { _payload_, }
-packet LeConnectionManagementCommand : CommandPacket { _payload_, }
+packet LeConnectionManagementCommand : AclCommand { _payload_, }
 packet LeSecurityCommand : CommandPacket { _payload_, }
 packet VendorCommand : CommandPacket { _payload_, }
 
@@ -888,7 +889,7 @@ enum DisconnectReason : 8 {
   UNACCEPTABLE_CONNECTION_PARAMETERS = 0x3B,
 }
 
-packet Disconnect : ConnectionManagementCommand (op_code = DISCONNECT) {
+packet Disconnect : AclCommand (op_code = DISCONNECT) {
   connection_handle : 12,
   _reserved_ : 4,
   reason : DisconnectReason,
@@ -1055,7 +1056,7 @@ packet ReadRemoteExtendedFeatures : ConnectionManagementCommand (op_code = READ_
 packet ReadRemoteExtendedFeaturesStatus : CommandStatus (command_op_code = READ_REMOTE_EXTENDED_FEATURES) {
 }
 
-packet ReadRemoteVersionInformation : ConnectionManagementCommand (op_code = READ_REMOTE_VERSION_INFORMATION) {
+packet ReadRemoteVersionInformation : AclCommand (op_code = READ_REMOTE_VERSION_INFORMATION) {
   connection_handle : 12,
   _reserved_ : 4,
 }
@@ -2301,7 +2302,7 @@ packet ReadLinkQualityComplete : CommandComplete (command_op_code = READ_LINK_QU
   link_quality : 8,
 }
 
-packet ReadRssi : ConnectionManagementCommand (op_code = READ_RSSI) {
+packet ReadRssi : AclCommand (op_code = READ_RSSI) {
   connection_handle : 12,
   _reserved_ : 4,
 }
index 5379af7..589dca5 100644 (file)
@@ -429,7 +429,7 @@ TEST(HciPacketsTest, testLeExtendedCreateConnection) {
       std::make_shared<std::vector<uint8_t>>(le_extended_create_connection);
   PacketView<kLittleEndian> packet_bytes_view(packet_bytes);
   auto view = LeExtendedCreateConnectionView::Create(
-      LeConnectionManagementCommandView::Create(CommandPacketView::Create(packet_bytes_view)));
+      LeConnectionManagementCommandView::Create(AclCommandView::Create(CommandPacketView::Create(packet_bytes_view))));
   ASSERT_TRUE(view.IsValid());
 }
 
index 08ec6d0..8f1a948 100644 (file)
@@ -31,7 +31,7 @@ constexpr SubeventCode LeConnectionManagementEvents[] = {
     SubeventCode::REMOTE_CONNECTION_PARAMETER_REQUEST,
 };
 
-typedef CommandInterface<LeConnectionManagementCommandBuilder> LeAclConnectionInterface;
+typedef CommandInterface<AclCommandBuilder> LeAclConnectionInterface;
 
 }  // namespace hci
 }  // namespace bluetooth
index 9f2ff42..bb2ea28 100644 (file)
@@ -324,7 +324,8 @@ TEST_F(LeAddressManagerWithSingleClientTest, add_device_to_connect_list) {
   test_hci_layer_->SetCommandFuture();
   le_address_manager_->AddDeviceToConnectList(ConnectListAddressType::RANDOM, address);
   auto packet = test_hci_layer_->GetCommandPacket(OpCode::LE_ADD_DEVICE_TO_CONNECT_LIST);
-  auto packet_view = LeAddDeviceToConnectListView::Create(LeConnectionManagementCommandView::Create(packet));
+  auto packet_view =
+      LeAddDeviceToConnectListView::Create(LeConnectionManagementCommandView::Create(AclCommandView::Create(packet)));
   ASSERT_TRUE(packet_view.IsValid());
   ASSERT_EQ(ConnectListAddressType::RANDOM, packet_view.GetAddressType());
   ASSERT_EQ(address, packet_view.GetAddress());
@@ -344,7 +345,8 @@ TEST_F(LeAddressManagerWithSingleClientTest, remove_device_from_connect_list) {
   test_hci_layer_->SetCommandFuture();
   le_address_manager_->RemoveDeviceFromConnectList(ConnectListAddressType::RANDOM, address);
   auto packet = test_hci_layer_->GetCommandPacket(OpCode::LE_REMOVE_DEVICE_FROM_CONNECT_LIST);
-  auto packet_view = LeRemoveDeviceFromConnectListView::Create(LeConnectionManagementCommandView::Create(packet));
+  auto packet_view = LeRemoveDeviceFromConnectListView::Create(
+      LeConnectionManagementCommandView::Create(AclCommandView::Create(packet)));
   ASSERT_TRUE(packet_view.IsValid());
   ASSERT_EQ(ConnectListAddressType::RANDOM, packet_view.GetAddressType());
   ASSERT_EQ(address, packet_view.GetAddress());
@@ -435,7 +437,8 @@ TEST_F(LeAddressManagerWithSingleClientTest, register_during_command_complete) {
   test_hci_layer_->SetCommandFuture();
   le_address_manager_->AddDeviceToConnectList(ConnectListAddressType::RANDOM, address);
   auto packet = test_hci_layer_->GetCommandPacket(OpCode::LE_ADD_DEVICE_TO_CONNECT_LIST);
-  auto packet_view = LeAddDeviceToConnectListView::Create(LeConnectionManagementCommandView::Create(packet));
+  auto packet_view =
+      LeAddDeviceToConnectListView::Create(LeConnectionManagementCommandView::Create(AclCommandView::Create(packet)));
   ASSERT_TRUE(packet_view.IsValid());
   ASSERT_EQ(ConnectListAddressType::RANDOM, packet_view.GetAddressType());
   ASSERT_EQ(address, packet_view.GetAddress());
index dc76ecd..4a4e2b8 100644 (file)
@@ -128,12 +128,12 @@ class TestHciLayer : public HciLayer {
 
   ConnectionManagementCommandView GetCommandPacket(OpCode op_code) {
     if (command_queue_.empty()) {
-      return ConnectionManagementCommandView::Create(
-          CommandPacketView::Create(PacketView<kLittleEndian>(std::make_shared<std::vector<uint8_t>>())));
+      return ConnectionManagementCommandView::Create(AclCommandView::Create(
+          CommandPacketView::Create(PacketView<kLittleEndian>(std::make_shared<std::vector<uint8_t>>()))));
     }
     CommandPacketView command_packet_view = CommandPacketView::Create(command_queue_.front());
     command_queue_.pop_front();
-    ConnectionManagementCommandView command = ConnectionManagementCommandView::Create(command_packet_view);
+    auto command = ConnectionManagementCommandView::Create(AclCommandView::Create(command_packet_view));
     EXPECT_TRUE(command.IsValid());
     EXPECT_EQ(command.GetOpCode(), op_code);
 
@@ -409,7 +409,7 @@ class LeExtendedAdvertisingAPITest : public LeExtendedAdvertisingManagerTest {
     for (size_t i = 0; i < adv_opcodes.size(); i++) {
       auto packet_view = test_hci_layer_->GetCommandPacket(adv_opcodes[i]);
       CommandPacketView command_packet_view = CommandPacketView::Create(packet_view);
-      ConnectionManagementCommandView command = ConnectionManagementCommandView::Create(command_packet_view);
+      auto command = ConnectionManagementCommandView::Create(AclCommandView::Create(command_packet_view));
       if (adv_opcodes[i] == OpCode::LE_SET_EXTENDED_ADVERTISING_PARAMETERS) {
         test_hci_layer_->IncomingEvent(LeSetExtendedAdvertisingParametersCompleteBuilder::Create(
             uint8_t{1}, ErrorCode::SUCCESS, static_cast<uint8_t>(-23)));
@@ -464,7 +464,7 @@ TEST_F(LeAdvertisingManagerTest, create_advertiser_test) {
   for (size_t i = 0; i < adv_opcodes.size(); i++) {
     auto packet_view = test_hci_layer_->GetCommandPacket(adv_opcodes[i]);
     CommandPacketView command_packet_view = CommandPacketView::Create(packet_view);
-    ConnectionManagementCommandView command = ConnectionManagementCommandView::Create(command_packet_view);
+    auto command = ConnectionManagementCommandView::Create(AclCommandView::Create(command_packet_view));
     test_hci_layer_->IncomingEvent(
         CommandCompleteBuilder::Create(uint8_t{1}, adv_opcodes[i], std::make_unique<RawBuilder>(success_vector)));
   }
@@ -555,7 +555,7 @@ TEST_F(LeExtendedAdvertisingManagerTest, create_advertiser_test) {
   for (size_t i = 0; i < adv_opcodes.size(); i++) {
     auto packet_view = test_hci_layer_->GetCommandPacket(adv_opcodes[i]);
     CommandPacketView command_packet_view = CommandPacketView::Create(packet_view);
-    ConnectionManagementCommandView command = ConnectionManagementCommandView::Create(command_packet_view);
+    auto command = ConnectionManagementCommandView::Create(AclCommandView::Create(command_packet_view));
     if (adv_opcodes[i] == OpCode::LE_SET_EXTENDED_ADVERTISING_PARAMETERS) {
       test_hci_layer_->IncomingEvent(LeSetExtendedAdvertisingParametersCompleteBuilder::Create(
           uint8_t{1}, ErrorCode::SUCCESS, static_cast<uint8_t>(-23)));
index 6d75ed1..4e52014 100644 (file)
@@ -106,7 +106,7 @@ class TestHciLayer : public HciLayer {
 
   ConnectionManagementCommandView GetCommandPacket(OpCode op_code) {
     CommandPacketView command_packet_view = GetLastCommand();
-    ConnectionManagementCommandView command = ConnectionManagementCommandView::Create(command_packet_view);
+    auto command = ConnectionManagementCommandView::Create(AclCommandView::Create(command_packet_view));
     EXPECT_TRUE(command.IsValid());
     EXPECT_EQ(command.GetOpCode(), op_code);
     return command;
index 537a58d..53c4fe9 100644 (file)
@@ -285,7 +285,8 @@ DualModeController::DualModeController(const std::string& properties_filename, u
 
 void DualModeController::SniffSubrating(CommandPacketView command) {
   auto command_view = gd_hci::SniffSubratingView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
 
   send_event_(gd_hci::SniffSubratingCompleteBuilder::Create(
@@ -487,7 +488,8 @@ void DualModeController::ReadLocalVersionInformation(
 void DualModeController::ReadRemoteVersionInformation(
     CommandPacketView command) {
   auto command_view = gd_hci::ReadRemoteVersionInformationView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
 
   auto status = link_layer_controller_.SendCommandToRemoteByHandle(
@@ -563,7 +565,8 @@ void DualModeController::ReadLocalExtendedFeatures(CommandPacketView command) {
 
 void DualModeController::ReadRemoteExtendedFeatures(CommandPacketView command) {
   auto command_view = gd_hci::ReadRemoteExtendedFeaturesView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
 
   auto status = link_layer_controller_.SendCommandToRemoteByHandle(
@@ -577,7 +580,8 @@ void DualModeController::ReadRemoteExtendedFeatures(CommandPacketView command) {
 
 void DualModeController::SwitchRole(CommandPacketView command) {
   auto command_view = gd_hci::SwitchRoleView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
 
   auto status = link_layer_controller_.SwitchRole(
@@ -591,7 +595,8 @@ void DualModeController::SwitchRole(CommandPacketView command) {
 void DualModeController::ReadRemoteSupportedFeatures(
     CommandPacketView command) {
   auto command_view = gd_hci::ReadRemoteSupportedFeaturesView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
 
   auto status = link_layer_controller_.SendCommandToRemoteByHandle(
@@ -606,7 +611,8 @@ void DualModeController::ReadRemoteSupportedFeatures(
 
 void DualModeController::ReadClockOffset(CommandPacketView command) {
   auto command_view = gd_hci::ReadClockOffsetView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
 
   uint16_t handle = command_view.GetConnectionHandle();
@@ -841,7 +847,8 @@ void DualModeController::WriteSimplePairingMode(CommandPacketView command) {
 
 void DualModeController::ChangeConnectionPacketType(CommandPacketView command) {
   auto command_view = gd_hci::ChangeConnectionPacketTypeView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
 
   uint16_t handle = command_view.GetConnectionHandle();
@@ -944,7 +951,8 @@ void DualModeController::WriteInquiryScanType(CommandPacketView command) {
 
 void DualModeController::AuthenticationRequested(CommandPacketView command) {
   auto command_view = gd_hci::AuthenticationRequestedView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   uint16_t handle = command_view.GetConnectionHandle();
   auto status = link_layer_controller_.AuthenticationRequested(handle);
@@ -956,7 +964,8 @@ void DualModeController::AuthenticationRequested(CommandPacketView command) {
 
 void DualModeController::SetConnectionEncryption(CommandPacketView command) {
   auto command_view = gd_hci::SetConnectionEncryptionView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   uint16_t handle = command_view.GetConnectionHandle();
   uint8_t encryption_enable =
@@ -971,7 +980,8 @@ void DualModeController::SetConnectionEncryption(CommandPacketView command) {
 
 void DualModeController::ChangeConnectionLinkKey(CommandPacketView command) {
   auto command_view = gd_hci::ChangeConnectionLinkKeyView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   uint16_t handle = command_view.GetConnectionHandle();
 
@@ -984,7 +994,8 @@ void DualModeController::ChangeConnectionLinkKey(CommandPacketView command) {
 
 void DualModeController::CentralLinkKey(CommandPacketView command) {
   auto command_view = gd_hci::CentralLinkKeyView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   uint8_t key_flag = static_cast<uint8_t>(command_view.GetKeyFlag());
 
@@ -1050,7 +1061,8 @@ void DualModeController::WritePageTimeout(CommandPacketView command) {
 
 void DualModeController::HoldMode(CommandPacketView command) {
   auto command_view = gd_hci::HoldModeView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   uint16_t handle = command_view.GetConnectionHandle();
   uint16_t hold_mode_max_interval = command_view.GetHoldModeMaxInterval();
@@ -1066,7 +1078,8 @@ void DualModeController::HoldMode(CommandPacketView command) {
 
 void DualModeController::SniffMode(CommandPacketView command) {
   auto command_view = gd_hci::SniffModeView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   uint16_t handle = command_view.GetConnectionHandle();
   uint16_t sniff_max_interval = command_view.GetSniffMaxInterval();
@@ -1085,7 +1098,8 @@ void DualModeController::SniffMode(CommandPacketView command) {
 
 void DualModeController::ExitSniffMode(CommandPacketView command) {
   auto command_view = gd_hci::ExitSniffModeView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
 
   auto status =
@@ -1098,7 +1112,8 @@ void DualModeController::ExitSniffMode(CommandPacketView command) {
 
 void DualModeController::QosSetup(CommandPacketView command) {
   auto command_view = gd_hci::QosSetupView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   uint16_t handle = command_view.GetConnectionHandle();
   uint8_t service_type = static_cast<uint8_t>(command_view.GetServiceType());
@@ -1119,7 +1134,8 @@ void DualModeController::QosSetup(CommandPacketView command) {
 void DualModeController::ReadDefaultLinkPolicySettings(
     CommandPacketView command) {
   auto command_view = gd_hci::ReadDefaultLinkPolicySettingsView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   uint16_t settings = link_layer_controller_.ReadDefaultLinkPolicySettings();
   auto packet =
@@ -1131,7 +1147,8 @@ void DualModeController::ReadDefaultLinkPolicySettings(
 void DualModeController::WriteDefaultLinkPolicySettings(
     CommandPacketView command) {
   auto command_view = gd_hci::WriteDefaultLinkPolicySettingsView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   ErrorCode status = link_layer_controller_.WriteDefaultLinkPolicySettings(
       command_view.GetDefaultLinkPolicySettings());
@@ -1143,7 +1160,8 @@ void DualModeController::WriteDefaultLinkPolicySettings(
 
 void DualModeController::FlowSpecification(CommandPacketView command) {
   auto command_view = gd_hci::FlowSpecificationView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   uint16_t handle = command_view.GetConnectionHandle();
   uint8_t flow_direction =
@@ -1165,7 +1183,8 @@ void DualModeController::FlowSpecification(CommandPacketView command) {
 
 void DualModeController::WriteLinkPolicySettings(CommandPacketView command) {
   auto command_view = gd_hci::WriteLinkPolicySettingsView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
 
   uint16_t handle = command_view.GetConnectionHandle();
@@ -1182,7 +1201,8 @@ void DualModeController::WriteLinkPolicySettings(CommandPacketView command) {
 void DualModeController::WriteLinkSupervisionTimeout(
     CommandPacketView command) {
   auto command_view = gd_hci::WriteLinkSupervisionTimeoutView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
 
   uint16_t handle = command_view.GetConnectionHandle();
@@ -1393,7 +1413,8 @@ void DualModeController::InquiryCancel(CommandPacketView command) {
 
 void DualModeController::AcceptConnectionRequest(CommandPacketView command) {
   auto command_view = gd_hci::AcceptConnectionRequestView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   Address addr = command_view.GetBdAddr();
   bool try_role_switch = command_view.GetRole() ==
@@ -1407,7 +1428,8 @@ void DualModeController::AcceptConnectionRequest(CommandPacketView command) {
 
 void DualModeController::RejectConnectionRequest(CommandPacketView command) {
   auto command_view = gd_hci::RejectConnectionRequestView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   Address addr = command_view.GetBdAddr();
   uint8_t reason = static_cast<uint8_t>(command_view.GetReason());
@@ -1619,7 +1641,8 @@ void DualModeController::LeSetScanEnable(CommandPacketView command) {
 
 void DualModeController::LeCreateConnection(CommandPacketView command) {
   auto command_view = gd_hci::LeCreateConnectionView::Create(
-      gd_hci::LeConnectionManagementCommandView::Create(command));
+      gd_hci::LeConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   link_layer_controller_.SetLeScanInterval(command_view.GetLeScanInterval());
   link_layer_controller_.SetLeScanWindow(command_view.GetLeScanWindow());
@@ -1656,7 +1679,8 @@ void DualModeController::LeCreateConnection(CommandPacketView command) {
 
 void DualModeController::LeConnectionUpdate(CommandPacketView command) {
   auto command_view = gd_hci::LeConnectionUpdateView::Create(
-      gd_hci::LeConnectionManagementCommandView::Create(command));
+      gd_hci::LeConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   ErrorCode status = link_layer_controller_.LeConnectionUpdate(command_view);
 
@@ -1667,7 +1691,8 @@ void DualModeController::LeConnectionUpdate(CommandPacketView command) {
 
 void DualModeController::CreateConnection(CommandPacketView command) {
   auto command_view = gd_hci::CreateConnectionView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
 
   Address address = command_view.GetBdAddr();
@@ -1691,7 +1716,8 @@ void DualModeController::CreateConnection(CommandPacketView command) {
 
 void DualModeController::CreateConnectionCancel(CommandPacketView command) {
   auto command_view = gd_hci::CreateConnectionCancelView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
 
   Address address = command_view.GetBdAddr();
@@ -1705,7 +1731,8 @@ void DualModeController::CreateConnectionCancel(CommandPacketView command) {
 
 void DualModeController::Disconnect(CommandPacketView command) {
   auto command_view = gd_hci::DisconnectView::Create(
-      gd_hci::ConnectionManagementCommandView::Create(command));
+      gd_hci::ConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
 
   uint16_t handle = command_view.GetConnectionHandle();
@@ -1720,7 +1747,8 @@ void DualModeController::Disconnect(CommandPacketView command) {
 
 void DualModeController::LeConnectionCancel(CommandPacketView command) {
   auto command_view = gd_hci::LeCreateConnectionCancelView::Create(
-      gd_hci::LeConnectionManagementCommandView::Create(command));
+      gd_hci::LeConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   ErrorCode status = link_layer_controller_.SetLeConnect(false);
   send_event_(bluetooth::hci::LeCreateConnectionCancelCompleteBuilder::Create(
@@ -1729,7 +1757,8 @@ void DualModeController::LeConnectionCancel(CommandPacketView command) {
 
 void DualModeController::LeReadConnectListSize(CommandPacketView command) {
   auto command_view = gd_hci::LeReadConnectListSizeView::Create(
-      gd_hci::LeConnectionManagementCommandView::Create(command));
+      gd_hci::LeConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   auto packet = bluetooth::hci::LeReadConnectListSizeCompleteBuilder::Create(
       kNumCommandPackets, ErrorCode::SUCCESS,
@@ -1739,7 +1768,8 @@ void DualModeController::LeReadConnectListSize(CommandPacketView command) {
 
 void DualModeController::LeClearConnectList(CommandPacketView command) {
   auto command_view = gd_hci::LeClearConnectListView::Create(
-      gd_hci::LeConnectionManagementCommandView::Create(command));
+      gd_hci::LeConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   link_layer_controller_.LeConnectListClear();
   auto packet = bluetooth::hci::LeClearConnectListCompleteBuilder::Create(
@@ -1749,7 +1779,8 @@ void DualModeController::LeClearConnectList(CommandPacketView command) {
 
 void DualModeController::LeAddDeviceToConnectList(CommandPacketView command) {
   auto command_view = gd_hci::LeAddDeviceToConnectListView::Create(
-      gd_hci::LeConnectionManagementCommandView::Create(command));
+      gd_hci::LeConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
 
   if (link_layer_controller_.LeConnectListFull()) {
@@ -1770,7 +1801,8 @@ void DualModeController::LeAddDeviceToConnectList(CommandPacketView command) {
 void DualModeController::LeRemoveDeviceFromConnectList(
     CommandPacketView command) {
   auto command_view = gd_hci::LeRemoveDeviceFromConnectListView::Create(
-      gd_hci::LeConnectionManagementCommandView::Create(command));
+      gd_hci::LeConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
 
   uint8_t addr_type = static_cast<uint8_t>(command_view.GetAddressType());
@@ -1817,7 +1849,8 @@ void DualModeController::LeReadMaximumDataLength(CommandPacketView command) {
 
 void DualModeController::LeReadSuggestedDefaultDataLength(CommandPacketView command) {
   auto command_view = gd_hci::LeReadSuggestedDefaultDataLengthView::Create(
-      gd_hci::LeConnectionManagementCommandView::Create(command));
+      gd_hci::LeConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   send_event_(bluetooth::hci::LeReadSuggestedDefaultDataLengthCompleteBuilder::Create(
       kNumCommandPackets, ErrorCode::SUCCESS, kLeMaximumDataLength, kLeMaximumDataTime));
@@ -1910,7 +1943,8 @@ void DualModeController::LeSetExtendedScanEnable(CommandPacketView command) {
 
 void DualModeController::LeExtendedCreateConnection(CommandPacketView command) {
   auto command_view = gd_hci::LeExtendedCreateConnectionView::Create(
-      gd_hci::LeConnectionManagementCommandView::Create(command));
+      gd_hci::LeConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
   ASSERT_LOG(command_view.GetInitiatingPhys() == 1, "Only LE_1M is supported");
   auto params = command_view.GetPhyScanParameters();
@@ -2089,7 +2123,8 @@ void DualModeController::LeRemoveIsoDataPath(CommandPacketView command) {
 
 void DualModeController::LeReadRemoteFeatures(CommandPacketView command) {
   auto command_view = gd_hci::LeReadRemoteFeaturesView::Create(
-      gd_hci::LeConnectionManagementCommandView::Create(command));
+      gd_hci::LeConnectionManagementCommandView::Create(
+          gd_hci::AclCommandView::Create(command)));
   ASSERT(command_view.IsValid());
 
   uint16_t handle = command_view.GetConnectionHandle();