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

Commit aa5bd18d authored by Chris Manton's avatar Chris Manton
Browse files

[18/25] stack::gatt Use stack::l2cap::get_interface()

Bug: 343808590
Test: m .
Flag: EXEMPT, Mechanical Refactor

Change-Id: I465c73d81bd3407cf9fcfffaef03dddd70b6cef9
parent f7cdbfe3
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#include "osi/include/allocator.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_types.h"
#include "stack/include/l2cap_interface.h"
#include "stack/include/l2cdefs.h"
#include "types/bluetooth/uuid.h"

@@ -370,10 +371,10 @@ tGATT_STATUS attp_send_msg_to_l2cap(tGATT_TCB& tcb, uint16_t lcid, BT_HDR* p_toL

  if (lcid == L2CAP_ATT_CID) {
    log::debug("Sending ATT message on att fixed channel");
    l2cap_ret = L2CA_SendFixedChnlData(lcid, tcb.peer_bda, p_toL2CAP);
    l2cap_ret = stack::l2cap::get_interface().L2CA_SendFixedChnlData(lcid, tcb.peer_bda, p_toL2CAP);
  } else {
    log::debug("Sending ATT message on lcid:{}", lcid);
    l2cap_ret = L2CA_DataWrite(lcid, p_toL2CAP);
    l2cap_ret = stack::l2cap::get_interface().L2CA_DataWrite(lcid, p_toL2CAP);
  }

  if (l2cap_ret == tL2CAP_DW_RESULT::FAILED) {
+5 −4
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
#include "stack/include/bt_uuid16.h"
#include "stack/include/btm_client_interface.h"
#include "stack/include/l2cap_acl_interface.h"
#include "stack/include/l2cap_interface.h"
#include "stack/include/l2cdefs.h"
#include "stack/include/sdp_api.h"
#include "types/bluetooth/uuid.h"
@@ -1190,15 +1191,15 @@ void GATT_SetIdleTimeout(const RawAddress& bd_addr, uint16_t idle_tout, tBT_TRAN

  tGATT_TCB* p_tcb = gatt_find_tcb_by_addr(bd_addr, transport);
  if (p_tcb != nullptr) {
    status = L2CA_SetLeGattTimeout(bd_addr, idle_tout);
    status = stack::l2cap::get_interface().L2CA_SetLeGattTimeout(bd_addr, idle_tout);

    if (is_active) {
      status &= L2CA_MarkLeLinkAsActive(bd_addr);
      status &= stack::l2cap::get_interface().L2CA_MarkLeLinkAsActive(bd_addr);
    }

    if (idle_tout == GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP) {
      if (!L2CA_SetIdleTimeoutByBdAddr(p_tcb->peer_bda, GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP,
                                       BT_TRANSPORT_LE)) {
      if (!stack::l2cap::get_interface().L2CA_SetIdleTimeoutByBdAddr(
                  p_tcb->peer_bda, GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP, BT_TRANSPORT_LE)) {
        log::warn("Unable to set L2CAP link idle timeout peer:{} transport:{}", p_tcb->peer_bda,
                  bt_transport_text(transport));
      }
+1 −2
Original line number Diff line number Diff line
@@ -26,10 +26,9 @@
#include <string.h>

#include "gatt_int.h"
#include "l2c_api.h"
#include "osi/include/osi.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_types.h"
#include "stack/include/l2cap_types.h"
#include "types/bluetooth/uuid.h"

using bluetooth::Uuid;
+10 −8
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@
#include "stack/include/bt_types.h"
#include "stack/include/btm_client_interface.h"
#include "stack/include/l2cap_acl_interface.h"
#include "stack/include/l2cap_interface.h"
#include "stack/include/l2cdefs.h"
#include "stack/include/srvc_api.h"  // tDIS_VALUE
#include "types/raw_address.h"
@@ -131,14 +132,14 @@ void gatt_init(void) {
  // clients exist
  fixed_reg.default_idle_tout = L2CAP_NO_IDLE_TIMEOUT;

  if (!L2CA_RegisterFixedChannel(L2CAP_ATT_CID, &fixed_reg)) {
  if (!stack::l2cap::get_interface().L2CA_RegisterFixedChannel(L2CAP_ATT_CID, &fixed_reg)) {
    log::error("Unable to register L2CAP ATT fixed channel");
  }

  gatt_cb.over_br_enabled = osi_property_get_bool("bluetooth.gatt.over_bredr.enabled", true);
  /* Now, register with L2CAP for ATT PSM over BR/EDR */
  if (gatt_cb.over_br_enabled &&
      !L2CA_RegisterWithSecurity(BT_PSM_ATT, dyn_info, false /* enable_snoop */, nullptr,
  if (gatt_cb.over_br_enabled && !stack::l2cap::get_interface().L2CA_RegisterWithSecurity(
                                         BT_PSM_ATT, dyn_info, false /* enable_snoop */, nullptr,
                                         GATT_MAX_MTU_SIZE, 0, BTM_SEC_NONE)) {
    log::error("ATT Dynamic Registration failed");
  }
@@ -223,7 +224,8 @@ bool gatt_connect(const RawAddress& rem_bda, tBLE_ADDR_TYPE addr_type, tGATT_TCB
  }

  if (transport != BT_TRANSPORT_LE) {
    p_tcb->att_lcid = L2CA_ConnectReqWithSecurity(BT_PSM_ATT, rem_bda, BTM_SEC_NONE);
    p_tcb->att_lcid = stack::l2cap::get_interface().L2CA_ConnectReqWithSecurity(BT_PSM_ATT, rem_bda,
                                                                                BTM_SEC_NONE);
    return p_tcb->att_lcid != 0;
  }

@@ -308,7 +310,7 @@ bool gatt_disconnect(tGATT_TCB* p_tcb) {
         */
        EattExtension::GetInstance()->Disconnect(p_tcb->peer_bda);
      }
      if (!L2CA_RemoveFixedChnl(L2CAP_ATT_CID, p_tcb->peer_bda)) {
      if (!stack::l2cap::get_interface().L2CA_RemoveFixedChnl(L2CAP_ATT_CID, p_tcb->peer_bda)) {
        log::warn("Unable to remove L2CAP ATT fixed channel peer:{}", p_tcb->peer_bda);
      }
      gatt_set_ch_state(p_tcb, GATT_CH_CLOSING);
@@ -849,7 +851,7 @@ static void gatt_l2cif_connect_ind_cback(const RawAddress& bd_addr, uint16_t lci

  /* If we reject the connection, send DisconnectReq */
  if (result != tL2CAP_CONN::L2CAP_CONN_OK) {
    if (!L2CA_DisconnectReq(lcid)) {
    if (!stack::l2cap::get_interface().L2CA_DisconnectReq(lcid)) {
      log::warn("Unable to disconnect L2CAP peer:{} cid:{}", bd_addr, lcid);
    }
    return;
@@ -955,7 +957,7 @@ void gatt_l2cif_disconnect_ind_cback(uint16_t lcid, bool /* ack_needed */) {
}

static void gatt_l2cif_disconnect(uint16_t lcid) {
  if (!L2CA_DisconnectReq(lcid)) {
  if (!stack::l2cap::get_interface().L2CA_DisconnectReq(lcid)) {
    log::warn("Unable to disconnect L2CAP cid:{}", lcid);
  }

+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@
#include "stack/gatt/gatt_int.h"
#include "stack/include/bt_types.h"
#include "stack/include/gatt_api.h"
#include "stack/include/l2c_api.h"
#include "stack/include/l2cap_types.h"
#include "stack/sdp/internal/sdp_api.h"
#include "test/mock/mock_stack_sdp_legacy_api.h"
#include "types/bluetooth/uuid.h"
Loading