Permalink
Browse files

Don't return a fallback value for Alias property of BT device.

When getting properties for a Bluetooth device, or getting info about a newly
discovered device, do not set the Alias property to the device name or to the
Bluetooth address as a fallback. The Alias property will only be set if the
user has actually set a custom alias for the device.

Bug: 5346926
Change-Id: Iea51b642592fae066ab075b0fe46d255f2d73119
  • Loading branch information...
1 parent 635699a commit e73c02b4397b97f6bc5b7fd862ca3babf18da497 Jake Hamby committed Jun 4, 2012
Showing with 15 additions and 0 deletions.
  1. +7 −0 src/adapter.c
  2. +8 −0 src/device.c
View
@@ -3396,11 +3396,18 @@ void adapter_emit_device_found(struct btd_adapter *adapter,
icon = class_to_icon(dev->class);
if (!dev->alias) {
+#ifdef ANDROID
+ /* Android doesn't fallback to name or address if there is no alias.
+ It's safe to set alias to NULL because dict_append_entry() will
+ silently return and not set the property when value is NULL. */
+ alias = NULL;
+#else
if (!dev->name) {
alias = g_strdup(peer_addr);
g_strdelimit(alias, ":", '-');
} else
alias = g_strdup(dev->name);
+#endif
} else
alias = g_strdup(dev->alias);
View
@@ -279,6 +279,13 @@ static DBusMessage *get_properties(DBusConnection *conn,
ptr = device->name;
dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &ptr);
+#ifdef ANDROID
+ /* Alias (Android doesn't fallback to name or address) */
+ if (device->alias != NULL) {
+ ptr = device->alias;
+ dict_append_entry(&dict, "Alias", DBUS_TYPE_STRING, &ptr);
+ }
+#else
/* Alias (fallback to name or address) */
if (device->alias != NULL)
ptr = device->alias;
@@ -288,6 +295,7 @@ static DBusMessage *get_properties(DBusConnection *conn,
}
dict_append_entry(&dict, "Alias", DBUS_TYPE_STRING, &ptr);
+#endif
/* Class */
if (read_remote_class(&src, &device->bdaddr, &class) == 0) {

0 comments on commit e73c02b

Please sign in to comment.