From 1c2ec29900e48c785f7faa8fbe88f3085aaf806b Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Mon, 24 Mar 2025 16:38:02 -0400 Subject: [PATCH] device: Make Connect and Pair mutually exclusive This makes Device.Connect and Device.Pair methods mutually exclusive so they cannot happen in parallel, so just as Connect:Connect and Pair:Pair combinations the Connect:Pair and Pair:Connect will now return org.bluez.Error.InProgress. --- src/device.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/device.c b/src/device.c index f76c1ec3e..6a6c379fc 100644 --- a/src/device.c +++ b/src/device.c @@ -2629,6 +2629,9 @@ static DBusMessage *dev_connect(DBusConnection *conn, DBusMessage *msg, struct btd_device *dev = user_data; uint8_t bdaddr_type; + if (dev->bonding) + return btd_error_in_progress(msg); + if (dev->bredr_state.connected) { /* * Check if services have been resolved and there is at least @@ -2648,6 +2651,9 @@ static DBusMessage *dev_connect(DBusConnection *conn, DBusMessage *msg, if (bdaddr_type != BDADDR_BREDR) { int err; + if (dev->connect) + return btd_error_in_progress(msg); + if (dev->le_state.connected) return dbus_message_new_method_return(msg); @@ -3133,7 +3139,7 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_INVALID)) return btd_error_invalid_args(msg); - if (device->bonding) + if (device->bonding || device->connect) return btd_error_in_progress(msg); /* Only use this selection algorithms when device is combo -- 2.47.3