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

Commit 3155bca4 authored by Bill Schilit's avatar Bill Schilit
Browse files

Allow specifying address with AddHciConnection.

Bumble clients want more control over addresses in order to preserve
pairing information. The re-use of device ids is not sufficient
because it depends on the timing of device connection. Allow clients
to specify the BD_ADDR on device creation.

Bug: 294435861
Test: m root-canal
Change-Id: I829596b6b137b1ea190926181fd9645bd8aa8276
parent d5f4e5ec
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <optional>
#include <type_traits>  // for remove_extent_t
#include <utility>      // for move
#include <optional>

#include "include/phy.h"  // for Phy, Phy::Type
#include "log.h"
@@ -203,8 +204,9 @@ void TestModel::AddRemote(const std::string& server, int port, Phy::Type type) {
}

PhyDevice::Identifier TestModel::AddHciConnection(
    std::shared_ptr<HciDevice> device) {
  device->SetAddress(GenerateBluetoothAddress());
    std::shared_ptr<HciDevice> device, std::optional<Address> address) {
  // clients can specify BD_ADDR or have it set based on device_id.
  device->SetAddress(address.value_or(GenerateBluetoothAddress()));
  AddDevice(std::static_pointer_cast<Device>(device));

  INFO(device->id_, "Initialized device with address {}", device->GetAddress());
+3 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <memory>      // for shared_ptr
#include <string>      // for string
#include <vector>      // for vector
#include <optional>

#include "hci/address.h"                       // for Address
#include "model/devices/hci_device.h"          // for HciDevice
@@ -84,8 +85,8 @@ class TestModel {
  // Handle incoming remote connections
  void AddLinkLayerConnection(std::shared_ptr<Device> dev, Phy::Type phy_type);
  // Add an HCI device, return its index
  PhyDevice::Identifier AddHciConnection(std::shared_ptr<HciDevice> dev);

  PhyDevice::Identifier AddHciConnection(std::shared_ptr<HciDevice> dev,
                                         std::optional<Address> address = {});
  // Handle closed remote connections (both hci & link layer)
  void OnConnectionClosed(PhyDevice::Identifier device_id, AsyncUserId user_id);