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

Commit 37f2ef2c authored by Myles Watson's avatar Myles Watson Committed by Gerrit Code Review
Browse files

Merge "Add DisableBtQualityReport" into main

parents 9a94662d eb0ea9fa
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -14,16 +14,14 @@
 * limitations under the License.
 */

#ifndef BTIF_BQR_H_
#define BTIF_BQR_H_
#pragma once

#include <bluetooth/log.h>

#include "common/postable_context.h"
#include "hci/hci_packets.h"
#include "include/hardware/bt_bqr.h"
#include "osi/include/osi.h"
#include "raw_address.h"
#include "types/raw_address.h"

namespace bluetooth {
namespace bqr {
@@ -386,16 +384,19 @@ public:

BluetoothQualityReportInterface* getBluetoothQualityReportInterface();

// Enable/Disable Bluetooth Quality Report mechanism.
// Enable Bluetooth Quality Report mechanism.
//
// Which Quality event will be enabled is according to the setting of the
// property "persist.bluetooth.bqr.event_mask".
// And the minimum time interval of quality event reporting depends on the
// setting of property "persist.bluetooth.bqr.min_interval_ms".
//
// @param to_bind gives the postable for the callback, or null if disabling.
// @param to_bind gives the postable for the callback.
void EnableBtQualityReport(common::PostableContext* to_bind);

// Disable Bluetooth Quality Report mechanism.
void DisableBtQualityReport();

// Dump Bluetooth Quality Report information.
//
// @param fd The file descriptor to use for dumping information.
@@ -411,5 +412,3 @@ struct formatter<bluetooth::bqr::BqrReportAction>
template <>
struct formatter<bluetooth::bqr::BqrVseSubEvt> : ostream_formatter {};
}  // namespace fmt

#endif  // BTIF_BQR_H_
+16 −12
Original line number Diff line number Diff line
@@ -316,12 +316,7 @@ void unregister_vse();

static void ConfigureBqr(const BqrConfiguration& bqr_config);

void EnableBtQualityReport(common::PostableContext* to_bind) {
  log::info("is_enable: {}", to_bind != nullptr);
  if (to_bind != nullptr) {
    to_bind_ = to_bind;
  }

static void EnableDisableBtQualityReport(bool enable) {
  char bqr_prop_evtmask[PROPERTY_VALUE_MAX] = {0};
  char bqr_prop_interval_ms[PROPERTY_VALUE_MAX] = {0};
  char bqr_prop_vnd_quality_mask[PROPERTY_VALUE_MAX] = {0};
@@ -343,7 +338,7 @@ void EnableBtQualityReport(common::PostableContext* to_bind) {

  BqrConfiguration bqr_config = {};

  if (to_bind) {
  if (enable) {
    bqr_config.report_action = REPORT_ACTION_ADD;
    bqr_config.quality_event_mask = static_cast<uint32_t>(atoi(bqr_prop_evtmask));
    bqr_config.minimum_report_interval_ms = static_cast<uint16_t>(atoi(bqr_prop_interval_ms));
@@ -366,14 +361,23 @@ void EnableBtQualityReport(common::PostableContext* to_bind) {
  BTM_BleGetVendorCapabilities(&cmn_vsc_cb);
  vendor_cap_supported_version = cmn_vsc_cb.version_supported;

  log::info(
          "Event Mask: 0x{:x}, Interval: {}, Multiple: {}, "
          "vendor_cap_supported_version: {}",
  log::info("Event Mask: 0x{:x}, Interval: {}, Multiple: {}, vendor_cap_supported_version: {}",
            bqr_config.quality_event_mask, bqr_config.minimum_report_interval_ms,
            bqr_config.report_interval_multiple, vendor_cap_supported_version);
  ConfigureBqr(bqr_config);
}

void EnableBtQualityReport(common::PostableContext* to_bind) {
  log::info("");
  to_bind_ = to_bind;
  EnableDisableBtQualityReport(true);
}

void DisableBtQualityReport() {
  log::info("");
  EnableDisableBtQualityReport(false);
}

static void BqrVscCompleteCallback(hci::CommandCompleteView complete);

// Configure Bluetooth Quality Report setting to the Bluetooth controller.
+1 −1
Original line number Diff line number Diff line
@@ -2013,7 +2013,7 @@ void BTIF_dm_disable() {
      btif_in_execute_service_request(i, false);
    }
  }
  bluetooth::bqr::EnableBtQualityReport(nullptr);
  bluetooth::bqr::DisableBtQualityReport();
  log::info("Stack device manager shutdown finished");
  future_ready(stack_manager_get_hack_future(), FUTURE_SUCCESS);
}
+1 −1
Original line number Diff line number Diff line
@@ -847,7 +847,7 @@ protected:
                EnqueueCommand(_, Matcher<ContextualOnceCallback<void(CommandCompleteView)>>(_)))
            .WillOnce(Invoke(set_promise))
            .RetiresOnSaturation();
    do_in_main_thread(BindOnce([]() { bluetooth::bqr::EnableBtQualityReport(nullptr); }));
    do_in_main_thread(BindOnce([]() { bluetooth::bqr::DisableBtQualityReport(); }));
    ASSERT_EQ(std::future_status::ready, disable_future.wait_for(std::chrono::seconds(1)));

    bluetooth::hci::testing::mock_hci_layer_ = nullptr;