diff options
author | Priti Aghera <paghera@broadcom.com> | 2012-04-10 20:47:32 -0700 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2012-07-14 11:19:16 -0700 |
commit | aeddde20be2d01a2c052ee516f9015243dbaebf1 (patch) | |
tree | 0e3f913820df05b3a586ef5e3db4b91932f7528a /btif | |
parent | b785e0a4f28b88a6a3a4ca259305841cb142ee91 (diff) | |
download | external_bluetooth_bluedroid-aeddde20be2d01a2c052ee516f9015243dbaebf1.zip external_bluetooth_bluedroid-aeddde20be2d01a2c052ee516f9015243dbaebf1.tar.gz external_bluetooth_bluedroid-aeddde20be2d01a2c052ee516f9015243dbaebf1.tar.bz2 |
Patch for GetBondedDevices
Change-Id: I8be25cda42c3e52198ce19ca4e924b2b1154a51e
Diffstat (limited to 'btif')
-rwxr-xr-x | btif/src/btif_dm.c | 8 | ||||
-rwxr-xr-x | btif/src/btif_storage.c | 76 |
2 files changed, 82 insertions, 2 deletions
diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c index db23e69..095790a 100755 --- a/btif/src/btif_dm.c +++ b/btif/src/btif_dm.c @@ -255,6 +255,13 @@ static void bond_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr, bt_bond else { memset(&pairing_cb, 0, sizeof(pairing_cb)); + char buf[512]; + bt_property_t prop; + prop.type = BT_PROPERTY_ADAPTER_BONDED_DEVICES; + prop.val = (void*)buf; + prop.len = sizeof(buf); + status = btif_storage_get_adapter_property(&prop); + HAL_CBACK(bt_hal_cbacks, adapter_properties_cb, status, 1, &prop); } } @@ -686,6 +693,7 @@ static void btif_dm_search_devices_evt (UINT16 event, char *p_param) { } break; + case BTA_DM_SEARCH_CANCEL_CMPL_EVT: case BTA_DM_DISC_CMPL_EVT: { HAL_CBACK(bt_hal_cbacks, discovery_state_changed_cb, BT_DISCOVERY_STOPPED); diff --git a/btif/src/btif_storage.c b/btif/src/btif_storage.c index 879be48..2c3ed69 100755 --- a/btif/src/btif_storage.c +++ b/btif/src/btif_storage.c @@ -524,6 +524,57 @@ int btif_in_load_device_iter_cb(char *key, char *value, void *userdata) return 0; } + +int btif_in_get_device_iter_cb(char *key, char *value, void *userdata) +{ + btif_bonded_devices_t *p_bonded_devices = (btif_bonded_devices_t *)userdata; + DEV_CLASS dev_class = {0, 0, 0}; + bt_bdaddr_t bd_addr; + LINK_KEY link_key; + uint8_t key_type; + uint8_t pin_length; + int offset = 0; + int8_t temp[3]; + uint32_t i; + + memset(temp, 0, sizeof(temp)); + + BTIF_TRACE_DEBUG3("%s %s %s", __FUNCTION__, key, value); + + /* convert 32 char linkkey (fixed size) */ + for (i = 0; i < LINK_KEY_LEN; i++) + { + memcpy(temp, value + (i * 2), 2); + link_key[i] = (uint8_t) strtol((const char *)temp, NULL, 16); + offset+=2; + } + + /* skip space */ + offset++; + + /* convert decimal keytype (max 2 ascii chars) */ + memset(temp, 0, sizeof(temp)); + memcpy(temp, value + offset, 2); + key_type = (uint8_t)strtoul((const char *)temp, NULL, 10); + + /* value + space */ + offset+=2; + + /* convert decimal pinlen (max 2 ascii chars) */ + memset(temp, 0, sizeof(temp)); + memcpy(temp, value + offset, 2); + pin_length = (uint8_t)strtoul((const char *)temp, NULL, 10); + + /* convert bd address (keystring) */ + str2bd(key, &bd_addr); + + + /* Fill in the bonded devices */ + memcpy(&p_bonded_devices->devices[p_bonded_devices->num_devices++], &bd_addr, sizeof(bt_bdaddr_t)); + + return 0; +} + /******************************************************************************* ** ** Function btif_in_fetch_bonded_devices @@ -534,7 +585,7 @@ int btif_in_load_device_iter_cb(char *key, char *value, void *userdata) ** Returns BT_STATUS_SUCCESS if successful, BT_STATUS_FAIL otherwise ** *******************************************************************************/ -static bt_status_t btif_in_fetch_bonded_devices(btif_bonded_devices_t *p_bonded_devices) +static bt_status_t btif_in_fetch_and_load_bonded_devices(btif_bonded_devices_t *p_bonded_devices) { char *fname; int ret; @@ -553,6 +604,27 @@ static bt_status_t btif_in_fetch_bonded_devices(btif_bonded_devices_t *p_bonded_ return BT_STATUS_SUCCESS; } + +static bt_status_t btif_in_fetch_bonded_devices(btif_bonded_devices_t *p_bonded_devices) +{ + char *fname; + int ret; + + memset(p_bonded_devices, 0, sizeof(btif_bonded_devices_t)); + + fname = btif_in_make_filename(NULL, BTIF_STORAGE_PATH_REMOTE_LINKKEYS); + + if (fname == NULL) + return BT_STATUS_FAIL; + + ret = unv_read_key_iter(fname, btif_in_get_device_iter_cb, p_bonded_devices); + + if (ret < 0) + return BT_STATUS_FAIL; + + return BT_STATUS_SUCCESS; +} + static int hex_str_to_int(const char* str, int size) { int n = 0; @@ -1083,7 +1155,7 @@ bt_status_t btif_storage_load_bonded_devices(void) bt_uuid_t remote_uuids[BT_MAX_NUM_UUIDS]; uint32_t cod, devtype; - btif_in_fetch_bonded_devices(&bonded_devices); + btif_in_fetch_and_load_bonded_devices(&bonded_devices); /* Now send the adapter_properties_cb with all adapter_properties */ { |