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

Commit 8805f617 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Race condition handling when connection happens after cancel" into...

Merge "Race condition handling when connection happens after cancel" into tm-dev am: db85eae2 am: 5ed076bd

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



Change-Id: Ia1d2e5520f75a47c5dbc51b04c35959cc7caa862
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 2060fcad 5ed076bd
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -78,6 +78,12 @@ class LeAclConnection : public AclConnection {
  // Time Range: 100 ms to 32 s
  uint16_t supervision_timeout_;

  // True if connection address was in the filter accept list, false otherwise
  bool in_filter_accept_list_;
  bool IsInFilterAcceptList() const {
    return in_filter_accept_list_;
  }

  Address local_resolvable_private_address_ = Address::kEmpty;
  Address peer_resolvable_private_address_ = Address::kEmpty;

+4 −0
Original line number Diff line number Diff line
@@ -308,6 +308,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {

    arm_on_resume_ = false;
    ready_to_unregister = true;
    const bool in_filter_accept_list = is_device_in_connect_list(remote_address);
    remove_device_from_connect_list(remote_address);

    if (!connect_list.empty()) {
@@ -345,6 +346,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
    connection->interval_ = conn_interval;
    connection->latency_ = conn_latency;
    connection->supervision_timeout_ = supervision_timeout;
    connection->in_filter_accept_list_ = in_filter_accept_list;
    connections.add(
        handle, remote_address, queue_down_end, handler_, connection->GetEventCallbacks([this](uint16_t handle) {
          this->connections.invalidate(handle);
@@ -393,6 +395,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {

    arm_on_resume_ = false;
    ready_to_unregister = true;
    const bool in_filter_accept_list = is_device_in_connect_list(remote_address);
    remove_device_from_connect_list(remote_address);

    if (!connect_list.empty()) {
@@ -440,6 +443,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
    connection->supervision_timeout_ = supervision_timeout;
    connection->local_resolvable_private_address_ = connection_complete.GetLocalResolvablePrivateAddress();
    connection->peer_resolvable_private_address_ = connection_complete.GetPeerResolvablePrivateAddress();
    connection->in_filter_accept_list_ = in_filter_accept_list;
    connections.add(
        handle, remote_address, queue_down_end, handler_, connection->GetEventCallbacks([this](uint16_t handle) {
          this->connections.invalidate(handle);
+20 −6
Original line number Diff line number Diff line
@@ -779,6 +779,10 @@ class LeShimAclConnection
    return connection_->locally_initiated_;
  }

  bool IsInFilterAcceptList() const {
    return connection_->IsInFilterAcceptList();
  }

 private:
  OnDisconnect on_disconnect_;
  const shim::legacy::acl_le_link_interface_t interface_;
@@ -1522,12 +1526,6 @@ void shim::legacy::Acl::OnLeConnectSuccess(
                  std::chrono::system_clock::now()));
  pimpl_->handle_to_le_connection_map_[handle]->RegisterCallbacks();

  pimpl_->handle_to_le_connection_map_[handle]
      ->ReadRemoteControllerInformation();

  tBLE_BD_ADDR legacy_address_with_type =
      ToLegacyAddressWithType(address_with_type);

  // Once an le connection has successfully been established
  // the device address is removed from the controller accept list.

@@ -1542,6 +1540,22 @@ void shim::legacy::Acl::OnLeConnectSuccess(
    pimpl_->shadow_acceptlist_.Remove(address_with_type);
  }

  if (!pimpl_->handle_to_le_connection_map_[handle]->IsInFilterAcceptList() &&
      connection_role == hci::Role::CENTRAL) {
    pimpl_->handle_to_le_connection_map_[handle]->InitiateDisconnect(
        hci::DisconnectReason::REMOTE_USER_TERMINATED_CONNECTION);
    LOG_INFO("Disconnected ACL after connection canceled");
    BTM_LogHistory(kBtmLogTag, ToLegacyAddressWithType(address_with_type),
                   "Connection canceled", "Le");
    return;
  }

  pimpl_->handle_to_le_connection_map_[handle]
      ->ReadRemoteControllerInformation();

  tBLE_BD_ADDR legacy_address_with_type =
      ToLegacyAddressWithType(address_with_type);

  TRY_POSTING_ON_MAIN(
      acl_interface_.connection.le.on_connected, legacy_address_with_type,
      handle, ToLegacyRole(connection_role), conn_interval, conn_latency,