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

Commit a5202874 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Make bta_gattc_listen only start listening

The bta_gattc_listen method is used only to start advertising on devices
not using Vendor-Specific Callbacks. It should not notify the client
calling it of all connected devices.

It is also unnecessary to add the gatt client as listening for background
connections. No such thing is done for multi advertising.

Bug: 30622771
Bug: 24099160
Test: code is still compiling
Change-Id: Ia11a247b8416f77543087cd3f18331fcfe7bd207
parent db92b434
Loading
Loading
Loading
Loading
+6 −89
Original line number Diff line number Diff line
@@ -283,13 +283,9 @@ void bta_gattc_deregister(tBTA_GATTC_RCB *p_clreg)
            {
                if (bta_gattc_cb.bg_track[i].cif_mask & (1 <<(p_clreg->client_if - 1)))
                {
                    bta_gattc_mark_bg_conn(p_clreg->client_if, bta_gattc_cb.bg_track[i].remote_bda, false, false);
                    bta_gattc_mark_bg_conn(p_clreg->client_if, bta_gattc_cb.bg_track[i].remote_bda, false);
                    GATT_CancelConnect(p_clreg->client_if, bta_gattc_cb.bg_track[i].remote_bda, false);
                }
                if (bta_gattc_cb.bg_track[i].cif_adv_mask & (1 <<(p_clreg->client_if - 1)))
                {
                    bta_gattc_mark_bg_conn(p_clreg->client_if, bta_gattc_cb.bg_track[i].remote_bda, false, true);
                }
            }
        }

