From 6a7fe599e70b85af4369cab49529c658b3437494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Mon, 13 Apr 2020 18:25:11 +0200 Subject: [PATCH] profile: Fix not setting default features for HFP 1.7 When HFP AG features are not set then according to HFP 1.7.2 specification it has value 0b001001. --- src/profile.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/profile.c b/src/profile.c index 192fd0245..f00883431 100644 --- a/src/profile.c +++ b/src/profile.c @@ -920,13 +920,14 @@ static void append_prop(gpointer a, gpointer b) dbus_message_iter_close_container(dict, &entry); } -static uint16_t get_supported_features(const sdp_record_t *rec) +static int get_supported_features(const sdp_record_t *rec) { sdp_data_t *data; data = sdp_data_get(rec, SDP_ATTR_SUPPORTED_FEATURES); - if (!data || data->dtd != SDP_UINT16) - return 0; + if (!data || data->dtd != SDP_UINT16) { + return -ENOENT; + } return data->val.uint16; } @@ -959,7 +960,8 @@ static bool send_new_connection(struct ext_profile *ext, struct ext_io *conn) const char *remote_uuid = ext->remote_uuid; const sdp_record_t *rec; const char *path; - int fd; + int fd, features; + bool has_features = false; msg = dbus_message_new_method_call(ext->owner, ext->path, "org.bluez.Profile1", @@ -972,7 +974,11 @@ static bool send_new_connection(struct ext_profile *ext, struct ext_io *conn) if (remote_uuid) { rec = btd_device_get_record(conn->device, remote_uuid); if (rec) { - conn->features = get_supported_features(rec); + features = get_supported_features(rec); + if (features >= 0) { + conn->features = features; + has_features = true; + } conn->version = get_profile_version(rec); } } @@ -991,7 +997,7 @@ static bool send_new_connection(struct ext_profile *ext, struct ext_io *conn) dict_append_entry(&dict, "Version", DBUS_TYPE_UINT16, &conn->version); - if (conn->features) + if (has_features) dict_append_entry(&dict, "Features", DBUS_TYPE_UINT16, &conn->features); @@ -1983,6 +1989,8 @@ static struct default_settings { .auto_connect = true, .get_record = get_hfp_ag_record, .version = 0x0107, + /* HFP 1.7.2: By default features bitfield is 0b001001 */ + .features = 0x09, }, { .uuid = HSP_AG_UUID, .name = "Headset Voice gateway", -- 2.47.3