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

Commit ae0979e7 authored by Myles Watson's avatar Myles Watson
Browse files

Revert "RootCanal: Clean up device and phy allocations"

This reverts commit 5e71c4b2.

Reason for revert: broken test
Bug: 160354481
Change-Id: I3340c8661470f67bb65f8189324d28d588d0781e
parent 5e71c4b2
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -224,7 +224,6 @@ Return<void> BluetoothHci::initialize_impl(

Return<void> BluetoothHci::close() {
  LOG_INFO("%s", __func__);
  test_model_.Reset();
  return Void();
}

+2 −2
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ void Beacon::TimerTick() {
    std::shared_ptr<model::packets::LinkLayerPacketBuilder> to_send =
        std::move(ad);

    for (const auto& phy : phy_layers_) {
    for (const auto& phy : phy_layers_[Phy::Type::LOW_ENERGY]) {
      phy->Send(to_send);
    }
  }
@@ -87,7 +87,7 @@ void Beacon::IncomingPacket(model::packets::LinkLayerPacketView packet) {
    std::shared_ptr<model::packets::LinkLayerPacketBuilder> to_send =
        std::move(scan_response);

    for (const auto& phy : phy_layers_) {
    for (const auto& phy : phy_layers_[Phy::Type::LOW_ENERGY]) {
      phy->Send(to_send);
    }
  }
+14 −17
Original line number Diff line number Diff line
@@ -29,22 +29,23 @@ std::string Device::ToString() const {
}

void Device::RegisterPhyLayer(std::shared_ptr<PhyLayer> phy) {
  phy_layers_.push_back(std::move(phy));
  phy_layers_[phy->GetType()].push_back(phy);
}

void Device::UnregisterPhyLayers() {
  for (const auto& phy : phy_layers_) {
  for (auto phy_pair : phy_layers_) {
    auto phy_list = std::get<1>(phy_pair);
    for (auto phy : phy_list) {
      phy->Unregister();
    }
  phy_layers_.clear();
  }
}

void Device::UnregisterPhyLayer(Phy::Type phy_type, uint32_t factory_id) {
  for (const auto& phy : phy_layers_) {
    if (phy->GetType() == phy_type && phy->IsFactoryId(factory_id)) {
      phy->Unregister();
      phy_layers_.remove(phy);
      break;
  for (const auto phy_layer : phy_layers_[phy_type]) {
    if (phy_layer->IsFactoryId(factory_id)) {
      phy_layer->Unregister();
      phy_layers_[phy_type].remove(phy_layer);
    }
  }
}
@@ -57,21 +58,17 @@ bool Device::IsAdvertisementAvailable() const {
void Device::SendLinkLayerPacket(
    std::shared_ptr<model::packets::LinkLayerPacketBuilder> to_send,
    Phy::Type phy_type) {
  for (const auto& phy : phy_layers_) {
    if (phy->GetType() == phy_type) {
  for (const auto& phy : phy_layers_[phy_type]) {
    phy->Send(to_send);
  }
}
}

void Device::SendLinkLayerPacket(model::packets::LinkLayerPacketView to_send,
                                 Phy::Type phy_type) {
  for (const auto& phy : phy_layers_) {
    if (phy->GetType() == phy_type) {
  for (const auto& phy : phy_layers_[phy_type]) {
    phy->Send(to_send);
  }
}
}

void Device::SetAddress(Address) {
  LOG_INFO("%s does not implement %s", GetTypeString().c_str(), __func__);
+1 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ class Device {
                                   Phy::Type phy_type);

 protected:
  std::list<std::shared_ptr<PhyLayer>> phy_layers_;
  std::map<Phy::Type, std::list<std::shared_ptr<PhyLayer>>> phy_layers_;

  std::chrono::steady_clock::time_point last_advertisement_;

+1 −1
Original line number Diff line number Diff line
@@ -88,8 +88,8 @@ HciSocketDevice::HciSocketDevice(int file_descriptor) : socket_file_descriptor_(
      },
      [this]() {
        LOG_INFO("HCI socket device disconnected");
        socket_file_descriptor_ = -1;
        close_callback_();
        socket_file_descriptor_ = -1;
      });

  RegisterEventChannel([this](std::shared_ptr<std::vector<uint8_t>> packet) {
Loading