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

Commit d2d4f6ee authored by Chienyuan's avatar Chienyuan
Browse files

gd: Check cached commands by handler

Tag: #gd-refactor
Bug: 194180110
Test: gd/cert/run
Test: bluetooth_test_gd
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines

Change-Id: Ic9c8f0e9e3fc902c3c68caca9c8ac74cd5418c4f
parent 48382eea
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -440,10 +440,20 @@ void LeAddressManager::OnCommandComplete(bluetooth::hci::CommandCompleteView vie
    }
  }

  handler_->BindOnceOn(this, &LeAddressManager::check_cached_commands).Invoke();
}

void LeAddressManager::check_cached_commands() {
  for (auto client : registered_clients_) {
    if (client.second != ClientState::PAUSED) {
      return;
    }
  }

  if (cached_commands_.empty()) {
    handler_->BindOnceOn(this, &LeAddressManager::resume_registered_clients).Invoke();
    resume_registered_clients();
  } else {
    handler_->BindOnceOn(this, &LeAddressManager::handle_next_command).Invoke();
    handle_next_command();
  }
}

+1 −0
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ class LeAddressManager {
  hci::Address generate_rpa();
  hci::Address generate_nrpa();
  void handle_next_command();
  void check_cached_commands();

  common::Callback<void(std::unique_ptr<CommandBuilder>)> enqueue_command_;
  os::Handler* handler_;