From dd2021c65b8a1a14e67e4f23628b3e15faf9fdcc Mon Sep 17 00:00:00 2001 From: Tucker Sylvestro Date: Thu, 18 Jun 2015 18:14:25 -0400 Subject: [PATCH] Always ACK indications in the event of an error This works around a race condition in which the just-connected remote device sends the local device an indication before the appropriate handle/device/etc. has been added to the cache. Previously we were dropping that indication, which led to the remote device timing out and disconnecting some time after the connection had been successfully established. Bug: 21026847 Change-Id: Iea43e7c93e48b5e7a7e78a1c3fb591d6fe972fc3 --- bta/gatt/bta_gattc_act.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/bta/gatt/bta_gattc_act.c b/bta/gatt/bta_gattc_act.c index b07c47bc7..be5e8e125 100755 --- a/bta/gatt/bta_gattc_act.c +++ b/bta/gatt/bta_gattc_act.c @@ -2043,19 +2043,25 @@ void bta_gattc_process_indicate(UINT16 conn_id, tGATTC_OPTYPE op, tGATT_CL_COMPL if (!GATT_GetConnectionInfor(conn_id, &gatt_if, remote_bda, &transport)) { - APPL_TRACE_ERROR("indication/notif for unknown app"); + APPL_TRACE_ERROR("%s indication/notif for unknown app", __func__); + if (op == GATTC_OPTYPE_INDICATION) + GATTC_SendHandleValueConfirm(conn_id, handle); return; } if ((p_clrcb = bta_gattc_cl_get_regcb(gatt_if)) == NULL) { - APPL_TRACE_ERROR("indication/notif for unregistered app"); + APPL_TRACE_ERROR("%s indication/notif for unregistered app", __func__); + if (op == GATTC_OPTYPE_INDICATION) + GATTC_SendHandleValueConfirm(conn_id, handle); return; } if ((p_srcb = bta_gattc_find_srcb(remote_bda)) == NULL) { - APPL_TRACE_ERROR("indication/notif for unknown device, ignore"); + APPL_TRACE_ERROR("%s indication/notif for unknown device, ignore", __func__); + if (op == GATTC_OPTYPE_INDICATION) + GATTC_SendHandleValueConfirm(conn_id, handle); return; } @@ -2094,15 +2100,17 @@ void bta_gattc_process_indicate(UINT16 conn_id, tGATTC_OPTYPE op, tGATT_CL_COMPL /* no one intersted and need ack? */ else if (op == GATTC_OPTYPE_INDICATION) { - APPL_TRACE_DEBUG("no one interested, ack now"); + APPL_TRACE_DEBUG("%s no one interested, ack now", __func__); GATTC_SendHandleValueConfirm(conn_id, handle); } } } else { - APPL_TRACE_ERROR("Indi/Notif for Unknown handle[0x%04x], can not find in local cache.", - handle); + APPL_TRACE_ERROR("%s Indi/Notif for Unknown handle[0x%04x], can not find in local cache.", + __func__, handle); + if (op == GATTC_OPTYPE_INDICATION) + GATTC_SendHandleValueConfirm(conn_id, handle); } } /******************************************************************************* -- 2.11.0