Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/8] android: Fix turning BT off during pairing
@ 2013-12-05 10:37 Jakub Tyszkowski
  2013-12-05 10:37 ` [PATCH 2/8] android: Update haltest tool entry in README Jakub Tyszkowski
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Jakub Tyszkowski @ 2013-12-05 10:37 UTC (permalink / raw)
  To: linux-bluetooth

Not turning BT off in time due to actions queued in mgmt makes Android
unstable and locks Bluetooth UI controlls. This patch fixes this issue
by cancelling queued actions.

---
 android/bluetooth.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index 6174b1f..e67864a 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -1982,6 +1982,9 @@ static void pair_device_complete(uint8_t status, uint16_t length,
 
 	DBG("status %u", status);
 
+	/*Data used for bond cancelling can be freed now*/
+	g_free(user_data);
+
 	/* On success bond state change will be send when new link key event
 	 * is received */
 	if (status == MGMT_STATUS_SUCCESS)
@@ -1991,19 +1994,34 @@ static void pair_device_complete(uint8_t status, uint16_t length,
 							HAL_BOND_STATE_NONE);
 }
 
+static void pair_device_cancelled(void *data)
+{
+	bdaddr_t *addr = data;
+
+	set_device_bond_state(addr, HAL_STATUS_FAILED, HAL_BOND_STATE_NONE);
+
+	g_free(data);
+}
+
 static void handle_create_bond_cmd(const void *buf, uint16_t len)
 {
 	const struct hal_cmd_create_bond *cmd = buf;
 	uint8_t status;
 	struct mgmt_cp_pair_device cp;
+	bdaddr_t *addr;
 
 	cp.io_cap = DEFAULT_IO_CAPABILITY;
 	cp.addr.type = BDADDR_BREDR;
 	android2bdaddr(cmd->bdaddr, &cp.addr.bdaddr);
 
+	addr = g_new(bdaddr_t, 1);
+	bacpy(addr, &cp.addr.bdaddr);
+
 	if (mgmt_send(mgmt_if, MGMT_OP_PAIR_DEVICE, adapter.index, sizeof(cp),
-				&cp, pair_device_complete, NULL, NULL) == 0) {
+				&cp, pair_device_complete,
+				addr, pair_device_cancelled) == 0) {
 		status = HAL_STATUS_FAILED;
+		g_free(addr);
 		goto fail;
 	}
 
@@ -2253,6 +2271,8 @@ static void handle_disable_cmd(const void *buf, uint16_t len)
 		goto failed;
 	}
 
+	mgmt_cancel_index(mgmt_if, adapter.index);
+
 	if (!set_mode(MGMT_OP_SET_POWERED, 0x00)) {
 		status = HAL_STATUS_FAILED;
 		goto failed;
-- 
1.8.5


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-12-08 16:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-05 10:37 [PATCH 1/8] android: Fix turning BT off during pairing Jakub Tyszkowski
2013-12-05 10:37 ` [PATCH 2/8] android: Update haltest tool entry in README Jakub Tyszkowski
2013-12-05 10:37 ` [PATCH 3/8] android: Fix sending status on bluetooth init if already initialized Jakub Tyszkowski
2013-12-05 10:37 ` [PATCH 4/8] android/hidhost: Unregister ipc handlers if init fails Jakub Tyszkowski
2013-12-05 10:37 ` [PATCH 5/8] android/pan: " Jakub Tyszkowski
2013-12-05 10:37 ` [PATCH 6/8] android/a2dp: " Jakub Tyszkowski
2013-12-05 10:37 ` [PATCH 7/8] android/pan: Move logic from HAL layer to daemon Jakub Tyszkowski
2013-12-05 10:37 ` [PATCH 8/8] android/pan: Move logic from HAL " Jakub Tyszkowski
2013-12-05 13:02 ` [PATCH 1/8] android: Fix turning BT off during pairing Tyszkowski Jakub
2013-12-06 15:30 ` [PATCHv2] android: Fix delayed adapter turn off Jakub Tyszkowski
2013-12-08 16:07   ` Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox