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

Commit 2492f9e8 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "gd: Update random address when command success"

parents 8e4cf089 8510e210
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -267,7 +267,7 @@ void LeAddressManager::set_random_address() {
  }
  auto packet = hci::LeSetRandomAddressBuilder::Create(address);
  enqueue_command_.Run(std::move(packet));
  le_address_ = AddressWithType(address, AddressType::RANDOM_DEVICE_ADDRESS);
  cached_address_ = AddressWithType(address, AddressType::RANDOM_DEVICE_ADDRESS);
}

void LeAddressManager::rotate_random_address() {
@@ -422,11 +422,22 @@ void LeAddressManager::OnCommandComplete(bluetooth::hci::CommandCompleteView vie
  LOG_INFO("Received command complete with op_code %s", op_code.c_str());

  // The command was sent before any client registered, we can make sure all the clients paused when command complete.
  if (view.GetCommandOpCode() == OpCode::LE_SET_RANDOM_ADDRESS &&
      address_policy_ == AddressPolicy::USE_STATIC_ADDRESS) {
  if (view.GetCommandOpCode() == OpCode::LE_SET_RANDOM_ADDRESS) {
    if (address_policy_ == AddressPolicy::USE_STATIC_ADDRESS) {
      LOG_INFO("Received LE_SET_RANDOM_ADDRESS complete and Address policy is USE_STATIC_ADDRESS, return");
      return;
    }
    auto complete_view = LeSetRandomAddressCompleteView::Create(view);
    if (!complete_view.IsValid()) {
      LOG_ERROR("Received LE_SET_RANDOM_ADDRESS complete with invalid packet");
    } else if (complete_view.IsValid() && complete_view.GetStatus() != ErrorCode::SUCCESS) {
      LOG_ERROR(
          "Received LE_SET_RANDOM_ADDRESS complete with status %s", ErrorCodeText(complete_view.GetStatus()).c_str());
    } else {
      LOG_INFO("update random address : %s", cached_address_.GetAddress().ToString().c_str());
      le_address_ = cached_address_;
    }
  }

  if (cached_commands_.empty()) {
    handler_->BindOnceOn(this, &LeAddressManager::resume_registered_clients).Invoke();
+1 −0
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ class LeAddressManager {

  AddressPolicy address_policy_ = AddressPolicy::POLICY_NOT_SET;
  AddressWithType le_address_;
  AddressWithType cached_address_;
  Address public_address_;
  std::unique_ptr<os::Alarm> address_rotation_alarm_;
  crypto_toolbox::Octet16 rotation_irk_;