Re: [PATCH 1/8] android: Fix turning BT off during pairing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/05/2013 11:37 AM, Jakub Tyszkowski wrote:
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;


Hi,

Please ignore this one patch as it makes user_data being freed twice.

BR,
Jakub Tyszkowski
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux