From 7e6b4a0de4580af0cefa8b3d45677f2f9f103f65 Mon Sep 17 00:00:00 2001
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date: Mon, 22 Aug 2016 13:04:15 +0300
Subject: [PATCH 3/7] core/device: Fix marking auto-connect flag

Device auto-connect shall be set only if the profile is able to accept
incoming connections, this fixes the wrong behavior or connecting LE
with dual mode devices immediatelly after probing service as profiles
may have auto-connect flag for outgoing connection (usually BR/EDR only).
---
 src/device.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/device.c b/src/device.c
index 460a9980fc63..0b13a3190539 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4084,7 +4084,10 @@ static struct btd_service *probe_service(struct btd_device *device,
 		return NULL;
 	}
 
-	if (profile->auto_connect)
+	/* Only set auto connect if profile has set the flag and can really
+	 * accept connections.
+	 */
+	if (profile->auto_connect && profile->accept)
 		device_set_auto_connect(device, TRUE);
 
 	return service;
