diff options
| -rw-r--r-- | hcid/dbus-adapter.c | 16 | 
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); | 
