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

Commit 288279c5 authored by Antoine SOULIER's avatar Antoine SOULIER
Browse files

BQR: Do not enqueue HCI command binded to "null" callback instance.

Bug: 365653608
Flag: EXEMPT, bug fix
Test: m .
Change-Id: Id955c06a7d25391b641d0e4bfaa200f8a56e662b
parent 4521cb17
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -69,7 +69,8 @@ class BluetoothQualityReportInterfaceImpl;
std::unique_ptr<BluetoothQualityReportInterface> bluetoothQualityReportInstance;

namespace {
common::PostableContext* to_bind_ = nullptr;
static std::recursive_mutex life_cycle_guard_;
static common::PostableContext* to_bind_ = nullptr;
}

void BqrVseSubEvt::ParseBqrLinkQualityEvt(uint8_t length, const uint8_t* p_param_buf) {
@@ -385,6 +386,7 @@ void EnableBtQualityReport(common::PostableContext* to_bind) {

void DisableBtQualityReport() {
  log::info("");
  std::unique_lock<std::recursive_mutex> lock(life_cycle_guard_);
  if (to_bind_ == nullptr) {
    log::warn("Skipping second call (Lifecycle issue).");
    return;
@@ -480,6 +482,16 @@ static void BqrVscCompleteCallback(hci::CommandCompleteView complete) {
    return;
  }

  {
    // `DisableBtQualityReport()` set `to_bind_` at nullptr, after sending the command that clear
    // reporting. When disabled, we don't want to continue and use nulled `to_bind_` (b/365653608).
    std::unique_lock<std::recursive_mutex> lock(life_cycle_guard_);
    if (to_bind_ == nullptr) {
      log::info("Disabled");
      return;
    }
  }

  if (vendor_cap_supported_version >= kBqrVndLogVersion) {
    command_complete_param_len = 13;
  }