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

Commit 50e5b23a authored by Hansong Zhang's avatar Hansong Zhang Committed by Automerger Merge Worker
Browse files

Use gatt_on_l2cap_error for error handling am: 58f8601d am: 85d4bab3

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1439958

Change-Id: I170ddb81f2220ef1ccc2dc0eb2f7b7da9abd5773
parents b7182450 85d4bab3
Loading
Loading
Loading
Loading
+14 −20
Original line number Diff line number Diff line
@@ -581,6 +581,15 @@ static void gatt_l2cif_connect_ind_cback(const RawAddress& bd_addr,
  gatt_set_ch_state(p_tcb, GATT_CH_CFG);
}

static void gatt_on_l2cap_error(uint16_t lcid, uint16_t result) {
  tGATT_TCB* p_tcb = gatt_find_tcb_by_cid(lcid);
  if (gatt_get_ch_state(p_tcb) == GATT_CH_CONN) {
    gatt_cleanup_upon_disc(p_tcb->peer_bda, result, BT_TRANSPORT_BR_EDR);
  } else {
    gatt_l2cif_disconnect(lcid);
  }
}

/** This is the L2CAP connect confirm callback function */
static void gatt_l2cif_connect_cfm_cback(uint16_t lcid, uint16_t result) {
  tGATT_TCB* p_tcb;
@@ -593,24 +602,10 @@ static void gatt_l2cif_connect_cfm_cback(uint16_t lcid, uint16_t result) {
          << StringPrintf(" result: %d ch_state: %d, lcid:0x%x", result,
                          gatt_get_ch_state(p_tcb), p_tcb->att_lcid);

  /* if in correct state */
  if (gatt_get_ch_state(p_tcb) == GATT_CH_CONN) {
    /* if result successful */
    if (result == L2CAP_CONN_OK) {
      /* set channel state */
  if (gatt_get_ch_state(p_tcb) == GATT_CH_CONN && result == L2CAP_CONN_OK) {
    gatt_set_ch_state(p_tcb, GATT_CH_CFG);
    }
    /* else initiating connection failure */
    else {
      gatt_cleanup_upon_disc(p_tcb->peer_bda, result, BT_TRANSPORT_BR_EDR);
    }
  } else /* wrong state, disconnect it */
  {
    if (result == L2CAP_CONN_OK) {
      /* just in case the peer also accepts our connection - Send L2CAP
       * disconnect req */
      gatt_l2cif_disconnect(lcid);
    }
  } else {
    gatt_on_l2cap_error(lcid, result);
  }
}

@@ -625,8 +620,7 @@ void gatt_l2cif_config_cfm_cback(uint16_t lcid, uint16_t result) {

  /* if result not successful */
  if (result != L2CAP_CFG_OK) {
    /* Send L2CAP disconnect req */
    gatt_l2cif_disconnect(lcid);
    gatt_on_l2cap_error(lcid, result);
    return;
  }