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

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

[13/25] stack::avdt Use stack::l2cap::get_interface()

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

Change-Id: I0b944c99cfd664dcf0c35d40bca3aacc28a0a141
parent 977a1687
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#define LOG_TAG "bluetooth-a2dp"

#include <bluetooth/log.h>
#include <com_android_bluetooth_flags.h>
#include <string.h>

#include "avdt_api.h"
@@ -35,7 +36,7 @@
#include "osi/include/allocator.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/btm_sec_api_types.h"
#include <com_android_bluetooth_flags.h>
#include "stack/include/l2cap_interface.h"

using namespace bluetooth;

@@ -349,8 +350,8 @@ void avdt_ad_tc_open_ind(AvdtpTransportChannel* p_tbl) {
  /* if signaling channel, notify ccb that channel open */
  if (p_tbl->tcid == 0) {
    /* set the signal channel to use high priority within the ACL link */
    if (!L2CA_SetTxPriority(avdtp_cb.ad.rt_tbl[p_tbl->ccb_idx][AVDT_CHAN_SIG].lcid,
                            L2CAP_CHNL_PRIORITY_HIGH)) {
    if (!stack::l2cap::get_interface().L2CA_SetTxPriority(
                avdtp_cb.ad.rt_tbl[p_tbl->ccb_idx][AVDT_CHAN_SIG].lcid, L2CAP_CHNL_PRIORITY_HIGH)) {
      log::warn("Unable to set L2CAP transmit high priority cid:{}",
                avdtp_cb.ad.rt_tbl[p_tbl->ccb_idx][AVDT_CHAN_SIG].lcid);
    }
@@ -479,7 +480,8 @@ tL2CAP_DW_RESULT avdt_ad_write_req(uint8_t type, AvdtpCcb* p_ccb, AvdtpScb* p_sc
  /* get tcid from type, scb */
  tcid = avdt_ad_type_to_tcid(type, p_scb);

  return L2CA_DataWrite(avdtp_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][tcid].lcid, p_buf);
  return stack::l2cap::get_interface().L2CA_DataWrite(
          avdtp_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][tcid].lcid, p_buf);
}

/*******************************************************************************
@@ -534,10 +536,10 @@ void avdt_ad_open_req(uint8_t type, AvdtpCcb* p_ccb, AvdtpScb* p_scb, uint8_t ro

    /* call l2cap connect req */
    if (com::android::bluetooth::flags::use_encrypt_req_for_av()) {
      lcid = L2CA_ConnectReqWithSecurity(AVDT_PSM, p_ccb->peer_addr,
               BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_OUT_ENCRYPT);
      lcid = stack::l2cap::get_interface().L2CA_ConnectReqWithSecurity(
              AVDT_PSM, p_ccb->peer_addr, BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_OUT_ENCRYPT);
    } else {
      lcid = L2CA_ConnectReqWithSecurity(AVDT_PSM, p_ccb->peer_addr,
      lcid = stack::l2cap::get_interface().L2CA_ConnectReqWithSecurity(AVDT_PSM, p_ccb->peer_addr,
                                                                       BTM_SEC_OUT_AUTHENTICATE);
    }
    if (lcid != 0) {
+4 −5
Original line number Diff line number Diff line
@@ -35,10 +35,9 @@
#include "avdtc_api.h"
#include "bta/include/bta_sec_api.h"
#include "internal_include/bt_target.h"
#include "l2c_api.h"
#include "os/log.h"
#include "stack/include/a2dp_codec_api.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/l2cap_interface.h"
#include "types/raw_address.h"

using namespace bluetooth;
@@ -103,8 +102,8 @@ void AVDT_Register(AvdtpRcb* p_reg, tAVDT_CTRL_CBACK* p_cback) {
    sec = BTA_SEC_AUTHENTICATE;
  }
  /* register PSM with L2CAP */
  if (!L2CA_RegisterWithSecurity(AVDT_PSM, avdt_l2c_appl, true /* enable_snoop */, nullptr,
                                 kAvdtpMtu, 0, sec)) {
  if (!stack::l2cap::get_interface().L2CA_RegisterWithSecurity(
              AVDT_PSM, avdt_l2c_appl, true /* enable_snoop */, nullptr, kAvdtpMtu, 0, sec)) {
    log::error("Unable to register with L2CAP profile AVDT psm:AVDT_PSM[0x0019]");
  }

@@ -134,7 +133,7 @@ void AVDT_Register(AvdtpRcb* p_reg, tAVDT_CTRL_CBACK* p_cback) {
 ******************************************************************************/
void AVDT_Deregister(void) {
  /* deregister PSM with L2CAP */
  L2CA_Deregister(AVDT_PSM);
  stack::l2cap::get_interface().L2CA_Deregister(AVDT_PSM);
}

void AVDT_AbortReq(uint8_t handle) {
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include "osi/include/alarm.h"
#include "osi/include/fixed_queue.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/l2cap_interface.h"
#include "types/raw_address.h"

#ifndef AVDT_DEBUG
+2 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include "stack/include/acl_api.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/btm_status.h"
#include "stack/include/l2cap_interface.h"
#include "types/raw_address.h"

using namespace bluetooth;
@@ -206,7 +207,7 @@ void avdt_l2c_connect_ind_cback(const RawAddress& bd_addr, uint16_t lcid, uint16
  /* If we reject the connection, send DisconnectReq */
  if (result != tL2CAP_CONN::L2CAP_CONN_OK) {
    log::warn("lcid: 0x{:04x}, result: {}", lcid, l2cap_result_code_text(result));
    if (!L2CA_DisconnectReq(lcid)) {
    if (!stack::l2cap::get_interface().L2CA_DisconnectReq(lcid)) {
      log::warn("Unable to disconnect L2CAP lcid: 0x{:04x}", lcid);
    }
    return;
+3 −3
Original line number Diff line number Diff line
@@ -33,11 +33,10 @@
#include "avdt_api.h"
#include "avdt_int.h"
#include "internal_include/bt_target.h"
#include "os/log.h"
#include "osi/include/allocator.h"
#include "osi/include/osi.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_types.h"
#include "stack/include/l2cap_interface.h"
#include "types/raw_address.h"

using namespace bluetooth;
@@ -1478,7 +1477,8 @@ void avdt_scb_clr_pkt(AvdtpScb* p_scb, tAVDT_SCB_EVT* /* p_data */) {
    tcid = avdt_ad_type_to_tcid(AVDT_CHAN_MEDIA, p_scb);

    lcid = avdtp_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][tcid].lcid;
    const uint16_t buffers_left = L2CA_FlushChannel(lcid, L2CAP_FLUSH_CHANS_ALL);
    const uint16_t buffers_left =
            stack::l2cap::get_interface().L2CA_FlushChannel(lcid, L2CAP_FLUSH_CHANS_ALL);
    if (buffers_left) {
      log::warn("Unable to flush L2CAP ALL channel peer:{} cid:{} buffers_left:{}",
                p_ccb->peer_addr, lcid, buffers_left);