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

Commit e3eb29b2 authored by Myles Watson's avatar Myles Watson
Browse files

Skip btu_hcif for BQR events

Call btm_vendor_specific_evt on the main thread.

Bug: 322230000
Test: mma -j32
Flag: EXEMPT, no logical change
Change-Id: I151db25512f6c49ac58fa2aeaa8f2a6bbd71361b
parent 602a6829
Loading
Loading
Loading
Loading
+9 −6
Original line number Original line Diff line number Diff line
@@ -37,6 +37,7 @@
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_types.h"
#include "stack/include/bt_types.h"
#include "stack/include/btm_iso_api.h"
#include "stack/include/btm_iso_api.h"
#include "stack/include/dev_hci_link_interface.h"
#include "stack/include/hcimsgs.h"
#include "stack/include/hcimsgs.h"
#include "stack/include/main_thread.h"
#include "stack/include/main_thread.h"


@@ -228,12 +229,15 @@ static void subevent_callback(


static void vendor_specific_event_callback(
static void vendor_specific_event_callback(
    bluetooth::hci::VendorSpecificEventView vendor_specific_event_view) {
    bluetooth::hci::VendorSpecificEventView vendor_specific_event_view) {
  if (!send_data_upwards) {
  auto bqr =
      bluetooth::hci::BqrEventView::CreateOptional(vendor_specific_event_view);
  if (!bqr) {
    return;
    return;
  }
  }
  send_data_upwards.Run(

      FROM_HERE,
  auto payload = vendor_specific_event_view.GetPayload();
      WrapPacketAndCopy(MSG_HC_TO_STACK_HCI_EVT, &vendor_specific_event_view));
  std::vector<uint8_t> bytes{payload.begin(), payload.end()};
  btm_vendor_specific_evt(bytes.data(), bytes.size());
}
}


void OnTransmitPacketCommandComplete(command_complete_cb complete_callback,
void OnTransmitPacketCommandComplete(command_complete_cb complete_callback,
@@ -465,10 +469,9 @@ void bluetooth::shim::hci_on_reset_complete() {
  }
  }


  // TODO handle BQR event in GD
  // TODO handle BQR event in GD
  auto handler = bluetooth::shim::GetGdShimHandler();
  bluetooth::shim::GetVendorSpecificEventManager()->RegisterEventHandler(
  bluetooth::shim::GetVendorSpecificEventManager()->RegisterEventHandler(
      bluetooth::hci::VseSubeventCode::BQR_EVENT,
      bluetooth::hci::VseSubeventCode::BQR_EVENT,
      handler->Bind(cpp::vendor_specific_event_callback));
      get_main_thread()->Bind(cpp::vendor_specific_event_callback));


  cpp::register_for_iso();
  cpp::register_for_iso();
}
}
+1 −29
Original line number Original line Diff line number Diff line
@@ -108,7 +108,6 @@ static void btu_hcif_create_conn_cancel_complete(const uint8_t* p,
static void btu_hcif_read_local_oob_complete(const uint8_t* p,
static void btu_hcif_read_local_oob_complete(const uint8_t* p,
                                             uint16_t evt_len);
                                             uint16_t evt_len);


static void btu_hcif_vendor_specific_evt(const uint8_t* p, uint16_t evt_len);
/* Simple Pairing Events */
/* Simple Pairing Events */
static void btu_hcif_io_cap_request_evt(const uint8_t* p);
static void btu_hcif_io_cap_request_evt(const uint8_t* p);
static void btu_hcif_io_cap_response_evt(const uint8_t* p);
static void btu_hcif_io_cap_response_evt(const uint8_t* p);
@@ -391,11 +390,8 @@ void btu_hcif_process_event(UNUSED_ATTR uint8_t controller_id,
      }
      }
    } break;
    } break;


    case HCI_VENDOR_SPECIFIC_EVT:
      btu_hcif_vendor_specific_evt(p, hci_evt_len);
      break;

      // Events now captured by gd::hci_layer module
      // Events now captured by gd::hci_layer module
    case HCI_VENDOR_SPECIFIC_EVT:
    case HCI_HARDWARE_ERROR_EVT:
    case HCI_HARDWARE_ERROR_EVT:
    case HCI_NUM_COMPL_DATA_PKTS_EVT:  // EventCode::NUMBER_OF_COMPLETED_PACKETS
    case HCI_NUM_COMPL_DATA_PKTS_EVT:  // EventCode::NUMBER_OF_COMPLETED_PACKETS
    case HCI_CONNECTION_COMP_EVT:  // EventCode::CONNECTION_COMPLETE
    case HCI_CONNECTION_COMP_EVT:  // EventCode::CONNECTION_COMPLETE
@@ -1412,30 +1408,6 @@ void btu_hcif_read_local_oob_complete(const uint8_t* p, uint16_t evt_len) {
err_out:
err_out:
  log::error("bogus event packet, too short");
  log::error("bogus event packet, too short");
}
}
void btu_hcif_vendor_specific_evt(const uint8_t* p, uint16_t evt_len) {
  LOG_VERBOSE("BTM Event: Vendor Specific event from controller");

  // Handle BQR events
  const uint8_t* bqr_ptr = p;
  uint8_t event_code;
  uint8_t len;

  if (evt_len >= 2) {
    STREAM_TO_UINT8(event_code, bqr_ptr);
    STREAM_TO_UINT8(len, bqr_ptr);
    // Check if there's at least a subevent code
    if (len > 1 && evt_len >= 2 + 1 && event_code == HCI_VENDOR_SPECIFIC_EVT) {
      uint8_t sub_event_code;
      STREAM_TO_UINT8(sub_event_code, bqr_ptr);
      if (sub_event_code == HCI_VSE_SUBCODE_BQR_SUB_EVT) {
        // Excluding the HCI Event packet header and 1 octet sub-event code
        int16_t bqr_parameter_length = evt_len - HCIE_PREAMBLE_SIZE - 1;
        // The stream currently points to the BQR sub-event parameters
        btm_vendor_specific_evt(bqr_ptr, bqr_parameter_length);
      }
    }
  }
}


/*******************************************************************************
/*******************************************************************************
 *
 *
+0 −2
Original line number Original line Diff line number Diff line
@@ -21,8 +21,6 @@


#include <cstdint>
#include <cstdint>


#include "types/raw_address.h"

void btm_delete_stored_link_key_complete(uint8_t* p, uint16_t evt_len);
void btm_delete_stored_link_key_complete(uint8_t* p, uint16_t evt_len);
void btm_vendor_specific_evt(const uint8_t* p, uint8_t evt_len);
void btm_vendor_specific_evt(const uint8_t* p, uint8_t evt_len);
void btm_read_local_name_complete(uint8_t* p, uint16_t evt_len);
void btm_read_local_name_complete(uint8_t* p, uint16_t evt_len);