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

Commit 2fcf03e3 authored by Sam Chiu's avatar Sam Chiu
Browse files

Revert "BQR: Make internal functions static"

Revert submission 3074206

Reason for revert: To verify the test failure b/339556159

Reverted changes: /q/submissionid:3074206

Change-Id: I581916b125a5f24a6a3ad03d03933dd9fcba7082
parent abd2b6e3
Loading
Loading
Loading
Loading
+72 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

#include <bluetooth/log.h>

#include "btm_api_types.h"
#include "common/postable_context.h"
#include "hci/hci_packets.h"
#include "include/hardware/bt_bqr.h"
@@ -393,6 +394,18 @@ class BqrVseSubEvt {

BluetoothQualityReportInterface* getBluetoothQualityReportInterface();

// Get a string representation of the Quality Report ID.
//
// @param quality_report_id The quality report ID to convert.
// @return a string representation of the Quality Report ID.
std::string QualityReportIdToString(uint8_t quality_report_id);

// Get a string representation of the Packet Type.
//
// @param packet_type The packet type to convert.
// @return a string representation of the Packet Type.
std::string PacketTypeToString(uint8_t packet_type);

// Enable/Disable Bluetooth Quality Report mechanism.
//
// Which Quality event will be enabled is according to the setting of the
@@ -403,6 +416,65 @@ BluetoothQualityReportInterface* getBluetoothQualityReportInterface();
// @param to_bind gives the postable for the callback, or null if disabling.
void EnableBtQualityReport(common::PostableContext* to_bind);

// Configure Bluetooth Quality Report setting to the Bluetooth controller.
//
// @param bqr_config The struct of configuration parameters.
void ConfigureBqr(const BqrConfiguration& bqr_config);

// Callback invoked on completion of vendor specific Bluetooth Quality Report
// command.
//
// @param p_vsc_cmpl_params A pointer to the parameters contained in the vendor
//   specific command complete event.
void BqrVscCompleteCallback(hci::CommandCompleteView complete);

// Invoked on completion of Bluetooth Quality Report configuration. Then it will
// Register/Unregister for receiving VSE - Bluetooth Quality Report sub-event.
//
// @param current_evt_mask Indicates current quality event bit mask setting in
//   the Bluetooth controller.
void ConfigureBqrCmpl(uint32_t current_evt_mask);

// Categorize the incoming Bluetooth Quality Report.
//
// @param length Lengths of the quality report sent from the Bluetooth
//   controller.
// @param p_bqr_event A pointer to the BQR VSE sub-event which is sent from the
//   Bluetooth controller.
void CategorizeBqrEvent(uint8_t length, const uint8_t* p_bqr_event);

// Record a new incoming Link Quality related BQR event in quality event queue.
//
// @param length Lengths of the Link Quality related BQR event.
// @param p_link_quality_event A pointer to the Link Quality related BQR event.
void AddLinkQualityEventToQueue(uint8_t length,
                                const uint8_t* p_link_quality_event);

// Dump the LMP/LL message handshaking with the remote device to a log file.
//
// @param length Lengths of the LMP/LL message trace event.
// @param p_lmp_ll_message_event A pointer to the LMP/LL message trace event.
void DumpLmpLlMessage(uint8_t length, const uint8_t* p_lmp_ll_message_event);

// Open the LMP/LL message trace log file.
//
// @return a file descriptor of the LMP/LL message trace log file.
int OpenLmpLlTraceLogFile();

// Dump the Bluetooth Multi-profile/Coex scheduling information to a log file.
//
// @param length Lengths of the Bluetooth Multi-profile/Coex scheduling trace
//   event.
// @param p_bt_scheduling_event A pointer to the Bluetooth Multi-profile/Coex
//   scheduling trace event.
void DumpBtScheduling(uint8_t length, const uint8_t* p_bt_scheduling_event);

// Open the Bluetooth Multi-profile/Coex scheduling trace log file.
//
// @return a file descriptor of the Bluetooth Multi-profile/Coex scheduling
//   trace log file.
int OpenBtSchedulingTraceLogFile();

// Dump Bluetooth Quality Report information.
//
// @param fd The file descriptor to use for dumping information.
+12 −80
Original line number Diff line number Diff line
@@ -211,9 +211,6 @@ void BqrVseSubEvt::WriteBtSchedulingTraceLogFile(int fd, uint8_t length,
  BtSchedulingTraceCounter++;
}

static std::string QualityReportIdToString(uint8_t quality_report_id);
static std::string PacketTypeToString(uint8_t packet_type);

std::string BqrVseSubEvt::ToString() const {
  std::stringstream ss;
  ss << QualityReportIdToString(bqr_link_quality_event_.quality_report_id)
@@ -261,11 +258,7 @@ std::string BqrVseSubEvt::ToString() const {
  return ss.str();
}

// Get a string representation of the Quality Report ID.
//
// @param quality_report_id The quality report ID to convert.
// @return a string representation of the Quality Report ID.
static std::string QualityReportIdToString(uint8_t quality_report_id) {
std::string QualityReportIdToString(uint8_t quality_report_id) {
  switch (quality_report_id) {
    case QUALITY_REPORT_ID_MONITOR_MODE:
      return "Monitoring";
@@ -284,11 +277,7 @@ static std::string QualityReportIdToString(uint8_t quality_report_id) {
  }
}

// Get a string representation of the Packet Type.
//
// @param packet_type The packet type to convert.
// @return a string representation of the Packet Type.
static std::string PacketTypeToString(uint8_t packet_type) {
std::string PacketTypeToString(uint8_t packet_type) {
  switch (packet_type) {
    case PACKET_TYPE_ID:
      return "ID";
@@ -356,8 +345,6 @@ static std::string PacketTypeToString(uint8_t packet_type) {
void register_vse();
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) {
@@ -422,12 +409,6 @@ void EnableBtQualityReport(common::PostableContext* to_bind) {
  ConfigureBqr(bqr_config);
}

static void BqrVscCompleteCallback(
    bluetooth::hci::CommandCompleteView complete);

// Configure Bluetooth Quality Report setting to the Bluetooth controller.
//
// @param bqr_config The struct of configuration parameters.
void ConfigureBqr(const BqrConfiguration& bqr_config) {
  if (vendor_cap_supported_version >= kBqrVersion6_0) {
    if (bqr_config.report_action > REPORT_ACTION_QUERY ||
@@ -476,15 +457,7 @@ void ConfigureBqr(const BqrConfiguration& bqr_config) {
      to_bind_->BindOnce(BqrVscCompleteCallback));
}

static void ConfigureBqrCmpl(uint32_t current_evt_mask);

// Callback invoked on completion of vendor specific Bluetooth Quality Report
// command.
//
// @param p_vsc_cmpl_params A pointer to the parameters contained in the vendor
//   specific command complete event.
static void BqrVscCompleteCallback(
    bluetooth::hci::CommandCompleteView complete) {
void BqrVscCompleteCallback(bluetooth::hci::CommandCompleteView complete) {
  std::vector<uint8_t> payload_vector{complete.GetPayload().begin(),
                                      complete.GetPayload().end()};
  tBTM_VSC_CMPL vsc_cmpl_params = {
@@ -592,14 +565,8 @@ void ConfigBqrA2dpScoThreshold() {

static tBTM_STATUS BTM_BT_Quality_Report_VSE_Register(
    bool is_register, tBTM_BT_QUALITY_REPORT_RECEIVER* p_bqr_report_receiver);
static void CategorizeBqrEvent(uint8_t length, const uint8_t* p_bqr_event);

// Invoked on completion of Bluetooth Quality Report configuration. Then it will
// Register/Unregister for receiving VSE - Bluetooth Quality Report sub-event.
//
// @param current_evt_mask Indicates current quality event bit mask setting in
//   the Bluetooth controller.
static void ConfigureBqrCmpl(uint32_t current_evt_mask) {

void ConfigureBqrCmpl(uint32_t current_evt_mask) {
  log::info("current_evt_mask: 0x{:x}", current_evt_mask);
  // (Un)Register for VSE of Bluetooth Quality Report sub event
  tBTM_STATUS btm_status = BTM_BT_Quality_Report_VSE_Register(
@@ -629,15 +596,7 @@ static void ConfigureBqrCmpl(uint32_t current_evt_mask) {
  }
}

static void AddLinkQualityEventToQueue(uint8_t length,
                                       const uint8_t* p_link_quality_event);
// Categorize the incoming Bluetooth Quality Report.
//
// @param length Lengths of the quality report sent from the Bluetooth
//   controller.
// @param p_bqr_event A pointer to the BQR VSE sub-event which is sent from the
//   Bluetooth controller.
static void CategorizeBqrEvent(uint8_t length, const uint8_t* p_bqr_event) {
void CategorizeBqrEvent(uint8_t length, const uint8_t* p_bqr_event) {
  if (length == 0) {
    log::warn("Lengths of all of the parameters are zero.");
    return;
@@ -679,11 +638,7 @@ static void CategorizeBqrEvent(uint8_t length, const uint8_t* p_bqr_event) {
  }
}

// Record a new incoming Link Quality related BQR event in quality event queue.
//
// @param length Lengths of the Link Quality related BQR event.
// @param p_link_quality_event A pointer to the Link Quality related BQR event.
static void AddLinkQualityEventToQueue(uint8_t length,
void AddLinkQualityEventToQueue(uint8_t length,
                                const uint8_t* p_link_quality_event) {
  std::unique_ptr<BqrVseSubEvt> p_bqr_event = std::make_unique<BqrVseSubEvt>();
  RawAddress bd_addr;
@@ -754,14 +709,7 @@ static void AddLinkQualityEventToQueue(uint8_t length,
  kpBqrEventQueue->Enqueue(p_bqr_event.release());
}

static int OpenLmpLlTraceLogFile();

// Dump the LMP/LL message handshaking with the remote device to a log file.
//
// @param length Lengths of the LMP/LL message trace event.
// @param p_lmp_ll_message_event A pointer to the LMP/LL message trace event.
static void DumpLmpLlMessage(uint8_t length,
                             const uint8_t* p_lmp_ll_message_event) {
void DumpLmpLlMessage(uint8_t length, const uint8_t* p_lmp_ll_message_event) {
  std::unique_ptr<BqrVseSubEvt> p_bqr_event = std::make_unique<BqrVseSubEvt>();

  if (LmpLlMessageTraceLogFd == INVALID_FD ||
@@ -774,10 +722,7 @@ static void DumpLmpLlMessage(uint8_t length,
  }
}

// Open the LMP/LL message trace log file.
//
// @return a file descriptor of the LMP/LL message trace log file.
static int OpenLmpLlTraceLogFile() {
int OpenLmpLlTraceLogFile() {
  if (rename(kpLmpLlMessageTraceLogPath, kpLmpLlMessageTraceLastLogPath) != 0 &&
      errno != ENOENT) {
    log::error("Unable to rename '{}' to '{}' : {}", kpLmpLlMessageTraceLogPath,
@@ -798,16 +743,7 @@ static int OpenLmpLlTraceLogFile() {
  return logfile_fd;
}

static int OpenBtSchedulingTraceLogFile();

// Dump the Bluetooth Multi-profile/Coex scheduling information to a log file.
//
// @param length Lengths of the Bluetooth Multi-profile/Coex scheduling trace
//   event.
// @param p_bt_scheduling_event A pointer to the Bluetooth Multi-profile/Coex
//   scheduling trace event.
static void DumpBtScheduling(uint8_t length,
                             const uint8_t* p_bt_scheduling_event) {
void DumpBtScheduling(uint8_t length, const uint8_t* p_bt_scheduling_event) {
  std::unique_ptr<BqrVseSubEvt> p_bqr_event = std::make_unique<BqrVseSubEvt>();

  if (BtSchedulingTraceLogFd == INVALID_FD ||
@@ -820,11 +756,7 @@ static void DumpBtScheduling(uint8_t length,
  }
}

// Open the Bluetooth Multi-profile/Coex scheduling trace log file.
//
// @return a file descriptor of the Bluetooth Multi-profile/Coex scheduling
//   trace log file.
static int OpenBtSchedulingTraceLogFile() {
int OpenBtSchedulingTraceLogFile() {
  if (rename(kpBtSchedulingTraceLogPath, kpBtSchedulingTraceLastLogPath) != 0 &&
      errno != ENOENT) {
    log::error("Unable to rename '{}' to '{}' : {}", kpBtSchedulingTraceLogPath,