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

Commit 5b2bd58a authored by Hansong Zhang's avatar Hansong Zhang
Browse files

L2cap shim flag update

Tag: #gd-refactor
Bug: 141555841
Test: cert/run --host
Test: Pair and connect with a headset
Change-Id: Iccb704e6d87f6758c4af7cd9148b88d00751b1c2
parent 4c7ad8f5
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -224,10 +224,11 @@ static bool event_already_registered_in_hci_layer(
    case bluetooth::hci::EventCode::MAX_SLOTS_CHANGE:
    case bluetooth::hci::EventCode::VENDOR_SPECIFIC:
      return bluetooth::shim::is_gd_hci_enabled();
    case bluetooth::hci::EventCode::LE_META_EVENT:
    case bluetooth::hci::EventCode::DISCONNECTION_COMPLETE:
    case bluetooth::hci::EventCode::READ_REMOTE_VERSION_INFORMATION_COMPLETE:
      return bluetooth::shim::is_gd_acl_enabled();
    case bluetooth::hci::EventCode::LE_META_EVENT:
      return bluetooth::shim::is_gd_acl_enabled() ||
             bluetooth::shim::is_gd_l2cap_enabled();
    default:
      return false;
  }
@@ -237,7 +238,8 @@ static bool event_already_registered_in_controller_layer(
    bluetooth::hci::EventCode event_code) {
  switch (event_code) {
    case bluetooth::hci::EventCode::NUMBER_OF_COMPLETED_PACKETS:
      return bluetooth::shim::is_gd_acl_enabled();
      return bluetooth::shim::is_gd_acl_enabled() ||
             bluetooth::shim::is_gd_l2cap_enabled();
    default:
      return false;
  }
@@ -247,7 +249,8 @@ static bool event_already_registered_in_acl_layer(
    bluetooth::hci::EventCode event_code) {
  for (auto event : bluetooth::hci::AclConnectionEvents) {
    if (event == event_code) {
      return bluetooth::shim::is_gd_acl_enabled();
      return bluetooth::shim::is_gd_acl_enabled() ||
             bluetooth::shim::is_gd_l2cap_enabled();
    }
  }
  return false;
@@ -263,11 +266,11 @@ static bool subevent_already_registered_in_le_hci_layer(
    case bluetooth::hci::SubeventCode::PHY_UPDATE_COMPLETE:
    case bluetooth::hci::SubeventCode::REMOTE_CONNECTION_PARAMETER_REQUEST:
      return bluetooth::shim::is_gd_acl_enabled() ||
             bluetooth::shim::is_gd_advertising_enabled();
             bluetooth::shim::is_gd_l2cap_enabled();
    case bluetooth::hci::SubeventCode::ADVERTISING_SET_TERMINATED:
    case bluetooth::hci::SubeventCode::SCAN_REQUEST_RECEIVED:
      return bluetooth::shim::is_gd_advertising_enabled();
    case bluetooth::hci::SubeventCode::SCAN_TIMEOUT:
      return bluetooth::shim::is_gd_acl_enabled() ||
             bluetooth::shim::is_gd_l2cap_enabled();
    case bluetooth::hci::SubeventCode::ADVERTISING_REPORT:
    case bluetooth::hci::SubeventCode::DIRECTED_ADVERTISING_REPORT:
    case bluetooth::hci::SubeventCode::EXTENDED_ADVERTISING_REPORT:
@@ -278,6 +281,7 @@ static bool subevent_already_registered_in_le_hci_layer(
    case bluetooth::hci::SubeventCode::READ_REMOTE_FEATURES_COMPLETE:
    case bluetooth::hci::SubeventCode::READ_LOCAL_P256_PUBLIC_KEY_COMPLETE:
    case bluetooth::hci::SubeventCode::GENERATE_DHKEY_COMPLETE:
    case bluetooth::hci::SubeventCode::SCAN_TIMEOUT:
    case bluetooth::hci::SubeventCode::CHANNEL_SELECTION_ALGORITHM:
    case bluetooth::hci::SubeventCode::CONNECTIONLESS_IQ_REPORT:
    case bluetooth::hci::SubeventCode::CONNECTION_IQ_REPORT:
@@ -582,7 +586,8 @@ void bluetooth::shim::hci_on_reset_complete() {

  // if gd advertising enabled, hci_queue_end will be register in
  // AclManager::impl::Start
  if (!bluetooth::shim::is_gd_advertising_enabled()) {
  if (!bluetooth::shim::is_gd_advertising_enabled() &&
      !bluetooth::shim::is_gd_l2cap_enabled()) {
    hci_queue_end->RegisterDequeue(bluetooth::shim::GetGdShimHandler(),
                                   bluetooth::common::Bind(acl_data_callback));
  }
@@ -599,7 +604,8 @@ void bluetooth::shim::hci_on_shutting_down() {
    pending_data = nullptr;
  }
  if (hci_queue_end != nullptr) {
    if (!bluetooth::shim::is_gd_advertising_enabled()) {
    if (!bluetooth::shim::is_gd_advertising_enabled() &&
        !bluetooth::shim::is_gd_l2cap_enabled()) {
      hci_queue_end->UnregisterDequeue();
    }
    for (uint8_t event_code_raw = 0; event_code_raw < 0xFF; event_code_raw++) {
+1 −1
Original line number Diff line number Diff line
@@ -1077,7 +1077,7 @@ tBTM_STATUS BTM_SetEncryption(const RawAddress& bd_addr,
      p_dev_rec->security_required, p_dev_rec, p_callback);

  if (transport == BT_TRANSPORT_LE) {
    if (BTM_IsAclConnectionUp(bd_addr, transport)) {
    if (BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_LE)) {
      rc = btm_ble_set_encryption(bd_addr, sec_act,
                                  acl_link_role(bd_addr, transport));
    } else {
+2 −2
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ std::set<tAPP_ID> get_apps_connecting_to(const RawAddress& address) {
/** Add a device from the background connection list.  Returns true if device
 * added to the list, or already in list, false otherwise */
bool background_connect_add(uint8_t app_id, const RawAddress& address) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
  if (bluetooth::shim::is_gd_l2cap_enabled()) {
    return L2CA_ConnectFixedChnl(L2CAP_ATT_CID, address);
  }

@@ -205,7 +205,7 @@ void wl_direct_connect_timeout_cb(uint8_t app_id, const RawAddress& address) {
/** Add a device to the direcgt connection list.  Returns true if device
 * added to the list, false otherwise */
bool direct_connect_add(uint8_t app_id, const RawAddress& address) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
  if (bluetooth::shim::is_gd_l2cap_enabled()) {
    return L2CA_ConnectFixedChnl(L2CAP_ATT_CID, address);
  }

+4 −5
Original line number Diff line number Diff line
@@ -44,11 +44,6 @@

using base::StringPrintf;

tL2CAP_LE_RESULT_CODE btm_ble_start_sec_check(const RawAddress& bd_addr,
                                              uint16_t psm, bool is_originator,
                                              tBTM_SEC_CALLBACK* p_callback,
                                              void* p_ref_data);

static void l2cble_start_conn_update(tL2C_LCB* p_lcb);

/*******************************************************************************
@@ -1127,6 +1122,10 @@ bool l2cble_create_conn(tL2C_LCB* p_lcb) {
 *
 ******************************************************************************/
void l2c_link_processs_ble_num_bufs(uint16_t num_lm_ble_bufs) {
  if (bluetooth::shim::is_gd_l2cap_enabled()) {
    return;
  }

  if (num_lm_ble_bufs == 0) {
    num_lm_ble_bufs = L2C_DEF_NUM_BLE_BUF_SHARED;
    l2cb.num_lm_acl_bufs -= L2C_DEF_NUM_BLE_BUF_SHARED;
+10 −1
Original line number Diff line number Diff line
@@ -322,7 +322,6 @@ void l2c_link_sec_comp2(const RawAddress& p_bda,
 ******************************************************************************/
bool l2c_link_hci_disc_comp(uint16_t handle, uint8_t reason) {
  if (bluetooth::shim::is_gd_l2cap_enabled()) {
    btm_acl_removed(handle);
    return false;
  }

@@ -735,6 +734,11 @@ void l2c_link_adjust_chnl_allocation(void) {
}

void l2c_link_init() {
  if (bluetooth::shim::is_gd_l2cap_enabled()) {
    // GD L2cap gets this info through GD ACL
    return;
  }

  const controller_t* controller = controller_get_interface();

  l2cb.num_lm_acl_bufs = controller->get_acl_buffer_count_classic();
@@ -1330,6 +1334,11 @@ void l2c_link_segments_xmitted(BT_HDR* p_msg) {
}

tBTM_STATUS l2cu_ConnectAclForSecurity(const RawAddress& bd_addr) {
  if (bluetooth::shim::is_gd_l2cap_enabled()) {
    bluetooth::shim::L2CA_ConnectForSecurity(bd_addr);
    return BTM_SUCCESS;
  }

  tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, BT_TRANSPORT_BR_EDR);
  if (p_lcb && (p_lcb->link_state == LST_CONNECTED ||
                p_lcb->link_state == LST_CONNECTING)) {
Loading