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

Commit acffc03f authored by Rahul Arya's avatar Rahul Arya
Browse files

Reschedule address rotation after connection to advertising set

Otherwise we stop rotating our address and lose all benefits of privacy.

Ignore-AOSP-First: Security fix
Bug: 246692649
Bug: 195410559
Test: Nearby QA test, and I'll write a cert test eventually
Tag: #stability
Change-Id: Ib63d79256acbb956413849c17f761aa902fa2eae
(cherry picked from commit 279e3c3a)
Merged-In: Ib63d79256acbb956413849c17f761aa902fa2eae
parent 57d4dc3e
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -182,7 +182,9 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb

    uint8_t advertiser_id = event_view.GetAdvertisingHandle();

    bool was_rotating_address = false;
    if (advertising_sets_[advertiser_id].address_rotation_alarm != nullptr) {
      was_rotating_address = true;
      advertising_sets_[advertiser_id].address_rotation_alarm->Cancel();
      advertising_sets_[advertiser_id].address_rotation_alarm.reset();
    }
@@ -209,6 +211,13 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
      if (advertising_sets_[advertiser_id].duration == 0 &&
          advertising_sets_[advertiser_id].max_extended_advertising_events == 0) {
        LOG_INFO("Reenable advertising");
        if (was_rotating_address) {
          advertising_sets_[advertiser_id].address_rotation_alarm = std::make_unique<os::Alarm>(module_handler_);
          advertising_sets_[advertiser_id].address_rotation_alarm->Schedule(
              common::BindOnce(
                  &impl::set_advertising_set_random_address_on_timer, common::Unretained(this), advertiser_id),
              le_address_manager_->GetNextPrivateAddressIntervalMs());
        }
        enable_advertiser(advertiser_id, true, 0, 0);
      }
    }