From a63cadbdc349139548af16d481f2ac1d6d219a74 Mon Sep 17 00:00:00 2001 From: Matadeen Mishra Date: Fri, 29 Apr 2016 20:45:34 +0530 Subject: [PATCH] Bluetooth: GAP: Don't update short name if the device paired Don't notify the BT APP about the shortened device name which will be part of EIR response,incase of device is already paired. Incase if the alias name present for that device, it will notify th BT APP alias name as the actual device name. CRs-Fixed: 576911 Change-Id: Ia64e1e90aae8c4e0cc52643ce3bbbb1332fe5b66 --- btif/include/btif_storage.h | 12 ++++++++++++ btif/src/btif_dm.c | 46 +++++++++++++++++++++++++++++++++++++++++---- btif/src/btif_storage.c | 21 +++++++++++++++++++++ 3 files changed, 75 insertions(+), 4 deletions(-) diff --git a/btif/include/btif_storage.h b/btif/include/btif_storage.h index bc1060c26..2da8bd121 100644 --- a/btif/include/btif_storage.h +++ b/btif/include/btif_storage.h @@ -138,6 +138,18 @@ bt_status_t btif_storage_remove_bonded_device(bt_bdaddr_t *remote_bd_addr); /******************************************************************************* ** +** Function btif_storage_is_device_bonded +** +* Description BTIF storage API - checks if device present in bonded list +** +** Returns TRUE if the device is bonded, +** FALSE otherwise +** +*******************************************************************************/ +BOOLEAN btif_storage_is_device_bonded(bt_bdaddr_t *remote_bd_addr); + +/******************************************************************************* +** ** Function btif_storage_remove_bonded_device ** ** Description BTIF storage API - Deletes the bonded device from NVRAM diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c index 08c28a69d..850c64a68 100644 --- a/btif/src/btif_dm.c +++ b/btif/src/btif_dm.c @@ -350,6 +350,36 @@ bt_status_t btif_in_execute_service_request(tBTA_SERVICE_ID service_id, return BT_STATUS_SUCCESS; } + +/******************************************************************************* +** +** Function check_eir_is_remote_name_short +** +** Description Check if remote name is shortened +** +** Returns TRUE if remote name found +** else FALSE +** +*******************************************************************************/ +static BOOLEAN check_eir_is_remote_name_short(tBTA_DM_SEARCH *p_search_data) +{ + UINT8 *p_eir_remote_name = NULL; + UINT8 remote_name_len = 0; + + /* Check EIR for remote name and services */ + if (p_search_data->inq_res.p_eir) + { + p_eir_remote_name = BTM_CheckEirData(p_search_data->inq_res.p_eir, + BTM_EIR_SHORTENED_LOCAL_NAME_TYPE, &remote_name_len); + + if (p_eir_remote_name) + { + return TRUE; + } + } + return FALSE; +} + /******************************************************************************* ** ** Function check_eir_remote_name @@ -1377,10 +1407,18 @@ static void btif_dm_search_devices_evt (UINT16 event, char *p_param) /* Don't send BDNAME if it is empty */ if (bdname.name[0]) { - BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties], - BT_PROPERTY_BDNAME, - strlen((char *)bdname.name), &bdname); - num_properties++; + if((check_eir_is_remote_name_short(p_search_data) == TRUE) && + (btif_storage_is_device_bonded(&bdaddr) == TRUE)) + { + BTIF_TRACE_DEBUG("%s Don't update about the device name ", __FUNCTION__); + } + else + { + BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties], + BT_PROPERTY_BDNAME, + strlen((char *)bdname.name), &bdname); + num_properties++; + } } /* DEV_CLASS */ diff --git a/btif/src/btif_storage.c b/btif/src/btif_storage.c index 82d377d75..61a67ddd0 100644 --- a/btif/src/btif_storage.c +++ b/btif/src/btif_storage.c @@ -831,6 +831,27 @@ bt_status_t btif_storage_remove_bonded_device(bt_bdaddr_t *remote_bd_addr) /******************************************************************************* ** +** Function btif_storage_is_device_bonded +** +** Description BTIF storage API - checks if device present in bonded list +** +** Returns TRUE if the device is bonded +** FALSE otherwise +** +*******************************************************************************/ +BOOLEAN btif_storage_is_device_bonded(bt_bdaddr_t *remote_bd_addr) +{ + bdstr_t bdstr; + bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr)); + if((btif_config_exist(bdstr, "LinkKey")) && + (btif_config_exist(bdstr, "LinkKeyType"))) + return TRUE; + else + return TRUE; +} + +/******************************************************************************* +** ** Function btif_storage_load_bonded_devices ** ** Description BTIF storage API - Loads all the bonded devices from NVRAM -- 2.11.0