Linux bluetooth development
 help / color / mirror / Atom feed
From: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
To: linux-bluetooth@vger.kernel.org
Cc: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
Subject: [PATCH v3 2/6] android/gatt: Unsubscribe from autoconnect on unregister
Date: Wed,  3 Sep 2014 16:42:29 +0200	[thread overview]
Message-ID: <1409755353-6027-2-git-send-email-lukasz.rymanowski@tieto.com> (raw)
In-Reply-To: <1409755353-6027-1-git-send-email-lukasz.rymanowski@tieto.com>

When application does unregister, lets make sure that BfA does not keep
any auto connect devices for this app.
---
 android/gatt.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/android/gatt.c b/android/gatt.c
index a3486ca..645f5f2 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -1865,10 +1865,31 @@ static bool trigger_connection(struct app_connection *connection)
 	return ret;
 }
 
+static void clear_autoconnect_devices(void *data, void *user_data)
+{
+	struct gatt_device *dev = data;
+
+	if (queue_remove(dev->autoconnect_apps, user_data))
+		if (queue_isempty(dev->autoconnect_apps)) {
+			bt_auto_connect_remove(&dev->bdaddr);
+
+			if (dev->state == DEVICE_CONNECT_INIT)
+				device_set_state(dev, DEVICE_DISCONNECTED);
+
+			device_unref(dev);
+		}
+}
+
 static uint8_t unregister_app(int client_if)
 {
 	struct gatt_app *cl;
 
+	/*
+	 * Make sure that there is no devices in auto connect list for this
+	 * application
+	 */
+	queue_foreach(gatt_devices, clear_autoconnect_devices, INT_TO_PTR(client_if));
+
 	cl = queue_remove_if(gatt_apps, match_app_by_id, INT_TO_PTR(client_if));
 	if (!cl) {
 		error("gatt: client_if=%d not found", client_if);
-- 
1.8.4


  reply	other threads:[~2014-09-03 14:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-03 14:42 [PATCH v3 1/6] android/gatt: Add API to remove autoconnect GATT based device Lukasz Rymanowski
2014-09-03 14:42 ` Lukasz Rymanowski [this message]
2014-09-03 14:42 ` [PATCH v3 3/6] android/gatt: Extract remove_autoconnect_device helper Lukasz Rymanowski
2014-09-03 14:42 ` [PATCH v3 4/6] android/gatt: Make sure GATT will reconnect after disconnection Lukasz Rymanowski
2014-09-03 14:42 ` [PATCH v3 5/6] android/gatt: Remove device from white list on device destroy Lukasz Rymanowski
2014-09-03 14:42 ` [PATCH v3 6/6] android/hidhost: Remove reconnect logic Lukasz Rymanowski
2014-09-05  9:11 ` [PATCH v3 1/6] android/gatt: Add API to remove autoconnect GATT based device Szymon Janc

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=1409755353-6027-2-git-send-email-lukasz.rymanowski@tieto.com \
    --to=lukasz.rymanowski@tieto.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