From 377cb1407ee6ee1ff91b15bfa7052abed1023d18 Mon Sep 17 00:00:00 2001 From: Sunny Kapdi Date: Wed, 20 Nov 2013 14:41:41 -0800 Subject: [PATCH] Bluetooth: Cleanup bt_config.xml during BLE Scan BLE Scan needs to clean up the bt_config.xml periodically so that new entries could be added to bt_config.xml. Also, there is no need to add BLE Random bd_addr to the bt_config.xml Change-Id: I00ba2e50dd39a021099052cb569786f6cb2cc8b9 b/12912008 --- btif/include/btif_storage.h | 1 + btif/src/btif_gatt_client.c | 27 ++++++++++++++++++++++++--- btif/src/btif_storage.c | 3 +-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/btif/include/btif_storage.h b/btif/include/btif_storage.h index 41507fbf8..951b376ba 100644 --- a/btif/include/btif_storage.h +++ b/btif/include/btif_storage.h @@ -30,6 +30,7 @@ #define BTIF_STORAGE_FILL_PROPERTY(p_prop, t, l, p_v) \ (p_prop)->type = t;(p_prop)->len = l; (p_prop)->val = (p_v); +#define BTIF_STORAGE_MAX_ALLOWED_REMOTE_DEVICE 512 /******************************************************************************* ** Functions diff --git a/btif/src/btif_gatt_client.c b/btif/src/btif_gatt_client.c index 64cd97670..524052f0c 100644 --- a/btif/src/btif_gatt_client.c +++ b/btif/src/btif_gatt_client.c @@ -463,10 +463,31 @@ static void btif_gattc_upstreams_evt(uint16_t event, char* p_param) case BTIF_GATT_OBSERVE_EVT: { btif_gattc_cb_t *p_btif_cb = (btif_gattc_cb_t*)p_param; - if (!btif_gattc_find_bdaddr(p_btif_cb->bd_addr.address)) + uint8_t remote_name_len; + uint8_t *p_eir_remote_name=NULL; + + p_eir_remote_name = BTA_CheckEirData(p_btif_cb->value, + BTM_EIR_COMPLETE_LOCAL_NAME_TYPE, &remote_name_len); + + if(p_eir_remote_name == NULL) { - btif_gattc_add_remote_bdaddr(p_btif_cb->bd_addr.address, p_btif_cb->addr_type); - btif_gattc_update_properties(p_btif_cb); + p_eir_remote_name = BTA_CheckEirData(p_btif_cb->value, + BT_EIR_SHORTENED_LOCAL_NAME_TYPE, &remote_name_len); + } + + if ((p_btif_cb->addr_type != BLE_ADDR_RANDOM) || (p_eir_remote_name)) + { + if (!btif_gattc_find_bdaddr(p_btif_cb->bd_addr.address)) + { + static const char* exclude_filter[] = + {"LinkKey", "LE_KEY_PENC", "LE_KEY_PID", "LE_KEY_PCSRK", "LE_KEY_LENC", "LE_KEY_LCSRK"}; + + btif_gattc_add_remote_bdaddr(p_btif_cb->bd_addr.address, p_btif_cb->addr_type); + btif_gattc_update_properties(p_btif_cb); + btif_config_filter_remove("Remote", exclude_filter, sizeof(exclude_filter)/sizeof(char*), + BTIF_STORAGE_MAX_ALLOWED_REMOTE_DEVICE); + } + } HAL_CBACK(bt_gatt_callbacks, client->scan_result_cb, &p_btif_cb->bd_addr, p_btif_cb->rssi, p_btif_cb->value); diff --git a/btif/src/btif_storage.c b/btif/src/btif_storage.c index 644fd1cba..83dbbeae1 100644 --- a/btif/src/btif_storage.c +++ b/btif/src/btif_storage.c @@ -38,7 +38,7 @@ #define LOG_TAG "BTIF_STORAGE" #include "btif_api.h" - +#include "btif_storage.h" #include "btif_util.h" #include "bd.h" #include "gki.h" @@ -150,7 +150,6 @@ #define BTIF_STORAGE_HL_APP_DATA "hl_app_data_" #define BTIF_STORAGE_HL_APP_MDL_DATA "hl_app_mdl_data_" -#define BTIF_STORAGE_MAX_ALLOWED_REMOTE_DEVICE 512 /************************************************************************************ ** Local type definitions ************************************************************************************/ -- 2.11.0