summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Pawlowski <jpawlowski@google.com>2016-07-18 09:06:49 -0700
committerAndre Eisenbach <eisenbach@google.com>2016-08-18 20:50:25 +0000
commit8ed030ff4a36b248e1b115f94ddd4650d4b5e360 (patch)
tree28734d6f779c05561b1e5128a119ad6519dda032
parent3b9c4610e02e45bb534f31cce127656520267f62 (diff)
downloadandroid-system-bt-8ed030ff4a36b248e1b115f94ddd4650d4b5e360.tar.gz
android-system-bt-8ed030ff4a36b248e1b115f94ddd4650d4b5e360.tar.xz
Make gatt_attr use opportunistic connection
This patch creates new connection mode - opportunistic connection. When such connection is made, no call to gatt_update_app_hold_link_status will be made when it's started. This means that connecting and disconnecting in this mode won't trigger disconnect timer. When other, app creates regular connection and then disconnects, the physical connection might get disconnected. Opportunistic connection is used only for code setting CCC right now. Bug: 30186455 Change-Id: Ia5be7682b6c3dcb4993060f818dee603aef3e19e
-rw-r--r--bta/gatt/bta_gattc_act.c4
-rw-r--r--bta/gatt/bta_gatts_act.c2
-rw-r--r--btif/src/btif_gatt_test.c2
-rw-r--r--stack/gap/gap_ble.c2
-rw-r--r--stack/gatt/gatt_api.c5
-rw-r--r--stack/gatt/gatt_attr.c2
-rw-r--r--stack/gatt/gatt_int.h2
-rw-r--r--stack/gatt/gatt_main.c9
-rw-r--r--stack/include/gatt_api.h8
-rw-r--r--stack/srvc/srvc_dis.c2
10 files changed, 24 insertions, 14 deletions
diff --git a/bta/gatt/bta_gattc_act.c b/bta/gatt/bta_gattc_act.c
index 388d9a4..01b06b8 100644
--- a/bta/gatt/bta_gattc_act.c
+++ b/bta/gatt/bta_gattc_act.c
@@ -518,7 +518,7 @@ void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
/* 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))
+ true, p_data->api_conn.transport, false))
{
APPL_TRACE_ERROR("Connection open failure");
@@ -558,7 +558,7 @@ void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg
if (bta_gattc_mark_bg_conn(p_data->client_if, p_data->remote_bda, TRUE, FALSE))
{
/* always call open to hold a connection */
- if (!GATT_Connect(p_data->client_if, p_data->remote_bda, FALSE, p_data->transport))
+ if (!GATT_Connect(p_data->client_if, p_data->remote_bda, false, p_data->transport, false))
{
uint8_t *bda = (uint8_t *)p_data->remote_bda;
status = BTA_GATT_ERROR;
diff --git a/bta/gatt/bta_gatts_act.c b/bta/gatt/bta_gatts_act.c
index 4c35b0c..3f357bf 100644
--- a/bta/gatt/bta_gatts_act.c
+++ b/bta/gatt/bta_gatts_act.c
@@ -689,7 +689,7 @@ void bta_gatts_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
{
/* should always get the connection ID */
if (GATT_Connect(p_rcb->gatt_if, p_msg->api_open.remote_bda,
- p_msg->api_open.is_direct, p_msg->api_open.transport))
+ p_msg->api_open.is_direct, p_msg->api_open.transport, false))
{
status = BTA_GATT_OK;
diff --git a/btif/src/btif_gatt_test.c b/btif/src/btif_gatt_test.c
index 349674e..ab1c1d2 100644
--- a/btif/src/btif_gatt_test.c
+++ b/btif/src/btif_gatt_test.c
@@ -240,7 +240,7 @@ bt_status_t btif_gattc_test_command_impl(uint16_t command, btgatt_test_params_t*
if (params->u1 == BT_DEVICE_TYPE_BLE)
BTM_SecAddBleDevice(params->bda1->address, NULL, BT_DEVICE_TYPE_BLE, params->u2);
- if ( !GATT_Connect(test_cb.gatt_if, params->bda1->address, TRUE, BT_TRANSPORT_LE) )
+ if ( !GATT_Connect(test_cb.gatt_if, params->bda1->address, true, BT_TRANSPORT_LE, false) )
{
LOG_ERROR(LOG_TAG, "%s: GATT_Connect failed!", __FUNCTION__);
}
diff --git a/stack/gap/gap_ble.c b/stack/gap/gap_ble.c
index d92665a..e14b13e 100644
--- a/stack/gap/gap_ble.c
+++ b/stack/gap/gap_ble.c
@@ -708,7 +708,7 @@ BOOLEAN gap_ble_accept_cl_operation(BD_ADDR peer_bda, UINT16 uuid, tGAP_BLE_CMPL
p_clcb->connected = TRUE;
/* hold the link here */
- if (!GATT_Connect(gap_cb.gatt_if, p_clcb->bda, TRUE, BT_TRANSPORT_LE))
+ if (!GATT_Connect(gap_cb.gatt_if, p_clcb->bda, TRUE, BT_TRANSPORT_LE, false))
return started;
/* enqueue the request */
diff --git a/stack/gatt/gatt_api.c b/stack/gatt/gatt_api.c
index b8c45d3..597dc63 100644
--- a/stack/gatt/gatt_api.c
+++ b/stack/gatt/gatt_api.c
@@ -1357,7 +1357,8 @@ void GATT_StartIf (tGATT_IF gatt_if)
** Returns TRUE if connection started; FALSE if connection start failure.
**
*******************************************************************************/
-BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, BOOLEAN is_direct, tBT_TRANSPORT transport)
+BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, BOOLEAN is_direct,
+ tBT_TRANSPORT transport, BOOLEAN opportunistic)
{
tGATT_REG *p_reg;
BOOLEAN status = FALSE;
@@ -1372,7 +1373,7 @@ BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, BOOLEAN is_direct, tBT_
}
if (is_direct)
- status = gatt_act_connect (p_reg, bd_addr, transport);
+ status = gatt_act_connect (p_reg, bd_addr, transport, opportunistic);
else
{
if (transport == BT_TRANSPORT_LE)
diff --git a/stack/gatt/gatt_attr.c b/stack/gatt/gatt_attr.c
index 596ea9b..74f0f35 100644
--- a/stack/gatt/gatt_attr.c
+++ b/stack/gatt/gatt_attr.c
@@ -457,7 +457,7 @@ void GATT_ConfigServiceChangeCCC (BD_ADDR remote_bda, BOOLEAN enable, tBT_TRANSP
p_clcb->connected = TRUE;
}
/* hold the link here */
- GATT_Connect(gatt_cb.gatt_if, remote_bda, TRUE, transport);
+ GATT_Connect(gatt_cb.gatt_if, remote_bda, TRUE, transport, true);
p_clcb->ccc_stage = GATT_SVC_CHANGED_CONNECTING;
if (!p_clcb->connected)
diff --git a/stack/gatt/gatt_int.h b/stack/gatt/gatt_int.h
index 56760e9..1f97cb7 100644
--- a/stack/gatt/gatt_int.h
+++ b/stack/gatt/gatt_int.h
@@ -532,7 +532,7 @@ extern void gatt_free(void);
/* from gatt_main.c */
extern BOOLEAN gatt_disconnect (tGATT_TCB *p_tcb);
-extern BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBT_TRANSPORT transport);
+extern BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBT_TRANSPORT transport, bool opportunistic);
extern BOOLEAN gatt_connect (BD_ADDR rem_bda, tGATT_TCB *p_tcb, tBT_TRANSPORT transport);
extern void gatt_data_process (tGATT_TCB *p_tcb, BT_HDR *p_buf);
extern void gatt_update_app_use_link_flag ( tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLEAN is_add, BOOLEAN check_acl_link);
diff --git a/stack/gatt/gatt_main.c b/stack/gatt/gatt_main.c
index 8bbd650..4a7fa6e 100644
--- a/stack/gatt/gatt_main.c
+++ b/stack/gatt/gatt_main.c
@@ -370,7 +370,8 @@ void gatt_update_app_use_link_flag (tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLEAN
** Returns void.
**
*******************************************************************************/
-BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBT_TRANSPORT transport)
+BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr,
+ tBT_TRANSPORT transport, BOOLEAN opportunistic)
{
BOOLEAN ret = FALSE;
tGATT_TCB *p_tcb;
@@ -417,7 +418,11 @@ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBT_TRANSPORT trans
if (ret)
{
- gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, TRUE, FALSE);
+ if (!opportunistic)
+ gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, TRUE, FALSE);
+ else
+ GATT_TRACE_DEBUG("%s: connection is opportunistic, not updating app usage",
+ __func__);
}
return ret;
diff --git a/stack/include/gatt_api.h b/stack/include/gatt_api.h
index a042bb9..182b5ba 100644
--- a/stack/include/gatt_api.h
+++ b/stack/include/gatt_api.h
@@ -1070,14 +1070,18 @@ extern void GATT_StartIf (tGATT_IF gatt_if);
**
** Parameters gatt_if: applicaiton interface
** bd_addr: peer device address.
-** is_direct: is a direct conenection or a background auto connection
+** is_direct: is a direct connection or a background auto connection
** transport : Physical transport for GATT connection (BR/EDR or LE)
+** opportunistic: will not keep device connected if other apps
+** disconnect, will not update connected apps counter, when
+** disconnected won't cause physical disconnection.
**
** Returns TRUE if connection started; FALSE if connection start failure.
**
*******************************************************************************/
extern BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr,
- BOOLEAN is_direct, tBT_TRANSPORT transport);
+ BOOLEAN is_direct, tBT_TRANSPORT transport,
+ BOOLEAN opportunistic);
/*******************************************************************************
diff --git a/stack/srvc/srvc_dis.c b/stack/srvc/srvc_dis.c
index c17c660..12ae5a5 100644
--- a/stack/srvc/srvc_dis.c
+++ b/stack/srvc/srvc_dis.c
@@ -472,7 +472,7 @@ BOOLEAN DIS_ReadDISInfo(BD_ADDR peer_bda, tDIS_READ_CBACK *p_cback, tDIS_ATTR_MA
if (conn_id == GATT_INVALID_CONN_ID)
{
- return GATT_Connect(srvc_eng_cb.gatt_if, peer_bda, TRUE, BT_TRANSPORT_LE);
+ return GATT_Connect(srvc_eng_cb.gatt_if, peer_bda, TRUE, BT_TRANSPORT_LE, false);
}
return dis_gatt_c_read_dis_req(conn_id);