aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJake Hamby <jhamby@google.com>2012-06-04 14:59:47 -0700
committerJake Hamby <jhamby@google.com>2012-06-05 16:32:22 -0700
commite73c02b4397b97f6bc5b7fd862ca3babf18da497 (patch)
treefa69ce14f8d29f9896b1d384a11c243037b6eff4
parent635699a5d1761b3ed9572537fc620e0eb05bf500 (diff)
downloadbluez-e73c02b4397b97f6bc5b7fd862ca3babf18da497.tar.gz
Don't return a fallback value for Alias property of BT device.android-cts-4.1_r4android-cts-4.1_r2android-cts-4.1_r1jb-dev
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
-rwxr-xr-xsrc/adapter.c7
-rwxr-xr-xsrc/device.c8
2 files changed, 15 insertions, 0 deletions
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) {