summaryrefslogtreecommitdiffstats
path: root/btif
diff options
context:
space:
mode:
authorzzy <zhenye@broadcom.com>2012-08-29 11:08:24 -0700
committerMatthew Xie <mattx@google.com>2012-08-29 19:32:00 -0700
commit1c613c3623cce7402f3f7b56956a1386a54c13f3 (patch)
treeedbfae4cabb1e13a5ad577e5c143500bcc6d9145 /btif
parentf8de9838ecff656343af5cb9c692b4944e6fe716 (diff)
downloadexternal_bluetooth_bluedroid-1c613c3623cce7402f3f7b56956a1386a54c13f3.zip
external_bluetooth_bluedroid-1c613c3623cce7402f3f7b56956a1386a54c13f3.tar.gz
external_bluetooth_bluedroid-1c613c3623cce7402f3f7b56956a1386a54c13f3.tar.bz2
Fixed the issue that local adapter name cannot be changed and lost last bonded device 2
Root case: the adapter name property set/get with wrong section & key; The end condition of the loop to load bonded device is wrong removed the wrong return value check when loading blacklist Change-Id: Ib02d472311cd872befd17e6d2445f649f53f02fb
Diffstat (limited to 'btif')
-rw-r--r--btif/src/btif_config.c10
-rwxr-xr-xbtif/src/btif_storage.c30
2 files changed, 21 insertions, 19 deletions
diff --git a/btif/src/btif_config.c b/btif/src/btif_config.c
index 8856b5a..2470110 100644
--- a/btif/src/btif_config.c
+++ b/btif/src/btif_config.c
@@ -541,9 +541,10 @@ static cfg_node* find_node(const char* section, const char* key, const char* nam
static short find_next_node(const cfg_node* p, short start, char* name, int* bytes)
{
asrt(0 <= start && start < GET_CHILD_MAX_COUNT(p));
- //debug("in");
- //dump_node("parent", p);
+ //debug("in, start:%d, max child count:%d", start, GET_CHILD_MAX_COUNT(p));
+ //dump_node("find_next_node, parent", p);
short next = -1;
+ if(name) *name = 0;
if(0 <= start && start < GET_CHILD_MAX_COUNT(p))
{
int i;
@@ -752,8 +753,9 @@ static void cfg_test_load()
kname_size = sizeof(kname);
kname[0] = 0;
kpos = 0;
- while((kpos = btif_config_next_key(kpos, "Remote Devices", kname, &kname_size)) != -1)
+ do
{
+ kpos = btif_config_next_key(kpos, "Remote Devices", kname, &kname_size);
debug("Remote devices:%s, size:%d", kname, kname_size);
vpos = 0;
vname[0] = 0;
@@ -772,7 +774,7 @@ static void cfg_test_load()
}
kname[0] = 0;
kname_size = sizeof(kname);
- }
+ } while(kpos != -1);
debug("out");
}
static void cfg_test_write()
diff --git a/btif/src/btif_storage.c b/btif/src/btif_storage.c
index 0110d04..0596ccd 100755
--- a/btif/src/btif_storage.c
+++ b/btif/src/btif_storage.c
@@ -282,8 +282,11 @@ static int prop2cfg(bt_bdaddr_t *remote_bd_addr, bt_property_t *prop)
case BT_PROPERTY_BDNAME:
strncpy(value, (char*)prop->val, prop->len);
value[prop->len]='\0';
- btif_config_set_str("Remote", bdstr,
+ if(remote_bd_addr)
+ btif_config_set_str("Remote", bdstr,
BTIF_STORAGE_PATH_REMOTE_NAME, value);
+ else btif_config_set_str("Local", "Adapter",
+ BTIF_STORAGE_KEY_ADAPTER_NAME, value);
break;
case BT_PROPERTY_REMOTE_FRIENDLY_NAME:
strncpy(value, (char*)prop->val, prop->len);
@@ -351,8 +354,11 @@ static int cfg2prop(bt_bdaddr_t *remote_bd_addr, bt_property_t *prop)
case BT_PROPERTY_BDNAME:
{
int len = prop->len;
- ret = btif_config_get_str("Remote", bdstr,
+ if(remote_bd_addr)
+ ret = btif_config_get_str("Remote", bdstr,
BTIF_STORAGE_PATH_REMOTE_NAME, (char*)prop->val, &len);
+ else ret = btif_config_get_str("Local", "Adapter",
+ BTIF_STORAGE_KEY_ADAPTER_NAME, (char*)prop->val, &len);
if(ret && len && len <= prop->len)
prop->len = len - 1;
else
@@ -440,8 +446,9 @@ static bt_status_t btif_in_fetch_bonded_devices(btif_bonded_devices_t *p_bonded_
kname_size = sizeof(kname);
kname[0] = 0;
kpos = 0;
- while((kpos = btif_config_next_key(kpos, "Remote", kname, &kname_size)) != -1)
+ do
{
+ kpos = btif_config_next_key(kpos, "Remote", kname, &kname_size);
debug("Remote device:%s, size:%d", kname, kname_size);
int type = BTIF_CFG_TYPE_BIN;
LINK_KEY link_key;
@@ -470,7 +477,7 @@ static bt_status_t btif_in_fetch_bonded_devices(btif_bonded_devices_t *p_bonded_
else debug("Remote device:%s, no link key", kname);
kname_size = sizeof(kname);
kname[0] = 0;
- }
+ } while(kpos != -1);
debug("out");
return BT_STATUS_SUCCESS;
}
@@ -527,9 +534,6 @@ static int hex_str_to_int(const char* str, int size)
bt_status_t btif_storage_get_adapter_property(bt_property_t *property)
{
- /* initialize property->len */
- property->len = 0;
-
/* Special handling for adapter BD_ADDR and BONDED_DEVICES */
if (property->type == BT_PROPERTY_BDADDR)
{
@@ -931,8 +935,9 @@ bt_status_t btif_storage_load_bonded_hid_info(void)
kname[0] = 0;
kpos = 0;
memset(&dscp_info, 0, sizeof(dscp_info));
- while((kpos = btif_config_next_key(kpos, "Remote", kname, &kname_size)) != -1)
+ do
{
+ kpos = btif_config_next_key(kpos, "Remote", kname, &kname_size);
debug("Remote device:%s, size:%d", kname, kname_size);
int value;
if(btif_config_get_int("Remote", kname, "HidAttrMask", &value))
@@ -974,7 +979,7 @@ bt_status_t btif_storage_load_bonded_hid_info(void)
app_id, dscp_info);
}
}
- }
+ } while(kpos != -1);
return BT_STATUS_SUCCESS;
}
@@ -1268,7 +1273,7 @@ bt_status_t btif_storage_write_hl_mdl_data(UINT8 app_idx, char *value, int value
bt_status_t btif_storage_load_autopair_device_list()
{
char *key_name, *key_value;
- int ret , i=0;
+ int i=0;
char linebuf[BTIF_STORAGE_MAX_LINE_SZ];
char *line;
FILE *fp;
@@ -1277,11 +1282,6 @@ bt_status_t btif_storage_load_autopair_device_list()
{
/* first time loading of auto pair blacklist configuration */
- if (ret < 0)
- {
- ALOGE("%s: Failed to create dynamic auto pair blacklist", __FUNCTION__);
- return BT_STATUS_FAIL;
- }
fp = fopen (BTIF_AUTO_PAIR_CONF_FILE, "r");
if (fp == NULL)