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

Commit 04f687c6 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Use Bind in BTA_JvRfcommClose

Bug: 68359837
Test: compilation test
Change-Id: I867107dbf86a2a0fcb9232ce902d38345d04c444
parent 885ba307
Loading
Loading
Loading
Loading
+9 −16
Original line number Diff line number Diff line
@@ -1435,26 +1435,19 @@ static int find_rfc_pcb(uint32_t rfcomm_slot_id, tBTA_JV_RFC_CB** cb,
  return 0;
}

/*******************************************************************************
 *
 * Function     bta_jv_rfcomm_close
 *
 * Description  Close an RFCOMM connection
 *
 * Returns      void
 *
 ******************************************************************************/
void bta_jv_rfcomm_close(tBTA_JV_MSG* p_data) {
  tBTA_JV_API_RFCOMM_CLOSE* cc = &(p_data->rfcomm_close);
  tBTA_JV_RFC_CB* p_cb = NULL;
  tBTA_JV_PCB* p_pcb = NULL;
  APPL_TRACE_DEBUG("bta_jv_rfcomm_close, rfc handle:%d", cc->handle);
  if (!cc->handle) {
/* Close an RFCOMM connection */
void bta_jv_rfcomm_close(uint32_t handle, uint32_t rfcomm_slot_id) {
  if (!handle) {
    APPL_TRACE_ERROR("bta_jv_rfcomm_close, rfc handle is null");
    return;
  }

  if (!find_rfc_pcb(cc->rfcomm_slot_id, &p_cb, &p_pcb)) return;
  APPL_TRACE_DEBUG("bta_jv_rfcomm_close, rfc handle:%d", handle);

  tBTA_JV_RFC_CB* p_cb = NULL;
  tBTA_JV_PCB* p_pcb = NULL;

  if (!find_rfc_pcb(rfcomm_slot_id, &p_cb, &p_pcb)) return;
  bta_jv_free_rfc_cb(p_cb, p_pcb);
  APPL_TRACE_DEBUG("bta_jv_rfcomm_close: sec id in use:%d, rfc_cb in use:%d",
                   get_sec_id_used(), get_rfc_cb_used());
+6 −16
Original line number Diff line number Diff line
@@ -616,28 +616,18 @@ tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
 *
 ******************************************************************************/
tBTA_JV_STATUS BTA_JvRfcommClose(uint32_t handle, uint32_t rfcomm_slot_id) {
  tBTA_JV_STATUS status = BTA_JV_FAILURE;
  uint32_t hi = ((handle & BTA_JV_RFC_HDL_MASK) & ~BTA_JV_RFCOMM_MASK) - 1;
  uint32_t si = BTA_JV_RFC_HDL_TO_SIDX(handle);

  APPL_TRACE_API("%s", __func__);

  if (hi < BTA_JV_MAX_RFC_CONN && bta_jv_cb.rfc_cb[hi].p_cback &&
      si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si]) {
    tBTA_JV_API_RFCOMM_CLOSE* p_msg =
        (tBTA_JV_API_RFCOMM_CLOSE*)osi_malloc(sizeof(tBTA_JV_API_RFCOMM_CLOSE));
    p_msg->hdr.event = BTA_JV_API_RFCOMM_CLOSE_EVT;
    p_msg->handle = handle;
    p_msg->p_cb = &bta_jv_cb.rfc_cb[hi];
    p_msg->p_pcb = &bta_jv_cb.port_cb[p_msg->p_cb->rfc_hdl[si] - 1];
    p_msg->rfcomm_slot_id = rfcomm_slot_id;

    bta_sys_sendmsg(p_msg);

    status = BTA_JV_SUCCESS;
  }
  if (hi >= BTA_JV_MAX_RFC_CONN || !bta_jv_cb.rfc_cb[hi].p_cback ||
      si >= BTA_JV_MAX_RFC_SR_SESSION || !bta_jv_cb.rfc_cb[hi].rfc_hdl[si])
    return BTA_JV_FAILURE;

  return status;
  do_in_bta_thread(FROM_HERE,
                   Bind(&bta_jv_rfcomm_close, handle, rfcomm_slot_id));
  return BTA_JV_SUCCESS;
}

/*******************************************************************************
+1 −12
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@
enum {
  /* these events are handled by the state machine */
  BTA_JV_API_START_DISCOVERY_EVT = BTA_SYS_EVT_START(BTA_ID_JV),
  BTA_JV_API_RFCOMM_CLOSE_EVT,
  BTA_JV_API_RFCOMM_START_SERVER_EVT,
  BTA_JV_API_RFCOMM_STOP_SERVER_EVT,
  BTA_JV_API_RFCOMM_WRITE_EVT,
@@ -178,15 +177,6 @@ typedef struct {
  tBTA_JV_PCB* p_pcb;
} tBTA_JV_API_RFCOMM_WRITE;

/* data type for BTA_JV_API_RFCOMM_CLOSE_EVT */
typedef struct {
  BT_HDR hdr;
  uint32_t handle;
  tBTA_JV_RFC_CB* p_cb;
  tBTA_JV_PCB* p_pcb;
  uint32_t rfcomm_slot_id;
} tBTA_JV_API_RFCOMM_CLOSE;

/* union of all data types */
typedef union {
  /* GKI event buffer header */
@@ -196,7 +186,6 @@ typedef union {
  tBTA_JV_API_RFCOMM_WRITE rfcomm_write;
  tBTA_JV_API_SET_PM_PROFILE set_pm;
  tBTA_JV_API_PM_STATE_CHANGE change_pm_state;
  tBTA_JV_API_RFCOMM_CLOSE rfcomm_close;
  tBTA_JV_API_RFCOMM_SERVER rfcomm_server;
} tBTA_JV_MSG;

@@ -268,7 +257,7 @@ extern void bta_jv_rfcomm_connect(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
                                  const RawAddress& peer_bd_addr,
                                  tBTA_JV_RFCOMM_CBACK* p_cback,
                                  uint32_t rfcomm_slot_id);
extern void bta_jv_rfcomm_close(tBTA_JV_MSG* p_data);
extern void bta_jv_rfcomm_close(uint32_t handle, uint32_t rfcomm_slot_id);
extern void bta_jv_rfcomm_start_server(tBTA_JV_MSG* p_data);
extern void bta_jv_rfcomm_stop_server(tBTA_JV_MSG* p_data);
extern void bta_jv_rfcomm_read(tBTA_JV_MSG* p_data);
+0 −1
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ typedef void (*tBTA_JV_ACTION)(tBTA_JV_MSG* p_data);
/* action function list */
const tBTA_JV_ACTION bta_jv_action[] = {
    bta_jv_start_discovery,       /* BTA_JV_API_START_DISCOVERY_EVT */
    bta_jv_rfcomm_close,          /* BTA_JV_API_RFCOMM_CLOSE_EVT */
    bta_jv_rfcomm_start_server,   /* BTA_JV_API_RFCOMM_START_SERVER_EVT */
    bta_jv_rfcomm_stop_server,    /* BTA_JV_API_RFCOMM_STOP_SERVER_EVT */
    bta_jv_rfcomm_write,          /* BTA_JV_API_RFCOMM_WRITE_EVT */