Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e32c537 authored by Myles Watson's avatar Myles Watson
Browse files

Add AclCommands for LE and BR/EDR

Bug: 172725986
Test: atest bluetooth_test_gd
Tag: #gd-refactor
Change-Id: I822ce0751be08a98a30c219853e1540e2e461a08
parent a905cb0d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ constexpr EventCode AclConnectionEvents[] = {
    EventCode::LINK_SUPERVISION_TIMEOUT_CHANGED,
};

typedef CommandInterface<ConnectionManagementCommandBuilder> AclConnectionInterface;
typedef CommandInterface<AclCommandBuilder> AclConnectionInterface;

}  // namespace hci
}  // namespace bluetooth
+18 −12
Original line number Diff line number Diff line
@@ -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_,
+3 −2
Original line number Diff line number Diff line
@@ -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");
    }
+3 −2
Original line number Diff line number Diff line
@@ -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");
    }
+2 −2
Original line number Diff line number Diff line
@@ -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_{};
Loading