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

Commit 11ff2874 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Do not add connected device to accept list" am: bad98867 am: 35c693b0

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

Change-Id: Iab0f371e261fd7d0bed740f34caf7df9b557fa74
parents 113dab4e 35c693b0
Loading
Loading
Loading
Loading
+26 −4
Original line number Diff line number Diff line
@@ -201,6 +201,16 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
      AddressWithType empty(Address::kEmpty, AddressType::RANDOM_DEVICE_ADDRESS);
      return empty;
    }

    bool alreadyConnected(AddressWithType address_with_type) {
      for (auto it = le_acl_connections_.begin(); it != le_acl_connections_.end(); it++) {
        if (it->second.remote_address_ == address_with_type) {
          return true;
        }
      }
      return false;
    }

  } connections;

 public:
@@ -370,10 +380,6 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
  static constexpr bool kRemoveConnectionAfterwards = true;
  void on_le_disconnect(uint16_t handle, ErrorCode reason) {
    AddressWithType remote_address = connections.getAddressWithType(handle);
    if (background_connections_.count(remote_address) == 1) {
      LOG_INFO("re-add device to connect list");
      add_device_to_connect_list(remote_address);
    }
    bool event_also_routes_to_other_receivers = connections.crash_on_unknown_handle_;
    connections.crash_on_unknown_handle_ = false;
    connections.execute(
@@ -384,6 +390,12 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
        },
        kRemoveConnectionAfterwards);
    connections.crash_on_unknown_handle_ = event_also_routes_to_other_receivers;

    if (background_connections_.count(remote_address) == 1) {
      LOG_INFO("re-add device to connect list");
      add_device_to_connect_list(remote_address);
    }

    if (!connect_list.empty()) {
      LOG_INFO("connect_list is not empty, send a new connection request");
      AddressWithType empty(Address::kEmpty, AddressType::RANDOM_DEVICE_ADDRESS);
@@ -477,6 +489,11 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
  }

  void add_device_to_connect_list(AddressWithType address_with_type) {
    if (connections.alreadyConnected(address_with_type)) {
      LOG_INFO("Device already connected, return");
      return;
    }

    connect_list.insert(address_with_type);
    register_with_address_manager();
    le_address_manager_->AddDeviceToConnectList(
@@ -528,6 +545,11 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
      return;
    }

    if (connections.alreadyConnected(address_with_type)) {
      LOG_INFO("Device already connected, return");
      return;
    }

    // TODO: Configure default LE connection parameters?
    if (add_to_connect_list) {
      add_device_to_connect_list(address_with_type);