summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorugo_yu <ugo_yu@htc.com>2016-06-03 18:04:24 +0800
committerAndre Eisenbach <eisenbach@google.com>2016-07-19 16:10:37 -0700
commit7592bcfe7a0be9dc4ffdfc3f29bf68fd68950418 (patch)
treee9aba20ff09e123eb0c134868eb140f119bb13f3
parentaf5b8248593c80acd8b1afb695eafe5801b44f7d (diff)
downloadandroid-system-bt-7592bcfe7a0be9dc4ffdfc3f29bf68fd68950418.tar.gz
android-system-bt-7592bcfe7a0be9dc4ffdfc3f29bf68fd68950418.tar.xz
GATT: Deregister notification when a GATT connection is closed
Precondition: 1. Pair with specific HOGP mouse. Steps: 1. Pair with HOGP mouse (iBuffalo BSMBB09DS) 2. Unpair the mouse. 3. Pair the mouse again. Failure: Pairing is successful, but the mouse won't connect. Root Cause: Some HOGP mice send notifications before the stack writes the client characteristic configuration descriptor. The Bluetooth stack doesn't deregister these notifiactions when disconnecting. Fix: Deregister notifications when the GATT connection closes. Fixes: 29111689 Change-Id: I520faeaa5fc396381cb248d3a2c49efbffa12261
-rw-r--r--bta/hh/bta_hh_le.c45
1 files changed, 41 insertions, 4 deletions
diff --git a/bta/hh/bta_hh_le.c b/bta/hh/bta_hh_le.c
index e6f854f..92b3c40 100644
--- a/bta/hh/bta_hh_le.c
+++ b/bta/hh/bta_hh_le.c
@@ -802,7 +802,7 @@ void bta_hh_le_register_input_notif(tBTA_HH_DEV_CB *p_dev_cb, UINT8 proto_mode,
if (p_rpt->uuid == GATT_UUID_HID_REPORT &&
p_rpt->client_cfg_value == BTA_GATT_CLT_CONFIG_NOTIFICATION)
{
- APPL_TRACE_DEBUG("---> Deregister Report ID: %d", p_rpt->rpt_id);
+ APPL_TRACE_DEBUG("%s ---> Deregister Report ID: %d", __func__, p_rpt->rpt_id);
BTA_GATTC_DeregisterForNotifications(bta_hh_cb.gatt_if, p_dev_cb->addr,
p_rpt->char_inst_id);
}
@@ -810,7 +810,7 @@ void bta_hh_le_register_input_notif(tBTA_HH_DEV_CB *p_dev_cb, UINT8 proto_mode,
else if (p_rpt->uuid == GATT_UUID_HID_BT_KB_INPUT ||
p_rpt->uuid == GATT_UUID_HID_BT_MOUSE_INPUT)
{
- APPL_TRACE_DEBUG("<--- Register Boot Report ID: %d", p_rpt->rpt_id);
+ APPL_TRACE_DEBUG("%s <--- Register Boot Report ID: %d", __func__, p_rpt->rpt_id);
BTA_GATTC_RegisterForNotifications(bta_hh_cb.gatt_if, p_dev_cb->addr,
p_rpt->char_inst_id);
}
@@ -822,14 +822,14 @@ void bta_hh_le_register_input_notif(tBTA_HH_DEV_CB *p_dev_cb, UINT8 proto_mode,
p_rpt->client_cfg_value == BTA_GATT_CLT_CONFIG_NOTIFICATION)
{
- APPL_TRACE_DEBUG("---> Deregister Boot Report ID: %d", p_rpt->rpt_id);
+ APPL_TRACE_DEBUG("%s ---> Deregister Boot Report ID: %d", __func__, p_rpt->rpt_id);
BTA_GATTC_DeregisterForNotifications(bta_hh_cb.gatt_if, p_dev_cb->addr,
p_rpt->char_inst_id);
}
else if (p_rpt->uuid == GATT_UUID_HID_REPORT &&
p_rpt->client_cfg_value == BTA_GATT_CLT_CONFIG_NOTIFICATION)
{
- APPL_TRACE_DEBUG("<--- Register Report ID: %d", p_rpt->rpt_id);
+ APPL_TRACE_DEBUG("%s <--- Register Report ID: %d", __func__, p_rpt->rpt_id);
BTA_GATTC_RegisterForNotifications(bta_hh_cb.gatt_if, p_dev_cb->addr,
p_rpt->char_inst_id);
}
@@ -842,6 +842,41 @@ void bta_hh_le_register_input_notif(tBTA_HH_DEV_CB *p_dev_cb, UINT8 proto_mode,
/*******************************************************************************
**
+** Function bta_hh_le_deregister_input_notif
+**
+** Description Deregister all notifications
+**
+*******************************************************************************/
+void bta_hh_le_deregister_input_notif(tBTA_HH_DEV_CB *p_dev_cb)
+{
+ tBTA_HH_LE_RPT *p_rpt = &p_dev_cb->hid_srvc.report[0];
+
+ for (UINT8 i = 0; i < BTA_HH_LE_RPT_MAX; i++, p_rpt++)
+ {
+ if (p_rpt->rpt_type == BTA_HH_RPTT_INPUT)
+ {
+ if (p_rpt->uuid == GATT_UUID_HID_REPORT &&
+ p_rpt->client_cfg_value == BTA_GATT_CLT_CONFIG_NOTIFICATION)
+ {
+ APPL_TRACE_DEBUG("%s ---> Deregister Report ID: %d", __func__, p_rpt->rpt_id);
+ BTA_GATTC_DeregisterForNotifications(bta_hh_cb.gatt_if, p_dev_cb->addr,
+ p_rpt->char_inst_id);
+ }
+ else if ((p_rpt->uuid == GATT_UUID_HID_BT_KB_INPUT ||
+ p_rpt->uuid == GATT_UUID_HID_BT_MOUSE_INPUT) &&
+ p_rpt->client_cfg_value == BTA_GATT_CLT_CONFIG_NOTIFICATION)
+ {
+ APPL_TRACE_DEBUG("%s ---> Deregister Boot Report ID: %d", __func__, p_rpt->rpt_id);
+ BTA_GATTC_DeregisterForNotifications(bta_hh_cb.gatt_if, p_dev_cb->addr,
+ p_rpt->char_inst_id);
+ }
+ }
+ }
+}
+
+
+/*******************************************************************************
+**
** Function bta_hh_le_open_cmpl
**
** Description HID over GATT connection sucessfully opened
@@ -2208,6 +2243,8 @@ void bta_hh_gatt_close(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
{
tBTA_HH_CBDATA disc_dat = {BTA_HH_OK, 0};
+ /* deregister all notification */
+ bta_hh_le_deregister_input_notif(p_cb);
/* finaliza device driver */
bta_hh_co_close(p_cb->hid_handle, p_cb->app_id);
/* update total conn number */