summaryrefslogtreecommitdiffstats
path: root/btif
diff options
context:
space:
mode:
Diffstat (limited to 'btif')
-rwxr-xr-x[-rw-r--r--]btif/src/btif_core.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/btif/src/btif_core.c b/btif/src/btif_core.c
index 29e493d..3440685 100644..100755
--- a/btif/src/btif_core.c
+++ b/btif/src/btif_core.c
@@ -342,17 +342,9 @@ static void btif_fetch_local_bdaddr(bt_bdaddr_t *local_addr)
{
char val[256];
uint8_t valid_bda = FALSE;
+ int val_size = 0;
const uint8_t null_bdaddr[BD_ADDR_LEN] = {0,0,0,0,0,0};
- BTIF_TRACE_DEBUG1("Look for bdaddr storage path in prop %s", PROPERTY_BT_BDADDR_PATH);
- int val_size = sizeof(val);
- if(btif_config_get_str("Local", "Adapter", "Address", val, &val_size))
- {
- str2bd(val, local_addr);
- BTIF_TRACE_DEBUG1("local bdaddr from bt_config.xml is %s", val);
- return;
- }
-
/* Get local bdaddr storage path from property */
if (property_get(PROPERTY_BT_BDADDR_PATH, val, NULL))
{
@@ -378,6 +370,18 @@ static void btif_fetch_local_bdaddr(bt_bdaddr_t *local_addr)
}
}
+ if(!valid_bda)
+ {
+ val_size = sizeof(val);
+ BTIF_TRACE_DEBUG1("Look for bdaddr storage path in prop %s", PROPERTY_BT_BDADDR_PATH);
+ if(btif_config_get_str("Local", "Adapter", "Address", val, &val_size))
+ {
+ str2bd(val, local_addr);
+ BTIF_TRACE_DEBUG1("local bdaddr from bt_config.xml is %s", val);
+ return;
+ }
+ }
+
/* No factory BDADDR found. Look for previously generated random BDA */
if ((!valid_bda) && \
(property_get(PERSIST_BDADDR_PROPERTY, val, NULL)))
@@ -416,6 +420,15 @@ static void btif_fetch_local_bdaddr(bt_bdaddr_t *local_addr)
//save the bd address to config file
bdstr_t bdstr;
bd2str(local_addr, &bdstr);
+ val_size = sizeof(val);
+ if (btif_config_get_str("Local", "Adapter", "Address", val, &val_size))
+ {
+ if (strcmp(bdstr, val) ==0)
+ {
+ // BDA is already present in the config file.
+ return;
+ }
+ }
btif_config_set_str("Local", "Adapter", "Address", bdstr);
btif_config_save();
}