diff options
author | Andre Eisenbach <andre@broadcom.com> | 2013-05-15 04:55:08 -0700 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2013-08-14 00:40:44 +0000 |
commit | e1202caae4920139ea0cfed5c51f5f76b2dc8bc4 (patch) | |
tree | 4cf11db521cf31dd8c01effc546329113fb4bf43 /stack/gatt/gatt_utils.c | |
parent | f052217962d0c06392eb79687820c9469cd6a75a (diff) | |
download | android_system_bt-e1202caae4920139ea0cfed5c51f5f76b2dc8bc4.tar.gz android_system_bt-e1202caae4920139ea0cfed5c51f5f76b2dc8bc4.tar.bz2 android_system_bt-e1202caae4920139ea0cfed5c51f5f76b2dc8bc4.zip |
LE: Add GATT disable functions
This patch adds required disable functions to the GATT sub-system to
properly unregister with the stack. Without the disable functions in
place, turning Bluetooth off with a GATT device connected may lead to
unexpected behaviour and cause GATT to fail on sub-sequent stack
restarts.
Change-Id: I7cb80e96109e2c09882991298d0487b506f5ffdd
Diffstat (limited to 'stack/gatt/gatt_utils.c')
-rw-r--r-- | stack/gatt/gatt_utils.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/stack/gatt/gatt_utils.c b/stack/gatt/gatt_utils.c index 5470f4ef8..5b375b54f 100644 --- a/stack/gatt/gatt_utils.c +++ b/stack/gatt/gatt_utils.c @@ -2322,6 +2322,8 @@ BOOLEAN gatt_add_bg_dev_list(tGATT_REG *p_reg, BD_ADDR bd_addr, BOOLEAN is_init p_dev->gatt_if[i] = gatt_if; if (i == 0) ret = BTM_BleUpdateBgConnDev(TRUE, bd_addr); + else + ret = TRUE; break; } } @@ -2342,6 +2344,8 @@ BOOLEAN gatt_add_bg_dev_list(tGATT_REG *p_reg, BD_ADDR bd_addr, BOOLEAN is_init if (i == 0) ret = BTM_BleUpdateAdvWhitelist(TRUE, bd_addr); + else + ret = TRUE; break; } } @@ -2515,26 +2519,38 @@ void gatt_deregister_bgdev_list(tGATT_IF gatt_if) { tGATT_BG_CONN_DEV *p_dev_list = &gatt_cb.bgconn_dev[0]; UINT8 i , j, k; + tGATT_REG *p_reg = gatt_get_regcb(gatt_if); + /* update the BG conn device list */ for (i = 0 ; i <GATT_MAX_BG_CONN_DEV; i ++, p_dev_list ++ ) { if (p_dev_list->in_use) { for (j = 0; j < GATT_MAX_APPS; j ++) { - if (p_dev_list->gatt_if[j] == 0) + if (p_dev_list->gatt_if[j] == 0 && p_dev_list->listen_gif[j] == 0) break; - else if (p_dev_list->gatt_if[j] == gatt_if) + + if (p_dev_list->gatt_if[j] == gatt_if) { for (k = j + 1; k < GATT_MAX_APPS; k ++) p_dev_list->gatt_if[k - 1] = p_dev_list->gatt_if[k]; if (p_dev_list->gatt_if[0] == 0) - { BTM_BleUpdateBgConnDev(FALSE, p_dev_list->remote_bda); - memset(p_dev_list, 0, sizeof(tGATT_BG_CONN_DEV)); - break; - } + } + + if (p_dev_list->listen_gif[j] == gatt_if) + { + p_dev_list->listen_gif[j] = 0; + p_reg->listening --; + + /* move all element behind one forward */ + for (k = j + 1; k < GATT_MAX_APPS; k ++) + p_dev_list->listen_gif[k - 1] = p_dev_list->listen_gif[k]; + + if (p_dev_list->listen_gif[0] == 0) + BTM_BleUpdateAdvWhitelist(FALSE, p_dev_list->remote_bda); } } } |