From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 2/2] sixaxis: Fix fliping device.trusted automatically
Date: Tue, 2 Aug 2022 09:34:41 -0700 [thread overview]
Message-ID: <20220802163441.2522333-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20220802163441.2522333-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
device.trusted is a user preference which controls if the devices needs
to be authorized or not so the plugin shall not overwrite it and instead
just honor what user has set and skip authorizing if already trusted.
Fixes: https://github.com/bluez/bluez/issues/372
---
plugins/sixaxis.c | 9 +++------
src/device.c | 6 ++++++
src/device.h | 1 +
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c
index 10cf15948..544ab399a 100644
--- a/plugins/sixaxis.c
+++ b/plugins/sixaxis.c
@@ -294,7 +294,6 @@ static void agent_auth_cb(DBusError *derr, void *user_data)
}
remove_device = false;
- btd_device_set_trusted(closure->device, true);
btd_device_set_temporary(closure->device, false);
if (closure->type == CABLE_PAIRING_SIXAXIS)
@@ -336,10 +335,9 @@ static bool setup_device(int fd, const char *sysfs_path,
* connected eg. to charge up battery. */
device = btd_adapter_find_device(adapter, &device_bdaddr,
BDADDR_BREDR);
- if (device != NULL &&
- btd_device_is_connected(device) &&
- g_slist_find_custom(btd_device_get_uuids(device), HID_UUID,
- (GCompareFunc)strcasecmp)) {
+ if (device && btd_device_has_uuid(device, HID_UUID) &&
+ (btd_device_is_connected(device) ||
+ btd_device_is_trusted(device))) {
char device_addr[18];
ba2str(&device_bdaddr, device_addr);
DBG("device %s already known, skipping", device_addr);
@@ -352,7 +350,6 @@ static bool setup_device(int fd, const char *sysfs_path,
btd_device_device_set_name(device, cp->name);
btd_device_set_pnpid(device, cp->source, cp->vid, cp->pid, cp->version);
- btd_device_set_trusted(device, false);
btd_device_set_temporary(device, true);
closure = g_new0(struct authentication_closure, 1);
diff --git a/src/device.c b/src/device.c
index 60762ac35..bc9942022 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4509,6 +4509,12 @@ GSList *btd_device_get_uuids(struct btd_device *device)
return device->uuids;
}
+bool btd_device_has_uuid(struct btd_device *device, const char *uuid)
+{
+ return g_slist_find_custom(device->uuids, uuid,
+ (GCompareFunc)strcasecmp);
+}
+
struct probe_data {
struct btd_device *dev;
GSList *uuids;
diff --git a/src/device.h b/src/device.h
index 004d3a78b..cc474bd88 100644
--- a/src/device.h
+++ b/src/device.h
@@ -54,6 +54,7 @@ struct device_addr_type {
int device_addr_type_cmp(gconstpointer a, gconstpointer b);
GSList *btd_device_get_uuids(struct btd_device *device);
+bool btd_device_has_uuid(struct btd_device *device, const char *uuid);
void device_probe_profiles(struct btd_device *device, GSList *profiles);
void btd_device_set_record(struct btd_device *device, const char *uuid,
--
2.37.1
next prev parent reply other threads:[~2022-08-02 16:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-02 16:34 [PATCH BlueZ 1/2] device: Add btd_ prefix to device_is_trusted Luiz Augusto von Dentz
2022-08-02 16:34 ` Luiz Augusto von Dentz [this message]
2022-08-02 17:21 ` [BlueZ,1/2] " bluez.test.bot
2022-08-02 19:50 ` [PATCH BlueZ 1/2] " patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220802163441.2522333-2-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox