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

Commit 8b1e0777 authored by Henri Chataing's avatar Henri Chataing
Browse files

system/stack/avct: Migrate to libbluetooth_log

Test: m com.android.btservices
Bug: 305066880
Flag: EXEMPT, mechanical refactor
Change-Id: Ib38bd1898e41af9f1ca1eea2ce3e4ca7f98b202f
parent d9973aff
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@

#include "avct_api.h"

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

#include "avct_int.h"
@@ -31,11 +32,12 @@
#include "internal_include/bt_target.h"
#include "l2c_api.h"
#include "l2cdefs.h"
#include "os/log.h"
#include "osi/include/allocator.h"
#include "stack/include/bt_hdr.h"
#include "types/raw_address.h"

using namespace bluetooth;

/* Control block for AVCT */
tAVCT_CB avct_cb;

@@ -54,7 +56,7 @@ tAVCT_CB avct_cb;
 *
 ******************************************************************************/
void AVCT_Register() {
  LOG_VERBOSE("AVCT_Register");
  log::verbose("AVCT_Register");

  /* initialize AVCTP data structures */
  memset(&avct_cb, 0, sizeof(tAVCT_CB));
@@ -87,7 +89,7 @@ void AVCT_Register() {
 *
 ******************************************************************************/
void AVCT_Deregister(void) {
  LOG_VERBOSE("AVCT_Deregister");
  log::verbose("AVCT_Deregister");

  /* deregister PSM with L2CAP */
  L2CA_Deregister(AVCT_PSM);
@@ -116,7 +118,7 @@ uint16_t AVCT_CreateConn(uint8_t* p_handle, tAVCT_CC* p_cc,
  tAVCT_CCB* p_ccb;
  tAVCT_LCB* p_lcb;

  LOG_VERBOSE("AVCT_CreateConn: %d, control:%d", p_cc->role, p_cc->control);
  log::verbose("AVCT_CreateConn: {}, control:{}", p_cc->role, p_cc->control);

  /* Allocate ccb; if no ccbs, return failure */
  p_ccb = avct_ccb_alloc(p_cc);
@@ -147,7 +149,7 @@ uint16_t AVCT_CreateConn(uint8_t* p_handle, tAVCT_CC* p_cc,
      if (result == AVCT_SUCCESS) {
        /* bind lcb to ccb */
        p_ccb->p_lcb = p_lcb;
        LOG_VERBOSE("ch_state: %d", p_lcb->ch_state);
        log::verbose("ch_state: {}", p_lcb->ch_state);
        tAVCT_LCB_EVT avct_lcb_evt;
        avct_lcb_evt.p_ccb = p_ccb;
        avct_lcb_event(p_lcb, AVCT_LCB_UL_BIND_EVT, &avct_lcb_evt);
@@ -174,7 +176,7 @@ uint16_t AVCT_RemoveConn(uint8_t handle) {
  uint16_t result = AVCT_SUCCESS;
  tAVCT_CCB* p_ccb;

  LOG_VERBOSE("AVCT_RemoveConn");
  log::verbose("AVCT_RemoveConn");

  /* map handle to ccb */
  p_ccb = avct_ccb_by_idx(handle);
@@ -217,7 +219,7 @@ uint16_t AVCT_CreateBrowse(uint8_t handle, uint8_t role) {
  tAVCT_BCB* p_bcb;
  int index;

  LOG_VERBOSE("AVCT_CreateBrowse: %d", role);
  log::verbose("AVCT_CreateBrowse: {}", role);

  /* map handle to ccb */
  p_ccb = avct_ccb_by_idx(handle);
@@ -251,7 +253,7 @@ uint16_t AVCT_CreateBrowse(uint8_t handle, uint8_t role) {
      /* bind bcb to ccb */
      p_ccb->p_bcb = p_bcb;
      p_bcb->peer_addr = p_ccb->p_lcb->peer_addr;
      LOG_VERBOSE("ch_state: %d", p_bcb->ch_state);
      log::verbose("ch_state: {}", p_bcb->ch_state);
      tAVCT_LCB_EVT avct_lcb_evt;
      avct_lcb_evt.p_ccb = p_ccb;
      avct_bcb_event(p_bcb, AVCT_LCB_UL_BIND_EVT, &avct_lcb_evt);
@@ -278,7 +280,7 @@ uint16_t AVCT_RemoveBrowse(uint8_t handle) {
  uint16_t result = AVCT_SUCCESS;
  tAVCT_CCB* p_ccb;

  LOG_VERBOSE("AVCT_RemoveBrowse");
  log::verbose("AVCT_RemoveBrowse");

  /* map handle to ccb */
  p_ccb = avct_ccb_by_idx(handle);
@@ -369,14 +371,13 @@ uint16_t AVCT_MsgReq(uint8_t handle, uint8_t label, uint8_t cr, BT_HDR* p_msg) {
  tAVCT_CCB* p_ccb;
  tAVCT_UL_MSG ul_msg;

  LOG_VERBOSE("%s", __func__);
  log::verbose("");

  /* verify p_msg parameter */
  if (p_msg == NULL) {
    return AVCT_NO_RESOURCES;
  }
  LOG_VERBOSE("%s len: %d layer_specific: %d", __func__, p_msg->len,
              p_msg->layer_specific);
  log::verbose("len: {} layer_specific: {}", p_msg->len, p_msg->layer_specific);

  /* map handle to ccb */
  p_ccb = avct_ccb_by_idx(handle);
+16 −14
Original line number Diff line number Diff line
@@ -28,19 +28,21 @@
#define LOG_TAG "bluetooth"

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

#include "avct_api.h"
#include "avct_int.h"
#include "bta/include/bta_sec_api.h"
#include "internal_include/bt_target.h"
#include "os/log.h"
#include "osi/include/allocator.h"
#include "osi/include/osi.h"
#include "stack/avct/avct_defs.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_types.h"

using namespace bluetooth;

/* action function list */
const tAVCT_BCB_ACTION avct_bcb_action[] = {
    avct_bcb_chnl_open,   /* AVCT_LCB_CHNL_OPEN */
@@ -88,7 +90,7 @@ static BT_HDR* avct_bcb_msg_asmbl(UNUSED_ATTR tAVCT_BCB* p_bcb, BT_HDR* p_buf) {
  /* must be single packet - can not fragment */
  if (pkt_type != AVCT_PKT_TYPE_SINGLE) {
    osi_free_and_reset((void**)&p_buf);
    LOG_WARN("Pkt type=%d - fragmentation not allowed. drop it", pkt_type);
    log::warn("Pkt type={} - fragmentation not allowed. drop it", pkt_type);
  }
  return p_buf;
}
@@ -422,7 +424,7 @@ void avct_bcb_discard_msg(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data) {
        (p_data->ul_msg.cr << 8) + p_data->ul_msg.label;

    /* the channel is closed, opening or closing - open it again */
    LOG_VERBOSE("ch_state: %d, allocated:%d->%d", p_bcb->ch_state,
    log::verbose("ch_state: {}, allocated:{}->{}", p_bcb->ch_state,
                 p_bcb->allocated, p_data->ul_msg.p_ccb->p_lcb->allocated);
    p_bcb->allocated = p_data->ul_msg.p_ccb->p_lcb->allocated;
    avct_bcb_event(p_bcb, AVCT_LCB_UL_BIND_EVT,
@@ -452,8 +454,8 @@ void avct_bcb_send_msg(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data) {

  /* initialize packet type and other stuff */
  if (curr_msg_len > (p_bcb->peer_mtu - AVCT_HDR_LEN_SINGLE)) {
    LOG_ERROR("%s msg len (%d) exceeds peer mtu(%d-%d)!!", __func__,
              curr_msg_len, p_bcb->peer_mtu, AVCT_HDR_LEN_SINGLE);
    log::error("msg len ({}) exceeds peer mtu({}-{})!!", curr_msg_len,
               p_bcb->peer_mtu, AVCT_HDR_LEN_SINGLE);
    osi_free_and_reset((void**)&p_data->ul_msg.p_buf);
    return;
  }
@@ -510,7 +512,7 @@ void avct_bcb_msg_ind(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data) {
  tAVCT_LCB* p_lcb = avct_lcb_by_bcb(p_bcb);

  if ((p_data == NULL) || (p_data->p_buf == NULL)) {
    LOG_WARN("%s p_data is NULL, returning!", __func__);
    log::warn("p_data is NULL, returning!");
    return;
  }

@@ -527,7 +529,7 @@ void avct_bcb_msg_ind(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data) {
  }

  if (p_data->p_buf->len < AVCT_HDR_LEN_SINGLE) {
    LOG_WARN("Invalid AVCTP packet length %d: must be at least %d",
    log::warn("Invalid AVCTP packet length {}: must be at least {}",
              p_data->p_buf->len, AVCT_HDR_LEN_SINGLE);
    osi_free_and_reset((void**)&p_data->p_buf);
    return;
@@ -542,7 +544,7 @@ void avct_bcb_msg_ind(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data) {

  /* check for invalid cr_ipid */
  if (cr_ipid == AVCT_CR_IPID_INVALID) {
    LOG_WARN("Invalid cr_ipid %d", cr_ipid);
    log::warn("Invalid cr_ipid {}", cr_ipid);
    osi_free_and_reset((void**)&p_data->p_buf);
    return;
  }
@@ -566,7 +568,7 @@ void avct_bcb_msg_ind(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data) {
  }

  /* PID not found; drop message */
  LOG_WARN("No ccb for PID=%x", pid);
  log::warn("No ccb for PID={:x}", pid);
  osi_free_and_reset((void**)&p_data->p_buf);

  /* if command send reject */
@@ -595,13 +597,13 @@ void avct_bcb_msg_ind(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data) {
void avct_bcb_dealloc(tAVCT_BCB* p_bcb, UNUSED_ATTR tAVCT_LCB_EVT* p_data) {
  tAVCT_CCB* p_ccb = &avct_cb.ccb[0];

  LOG_VERBOSE("%s %d", __func__, p_bcb->allocated);
  log::verbose("{}", p_bcb->allocated);

  for (int idx = 0; idx < AVCT_NUM_CONN; idx++, p_ccb++) {
    /* if ccb allocated and */
    if ((p_ccb->allocated) && (p_ccb->p_bcb == p_bcb)) {
      p_ccb->p_bcb = NULL;
      LOG_VERBOSE("%s used by ccb: %d", __func__, idx);
      log::verbose("used by ccb: {}", idx);
      break;
    }
  }
@@ -699,6 +701,6 @@ tAVCT_BCB* avct_bcb_by_lcid(uint16_t lcid) {
  }

  /* out of lcbs */
  LOG_WARN("No bcb for lcid %x", lcid);
  log::warn("No bcb for lcid {:x}", lcid);
  return NULL;
}
+8 −6
Original line number Diff line number Diff line
@@ -25,14 +25,16 @@

#define LOG_TAG "avctp"

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

#include "avct_api.h"
#include "avct_int.h"
#include "internal_include/bt_target.h"
#include "os/log.h"
#include "types/raw_address.h"

using namespace bluetooth;

/*******************************************************************************
 *
 * Function         avct_ccb_alloc
@@ -51,7 +53,7 @@ tAVCT_CCB* avct_ccb_alloc(tAVCT_CC* p_cc) {
    if (!p_ccb->allocated) {
      p_ccb->allocated = AVCT_ALOC_LCB;
      memcpy(&p_ccb->cc, p_cc, sizeof(tAVCT_CC));
      LOG_VERBOSE("avct_ccb_alloc %d", i);
      log::verbose("avct_ccb_alloc {}", i);
      break;
    }
  }
@@ -59,7 +61,7 @@ tAVCT_CCB* avct_ccb_alloc(tAVCT_CC* p_cc) {
  if (i == AVCT_NUM_CONN) {
    /* out of ccbs */
    p_ccb = NULL;
    LOG_WARN("Out of ccbs");
    log::warn("Out of ccbs");
  }
  return p_ccb;
}
@@ -79,7 +81,7 @@ void avct_ccb_dealloc(tAVCT_CCB* p_ccb, uint8_t event, uint16_t result,
                      const RawAddress* bd_addr) {
  tAVCT_CTRL_CBACK* p_cback = p_ccb->cc.p_ctrl_cback;

  LOG_VERBOSE("avct_ccb_dealloc %d", avct_ccb_to_idx(p_ccb));
  log::verbose("avct_ccb_dealloc {}", avct_ccb_to_idx(p_ccb));

  if (p_ccb->p_bcb == NULL) {
    memset(p_ccb, 0, sizeof(tAVCT_CCB));
@@ -131,11 +133,11 @@ tAVCT_CCB* avct_ccb_by_idx(uint8_t idx) {
    /* verify ccb is allocated */
    if (!p_ccb->allocated) {
      p_ccb = NULL;
      LOG_WARN("ccb %d not allocated", idx);
      log::warn("ccb {} not allocated", idx);
    }
  } else {
    p_ccb = NULL;
    LOG_WARN("No ccb for idx %d", idx);
    log::warn("No ccb for idx {}", idx);
  }
  return p_ccb;
}
+39 −36
Original line number Diff line number Diff line
@@ -24,19 +24,20 @@
#define LOG_TAG "avctp"

#include <android_bluetooth_sysprop.h>
#include <base/logging.h>
#include <bluetooth/log.h>

#include "avct_api.h"
#include "avct_int.h"
#include "internal_include/bt_target.h"
#include "l2c_api.h"
#include "l2cdefs.h"
#include "os/log.h"
#include "osi/include/allocator.h"
#include "osi/include/osi.h"
#include "stack/include/bt_hdr.h"
#include "types/raw_address.h"

using namespace bluetooth;

/* callback function declarations */
void avct_l2c_connect_ind_cback(const RawAddress& bd_addr, uint16_t lcid,
                                uint16_t psm, uint8_t id);
@@ -84,7 +85,7 @@ static bool avct_l2c_is_passive(tAVCT_LCB* p_lcb) {

  for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) {
    if (p_ccb->allocated && (p_ccb->p_lcb == p_lcb)) {
      LOG_VERBOSE("avct_l2c_is_ct control:x%x", p_ccb->cc.control);
      log::verbose("avct_l2c_is_ct control:x{:x}", p_ccb->cc.control);
      if (p_ccb->cc.control & AVCT_PASSIVE) {
        is_passive = true;
        break;
@@ -128,14 +129,14 @@ void avct_l2c_connect_ind_cback(const RawAddress& bd_addr, uint16_t lcid,
      /* TG role only - accept the connection from CT. move the channel ID to
       * the conflict list */
      p_lcb->conflict_lcid = p_lcb->ch_lcid;
      LOG_VERBOSE("avct_l2c_connect_ind_cback conflict_lcid:0x%x",
      log::verbose("avct_l2c_connect_ind_cback conflict_lcid:0x{:x}",
                   p_lcb->conflict_lcid);
    }
  }

  if (p_lcb) {
    LOG_VERBOSE("avct_l2c_connect_ind_cback: 0x%x, res: %d, ch_state: %d", lcid,
                result, p_lcb->ch_state);
    log::verbose("avct_l2c_connect_ind_cback: 0x{:x}, res: {}, ch_state: {}",
                 lcid, result, p_lcb->ch_state);
  }

  /* If we reject the connection, send DisconnectReq */
@@ -151,9 +152,10 @@ void avct_l2c_connect_ind_cback(const RawAddress& bd_addr, uint16_t lcid,
        if (p_ccb && p_ccb->allocated && (p_ccb->p_lcb == NULL) &&
            (p_ccb->cc.role == AVCT_ACP)) {
          p_ccb->p_lcb = p_lcb;
          LOG_VERBOSE(
              "ACP bind %d ccb to lcb, alloc %d, lcb %p, role %d, pid 0x%x", i,
              p_ccb->allocated, p_ccb->p_lcb, p_ccb->cc.role, p_ccb->cc.pid);
          log::verbose(
              "ACP bind {} ccb to lcb, alloc {}, lcb {}, role {}, pid 0x{:x}",
              i, p_ccb->allocated, fmt::ptr(p_ccb->p_lcb), p_ccb->cc.role,
              p_ccb->cc.pid);
        }
      }
    }
@@ -164,14 +166,14 @@ void avct_l2c_connect_ind_cback(const RawAddress& bd_addr, uint16_t lcid,
    p_lcb->ch_state = AVCT_CH_CFG;
  }

  if (p_lcb) LOG_VERBOSE("ch_state cni: %d ", p_lcb->ch_state);
  if (p_lcb) log::verbose("ch_state cni: {} ", p_lcb->ch_state);
}

static void avct_on_l2cap_error(uint16_t lcid, uint16_t result) {
  tAVCT_LCB* p_lcb = avct_lcb_by_lcid(lcid);
  if (p_lcb == nullptr) return;
  if (p_lcb->ch_state == AVCT_CH_CONN) {
    LOG_VERBOSE("avct_l2c_connect_cfm_cback conflict_lcid:0x%x",
    log::verbose("avct_l2c_connect_cfm_cback conflict_lcid:0x{:x}",
                 p_lcb->conflict_lcid);
    if (p_lcb->conflict_lcid == lcid) {
      p_lcb->conflict_lcid = 0;
@@ -181,7 +183,7 @@ static void avct_on_l2cap_error(uint16_t lcid, uint16_t result) {
      avct_lcb_event(p_lcb, AVCT_LCB_LL_CLOSE_EVT, &avct_lcb_evt);
    }
  } else if (p_lcb->ch_state == AVCT_CH_CFG) {
    LOG_VERBOSE("ERROR avct_l2c_config_cfm_cback L2CA_DisconnectReq %d ",
    log::verbose("ERROR avct_l2c_config_cfm_cback L2CA_DisconnectReq {} ",
                 p_lcb->ch_state);
    /* store result value */
    p_lcb->ch_result = result;
@@ -207,9 +209,9 @@ void avct_l2c_connect_cfm_cback(uint16_t lcid, uint16_t result) {
  /* look up lcb for this channel */
  p_lcb = avct_lcb_by_lcid(lcid);
  if (p_lcb != NULL) {
    LOG_VERBOSE(
        "avct_l2c_connect_cfm_cback lcid:0x%x result: %d ch_state: %d, "
        "conflict_lcid:0x%x",
    log::verbose(
        "avct_l2c_connect_cfm_cback lcid:0x{:x} result: {} ch_state: {}, "
        "conflict_lcid:0x{:x}",
        lcid, result, p_lcb->ch_state, p_lcb->conflict_lcid);
    /* if in correct state */
    if (p_lcb->ch_state == AVCT_CH_CONN) {
@@ -220,11 +222,12 @@ void avct_l2c_connect_cfm_cback(uint16_t lcid, uint16_t result) {
      }
      /* else failure */
      else {
        LOG(ERROR) << __func__ << ": invoked with non OK status";
        log::error("invoked with non OK status");
      }
    } else if (p_lcb->conflict_lcid == lcid) {
      /* we must be in AVCT_CH_CFG state for the ch_lcid channel */
      LOG_VERBOSE("avct_l2c_connect_cfm_cback ch_state: %d, conflict_lcid:0x%x",
      log::verbose(
          "avct_l2c_connect_cfm_cback ch_state: {}, conflict_lcid:0x{:x}",
          p_lcb->ch_state, p_lcb->conflict_lcid);
      if (result == L2CAP_CONN_OK) {
        /* just in case the peer also accepts our connection - Send L2CAP
@@ -233,7 +236,7 @@ void avct_l2c_connect_cfm_cback(uint16_t lcid, uint16_t result) {
      }
      p_lcb->conflict_lcid = 0;
    }
    LOG_VERBOSE("ch_state cnc: %d ", p_lcb->ch_state);
    log::verbose("ch_state cnc: {} ", p_lcb->ch_state);
  }
}

@@ -256,14 +259,14 @@ void avct_l2c_config_cfm_cback(uint16_t lcid, uint16_t initiator,
  /* look up lcb for this channel */
  p_lcb = avct_lcb_by_lcid(lcid);
  if (p_lcb != NULL) {
    LOG_VERBOSE("avct_l2c_config_cfm_cback: 0x%x, ch_state: %d,", lcid,
    log::verbose("avct_l2c_config_cfm_cback: 0x{:x}, ch_state: {},", lcid,
                 p_lcb->ch_state);
    /* if in correct state */
    if (p_lcb->ch_state == AVCT_CH_CFG) {
      p_lcb->ch_state = AVCT_CH_OPEN;
      avct_lcb_event(p_lcb, AVCT_LCB_LL_OPEN_EVT, NULL);
    }
    LOG_VERBOSE("ch_state cfc: %d ", p_lcb->ch_state);
    log::verbose("ch_state cfc: {} ", p_lcb->ch_state);
  }
}

@@ -283,7 +286,7 @@ void avct_l2c_config_ind_cback(uint16_t lcid, tL2CAP_CFG_INFO* p_cfg) {
  /* look up lcb for this channel */
  p_lcb = avct_lcb_by_lcid(lcid);
  if (p_lcb != NULL) {
    LOG_VERBOSE("avct_l2c_config_ind_cback: 0x%x, ch_state: %d", lcid,
    log::verbose("avct_l2c_config_ind_cback: 0x{:x}, ch_state: {}", lcid,
                 p_lcb->ch_state);
    /* store the mtu in tbl */
    if (p_cfg->mtu_present) {
@@ -311,12 +314,12 @@ void avct_l2c_disconnect_ind_cback(uint16_t lcid, bool ack_needed) {
  /* look up lcb for this channel */
  p_lcb = avct_lcb_by_lcid(lcid);
  if (p_lcb != NULL) {
    LOG_VERBOSE("avct_l2c_disconnect_ind_cback: 0x%x, ch_state: %d", lcid,
    log::verbose("avct_l2c_disconnect_ind_cback: 0x{:x}, ch_state: {}", lcid,
                 p_lcb->ch_state);
    tAVCT_LCB_EVT avct_lcb_evt;
    avct_lcb_evt.result = result;
    avct_lcb_event(p_lcb, AVCT_LCB_LL_CLOSE_EVT, &avct_lcb_evt);
    LOG_VERBOSE("ch_state di: %d ", p_lcb->ch_state);
    log::verbose("ch_state di: {} ", p_lcb->ch_state);
  }
}

@@ -329,7 +332,7 @@ void avct_l2c_disconnect(uint16_t lcid, uint16_t result) {
  /* look up lcb for this channel */
  p_lcb = avct_lcb_by_lcid(lcid);
  if (p_lcb != NULL) {
    LOG_VERBOSE("avct_l2c_disconnect_cfm_cback: 0x%x, ch_state: %d, res: %d",
    log::verbose("avct_l2c_disconnect_cfm_cback: 0x{:x}, ch_state: {}, res: {}",
                 lcid, p_lcb->ch_state, result);
    /* result value may be previously stored */
    res = (p_lcb->ch_result != 0) ? p_lcb->ch_result : result;
@@ -338,7 +341,7 @@ void avct_l2c_disconnect(uint16_t lcid, uint16_t result) {
    tAVCT_LCB_EVT avct_lcb_evt;
    avct_lcb_evt.result = res;
    avct_lcb_event(p_lcb, AVCT_LCB_LL_CLOSE_EVT, &avct_lcb_evt);
    LOG_VERBOSE("ch_state dc: %d ", p_lcb->ch_state);
    log::verbose("ch_state dc: {} ", p_lcb->ch_state);
  }
}

@@ -355,7 +358,7 @@ void avct_l2c_disconnect(uint16_t lcid, uint16_t result) {
void avct_l2c_congestion_ind_cback(uint16_t lcid, bool is_congested) {
  tAVCT_LCB* p_lcb;

  LOG_VERBOSE("avct_l2c_congestion_ind_cback: 0x%x", lcid);
  log::verbose("avct_l2c_congestion_ind_cback: 0x{:x}", lcid);
  /* look up lcb for this channel */
  p_lcb = avct_lcb_by_lcid(lcid);
  if (p_lcb != NULL) {
@@ -378,14 +381,14 @@ void avct_l2c_congestion_ind_cback(uint16_t lcid, bool is_congested) {
void avct_l2c_data_ind_cback(uint16_t lcid, BT_HDR* p_buf) {
  tAVCT_LCB* p_lcb;

  LOG_VERBOSE("avct_l2c_data_ind_cback: 0x%x", lcid);
  log::verbose("avct_l2c_data_ind_cback: 0x{:x}", lcid);
  /* look up lcb for this channel */
  p_lcb = avct_lcb_by_lcid(lcid);
  if (p_lcb != NULL) {
    avct_lcb_event(p_lcb, AVCT_LCB_LL_MSG_EVT, (tAVCT_LCB_EVT*)&p_buf);
  } else /* prevent buffer leak */
  {
    LOG_WARN("ERROR -> avct_l2c_data_ind_cback drop buffer");
    log::warn("ERROR -> avct_l2c_data_ind_cback drop buffer");
    osi_free(p_buf);
  }
}
+11 −10
Original line number Diff line number Diff line
@@ -26,19 +26,20 @@

#define LOG_TAG "avctp"

#include <base/logging.h>
#include <bluetooth/log.h>

#include "avct_api.h"
#include "avct_int.h"
#include "internal_include/bt_target.h"
#include "l2c_api.h"
#include "l2cdefs.h"
#include "os/log.h"
#include "osi/include/allocator.h"
#include "osi/include/osi.h"
#include "stack/include/bt_hdr.h"
#include "types/raw_address.h"

using namespace bluetooth;

/* callback function declarations */
void avct_l2c_br_connect_ind_cback(const RawAddress& bd_addr, uint16_t lcid,
                                   uint16_t psm, uint8_t id);
@@ -86,7 +87,7 @@ static bool avct_l2c_br_is_passive(tAVCT_BCB* p_bcb) {

  for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) {
    if (p_ccb->allocated && (p_ccb->p_lcb == p_lcb)) {
      LOG_VERBOSE("Is bcb associated ccb control passive :0x%x",
      log::verbose("Is bcb associated ccb control passive :0x{:x}",
                   p_ccb->cc.control);
      if (p_ccb->cc.control & AVCT_PASSIVE) {
        is_passive = true;
@@ -135,7 +136,7 @@ void avct_l2c_br_connect_ind_cback(const RawAddress& bd_addr, uint16_t lcid,
        /* add channel ID to conflict ID */
        p_bcb->conflict_lcid = p_bcb->ch_lcid;
        result = L2CAP_CONN_OK;
        LOG_VERBOSE("Detected conflict_lcid:0x%x", p_bcb->conflict_lcid);
        log::verbose("Detected conflict_lcid:0x{:x}", p_bcb->conflict_lcid);
      }
    }
  }
@@ -146,7 +147,7 @@ void avct_l2c_br_connect_ind_cback(const RawAddress& bd_addr, uint16_t lcid,

  /* If we reject the connection, send DisconnectReq */
  if (result != L2CAP_CONN_OK) {
    LOG_VERBOSE("Connection rejected to lcid:0x%x", lcid);
    log::verbose("Connection rejected to lcid:0x{:x}", lcid);
    L2CA_DisconnectReq(lcid);
  }

@@ -165,7 +166,7 @@ void avct_br_on_l2cap_error(uint16_t lcid, uint16_t result) {
  if (p_bcb == nullptr) return;

  if (p_bcb->ch_state == AVCT_CH_CONN && p_bcb->conflict_lcid == lcid) {
    LOG_VERBOSE("Reset conflict_lcid:0x%x", p_bcb->conflict_lcid);
    log::verbose("Reset conflict_lcid:0x{:x}", p_bcb->conflict_lcid);
    p_bcb->conflict_lcid = 0;
    return;
  }
@@ -204,14 +205,14 @@ void avct_l2c_br_connect_cfm_cback(uint16_t lcid, uint16_t result) {
    }
    /* else failure */
    else {
      LOG_ERROR("Invoked with non OK status");
      log::error("Invoked with non OK status");
    }
  } else if (p_bcb->conflict_lcid == lcid) {
    /* we must be in AVCT_CH_CFG state for the ch_lcid channel */
    if (result == L2CAP_CONN_OK) {
      /* just in case the peer also accepts our connection - Send L2CAP
       * disconnect req */
      LOG_VERBOSE("Disconnect conflict_lcid:0x%x", p_bcb->conflict_lcid);
      log::verbose("Disconnect conflict_lcid:0x{:x}", p_bcb->conflict_lcid);
      L2CA_DisconnectReq(lcid);
    }
    p_bcb->conflict_lcid = 0;
@@ -270,7 +271,7 @@ void avct_l2c_br_config_ind_cback(uint16_t lcid, tL2CAP_CFG_INFO* p_cfg) {
    p_lcb->peer_mtu = max_mtu;
  }

  LOG_VERBOSE("%s peer_mtu:%d use:%d", __func__, p_lcb->peer_mtu, max_mtu);
  log::verbose("peer_mtu:{} use:{}", p_lcb->peer_mtu, max_mtu);
}

/*******************************************************************************
Loading