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

Commit db3d3317 authored by Henri Chataing's avatar Henri Chataing Committed by Thomas Girardier
Browse files

RootCanal: Fix LE advertising with legacy HCI commands

When using the legacay advertising commands (a.k.a. non extended command set),
the address used for advertising messages may not be set, resulting in
scanning and connection failures for the peer device.

This commit only addresses this particular issue, larger changes are
required to solve other latent problems: http://b/228326164

Test: GATT PTS tests against Eiffel
Bug: 228326164
Ignore-AOSP-First: Cherry-picked from AOSP
Merged-In: Ib5b60683abbbe1063387bff6a59a58e981a914d3
Change-Id: Ib5b60683abbbe1063387bff6a59a58e981a914d3
parent 8b7a674c
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -20,14 +20,16 @@ using namespace bluetooth::hci;
using namespace std::literals;

namespace rootcanal {
void LeAdvertiser::Initialize(AddressWithType address,
void LeAdvertiser::Initialize(OwnAddressType address_type,
                              AddressWithType public_address,
                              AddressWithType peer_address,
                              LeScanningFilterPolicy filter_policy,
                              model::packets::AdvertisementType type,
                              const std::vector<uint8_t>& advertisement,
                              const std::vector<uint8_t>& scan_response,
                              std::chrono::steady_clock::duration interval) {
  address_ = address;
  own_address_type_ = address_type;
  public_address_ = public_address;
  peer_address_ = peer_address;
  filter_policy_ = filter_policy;
  type_ = type;
@@ -35,6 +37,8 @@ void LeAdvertiser::Initialize(AddressWithType address,
  scan_response_ = scan_response;
  interval_ = interval;
  tx_power_ = kTxPowerUnavailable;
  LOG_INFO("%s -> %s", public_address_.ToString().c_str(),
           peer_address.ToString().c_str());
}

void LeAdvertiser::InitializeExtended(
@@ -54,8 +58,8 @@ void LeAdvertiser::InitializeExtended(
  interval_ = interval;
  tx_power_ = tx_power;
  LOG_INFO("%s -> %s type = %hhx interval = %d ms tx_power = 0x%hhx",
           address_.ToString().c_str(), peer_address.ToString().c_str(), type_,
           static_cast<int>(interval_.count()), tx_power);
           public_address_.ToString().c_str(), peer_address.ToString().c_str(),
           type_, static_cast<int>(interval_.count()), tx_power);
}

void LeAdvertiser::Clear() {
+2 −1
Original line number Diff line number Diff line
@@ -32,7 +32,8 @@ class LeAdvertiser {
  LeAdvertiser() = default;
  virtual ~LeAdvertiser() = default;

  void Initialize(bluetooth::hci::AddressWithType address,
  void Initialize(bluetooth::hci::OwnAddressType address_type,
                  bluetooth::hci::AddressWithType public_address,
                  bluetooth::hci::AddressWithType peer_address,
                  bluetooth::hci::LeScanningFilterPolicy filter_policy,
                  model::packets::AdvertisementType type,
+5 −1
Original line number Diff line number Diff line
@@ -3734,7 +3734,11 @@ ErrorCode LinkLayerController::SetLeAdvertisingEnable(
    return ErrorCode::INVALID_HCI_COMMAND_PARAMETERS;
  }
  advertisers_[0].Initialize(
      own_address_with_type,
      static_cast<bluetooth::hci::OwnAddressType>(
          properties_.GetLeAdvertisingOwnAddressType()),
      bluetooth::hci::AddressWithType(
          properties_.GetAddress(),
          bluetooth::hci::AddressType::PUBLIC_DEVICE_ADDRESS),
      bluetooth::hci::AddressWithType(
          properties_.GetLeAdvertisingPeerAddress(),
          static_cast<bluetooth::hci::AddressType>(