From e73c02b4397b97f6bc5b7fd862ca3babf18da497 Mon Sep 17 00:00:00 2001 From: Jake Hamby Date: Mon, 4 Jun 2012 14:59:47 -0700 Subject: 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 --- src/adapter.c | 7 +++++++ src/device.c | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index 0ddbda94..08cd94f3 100755 --- a/src/adapter.c +++ b/src/adapter.c @@ -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); diff --git a/src/device.c b/src/device.c index 87286449..7324c360 100755 --- a/src/device.c +++ b/src/device.c @@ -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) { -- cgit v1.2.3