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

Commit ee4d97f1 authored by Vinit Deshpande's avatar Vinit Deshpande Committed by android-build-merger
Browse files

Merge "Fix LE cancel open when physical connection is established but not ready"

am: 49cf2b5f

Change-Id: I3e27ee66923fbc5eb6bd0357c6913ea82b904857
parents 2128d27a 49cf2b5f
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include "btu.h"
#include "device/include/controller.h"
#include "hcimsgs.h"
#include "l2c_api.h"
#include "l2c_int.h"
#include "l2cdefs.h"
#include "osi/include/osi.h"
@@ -52,11 +53,19 @@ static void l2cble_start_conn_update(tL2C_LCB* p_lcb);
 *
 ******************************************************************************/
bool L2CA_CancelBleConnectReq(const RawAddress& rem_bda) {
  tL2C_LCB* p_lcb;

  tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, BT_TRANSPORT_LE);
  /* There can be only one BLE connection request outstanding at a time */
  if (btm_ble_get_conn_st() == BLE_CONN_IDLE) {
    L2CAP_TRACE_WARNING("%s - no connection pending", __func__);
    tACL_CONN* p_acl = btm_bda_to_acl(rem_bda, BT_TRANSPORT_LE);
    if (p_acl) {
      if (p_lcb != NULL &&
          p_lcb->link_state == LST_CONNECTING && !l2cb.is_ble_connecting) {
        L2CAP_TRACE_WARNING("%s - disconnecting the LE link", __func__);
        L2CA_RemoveFixedChnl(L2CAP_ATT_CID, rem_bda);
        return (true);
      }
    }
    return (false);
  }

@@ -71,7 +80,6 @@ bool L2CA_CancelBleConnectReq(const RawAddress& rem_bda) {

  btsnd_hcic_ble_create_conn_cancel();

  p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, BT_TRANSPORT_LE);
  /* Do not remove lcb if an LE link is already up as a peripheral */
  if (p_lcb != NULL &&
      !(p_lcb->link_role == HCI_ROLE_SLAVE &&
+22 −12
Original line number Diff line number Diff line
@@ -1619,7 +1619,8 @@ void l2cu_release_ccb(tL2C_CCB* p_ccb) {
  p_ccb->in_use = false;

  /* If no channels on the connection, start idle timeout */
  if ((p_lcb) && p_lcb->in_use && (p_lcb->link_state == LST_CONNECTED)) {
  if ((p_lcb) && p_lcb->in_use) {
    if (p_lcb->link_state == LST_CONNECTED) {
      if (!p_lcb->ccb_queue.p_first_ccb) {
        // Closing a security channel on LE device should not start connection
        // timeout
@@ -1632,6 +1633,15 @@ void l2cu_release_ccb(tL2C_CCB* p_ccb) {
        /* Link is still active, adjust channel quotas. */
        l2c_link_adjust_chnl_allocation();
      }
    } else if (p_lcb->link_state == LST_CONNECTING && !l2cb.is_ble_connecting) {
      if (!p_lcb->ccb_queue.p_first_ccb) {
        if (p_lcb->transport == BT_TRANSPORT_LE &&
            p_ccb->local_cid == L2CAP_ATT_CID) {
          L2CAP_TRACE_WARNING("%s - disconnecting the LE link", __func__);
          l2cu_no_dynamic_ccbs(p_lcb);
        }
      }
    }
  }
}