Connections created by GAP profile should be ephemeral, and not
interfere with the connection timeout.
When a device is bonded, listing services through DM would cause a
DM APP to create a connection, and later to disconnect. This causes
connection to timeout. In case a device was already connected, this
should not happen.
Bug:
34951749
Test: manual
Change-Id: Iad04fd9eed4c664f35131442e3f83a704497a067
(cherry picked from commit
16bb48b320cde54a1a06a525f4d9be1421689649)
memset(bta_dm_search_cb.pending_close_bda, 0, BD_ADDR_LEN);
alarm_cancel(bta_dm_search_cb.gatt_close_timer);
btm_dm_start_disc_gatt_services(bta_dm_search_cb.conn_id);
- } else
- BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, true,
- BTA_GATT_TRANSPORT_LE);
+ } else {
+ if (BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_LE)) {
+ BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, true,
+ BTA_GATT_TRANSPORT_LE, true);
+ } else {
+ BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, true,
+ BTA_GATT_TRANSPORT_LE, false);
+ }
+ }
}
/*******************************************************************************
/* open/hold a connection */
if (!GATT_Connect(p_clcb->p_rcb->client_if, p_data->api_conn.remote_bda, true,
- p_data->api_conn.transport, false,
+ p_data->api_conn.transport, p_data->api_conn.opportunistic,
p_data->api_conn.initiating_phys)) {
APPL_TRACE_ERROR("Connection open failure");
* transport: Transport to be used for GATT connection
* (BREDR/LE)
* initiating_phys: LE PHY to use, optional
+ * opportunistic: wether the connection shall be opportunistic,
+ * and don't impact the disconnection timer
*
******************************************************************************/
void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, bool is_direct,
- tBTA_GATT_TRANSPORT transport) {
+ tBTA_GATT_TRANSPORT transport, bool opportunistic) {
uint8_t phy = controller_get_interface()->get_le_all_initiating_phys();
- BTA_GATTC_Open(client_if, remote_bda, is_direct, transport, phy);
+ BTA_GATTC_Open(client_if, remote_bda, is_direct, transport, phy,
+ opportunistic);
}
void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, bool is_direct,
- tBTA_GATT_TRANSPORT transport, uint8_t initiating_phys) {
+ tBTA_GATT_TRANSPORT transport, uint8_t initiating_phys,
+ bool opportunistic) {
tBTA_GATTC_API_OPEN* p_buf =
(tBTA_GATTC_API_OPEN*)osi_malloc(sizeof(tBTA_GATTC_API_OPEN));
p_buf->is_direct = is_direct;
p_buf->transport = transport;
p_buf->initiating_phys = initiating_phys;
+ p_buf->opportunistic = opportunistic;
memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN);
bta_sys_sendmsg(p_buf);
bool is_direct;
tBTA_TRANSPORT transport;
uint8_t initiating_phys;
+ bool opportunistic;
} tBTA_GATTC_API_OPEN;
typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN;
bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(p_cb->hid_handle)] = p_cb->index;
p_cb->in_use = true;
- BTA_GATTC_Open(bta_hh_cb.gatt_if, remote_bda, true, BTA_GATT_TRANSPORT_LE);
+ BTA_GATTC_Open(bta_hh_cb.gatt_if, remote_bda, true, BTA_GATT_TRANSPORT_LE,
+ false);
}
/*******************************************************************************
if (/*p_cb->dscp_info.flag & BTA_HH_LE_NORMAL_CONN &&*/
!p_cb->in_bg_conn && to_add) {
/* add device into BG connection to accept remote initiated connection */
- BTA_GATTC_Open(bta_hh_cb.gatt_if, p_cb->addr, false, BTA_GATT_TRANSPORT_LE);
+ BTA_GATTC_Open(bta_hh_cb.gatt_if, p_cb->addr, false, BTA_GATT_TRANSPORT_LE,
+ false);
p_cb->in_bg_conn = true;
BTA_DmBleStartAutoConn();
*
******************************************************************************/
extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda,
- bool is_direct, tBTA_GATT_TRANSPORT transport);
+ bool is_direct, tBTA_GATT_TRANSPORT transport,
+ bool opportunistic);
extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda,
bool is_direct, tBTA_GATT_TRANSPORT transport,
- uint8_t initiating_phys);
+ uint8_t initiating_phys, bool opportunistic);
/*******************************************************************************
*
BT_TRANSPORT_LE))
p_clcb->connected = true;
- /* hold the link here */
- if (!GATT_Connect(gap_cb.gatt_if, p_clcb->bda, true, BT_TRANSPORT_LE, false))
+ if (!GATT_Connect(gap_cb.gatt_if, p_clcb->bda, true, BT_TRANSPORT_LE, true))
return started;
/* enqueue the request */