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

Commit 5a930ed9 authored by Chienyuan's avatar Chienyuan
Browse files

Trigger create connection when connect list is not empty

Tag: #gd-refactor
Bug: 220970000
Test: gd/cert/run
Change-Id: I074e732c31c559882b3fa5f28f12b4e851a1fb93
parent 4024c5ee
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -241,6 +241,11 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
      remove_device_from_connect_list(remote_address);
    }

    if (!connect_list.empty()) {
      AddressWithType empty(Address::kEmpty, AddressType::RANDOM_DEVICE_ADDRESS);
      handler_->Post(common::BindOnce(&le_impl::create_le_connection, common::Unretained(this), empty, false, false));
    }

    if (le_client_handler_ == nullptr) {
      LOG_ERROR("No callbacks to call");
      return;
@@ -303,6 +308,11 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
      remove_device_from_connect_list(remote_address);
    }

    if (!connect_list.empty()) {
      AddressWithType empty(Address::kEmpty, AddressType::RANDOM_DEVICE_ADDRESS);
      handler_->Post(common::BindOnce(&le_impl::create_le_connection, common::Unretained(this), empty, false, false));
    }

    if (le_client_handler_ == nullptr) {
      LOG_ERROR("No callbacks to call");
      return;
@@ -447,12 +457,14 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
  }

  void add_device_to_connect_list(AddressWithType address_with_type) {
    connect_list.insert(address_with_type);
    register_with_address_manager();
    le_address_manager_->AddDeviceToConnectList(
        address_with_type.ToConnectListAddressType(), address_with_type.GetAddress());
  }

  void remove_device_from_connect_list(AddressWithType address_with_type) {
    connect_list.erase(address_with_type);
    direct_connections_.erase(address_with_type);
    register_with_address_manager();
    le_address_manager_->RemoveDeviceFromConnectList(
@@ -460,6 +472,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
  }

  void clear_connect_list() {
    connect_list.clear();
    register_with_address_manager();
    le_address_manager_->ClearConnectList();
  }
@@ -790,11 +803,12 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
  LeAclConnectionInterface* le_acl_connection_interface_ = nullptr;
  LeConnectionCallbacks* le_client_callbacks_ = nullptr;
  os::Handler* le_client_handler_ = nullptr;
  std::set<AddressWithType> connecting_le_;
  std::set<AddressWithType> canceled_connections_;
  std::set<AddressWithType> direct_connections_;
  std::unordered_set<AddressWithType> connecting_le_;
  std::unordered_set<AddressWithType> canceled_connections_;
  std::unordered_set<AddressWithType> direct_connections_;
  // Set of devices that will not be removed from connect list after direct connect timeout
  std::set<AddressWithType> background_connections_;
  std::unordered_set<AddressWithType> background_connections_;
  std::unordered_set<AddressWithType> connect_list;
  bool address_manager_registered = false;
  bool ready_to_unregister = false;
  bool pause_connection = false;