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

Commit 6b8fdfdf authored by Jack He's avatar Jack He Committed by Automerger Merge Worker
Browse files

Merge "Merge "Promote incoming connection from unary to unordered set" am:...

Merge "Merge "Promote incoming connection from unary to unordered set" am: 6a55ef23 am: faf1391c am: 87a353cd am: 8122c493 am: 08ec39dc" into tm-dev am: d9e5a8b3 am: 3f816d75

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/18110097



Change-Id: I9051ed52fad2016cbf802b6465aa3a2bb7867570
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 63fe5e6d 3f816d75
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@ filegroup {
    srcs: [
    srcs: [
        "acl_manager/le_impl_test.cc",
        "acl_manager/le_impl_test.cc",
        "acl_builder_test.cc",
        "acl_builder_test.cc",
        "acl_manager_unittest.cc",
        "address_unittest.cc",
        "address_unittest.cc",
        "address_with_type_test.cc",
        "address_with_type_test.cc",
        "class_of_device_unittest.cc",
        "class_of_device_unittest.cc",
+18 −10
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@


#include <atomic>
#include <atomic>
#include <memory>
#include <memory>
#include <unordered_set>


#include "common/bind.h"
#include "common/bind.h"
#include "hci/acl_manager/assembler.h"
#include "hci/acl_manager/assembler.h"
@@ -254,7 +255,7 @@ struct classic_impl : public security::ISecurityManagerListener {
        return;
        return;
    }
    }


    incoming_connecting_address_ = address;
    incoming_connecting_address_set_.insert(address);
    if (is_classic_link_already_connected(address)) {
    if (is_classic_link_already_connected(address)) {
      auto reason = RejectConnectionReason::UNACCEPTABLE_BD_ADDR;
      auto reason = RejectConnectionReason::UNACCEPTABLE_BD_ADDR;
      this->reject_connection(RejectConnectionRequestBuilder::Create(address, reason));
      this->reject_connection(RejectConnectionRequestBuilder::Create(address, reason));
@@ -281,7 +282,7 @@ struct classic_impl : public security::ISecurityManagerListener {
    std::unique_ptr<CreateConnectionBuilder> packet = CreateConnectionBuilder::Create(
    std::unique_ptr<CreateConnectionBuilder> packet = CreateConnectionBuilder::Create(
        address, packet_type, page_scan_repetition_mode, clock_offset, clock_offset_valid, allow_role_switch);
        address, packet_type, page_scan_repetition_mode, clock_offset, clock_offset_valid, allow_role_switch);


    if (incoming_connecting_address_ == Address::kEmpty && outgoing_connecting_address_ == Address::kEmpty) {
    if (incoming_connecting_address_set_.empty() && outgoing_connecting_address_ == Address::kEmpty) {
      if (is_classic_link_already_connected(address)) {
      if (is_classic_link_already_connected(address)) {
        LOG_WARN("already connected: %s", address.ToString().c_str());
        LOG_WARN("already connected: %s", address.ToString().c_str());
        return;
        return;
@@ -310,17 +311,18 @@ struct classic_impl : public security::ISecurityManagerListener {
    if (outgoing_connecting_address_ == address) {
    if (outgoing_connecting_address_ == address) {
      outgoing_connecting_address_ = Address::kEmpty;
      outgoing_connecting_address_ = Address::kEmpty;
    } else {
    } else {
      if (incoming_connecting_address_ != address && status == ErrorCode::UNKNOWN_CONNECTION) {
      auto incoming_address = incoming_connecting_address_set_.find(address);
      if (incoming_address == incoming_connecting_address_set_.end()) {
        ASSERT_LOG(
            status != ErrorCode::UNKNOWN_CONNECTION,
            "No prior connection request for %s expecting:%s",
            address.ToString().c_str(),
            set_of_incoming_connecting_addresses().c_str());
        LOG_WARN("No matching connection to %s (%s)", address.ToString().c_str(), ErrorCodeText(status).c_str());
        LOG_WARN("No matching connection to %s (%s)", address.ToString().c_str(), ErrorCodeText(status).c_str());
        LOG_WARN("Firmware error after RemoteNameRequestCancel?");
        LOG_WARN("Firmware error after RemoteNameRequestCancel?");
        return;
        return;
      }
      }
      ASSERT_LOG(
      incoming_connecting_address_set_.erase(incoming_address);
          incoming_connecting_address_ == address,
          "No prior connection request for %s expecting:%s",
          address.ToString().c_str(),
          incoming_connecting_address_.ToString().c_str());
      incoming_connecting_address_ = Address::kEmpty;
      current_role = Role::PERIPHERAL;
      current_role = Role::PERIPHERAL;
      locally_initiated = false;
      locally_initiated = false;
    }
    }
@@ -721,7 +723,13 @@ struct classic_impl : public security::ISecurityManagerListener {
  ConnectionCallbacks* client_callbacks_ = nullptr;
  ConnectionCallbacks* client_callbacks_ = nullptr;
  os::Handler* client_handler_ = nullptr;
  os::Handler* client_handler_ = nullptr;
  Address outgoing_connecting_address_{Address::kEmpty};
  Address outgoing_connecting_address_{Address::kEmpty};
  Address incoming_connecting_address_{Address::kEmpty};
  std::unordered_set<Address> incoming_connecting_address_set_;
  const std::string set_of_incoming_connecting_addresses() const {
    std::stringstream buffer;
    for (const auto& c : incoming_connecting_address_set_) buffer << " " << c;
    return buffer.str();
  }

  common::Callback<bool(Address, ClassOfDevice)> should_accept_connection_;
  common::Callback<bool(Address, ClassOfDevice)> should_accept_connection_;
  std::queue<std::pair<Address, std::unique_ptr<CreateConnectionBuilder>>> pending_outgoing_connections_;
  std::queue<std::pair<Address, std::unique_ptr<CreateConnectionBuilder>>> pending_outgoing_connections_;
  std::unique_ptr<RoleChangeView> delayed_role_change_ = nullptr;
  std::unique_ptr<RoleChangeView> delayed_role_change_ = nullptr;
+819 −0

File added.

Preview size limit exceeded, changes collapsed.