device: Fix not auto-connecting profile
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 1 Aug 2022 22:19:13 +0000 (15:19 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:54 +0000 (14:55 +0530)
If the profile is registered and marked to auto-connect it shall
automatically be connected whenever a device is already connected.

Fixes: https://github.com/bluez/bluez/issues/370
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/device.c

index 03d6966..3389240 100644 (file)
@@ -7496,7 +7496,8 @@ void device_probe_profile(gpointer a, gpointer b)
 
        device->services = g_slist_append(device->services, service);
 
-       if (!profile->auto_connect || !device->general_connect)
+       if (!profile->auto_connect || (!btd_device_is_connected(device) &&
+                                       !device->general_connect))
                return;
 
        device->pending = g_slist_append(device->pending, service);