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

Commit 774a56ea authored by Chris Manton's avatar Chris Manton
Browse files

gd: Present zeroed peer addr with type when using connect list

The fields are ignored but zeroed out for correctness.
Preserves original stack behavior

Bug: 171568335
Test: CtsVerifier
Test: atest --host bluetooth_test_gd
Tag: #refactor

Change-Id: I6235c9545115a247d4f4b3a7f31dfa97ce3d06b2
parent efce951c
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -390,6 +390,10 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {


    connecting_le_.insert(address_with_type);
    connecting_le_.insert(address_with_type);


    if (initiator_filter_policy == InitiatorFilterPolicy::USE_CONNECT_LIST) {
      address_with_type = AddressWithType();
    }

    if (controller_->IsSupported(OpCode::LE_EXTENDED_CREATE_CONNECTION)) {
    if (controller_->IsSupported(OpCode::LE_EXTENDED_CREATE_CONNECTION)) {
      LeCreateConnPhyScanParameters tmp;
      LeCreateConnPhyScanParameters tmp;
      tmp.scan_interval_ = le_scan_interval;
      tmp.scan_interval_ = le_scan_interval;
+14 −3
Original line number Original line Diff line number Diff line
@@ -43,6 +43,7 @@ using packet::PacketView;
using packet::RawBuilder;
using packet::RawBuilder;


constexpr std::chrono::seconds kTimeout = std::chrono::seconds(2);
constexpr std::chrono::seconds kTimeout = std::chrono::seconds(2);
const AddressWithType empty_address_with_type = hci::AddressWithType();


PacketView<kLittleEndian> GetPacketView(std::unique_ptr<packet::BasePacketBuilder> packet) {
PacketView<kLittleEndian> GetPacketView(std::unique_ptr<packet::BasePacketBuilder> packet) {
  auto bytes = std::make_shared<std::vector<uint8_t>>();
  auto bytes = std::make_shared<std::vector<uint8_t>>();
@@ -352,6 +353,7 @@ class AclManagerNoCallbacksTest : public ::testing::Test {
  os::Handler* client_handler_ = nullptr;
  os::Handler* client_handler_ = nullptr;
  Address remote;
  Address remote;
  AddressWithType my_initiating_address;
  AddressWithType my_initiating_address;
  const bool use_connect_list_ = true;  // gd currently only supports connect list


  std::future<void> GetConnectionFuture() {
  std::future<void> GetConnectionFuture() {
    ASSERT_LOG(mock_connection_callback_.connection_promise_ == nullptr, "Promises promises ... Only one at a time");
    ASSERT_LOG(mock_connection_callback_.connection_promise_ == nullptr, "Promises promises ... Only one at a time");
@@ -582,8 +584,13 @@ class AclManagerWithLeConnectionTest : public AclManagerTest {
    auto le_connection_management_command_view = LeConnectionManagementCommandView::Create(packet);
    auto le_connection_management_command_view = LeConnectionManagementCommandView::Create(packet);
    auto command_view = LeCreateConnectionView::Create(le_connection_management_command_view);
    auto command_view = LeCreateConnectionView::Create(le_connection_management_command_view);
    ASSERT_TRUE(command_view.IsValid());
    ASSERT_TRUE(command_view.IsValid());
    EXPECT_EQ(command_view.GetPeerAddress(), remote);
    if (use_connect_list_) {
    EXPECT_EQ(command_view.GetPeerAddressType(), AddressType::PUBLIC_DEVICE_ADDRESS);
      ASSERT_EQ(command_view.GetPeerAddress(), empty_address_with_type.GetAddress());
      ASSERT_EQ(command_view.GetPeerAddressType(), empty_address_with_type.GetAddressType());
    } else {
      ASSERT_EQ(command_view.GetPeerAddress(), remote);
      ASSERT_EQ(command_view.GetPeerAddressType(), AddressType::PUBLIC_DEVICE_ADDRESS);
    }


    test_hci_layer_->IncomingEvent(LeCreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 0x01));
    test_hci_layer_->IncomingEvent(LeCreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 0x01));


@@ -659,7 +666,11 @@ TEST_F(AclManagerTest, invoke_registered_callback_le_connection_complete_fail) {
  auto le_connection_management_command_view = LeConnectionManagementCommandView::Create(packet);
  auto le_connection_management_command_view = LeConnectionManagementCommandView::Create(packet);
  auto command_view = LeCreateConnectionView::Create(le_connection_management_command_view);
  auto command_view = LeCreateConnectionView::Create(le_connection_management_command_view);
  ASSERT_TRUE(command_view.IsValid());
  ASSERT_TRUE(command_view.IsValid());
  EXPECT_EQ(command_view.GetPeerAddress(), remote);
  if (use_connect_list_) {
    ASSERT_EQ(command_view.GetPeerAddress(), hci::Address::kEmpty);
  } else {
    ASSERT_EQ(command_view.GetPeerAddress(), remote);
  }
  EXPECT_EQ(command_view.GetPeerAddressType(), AddressType::PUBLIC_DEVICE_ADDRESS);
  EXPECT_EQ(command_view.GetPeerAddressType(), AddressType::PUBLIC_DEVICE_ADDRESS);


  test_hci_layer_->IncomingEvent(LeCreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 0x01));
  test_hci_layer_->IncomingEvent(LeCreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 0x01));