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

Commit 659c626a authored by Prerepa Viswanadham's avatar Prerepa Viswanadham
Browse files

Avoid premature LE connection notifaction to app

To avoid premature connection notification to app, always wait for
LE read remote feature complete with success before the connection
event is sent to application.

This patch also deprecates the BTA_SKIP_BLE_READ_REMOTE_FEAT flag.
Since the remote feature request is now serialized and start encryption
won't be called until the connection is up, this flag is no longer
necessary and interferes with the new behaviour.

This is an extension of previous CL

Bug: 17326529
Change-Id: Icfd4c5dfdd9f89d1318ef429e132eb005abb1f64
parent 8aec345e
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -947,15 +947,14 @@ tBTA_GATTC_CLCB * bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA *p_msg)
    tGATT_DISCONN_REASON    reason = p_msg->int_conn.reason;

    bta_gattc_conn_dealloc(p_msg->int_conn.remote_bda);
    /* connection attempt timeout, send connection callback event */
    if (reason == GATT_CONN_CANCEL || reason == GATT_CONN_L2C_FAILURE
        || reason == GATT_CONN_FAIL_ESTABLISH)
    if ((p_clcb = bta_gattc_find_clcb_by_conn_id(p_msg->int_conn.hdr.layer_specific)) == NULL)
    {
        /* connection attempt failed, send connection callback event */
        p_clcb = bta_gattc_find_clcb_by_cif(p_msg->int_conn.client_if,
                                            p_msg->int_conn.remote_bda,
                                            p_msg->int_conn.transport);
    }
    else if ((p_clcb = bta_gattc_find_clcb_by_conn_id(p_msg->int_conn.hdr.layer_specific)) == NULL)
    if (p_clcb == NULL)
    {
        APPL_TRACE_DEBUG(" disconnection ID: [%d] not used by BTA",
            p_msg->int_conn.hdr.layer_specific);
+0 −5
Original line number Diff line number Diff line
@@ -260,11 +260,6 @@
#define BTA_HOST_INTERLEAVE_SEARCH FALSE
#endif

/* This feature is used to skip query of ble read remote features*/
#ifndef BTA_SKIP_BLE_READ_REMOTE_FEAT
#define BTA_SKIP_BLE_READ_REMOTE_FEAT FALSE
#endif

#ifndef BT_TRACE_PROTOCOL
#define BT_TRACE_PROTOCOL  TRUE
#endif
+3 −3
Original line number Diff line number Diff line
@@ -374,16 +374,16 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn,
                    &p->active_remote_addr_type);
#endif

#if (!defined(BTA_SKIP_BLE_READ_REMOTE_FEAT) || BTA_SKIP_BLE_READ_REMOTE_FEAT == FALSE)
                if (HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(btm_cb.devcb.local_le_features)
                    || link_role == HCI_ROLE_MASTER)
                {
                    btsnd_hcic_ble_read_remote_feat(p->hci_handle);
                }
                else
#endif
                {
                    btm_establish_continue(p);
                }
            }
            else
#endif
            {
+1 −2
Original line number Diff line number Diff line
@@ -3010,7 +3010,6 @@ void btm_ble_read_remote_features_complete(UINT8 *p)
            {
                STREAM_TO_ARRAY(p_acl_cb->peer_le_features, p, BD_FEATURES_LEN);
                /*notify link up here */
                btm_establish_continue(p_acl_cb);
                l2cble_notify_le_connection (p_acl_cb->remote_addr);
                break;
            }
+9 −16
Original line number Diff line number Diff line
@@ -280,10 +280,17 @@ UINT16 L2CA_GetDisconnectReason (BD_ADDR remote_bda, tBT_TRANSPORT transport)
void l2cble_notify_le_connection (BD_ADDR bda)
{
    tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr (bda, BT_TRANSPORT_LE);
    tACL_CONN *p_acl = btm_bda_to_acl(bda, BT_TRANSPORT_LE) ;

    if (p_lcb != NULL)
    if (p_lcb != NULL && p_acl != NULL && p_lcb->link_state != LST_CONNECTED)
    {
        /* update link status */
        btm_establish_continue(p_acl);
        /* update l2cap link status and send callback */
        p_lcb->link_state = LST_CONNECTED;
        l2cu_process_fixed_chnl_resp (p_lcb);
    }
}

/*******************************************************************************
**
@@ -340,7 +347,6 @@ void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type,
    p_lcb->handle = handle;

    /* Connected OK. Change state to connected, we were scanning so we are master */
    p_lcb->link_state = LST_CONNECTED;
    p_lcb->link_role  = HCI_ROLE_MASTER;
    p_lcb->transport  = BT_TRANSPORT_LE;

@@ -373,15 +379,8 @@ void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type,
    /* Tell BTM Acl management about the link */
    btm_acl_created (bda, NULL, p_dev_rec->sec_bd_name, handle, p_lcb->link_role, BT_TRANSPORT_LE);

#if(defined(BTA_SKIP_BLE_READ_REMOTE_FEAT) && BTA_SKIP_BLE_READ_REMOTE_FEAT == TRUE)
    {
            l2cu_process_fixed_chnl_resp (p_lcb);
    }
#endif

    p_lcb->peer_chnl_mask[0] = L2CAP_FIXED_CHNL_ATT_BIT | L2CAP_FIXED_CHNL_BLE_SIG_BIT | L2CAP_FIXED_CHNL_SMP_BIT;


    btm_ble_set_conn_st(BLE_CONN_IDLE);
}

@@ -434,7 +433,6 @@ void l2cble_advertiser_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE typ
    p_lcb->handle = handle;

    /* Connected OK. Change state to connected, we were advertising, so we are slave */
    p_lcb->link_state = LST_CONNECTED;
    p_lcb->link_role  = HCI_ROLE_SLAVE;
    p_lcb->transport  = BT_TRANSPORT_LE;

@@ -445,16 +443,11 @@ void l2cble_advertiser_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE typ

    p_lcb->peer_chnl_mask[0] = L2CAP_FIXED_CHNL_ATT_BIT | L2CAP_FIXED_CHNL_BLE_SIG_BIT | L2CAP_FIXED_CHNL_SMP_BIT;

#if (defined(BTA_SKIP_BLE_READ_REMOTE_FEAT) && BTA_SKIP_BLE_READ_REMOTE_FEAT == TRUE)
    {
        l2cu_process_fixed_chnl_resp (p_lcb);
    }
#else
    if (!HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(btm_cb.devcb.local_le_features))
    {
        p_lcb->link_state = LST_CONNECTED;
        l2cu_process_fixed_chnl_resp (p_lcb);
    }
#endif

    /* when adv and initiating are both active, cancel the direct connection */
    if (l2cb.is_ble_connecting && memcmp(bda, l2cb.ble_connecting_bda, BD_ADDR_LEN) == 0)
Loading