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

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

Merge "Reland BtQualityReports cpplint" into main

parents f441460b 719937bd
Loading
Loading
Loading
Loading
+25 −27
Original line number Diff line number Diff line
@@ -24,25 +24,26 @@
#include <cerrno>
#include <cstdint>

#include "btif/include/btif_bqr.h"
#include "btif/include/btif_common.h"
#include "btif/include/btif_storage.h"
#include "btif/include/core_callbacks.h"
#include "btif/include/stack_manager_t.h"
#include "btif_bqr.h"
#include "btif_common.h"
#include "btif_storage.h"
#include "common/leaky_bonded_queue.h"
#include "common/postable_context.h"
#include "common/time_util.h"
#include "core_callbacks.h"
#include "hardware/bluetooth.h"
#include "hci/hci_interface.h"
#include "hci/hci_packets.h"
#include "internal_include/bt_trace.h"
#include "main/shim/entry.h"
#include "osi/include/properties.h"
#include "packet/raw_builder.h"
#include "raw_address.h"
#include "stack/btm/btm_dev.h"
#include "stack/include/bt_types.h"
#include "stack/include/btm_ble_api.h"
#include "stack/include/btm_client_interface.h"
#include "types/raw_address.h"

namespace bluetooth {
namespace bqr {
@@ -672,7 +673,7 @@ static void AddLinkQualityEventToQueue(uint8_t length, const uint8_t* p_link_qua
    }

    if (!bd_addr.IsEmpty()) {
      bqrItf->bqr_delivery_event(bd_addr, (uint8_t*)p_link_quality_event, length);
      bqrItf->bqr_delivery_event(bd_addr, p_link_quality_event, length);
    } else {
      log::warn("failed to deliver BQR, bdaddr is empty");
    }
@@ -787,10 +788,7 @@ void DebugDump(int fd) {
  dprintf(fd, "\n");
}

static void btif_get_remote_version(const RawAddress& bd_addr, uint8_t& lmp_version,
                                    uint16_t& manufacturer, uint16_t& lmp_sub_version) {
  bt_property_t prop;
  bt_remote_version_t info;
static bt_remote_version_t btif_get_remote_version(const RawAddress& bd_addr) {
  uint8_t tmp_lmp_ver = 0;
  uint16_t tmp_manufacturer = 0;
  uint16_t tmp_lmp_subver = 0;
@@ -798,21 +796,24 @@ static void btif_get_remote_version(const RawAddress& bd_addr, uint8_t& lmp_vers
  const bool status = get_btm_client_interface().peer.BTM_ReadRemoteVersion(
          bd_addr, &tmp_lmp_ver, &tmp_manufacturer, &tmp_lmp_subver);
  if (status && (tmp_lmp_ver || tmp_manufacturer || tmp_lmp_subver)) {
    lmp_version = tmp_lmp_ver;
    manufacturer = tmp_manufacturer;
    lmp_sub_version = tmp_lmp_subver;
    return;
    return {
            .version = tmp_lmp_ver,
            .sub_ver = tmp_lmp_subver,
            .manufacturer = tmp_manufacturer,
    };
  }

  prop.type = BT_PROPERTY_REMOTE_VERSION_INFO;
  prop.len = sizeof(bt_remote_version_t);
  prop.val = (void*)&info;
  bt_remote_version_t info{};
  bt_property_t prop{
          .type = BT_PROPERTY_REMOTE_VERSION_INFO,
          .len = sizeof(bt_remote_version_t),
          .val = reinterpret_cast<void*>(&info),
  };

  if (btif_storage_get_remote_device_property(&bd_addr, &prop) == BT_STATUS_SUCCESS) {
    lmp_version = (uint8_t)info.version;
    manufacturer = (uint16_t)info.manufacturer;
    lmp_sub_version = (uint16_t)info.sub_ver;
    return info;
  }
  return {};
}

class BluetoothQualityReportInterfaceImpl : public bluetooth::bqr::BluetoothQualityReportInterface {
@@ -843,13 +844,10 @@ class BluetoothQualityReportInterfaceImpl : public bluetooth::bqr::BluetoothQual
      raw_data.insert(it, kVersion5_0ParamsTotalLen, 0);
    }

    uint8_t lmp_ver = 0;
    uint16_t lmp_subver = 0;
    uint16_t manufacturer_id = 0;
    btif_get_remote_version(bd_addr, lmp_ver, manufacturer_id, lmp_subver);
    bt_remote_version_t info = btif_get_remote_version(bd_addr);

    log::info("len: {}, addr: {}, lmp_ver: {}, manufacturer_id: {}, lmp_subver: {}",
              bqr_raw_data_len, bd_addr, lmp_ver, manufacturer_id, lmp_subver);
              bqr_raw_data_len, bd_addr, info.version, info.manufacturer, info.sub_ver);

    if (callbacks == nullptr) {
      log::error("callbacks is nullptr");
@@ -858,8 +856,8 @@ class BluetoothQualityReportInterfaceImpl : public bluetooth::bqr::BluetoothQual

    do_in_jni_thread(
            base::BindOnce(&bluetooth::bqr::BluetoothQualityReportCallbacks::bqr_delivery_callback,
                           base::Unretained(callbacks), bd_addr, lmp_ver, lmp_subver,
                           manufacturer_id, std::move(raw_data)));
                           base::Unretained(callbacks), bd_addr, info.version, info.sub_ver,
                           info.manufacturer, std::move(raw_data)));
  }

private: