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

Commit dbfb5e0d authored by Henri Chataing's avatar Henri Chataing
Browse files

RootCanal: Use unique device identifiers

Separate the generation of the device address from that of the
device identifier, to ensure that the address can be reused
while still having unique identifiers.

Bug: 279665786
Test: m root-canal
Change-Id: I4af61249fcdb734b8984349c557037f621fb02f1
parent abfabd4a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ TestEnvironment::TestEnvironment(
  link_socket_server_ = open_server(&async_manager_, link_port);
  link_ble_socket_server_ = open_server(&async_manager_, link_ble_port);
  connector_ = open_connector(&async_manager_);
  test_model_.SetReuseDeviceIds(!disable_address_reuse);
  test_model_.SetReuseDeviceAddresses(!disable_address_reuse);

  // Get a user ID for tasks scheduled within the test environment.
  socket_user_id_ = async_manager_.GetNextUserId();
+1 −7
Original line number Diff line number Diff line
@@ -33,11 +33,6 @@ constexpr uint16_t kLeMaximumDataLength = 64;
constexpr uint16_t kLeMaximumDataTime = 0x148;
constexpr uint8_t kTransmitPowerLevel = -20;

static int next_instance_id() {
  static int instance_counter = 0;
  return instance_counter++;
}

// Device methods.
std::string DualModeController::GetTypeString() const {
  return "Simulated Bluetooth Controller";
@@ -65,8 +60,7 @@ void DualModeController::SendCommandCompleteUnknownOpCodeEvent(
}

DualModeController::DualModeController(ControllerProperties properties)
    : id_(next_instance_id()), properties_(std::move(properties)),
      random_generator_(id_) {
    : properties_(std::move(properties)), random_generator_(id_) {
  Address public_address{};
  ASSERT(Address::FromString("3C:5A:B4:04:05:06", public_address));
  SetAddress(public_address);
+0 −3
Original line number Diff line number Diff line
@@ -50,9 +50,6 @@ using ::bluetooth::hci::CommandView;
// "Hci" to distinguish it as a controller command.
class DualModeController : public Device {
 public:
  // Unique instance identifier.
  const int id_;

  DualModeController(ControllerProperties properties = ControllerProperties());
  DualModeController(DualModeController&&) = delete;
  DualModeController(const DualModeController&) = delete;
+1 −1
Original line number Diff line number Diff line
@@ -1976,7 +1976,7 @@ void LinkLayerController::SetExtendedInquiryResponse(

LinkLayerController::LinkLayerController(const Address& address,
                                         const ControllerProperties& properties,
                                         int id)
                                         uint32_t id)
    : id_(id),
      address_(address),
      properties_(properties),
+2 −2
Original line number Diff line number Diff line
@@ -57,14 +57,14 @@ class LinkLayerController {
  static constexpr size_t kExtendedInquiryResponseSize = 240;

  // Unique instance identifier.
  const int id_;
  const uint32_t id_;

  // Generate a resolvable private address using the specified IRK.
  static Address generate_rpa(
      std::array<uint8_t, LinkLayerController::kIrkSize> irk);

  LinkLayerController(const Address& address,
                      const ControllerProperties& properties, int id = 0);
                      const ControllerProperties& properties, uint32_t id = 0);
  ~LinkLayerController();

  ErrorCode SendCommandToRemoteByAddress(OpCode opcode, pdl::packet::slice args,
Loading