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

Commit e32edb8e authored by Liana Kazanova's avatar Liana Kazanova Committed by Gerrit Code Review
Browse files

Revert "BtQualityReports cpplint"

Revert submission 3237049

Reason for revert: DroidMonitor: Potential culprit for http://b/362263539 - verifying through ABTD before submission. 

Reverted changes: /q/submissionid:3237049

Change-Id: I8e8f08dbd8f69b5be0246979c783faf929ba047f
parent 5b682914
Loading
Loading
Loading
Loading
+27 −25
Original line number Diff line number Diff line
@@ -24,26 +24,25 @@
#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 "hardware/bluetooth.h"
#include "core_callbacks.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 {
@@ -666,7 +665,7 @@ static void AddLinkQualityEventToQueue(uint8_t length, const uint8_t* p_link_qua
    }

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

static bt_remote_version_t btif_get_remote_version(const RawAddress& bd_addr) {
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;
  uint8_t tmp_lmp_ver = 0;
  uint16_t tmp_manufacturer = 0;
  uint16_t tmp_lmp_subver = 0;
@@ -789,24 +791,21 @@ static bt_remote_version_t btif_get_remote_version(const RawAddress& bd_addr) {
  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)) {
    return {
            .version = tmp_lmp_ver,
            .sub_ver = tmp_lmp_subver,
            .manufacturer = tmp_manufacturer,
    };
    lmp_version = tmp_lmp_ver;
    manufacturer = tmp_manufacturer;
    lmp_sub_version = tmp_lmp_subver;
    return;
  }

  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),
  };
  prop.type = BT_PROPERTY_REMOTE_VERSION_INFO;
  prop.len = sizeof(bt_remote_version_t);
  prop.val = (void*)&info;

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

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

    bt_remote_version_t info = btif_get_remote_version(bd_addr);
    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);

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

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

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

private: