summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2006-07-26 09:13:52 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2006-07-26 09:13:52 +0000
commit2338a866224cbb390afbee7140299ae7fcb1deb8 (patch)
tree9c3e989bc103c2a8dc5ac5d7ab6fdf61b4bd1ae3
parent88641040aaa501ee6a3d6f78e33db8efd1940acb (diff)
GetName: use local storage file if the adapter is DOWN
-rw-r--r--hcid/dbus-adapter.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c
index 1fdcbdda..b77424f0 100644
--- a/hcid/dbus-adapter.c
+++ b/hcid/dbus-adapter.c
@@ -878,12 +878,24 @@ static DBusHandlerResult handle_dev_get_name_req(DBusConnection *conn, DBusMessa
struct hci_dbus_data *dbus_data = data;
DBusMessage *reply;
char str[249], *str_ptr = str;
- int err;
+ int err = -1;
+ struct hci_dev_info di;
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
return error_invalid_arguments(conn, msg);
- err = get_device_name(dbus_data->dev_id, str, sizeof(str));
+ /* If the device is DOWN, try to read the name from storage file */
+ if (hci_devinfo(dbus_data->dev_id, &di) == 0 && !hci_test_bit(HCI_UP, &di.flags)) {
+ bdaddr_t ba;
+
+ str2ba(dbus_data->address, &ba);
+
+ err = read_local_name(&ba, str);
+ }
+
+ if (err < 0)
+ err = get_device_name(dbus_data->dev_id, str, sizeof(str));
+
if (err < 0)
return error_failed(conn, msg, -err);