@@ -549,7 +545,7 @@ void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg
    tBTA_GATTC_CLCB         *p_clcb;
    tBTA_GATTC_DATA         gattc_data;

    if (bta_gattc_mark_bg_conn(p_data->client_if, p_data->remote_bda, true, false))
    if (bta_gattc_mark_bg_conn(p_data->client_if, p_data->remote_bda, true))
    {
        /* always call open to hold a connection */
        if (!GATT_Connect(p_data->client_if, p_data->remote_bda, false, p_data->transport, false))
@@ -606,7 +602,7 @@ void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN *p_data)
    cb_data.status = BTA_GATT_ERROR;

    /* remove the device from the bg connection mask */
    if (bta_gattc_mark_bg_conn(p_data->client_if, p_data->remote_bda, false, false))
    if (bta_gattc_mark_bg_conn(p_data->client_if, p_data->remote_bda, false))
    {
        if (GATT_CancelConnect(p_data->client_if, p_data->remote_bda, false))
        {
@@ -1903,71 +1899,6 @@ static void bta_gattc_cong_cback (uint16_t conn_id, bool congested)
#if (BLE_INCLUDED == TRUE)
/*******************************************************************************
**
** Function         bta_gattc_init_clcb_conn
**
** Description      Initaite a BTA CLCB connection
**
** Returns          void
**
********************************************************************************/
void bta_gattc_init_clcb_conn(uint8_t cif, BD_ADDR remote_bda)
{
    tBTA_GATTC_CLCB     *p_clcb = NULL;
    tBTA_GATTC_DATA     gattc_data;
    uint16_t              conn_id;

    /* should always get the connection ID */
    if (GATT_GetConnIdIfConnected(cif, remote_bda, &conn_id, BTA_GATT_TRANSPORT_LE) == false)
    {
        APPL_TRACE_ERROR("bta_gattc_init_clcb_conn ERROR: not a connected device");
        return;
    }

    /* initaite a new connection here */
    if ((p_clcb = bta_gattc_clcb_alloc(cif, remote_bda, BTA_GATT_TRANSPORT_LE)) != NULL)
    {
        gattc_data.hdr.layer_specific = p_clcb->bta_conn_id = conn_id;

        gattc_data.api_conn.client_if = cif;
        memcpy(gattc_data.api_conn.remote_bda, remote_bda, BD_ADDR_LEN);
        gattc_data.api_conn.is_direct = true;

        bta_gattc_sm_execute(p_clcb, BTA_GATTC_API_OPEN_EVT, &gattc_data);
    }
    else
    {
        APPL_TRACE_ERROR("No resources");
    }
}
/*******************************************************************************
**
** Function         bta_gattc_process_listen_all
**
** Description      process listen all, send open callback to application for all
**                  connected slave LE link.
**
** Returns          void
**
********************************************************************************/
void bta_gattc_process_listen_all(uint8_t cif)
{
    uint8_t               i_conn = 0;
    tBTA_GATTC_CONN     *p_conn = &bta_gattc_cb.conn_track[0];

    for (i_conn = 0; i_conn < BTA_GATTC_CONN_MAX; i_conn++, p_conn ++)
    {
        if (p_conn->in_use )
        {
            if (bta_gattc_find_clcb_by_cif(cif, p_conn->remote_bda, BTA_GATT_TRANSPORT_LE) == NULL)
            {
                bta_gattc_init_clcb_conn(cif, p_conn->remote_bda);
            }
            /* else already connected */
        }
    }
}
/*******************************************************************************
**
** Function         bta_gattc_listen
**
** Description      Start or stop a listen for connection
@@ -1990,24 +1921,10 @@ void bta_gattc_listen(tBTA_GATTC_DATA * p_msg)
        return;
    }
    /* mark bg conn record */
    if (bta_gattc_mark_bg_conn(p_msg->api_listen.client_if,
                               (BD_ADDR_PTR) NULL,
                               p_msg->api_listen.start,
                               true))
    {
    GATT_Listen(p_msg->api_listen.start);
    cb_data.status = BTA_GATT_OK;

    (*p_clreg->p_cback)(BTA_GATTC_LISTEN_EVT, &cb_data);

        if (p_msg->api_listen.start)
        {
            LOG_DEBUG(LOG_TAG, "Listen For All now");
            /* go through all connected device and send
            callback for all connected slave connection */
            bta_gattc_process_listen_all(p_msg->api_listen.client_if);
        }
    }
}

/*******************************************************************************
+1 −2
Original line number Diff line number Diff line
@@ -355,7 +355,6 @@ typedef struct
    bool                 in_use;
    BD_ADDR                 remote_bda;
    tBTA_GATTC_CIF_MASK     cif_mask;
    tBTA_GATTC_CIF_MASK     cif_adv_mask;

}tBTA_GATTC_BG_TCK;

@@ -464,7 +463,7 @@ extern bool bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);

extern bool bta_gattc_uuid_compare (const tBT_UUID *p_src, const tBT_UUID *p_tar, bool is_precise);
extern bool bta_gattc_check_notif_registry(tBTA_GATTC_RCB  *p_clreg, tBTA_GATTC_SERV *p_srcb, tBTA_GATTC_NOTIFY  *p_notify);
extern bool bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if,  BD_ADDR_PTR remote_bda, bool add, bool is_listen);
extern bool bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if,  BD_ADDR_PTR remote_bda, bool add);
extern bool bta_gattc_check_bg_conn (tBTA_GATTC_IF client_if,  BD_ADDR remote_bda, uint8_t role);
extern uint8_t bta_gattc_num_reg_app(void);
extern void bta_gattc_clear_notif_registration(tBTA_GATTC_SERV *p_srcb, uint16_t conn_id, uint16_t start_handle, uint16_t end_handle);
+4 −8
Original line number Diff line number Diff line
@@ -524,7 +524,7 @@ void bta_gattc_clear_notif_registration(tBTA_GATTC_SERV *p_srcb, uint16_t conn_i
**
*******************************************************************************/
bool bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if,  BD_ADDR_PTR remote_bda_ptr,
                                bool add, bool is_listen)
                                bool add)
{
    tBTA_GATTC_BG_TCK   *p_bg_tck = &bta_gattc_cb.bg_track[0];
    uint8_t   i = 0;
@@ -536,7 +536,7 @@ bool bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR_PTR remote_bda_pt
            ((remote_bda_ptr != NULL && bdcmp(p_bg_tck->remote_bda, remote_bda_ptr) == 0) ||
            (remote_bda_ptr == NULL && bdcmp(p_bg_tck->remote_bda, dummy_bda) == 0)))
        {
             p_cif_mask = is_listen ? &p_bg_tck->cif_adv_mask : &p_bg_tck->cif_mask;
             p_cif_mask = &p_bg_tck->cif_mask;

            if (add)
                /* mask on the cif bit */
@@ -549,7 +549,7 @@ bool bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR_PTR remote_bda_pt
                    *p_cif_mask = 0;
            }
            /* no BG connection for this device, make it available */
            if (p_bg_tck->cif_mask == 0 && p_bg_tck->cif_adv_mask == 0)
            if (p_bg_tck->cif_mask == 0)
            {
                memset(p_bg_tck, 0, sizeof(tBTA_GATTC_BG_TCK));
            }
@@ -579,7 +579,7 @@ bool bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR_PTR remote_bda_pt
                else
                    bdcpy(p_bg_tck->remote_bda, dummy_bda);

                p_cif_mask = is_listen ? &p_bg_tck->cif_adv_mask : &p_bg_tck->cif_mask;
                p_cif_mask =  &p_bg_tck->cif_mask;

                *p_cif_mask = (1 <<(client_if - 1));
                return true;
@@ -613,10 +613,6 @@ bool bta_gattc_check_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR remote_bda, uint
            if (((p_bg_tck->cif_mask &(1 <<(client_if - 1))) != 0) &&
                role == HCI_ROLE_MASTER)
                is_bg_conn = true;

            if (((p_bg_tck->cif_adv_mask &(1 <<(client_if - 1))) != 0) &&
                role == HCI_ROLE_SLAVE)
                is_bg_conn = true;
        }
    }
    return is_bg_conn;