Diff between 6ef7f3244870bf0a0530059b439e40205d80758e and b1a95619dec73a50fd32c953230ae6d3d11d6f17

Changed Files

File Additions Deletions Status
src/adapter.c +7 -2 modified
src/device.c +3 -2 modified
src/storage.c +7 -4 modified
src/storage.h +2 -1 modified

Full Patch

diff --git a/src/adapter.c b/src/adapter.c
index f0b4beb..8d18f40 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1674,15 +1674,20 @@ static const GDBusSignalTable adapter_signals[] = {
 static void create_stored_device_from_profiles(char *key, char *value,
 						void *user_data)
 {
+	char address[18];
+	uint8_t bdaddr_type;
 	struct btd_adapter *adapter = user_data;
 	GSList *list, *uuids = bt_string2list(value);
 	struct btd_device *device;
 
+	if (sscanf(key, "%17s#%hhu", address, &bdaddr_type) < 2)
+		bdaddr_type = BDADDR_BREDR;
+
 	if (g_slist_find_custom(adapter->devices,
-				key, (GCompareFunc) device_address_cmp))
+				address, (GCompareFunc) device_address_cmp))
 		return;
 
-	device = device_create(connection, adapter, key, BDADDR_BREDR);
+	device = device_create(connection, adapter, address, bdaddr_type);
 	if (!device)
 		return;
 
diff --git a/src/device.c b/src/device.c
index 4459fd5..f94116a 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1540,12 +1540,13 @@ static void store_profiles(struct btd_device *device)
 	adapter_get_address(adapter, &src);
 
 	if (!device->uuids) {
-		write_device_profiles(&src, &device->bdaddr, "");
+		write_device_profiles(&src, &device->bdaddr,
+				      device->bdaddr_type, "");
 		return;
 	}
 
 	str = bt_list2string(device->uuids);
-	write_device_profiles(&src, &device->bdaddr, str);
+	write_device_profiles(&src, &device->bdaddr, device->bdaddr_type, str);
 	g_free(str);
 }
 
diff --git a/src/storage.c b/src/storage.c
index c10f9ae..05fb0a8 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -807,9 +807,10 @@ gboolean read_trust(const bdaddr_t *local, const char *addr, const char *service
 	return ret;
 }
 
-int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, const char *profiles)
+int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, uint8_t dst_type,
+							const char *profiles)
 {
-	char filename[PATH_MAX + 1], addr[18];
+	char filename[PATH_MAX + 1], key[20];
 
 	if (!profiles)
 		return -EINVAL;
@@ -818,8 +819,10 @@ int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, const char *profiles)
 
 	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 
-	ba2str(dst, addr);
-	return textfile_put(filename, addr, profiles);
+	ba2str(dst, key);
+	sprintf(&key[17], "#%hhu", dst_type);
+
+	return textfile_put(filename, key, profiles);
 }
 
 int delete_entry(bdaddr_t *src, const char *storage, bdaddr_t *dst,
diff --git a/src/storage.h b/src/storage.h
index cd7b161..6af2475 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -63,7 +63,8 @@ int read_link_key(bdaddr_t *local, bdaddr_t *peer, unsigned char *key, uint8_t *
 ssize_t read_pin_code(bdaddr_t *local, bdaddr_t *peer, char *pin);
 gboolean read_trust(const bdaddr_t *local, const char *addr, const char *service);
 int write_trust(const char *src, const char *addr, const char *service, gboolean trust);
-int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, const char *profiles);
+int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, uint8_t dst_type,
+							const char *profiles);
 int delete_entry(bdaddr_t *src, const char *storage, bdaddr_t *dst,
 							uint8_t dst_type);
 int store_record(const gchar *src, const gchar *dst, sdp_record_t *rec);