Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 05/13] android/tester: Execute adapter state changed cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-21 12:57 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392987473-19994-1-git-send-email-jakub.tyszkowski@tieto.com>

Execute generic adapter_state_changed_cb in tester's main loop.
---
 android/android-tester.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index 3c4bf6c..a941e9f 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -599,19 +599,33 @@ static void disable_success_cb(bt_state_t state)
 	}
 }
 
-static void adapter_state_changed_cb(bt_state_t state)
+static gboolean adapter_state_changed(gpointer user_data)
 {
 	struct test_data *data = tester_get_data();
 	const struct generic_data *test = data->test_data;
+	struct bt_cb_data *cb_data = user_data;
 
 	if (data->test_init_done &&
 			test->expected_hal_cb.adapter_state_changed_cb) {
-		test->expected_hal_cb.adapter_state_changed_cb(state);
-		return;
+		test->expected_hal_cb.adapter_state_changed_cb(cb_data->state);
+		goto cleanup;
 	}
 
-	if (!data->test_init_done && state == BT_STATE_ON)
+	if (!data->test_init_done && cb_data->state == BT_STATE_ON)
 		setup_powered_emulated_remote();
+
+cleanup:
+	g_free(cb_data);
+	return FALSE;
+}
+
+static void adapter_state_changed_cb(bt_state_t state)
+{
+	struct bt_cb_data *cb_data = g_new0(struct bt_cb_data, 1);
+
+	cb_data->state = state;
+
+	g_idle_add(adapter_state_changed, cb_data);
 }
 
 static void discovery_start_success_cb(bt_discovery_state_t state)
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 06/13] android/tester: Execute socket cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-21 12:57 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392987473-19994-1-git-send-email-jakub.tyszkowski@tieto.com>

Execute socket test's callbacks in tester's main loop.
---
 android/android-tester.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index a941e9f..c8496af 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -2778,9 +2778,11 @@ static void test_dev_setprop_disctimeout_fail(const void *test_data)
 }
 /* Test Socket HAL */
 
-static void adapter_socket_state_changed_cb(bt_state_t state)
+static gboolean adapter_socket_state_changed(gpointer user_data)
 {
-	switch (state) {
+	struct bt_cb_data *cb_data = user_data;
+
+	switch (cb_data->state) {
 	case BT_STATE_ON:
 		setup_powered_emulated_remote();
 		break;
@@ -2790,6 +2792,19 @@ static void adapter_socket_state_changed_cb(bt_state_t state)
 	default:
 		break;
 	}
+
+	g_free(cb_data);
+
+	return FALSE;
+}
+
+static void adapter_socket_state_changed_cb(bt_state_t state)
+{
+	struct bt_cb_data *cb_data = g_new0(struct bt_cb_data, 1);
+
+	cb_data->state = state;
+
+	g_idle_add(adapter_socket_state_changed, cb_data);
 }
 
 const bt_bdaddr_t bdaddr_dummy = {
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 07/13] android/tester: Execute hh connection state cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-21 12:57 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392987473-19994-1-git-send-email-jakub.tyszkowski@tieto.com>

Execute generic HIDHost connection_state_cb in tester's main loop.
---
 android/android-tester.c | 35 +++++++++++++++++++++++++++++++----
 1 file changed, 31 insertions(+), 4 deletions(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index c8496af..d756dfc 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -127,6 +127,18 @@ struct bt_cb_data {
 	bt_property_t *props;
 };
 
+struct hh_cb_data {
+	bt_bdaddr_t bdaddr;
+
+	bthh_status_t status;
+	bthh_hid_info_t hid_info;
+	bthh_protocol_mode_t mode;
+	bthh_connection_state_t state;
+
+	uint8_t *report;
+	int size;
+};
+
 static char exec_dir[PATH_MAX + 1];
 
 static void mgmt_debug(const char *str, void *user_data)
@@ -3210,19 +3222,34 @@ clean:
 		close(sock_fd);
 }
 
-static void hidhost_connection_state_cb(bt_bdaddr_t *bd_addr,
-						bthh_connection_state_t state)
+static gboolean hidhost_connection_state(gpointer user_data)
 {
 	struct test_data *data = tester_get_data();
 	const struct hidhost_generic_data *test = data->test_data;
+	struct hh_cb_data *cb_data = user_data;
 
 	data->cb_count++;
 
-	if (state == BTHH_CONN_STATE_CONNECTED)
+	if (cb_data->state == BTHH_CONN_STATE_CONNECTED)
 		tester_setup_complete();
 
 	if (test && test->expected_hal_cb.connection_state_cb)
-		test->expected_hal_cb.connection_state_cb(bd_addr, state);
+		test->expected_hal_cb.connection_state_cb(&cb_data->bdaddr,
+								cb_data->state);
+
+	g_free(cb_data);
+	return FALSE;
+}
+
+static void hidhost_connection_state_cb(bt_bdaddr_t *bd_addr,
+						bthh_connection_state_t state)
+{
+	struct hh_cb_data *cb_data = g_new0(struct hh_cb_data, 1);
+
+	cb_data->state = state;
+	cb_data->bdaddr = *bd_addr;
+
+	g_idle_add(hidhost_connection_state, cb_data);
 }
 
 static void hidhost_virual_unplug_cb(bt_bdaddr_t *bd_addr, bthh_status_t status)
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 08/13] android/tester: Execute hh info cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-21 12:57 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392987473-19994-1-git-send-email-jakub.tyszkowski@tieto.com>

Execute generic HIDHost hid_info_cb in tester's main loop.
---
 android/android-tester.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index d756dfc..9cd0c78 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -3263,15 +3263,30 @@ static void hidhost_virual_unplug_cb(bt_bdaddr_t *bd_addr, bthh_status_t status)
 		test->expected_hal_cb.virtual_unplug_cb(bd_addr, status);
 }
 
-static void hidhost_hid_info_cb(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid)
+static gboolean hidhost_hid_info(gpointer user_data)
 {
 	struct test_data *data = tester_get_data();
 	const struct hidhost_generic_data *test = data->test_data;
+	struct hh_cb_data *cb_data = user_data;
 
 	data->cb_count++;
 
 	if (test && test->expected_hal_cb.hid_info_cb)
-		test->expected_hal_cb.hid_info_cb(bd_addr, hid);
+		test->expected_hal_cb.hid_info_cb(&cb_data->bdaddr,
+							cb_data->hid_info);
+
+	g_free(cb_data);
+	return FALSE;
+}
+
+static void hidhost_hid_info_cb(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid)
+{
+	struct hh_cb_data *cb_data = g_new0(struct hh_cb_data, 1);
+
+	cb_data->bdaddr = *bd_addr;
+	cb_data->hid_info = hid;
+
+	g_idle_add(hidhost_hid_info, cb_data);
 }
 
 static void hidhost_protocol_mode_cb(bt_bdaddr_t *bd_addr,
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 09/13] android/tester: Execute hh protocol mode cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-21 12:57 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392987473-19994-1-git-send-email-jakub.tyszkowski@tieto.com>

Execute generic HIDHost protocol_mode_cb in tester's main loop.
---
 android/android-tester.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index 9cd0c78..137f171 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -3289,17 +3289,33 @@ static void hidhost_hid_info_cb(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid)
 	g_idle_add(hidhost_hid_info, cb_data);
 }
 
-static void hidhost_protocol_mode_cb(bt_bdaddr_t *bd_addr,
-						bthh_status_t status,
-						bthh_protocol_mode_t mode)
+static gboolean hidhost_protocol_mode(gpointer user_data)
 {
 	struct test_data *data = tester_get_data();
 	const struct hidhost_generic_data *test = data->test_data;
+	struct hh_cb_data *cb_data = user_data;
 
 	data->cb_count++;
 
 	if (test && test->expected_hal_cb.protocol_mode_cb)
-		test->expected_hal_cb.protocol_mode_cb(bd_addr, status, mode);
+		test->expected_hal_cb.protocol_mode_cb(&cb_data->bdaddr,
+						cb_data->status, cb_data->mode);
+
+	g_free(cb_data);
+	return FALSE;
+}
+
+static void hidhost_protocol_mode_cb(bt_bdaddr_t *bd_addr,
+						bthh_status_t status,
+						bthh_protocol_mode_t mode)
+{
+	struct hh_cb_data *cb_data = g_new0(struct hh_cb_data, 1);
+
+	cb_data->bdaddr = *bd_addr;
+	cb_data->status = status;
+	cb_data->mode = mode;
+
+	g_idle_add(hidhost_protocol_mode, cb_data);
 }
 
 static void hidhost_get_report_cb(bt_bdaddr_t *bd_addr, bthh_status_t status,
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 10/13] android/tester: Execute hh report cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-21 12:57 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392987473-19994-1-git-send-email-jakub.tyszkowski@tieto.com>

Execute HIDHost generic get_report_cb in tester's main loop.
---
 android/android-tester.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index 137f171..d9f9a57 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -3318,17 +3318,34 @@ static void hidhost_protocol_mode_cb(bt_bdaddr_t *bd_addr,
 	g_idle_add(hidhost_protocol_mode, cb_data);
 }
 
-static void hidhost_get_report_cb(bt_bdaddr_t *bd_addr, bthh_status_t status,
-						uint8_t *report, int size)
+static gboolean hidhost_get_report(gpointer user_data)
 {
 	struct test_data *data = tester_get_data();
 	const struct hidhost_generic_data *test = data->test_data;
+	struct hh_cb_data *cb_data = user_data;
 
 	data->cb_count++;
 
 	if (test && test->expected_hal_cb.get_report_cb)
-		test->expected_hal_cb.get_report_cb(bd_addr, status, report,
-									size);
+		test->expected_hal_cb.get_report_cb(&cb_data->bdaddr,
+			cb_data->status, cb_data->report, cb_data->size);
+
+	g_free(cb_data->report);
+	g_free(cb_data);
+	return FALSE;
+}
+
+static void hidhost_get_report_cb(bt_bdaddr_t *bd_addr, bthh_status_t status,
+						uint8_t *report, int size)
+{
+	struct hh_cb_data *cb_data = g_new0(struct hh_cb_data, 1);
+
+	cb_data->bdaddr = *bd_addr;
+	cb_data->status = status;
+	cb_data->report = g_memdup(report, size);
+	cb_data->size = size;
+
+	g_idle_add(hidhost_get_report, cb_data);
 }
 
 static bthh_callbacks_t bthh_callbacks = {
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 11/13] android/tester: Execute hh virtual unplug cbacks in main loop
From: Jakub Tyszkowski @ 2014-02-21 12:57 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392987473-19994-1-git-send-email-jakub.tyszkowski@tieto.com>

Execute generic HIDHost virtual_unplug_cb in tester's main loop.
---
 android/android-tester.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index d9f9a57..36e3b7e 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -3252,15 +3252,30 @@ static void hidhost_connection_state_cb(bt_bdaddr_t *bd_addr,
 	g_idle_add(hidhost_connection_state, cb_data);
 }
 
-static void hidhost_virual_unplug_cb(bt_bdaddr_t *bd_addr, bthh_status_t status)
+static gboolean hidhost_virual_unplug(gpointer user_data)
 {
 	struct test_data *data = tester_get_data();
 	const struct hidhost_generic_data *test = data->test_data;
+	struct hh_cb_data *cb_data = user_data;
 
 	data->cb_count++;
 
 	if (test && test->expected_hal_cb.virtual_unplug_cb)
-		test->expected_hal_cb.virtual_unplug_cb(bd_addr, status);
+		test->expected_hal_cb.virtual_unplug_cb(&cb_data->bdaddr,
+							cb_data->status);
+
+	g_free(cb_data);
+	return FALSE;
+}
+
+static void hidhost_virual_unplug_cb(bt_bdaddr_t *bd_addr, bthh_status_t status)
+{
+	struct hh_cb_data *cb_data = g_new0(struct hh_cb_data, 1);
+
+	cb_data->bdaddr = *bd_addr;
+	cb_data->status = status;
+
+	g_idle_add(hidhost_virual_unplug, cb_data);
 }
 
 static gboolean hidhost_hid_info(gpointer user_data)
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 12/13] android/tester: Non-blocking check for daemon termination
From: Jakub Tyszkowski @ 2014-02-21 12:57 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392987473-19994-1-git-send-email-jakub.tyszkowski@tieto.com>

This fixes the main loop being blocked, waiting for daemon termination
while daemon waits for freezed emulator to respond.
---
 android/android-tester.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index 36e3b7e..921204d 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -2172,6 +2172,27 @@ static void setup_enabled_adapter(const void *test_data)
 		tester_setup_failed();
 }
 
+static gboolean check_daemon_term(gpointer user_data)
+{
+	int status;
+	struct test_data *data = tester_get_data();
+
+	if (!data)
+		return FALSE;
+
+	if ((waitpid(data->bluetoothd_pid, &status, WNOHANG))
+							!= data->bluetoothd_pid)
+		return TRUE;
+
+	if (WIFEXITED(status) && (WEXITSTATUS(status) == EXIT_SUCCESS)) {
+		tester_teardown_complete();
+		return FALSE;
+	}
+
+	tester_warn("Unexpected Daemon shutdown with status %d", status);
+	return FALSE;
+}
+
 static void teardown(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
@@ -2191,10 +2212,7 @@ static void teardown(const void *test_data)
 
 	data->device->close(data->device);
 
-	if (data->bluetoothd_pid)
-		waitpid(data->bluetoothd_pid, NULL, 0);
-
-	tester_teardown_complete();
+	g_idle_add(check_daemon_term, NULL);
 }
 
 static void test_dummy(const void *test_data)
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 13/13] android/tester: Add guard for late callback calls
From: Jakub Tyszkowski @ 2014-02-21 12:57 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392987473-19994-1-git-send-email-jakub.tyszkowski@tieto.com>

This fixes callbacks being called in wrong test case when current test
has already failed or timed out.
---
 android/android-tester.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index 921204d..f539b87 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -43,6 +43,8 @@
 
 #include "utils.h"
 
+gint scheduled_cbacks_num = 0;
+
 struct priority_property {
 	bt_property_t prop;
 	int prio;
@@ -628,6 +630,8 @@ static gboolean adapter_state_changed(gpointer user_data)
 
 cleanup:
 	g_free(cb_data);
+
+	g_atomic_int_dec_and_test(&scheduled_cbacks_num);
 	return FALSE;
 }
 
@@ -637,6 +641,7 @@ static void adapter_state_changed_cb(bt_state_t state)
 
 	cb_data->state = state;
 
+	g_atomic_int_inc(&scheduled_cbacks_num);
 	g_idle_add(adapter_state_changed, cb_data);
 }
 
@@ -733,6 +738,7 @@ static gboolean discovery_state_changed(gpointer user_data)
 
 	g_free(cb_data);
 
+	g_atomic_int_dec_and_test(&scheduled_cbacks_num);
 	return FALSE;
 }
 
@@ -741,6 +747,7 @@ static void discovery_state_changed_cb(bt_discovery_state_t state)
 	struct bt_cb_data *cb_data = g_new0(struct bt_cb_data, 1);
 
 	cb_data->state = state;
+	g_atomic_int_inc(&scheduled_cbacks_num);
 	g_idle_add(discovery_state_changed, cb_data);
 }
 
@@ -919,6 +926,7 @@ static gboolean device_found(gpointer user_data)
 	free_properties(cb_data->num, cb_data->props);
 	g_free(cb_data);
 
+	g_atomic_int_dec_and_test(&scheduled_cbacks_num);
 	return FALSE;
 }
 
@@ -929,6 +937,7 @@ static void device_found_cb(int num_properties, bt_property_t *properties)
 	cb_data->num = num_properties;
 	cb_data->props = copy_properties(num_properties, properties);
 
+	g_atomic_int_inc(&scheduled_cbacks_num);
 	g_idle_add(device_found, cb_data);
 }
 
@@ -954,6 +963,7 @@ static gboolean adapter_properties(gpointer user_data)
 	free_properties(cb_data->num, cb_data->props);
 	g_free(cb_data);
 
+	g_atomic_int_dec_and_test(&scheduled_cbacks_num);
 	return FALSE;
 }
 
@@ -966,6 +976,7 @@ static void adapter_properties_cb(bt_status_t status, int num_properties,
 	cb_data->num = num_properties;
 	cb_data->props = copy_properties(num_properties, properties);
 
+	g_atomic_int_inc(&scheduled_cbacks_num);
 	g_idle_add(adapter_properties, cb_data);
 }
 
@@ -1017,6 +1028,7 @@ static gboolean remote_device_properties(gpointer user_data)
 	free_properties(cb_data->num, cb_data->props);
 	g_free(cb_data);
 
+	g_atomic_int_dec_and_test(&scheduled_cbacks_num);
 	return FALSE;
 }
 
@@ -1031,6 +1043,7 @@ static void remote_device_properties_cb(bt_status_t status,
 	cb_data->num = num_properties;
 	cb_data->props = copy_properties(num_properties, properties);
 
+	g_atomic_int_inc(&scheduled_cbacks_num);
 	g_idle_add(remote_device_properties, cb_data);
 }
 
@@ -2172,6 +2185,22 @@ static void setup_enabled_adapter(const void *test_data)
 		tester_setup_failed();
 }
 
+static gboolean check_callbacks_called(gpointer user_data)
+{
+	/*
+	 * Wait for all callbacks scheduled in current test context to execute
+	 * in main loop. This will avoid late callback calls after test case has
+	 * already failed or timed out.
+	 */
+
+	if (g_atomic_int_get(&scheduled_cbacks_num) == 0) {
+		tester_teardown_complete();
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
 static gboolean check_daemon_term(gpointer user_data)
 {
 	int status;
@@ -2185,7 +2214,7 @@ static gboolean check_daemon_term(gpointer user_data)
 		return TRUE;
 
 	if (WIFEXITED(status) && (WEXITSTATUS(status) == EXIT_SUCCESS)) {
-		tester_teardown_complete();
+		g_idle_add(check_callbacks_called, NULL);
 		return FALSE;
 	}
 
@@ -2825,6 +2854,7 @@ static gboolean adapter_socket_state_changed(gpointer user_data)
 
 	g_free(cb_data);
 
+	g_atomic_int_dec_and_test(&scheduled_cbacks_num);
 	return FALSE;
 }
 
@@ -2834,6 +2864,7 @@ static void adapter_socket_state_changed_cb(bt_state_t state)
 
 	cb_data->state = state;
 
+	g_atomic_int_inc(&scheduled_cbacks_num);
 	g_idle_add(adapter_socket_state_changed, cb_data);
 }
 
@@ -3256,6 +3287,8 @@ static gboolean hidhost_connection_state(gpointer user_data)
 								cb_data->state);
 
 	g_free(cb_data);
+
+	g_atomic_int_dec_and_test(&scheduled_cbacks_num);
 	return FALSE;
 }
 
@@ -3267,6 +3300,7 @@ static void hidhost_connection_state_cb(bt_bdaddr_t *bd_addr,
 	cb_data->state = state;
 	cb_data->bdaddr = *bd_addr;
 
+	g_atomic_int_inc(&scheduled_cbacks_num);
 	g_idle_add(hidhost_connection_state, cb_data);
 }
 
@@ -3283,6 +3317,8 @@ static gboolean hidhost_virual_unplug(gpointer user_data)
 							cb_data->status);
 
 	g_free(cb_data);
+
+	g_atomic_int_dec_and_test(&scheduled_cbacks_num);
 	return FALSE;
 }
 
@@ -3293,6 +3329,7 @@ static void hidhost_virual_unplug_cb(bt_bdaddr_t *bd_addr, bthh_status_t status)
 	cb_data->bdaddr = *bd_addr;
 	cb_data->status = status;
 
+	g_atomic_int_inc(&scheduled_cbacks_num);
 	g_idle_add(hidhost_virual_unplug, cb_data);
 }
 
@@ -3309,6 +3346,8 @@ static gboolean hidhost_hid_info(gpointer user_data)
 							cb_data->hid_info);
 
 	g_free(cb_data);
+
+	g_atomic_int_dec_and_test(&scheduled_cbacks_num);
 	return FALSE;
 }
 
@@ -3319,6 +3358,7 @@ static void hidhost_hid_info_cb(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid)
 	cb_data->bdaddr = *bd_addr;
 	cb_data->hid_info = hid;
 
+	g_atomic_int_inc(&scheduled_cbacks_num);
 	g_idle_add(hidhost_hid_info, cb_data);
 }
 
@@ -3335,6 +3375,8 @@ static gboolean hidhost_protocol_mode(gpointer user_data)
 						cb_data->status, cb_data->mode);
 
 	g_free(cb_data);
+
+	g_atomic_int_dec_and_test(&scheduled_cbacks_num);
 	return FALSE;
 }
 
@@ -3348,6 +3390,7 @@ static void hidhost_protocol_mode_cb(bt_bdaddr_t *bd_addr,
 	cb_data->status = status;
 	cb_data->mode = mode;
 
+	g_atomic_int_inc(&scheduled_cbacks_num);
 	g_idle_add(hidhost_protocol_mode, cb_data);
 }
 
@@ -3365,6 +3408,8 @@ static gboolean hidhost_get_report(gpointer user_data)
 
 	g_free(cb_data->report);
 	g_free(cb_data);
+
+	g_atomic_int_dec_and_test(&scheduled_cbacks_num);
 	return FALSE;
 }
 
@@ -3378,6 +3423,7 @@ static void hidhost_get_report_cb(bt_bdaddr_t *bd_addr, bthh_status_t status,
 	cb_data->report = g_memdup(report, size);
 	cb_data->size = size;
 
+	g_atomic_int_inc(&scheduled_cbacks_num);
 	g_idle_add(hidhost_get_report, cb_data);
 }
 
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH] android/socket: Fix calling cleanup with invalid pointer
From: Andrzej Kaczmarek @ 2014-02-21 13:58 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek

---
 android/socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/socket.c b/android/socket.c
index 48a8746..e2da689 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -1151,7 +1151,7 @@ void bt_socket_unregister(void)
 
 	for (ch = 0; ch <= RFCOMM_CHANNEL_MAX; ch++)
 		if (servers[ch].rfsock)
-			cleanup_rfsock(&servers[ch]);
+			cleanup_rfsock(servers[ch].rfsock);
 
 	memset(servers, 0, sizeof(servers));
 
-- 
1.8.5.4


^ permalink raw reply related

* [PATCH] Bluetooth: Fix iterating wrong list in hci_remove_irk()
From: johan.hedberg @ 2014-02-21 14:03 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

We should be iterating hdev->identity_resolving_keys in the
hci_remove_irk() function instead of hdev->long_term_keys. This patch
fixes the issue.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/hci_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 67192867c998..964aa8deb009 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2937,7 +2937,7 @@ void hci_remove_irk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type)
 {
 	struct smp_irk *k, *tmp;
 
-	list_for_each_entry_safe(k, tmp, &hdev->long_term_keys, list) {
+	list_for_each_entry_safe(k, tmp, &hdev->identity_resolving_keys, list) {
 		if (bacmp(bdaddr, &k->bdaddr) || k->addr_type != addr_type)
 			continue;
 
-- 
1.8.5.3


^ permalink raw reply related

* Re: [PATCH] android/socket: Fix calling cleanup with invalid pointer
From: Szymon Janc @ 2014-02-21 14:30 UTC (permalink / raw)
  To: Andrzej Kaczmarek; +Cc: linux-bluetooth
In-Reply-To: <1392991129-23026-1-git-send-email-andrzej.kaczmarek@tieto.com>

Hi Andrzej,

On Friday 21 of February 2014 14:58:49 Andrzej Kaczmarek wrote:
> ---
>  android/socket.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/android/socket.c b/android/socket.c
> index 48a8746..e2da689 100644
> --- a/android/socket.c
> +++ b/android/socket.c
> @@ -1151,7 +1151,7 @@ void bt_socket_unregister(void)
>  
>  	for (ch = 0; ch <= RFCOMM_CHANNEL_MAX; ch++)
>  		if (servers[ch].rfsock)
> -			cleanup_rfsock(&servers[ch]);
> +			cleanup_rfsock(servers[ch].rfsock);
>  
>  	memset(servers, 0, sizeof(servers));
>  

Pushed, thanks.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* [PATCHv2 1/6] unit/avrcp: First unit test for AVRCP profile
From: Andrei Emeltchenko @ 2014-02-21 15:23 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

The tests verifies connection establishment for control.
---
 Makefile.am       |   9 ++
 unit/test-avrcp.c | 265 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 274 insertions(+)
 create mode 100644 unit/test-avrcp.c

diff --git a/Makefile.am b/Makefile.am
index 11f2aa1..5fe58eb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -282,6 +282,15 @@ unit_test_avctp_SOURCES = unit/test-avctp.c \
 				android/avctp.c android/avctp.h
 unit_test_avctp_LDADD = @GLIB_LIBS@
 
+unit_tests += unit/test-avrcp
+
+unit_test_avrcp_SOURCES = unit/test-avrcp.c \
+				src/shared/util.h src/shared/util.c \
+				src/log.h src/log.c \
+				android/avctp.c android/avctp.h \
+				android/avrcp-lib.c android/avrcp-lib.h
+unit_test_avrcp_LDADD = @GLIB_LIBS@ lib/libbluetooth-internal.la
+
 unit_tests += unit/test-gdbus-client
 
 unit_test_gdbus_client_SOURCES = unit/test-gdbus-client.c
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
new file mode 100644
index 0000000..f1c0f46
--- /dev/null
+++ b/unit/test-avrcp.c
@@ -0,0 +1,265 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2014  Intel Corporation. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <inttypes.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+
+#include <glib.h>
+
+#include "src/shared/util.h"
+#include "src/log.h"
+#include "lib/bluetooth.h"
+
+#include "android/avctp.h"
+#include "android/avrcp-lib.h"
+
+struct test_pdu {
+	bool valid;
+	bool fragmented;
+	const uint8_t *data;
+	size_t size;
+};
+
+struct test_data {
+	char *test_name;
+	struct test_pdu *pdu_list;
+};
+
+struct context {
+	GMainLoop *main_loop;
+	struct avrcp *session;
+	guint source;
+	guint process;
+	int fd;
+	unsigned int pdu_offset;
+	const struct test_data *data;
+};
+
+#define data(args...) ((const unsigned char[]) { args })
+
+#define raw_pdu(args...)					\
+	{							\
+		.valid = true,					\
+		.data = data(args),				\
+		.size = sizeof(data(args)),			\
+	}
+
+#define frg_pdu(args...)					\
+	{							\
+		.valid = true,					\
+		.fragmented = true,				\
+		.data = data(args),				\
+		.size = sizeof(data(args)),			\
+	}
+
+#define define_test(name, function, args...)				\
+	do {								\
+		const struct test_pdu pdus[] = {			\
+			args, { }					\
+		};							\
+		static struct test_data data;				\
+		data.test_name = g_strdup(name);			\
+		data.pdu_list = g_malloc(sizeof(pdus));			\
+		memcpy(data.pdu_list, pdus, sizeof(pdus));		\
+		g_test_add_data_func(name, &data, function);		\
+	} while (0)
+
+static void test_debug(const char *str, void *user_data)
+{
+	const char *prefix = user_data;
+
+	g_print("%s%s\n", prefix, str);
+}
+
+static void test_free(gconstpointer user_data)
+{
+	const struct test_data *data = user_data;
+
+	g_free(data->test_name);
+	g_free(data->pdu_list);
+}
+
+static gboolean context_quit(gpointer user_data)
+{
+	struct context *context = user_data;
+
+	if (context->process > 0)
+		g_source_remove(context->process);
+
+	g_main_loop_quit(context->main_loop);
+
+	return FALSE;
+}
+
+static gboolean send_pdu(gpointer user_data)
+{
+	struct context *context = user_data;
+	const struct test_pdu *pdu;
+	ssize_t len;
+
+	pdu = &context->data->pdu_list[context->pdu_offset++];
+
+	len = write(context->fd, pdu->data, pdu->size);
+
+	if (g_test_verbose())
+		util_hexdump('<', pdu->data, len, test_debug, "AVRCP: ");
+
+	g_assert_cmpint(len, ==, pdu->size);
+
+	if (pdu->fragmented)
+		return send_pdu(user_data);
+
+	context->process = 0;
+	return FALSE;
+}
+
+static void context_process(struct context *context)
+{
+	if (!context->data->pdu_list[context->pdu_offset].valid) {
+		context_quit(context);
+		return;
+	}
+
+	context->process = g_idle_add(send_pdu, context);
+}
+
+static gboolean test_handler(GIOChannel *channel, GIOCondition cond,
+							gpointer user_data)
+{
+	struct context *context = user_data;
+	const struct test_pdu *pdu;
+	unsigned char buf[512];
+	ssize_t len;
+	int fd;
+
+	pdu = &context->data->pdu_list[context->pdu_offset++];
+
+	if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
+		context->source = 0;
+		g_print("%s: cond %x\n", __func__, cond);
+		return FALSE;
+	}
+
+	fd = g_io_channel_unix_get_fd(channel);
+
+	len = read(fd, buf, sizeof(buf));
+
+	g_assert(len > 0);
+
+	if (g_test_verbose())
+		util_hexdump('>', buf, len, test_debug, "AVRCP: ");
+
+	g_assert_cmpint(len, ==, pdu->size);
+
+	g_assert(memcmp(buf, pdu->data, pdu->size) == 0);
+
+	if (!pdu->fragmented)
+		context_process(context);
+
+	return TRUE;
+}
+
+static struct context *create_context(uint16_t version, gconstpointer data)
+{
+	struct context *context = g_new0(struct context, 1);
+	GIOChannel *channel;
+	int err, sv[2];
+
+	context->main_loop = g_main_loop_new(NULL, FALSE);
+	g_assert(context->main_loop);
+
+	err = socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, sv);
+	g_assert(err == 0);
+
+	context->session = avrcp_new(sv[0], 672, 672, version);
+	g_assert(context->session != NULL);
+
+	channel = g_io_channel_unix_new(sv[1]);
+
+	g_io_channel_set_close_on_unref(channel, TRUE);
+	g_io_channel_set_encoding(channel, NULL, NULL);
+	g_io_channel_set_buffered(channel, FALSE);
+
+	context->source = g_io_add_watch(channel,
+				G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+				test_handler, context);
+	g_assert(context->source > 0);
+
+	g_io_channel_unref(channel);
+
+	context->fd = sv[1];
+	context->data = data;
+
+	return context;
+}
+
+static void destroy_context(struct context *context)
+{
+	if (context->source > 0)
+		g_source_remove(context->source);
+
+	avrcp_shutdown(context->session);
+
+	g_main_loop_unref(context->main_loop);
+
+	test_free(context->data);
+	g_free(context);
+}
+
+static void test_dummy(gconstpointer data)
+{
+	struct context *context =  create_context(0x0100, data);
+
+	destroy_context(context);
+}
+
+int main(int argc, char *argv[])
+{
+	g_test_init(&argc, &argv, NULL);
+
+	if (g_test_verbose())
+		__btd_log_init("*", 0);
+
+	/* Connection Establishment for Control tests */
+
+	/*
+	 * Tests are checking connection establishement and release
+	 * for control channel. Since we are connected through socketpair
+	 * the tests are dummy
+	 */
+	define_test("/TP/CEC/BV-01-I", test_dummy, raw_pdu(0x00));
+	define_test("/TP/CEC/BV-02-I", test_dummy, raw_pdu(0x00));
+	define_test("/TP/CRC/BV-01-I", test_dummy, raw_pdu(0x00));
+	define_test("/TP/CRC/BV-02-I", test_dummy, raw_pdu(0x00));
+
+	return g_test_run();
+}
-- 
1.8.3.2


^ permalink raw reply related

* [PATCHv2 2/6] android/avctp: Add UNIT INFO command request
From: Andrei Emeltchenko @ 2014-02-21 15:23 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392996230-11789-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 android/avctp.c | 13 +++++++++++++
 android/avctp.h |  3 +++
 2 files changed, 16 insertions(+)

diff --git a/android/avctp.c b/android/avctp.c
index 1e414d1..57a8c23 100644
--- a/android/avctp.c
+++ b/android/avctp.c
@@ -1266,6 +1266,19 @@ int avctp_send_vendordep_req(struct avctp *session, uint8_t code,
 						func, user_data);
 }
 
+int avctp_send_unit_info_req(struct avctp *session, avctp_rsp_cb func,
+								void *user_data)
+{
+	uint8_t operands[5];
+
+	memset(operands, 0xFF, sizeof(operands));
+
+	return avctp_send_req(session, AVC_CTYPE_STATUS,
+				AVC_SUBUNIT_UNIT, AVC_OP_UNITINFO,
+				operands, sizeof(operands),
+				func, user_data);
+}
+
 unsigned int avctp_register_passthrough_handler(struct avctp *session,
 						avctp_passthrough_cb cb,
 						void *user_data)
diff --git a/android/avctp.h b/android/avctp.h
index dfa0ca6..7496e53 100644
--- a/android/avctp.h
+++ b/android/avctp.h
@@ -46,6 +46,7 @@
 
 /* subunits of interest */
 #define AVC_SUBUNIT_PANEL		0x09
+#define AVC_SUBUNIT_UNIT		0x1f
 
 /* operands in passthrough commands */
 #define AVC_SELECT			0x00
@@ -170,3 +171,5 @@ int avctp_send_vendordep_req(struct avctp *session, uint8_t code,
 int avctp_send_browsing_req(struct avctp *session,
 				uint8_t *operands, size_t operand_count,
 				avctp_browsing_rsp_cb func, void *user_data);
+int avctp_send_unit_info_req(struct avctp *session, avctp_rsp_cb func,
+							void *user_data);
-- 
1.8.3.2


^ permalink raw reply related

* [PATCHv2 3/6] android/avrcp: Implement avrcp_get_avctp
From: Andrei Emeltchenko @ 2014-02-21 15:23 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392996230-11789-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 android/avrcp-lib.c | 5 +++++
 android/avrcp-lib.h | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index ef48fa7..9180abd 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -39,6 +39,11 @@ struct avrcp {
 	struct avctp	*session;
 };
 
+struct avctp *avrcp_get_avctp(struct avrcp *session)
+{
+	return session->session;
+}
+
 void avrcp_shutdown(struct avrcp *session)
 {
 	if (session->session)
diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
index 7955d56..7bd8b25 100644
--- a/android/avrcp-lib.h
+++ b/android/avrcp-lib.h
@@ -21,8 +21,11 @@
  *
  */
 
+struct avrcp;
+
 typedef void (*avrcp_destroy_cb_t) (void *user_data);
 
+struct avctp *avrcp_get_avctp(struct avrcp *session);
 struct avrcp *avrcp_new(int fd, size_t imtu, size_t omtu, uint16_t version);
 void avrcp_shutdown(struct avrcp *session);
 void avrcp_set_destroy_cb(struct avrcp *session, avrcp_destroy_cb_t cb,
-- 
1.8.3.2


^ permalink raw reply related

* [PATCHv2 4/6] android/avrcp: Use NULL for zero pointers
From: Andrei Emeltchenko @ 2014-02-21 15:23 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392996230-11789-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 android/avrcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/avrcp.c b/android/avrcp.c
index 8ac9e2f..acffd56 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -222,7 +222,7 @@ static sdp_record_t *avrcp_record(void)
 	features = sdp_data_alloc(SDP_UINT16, &feat);
 	sdp_attr_add(record, SDP_ATTR_SUPPORTED_FEATURES, features);
 
-	sdp_set_info_attr(record, "AVRCP TG", 0, 0);
+	sdp_set_info_attr(record, "AVRCP TG", NULL, NULL);
 
 	sdp_data_free(psm);
 	sdp_data_free(version);
-- 
1.8.3.2


^ permalink raw reply related

* [PATCHv2 5/6] unit/avrcp: Add /TP/ICC/BV-01-I/CT test
From: Andrei Emeltchenko @ 2014-02-21 15:23 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392996230-11789-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Test verifies that the Controller can collect information of Target
by UNIT INFO command.
---
 unit/test-avrcp.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index f1c0f46..2cb28b1 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -242,6 +242,37 @@ static void test_dummy(gconstpointer data)
 	destroy_context(context);
 }
 
+static void execute_context(struct context *context)
+{
+	g_main_loop_run(context->main_loop);
+
+	if (context->source > 0)
+		g_source_remove(context->source);
+
+	avrcp_shutdown(context->session);
+
+	g_main_loop_unref(context->main_loop);
+
+	test_free(context->data);
+	g_free(context);
+}
+
+static void test_client(gconstpointer data)
+{
+	struct context *context = create_context(0x0100, data);
+	struct avctp *session = avrcp_get_avctp(context->session);
+	int ret = 0;
+
+	if (g_str_equal(context->data->test_name, "/TP/ICC/BV-01-I/CT"))
+		ret = avctp_send_unit_info_req(session, NULL, NULL);
+
+	DBG("ret = %d", ret);
+
+	g_assert(!ret);
+
+	execute_context(context);
+}
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
@@ -261,5 +292,11 @@ int main(int argc, char *argv[])
 	define_test("/TP/CRC/BV-01-I", test_dummy, raw_pdu(0x00));
 	define_test("/TP/CRC/BV-02-I", test_dummy, raw_pdu(0x00));
 
+	/* Information collection for control tests */
+
+	define_test("/TP/ICC/BV-01-I/CT", test_client,
+			raw_pdu(0x00, 0x11, 0x0e, 0x01, 0xf8, 0x30,
+				0xff, 0xff, 0xff, 0xff, 0xff));
+
 	return g_test_run();
 }
-- 
1.8.3.2


^ permalink raw reply related

* [PATCHv2 6/6] unit/avrcp: Add /TP/ICC/BV-01-I/TG test
From: Andrei Emeltchenko @ 2014-02-21 15:23 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392996230-11789-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Test verifies that the Target responds to UNIT INFO command initiated by
Controller.
---
 unit/test-avrcp.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 2cb28b1..0e7de96 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -273,6 +273,15 @@ static void test_client(gconstpointer data)
 	execute_context(context);
 }
 
+static void test_server(gconstpointer data)
+{
+	struct context *context = create_context(0x0100, data);
+
+	g_idle_add(send_pdu, context);
+
+	execute_context(context);
+}
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
@@ -298,5 +307,11 @@ int main(int argc, char *argv[])
 			raw_pdu(0x00, 0x11, 0x0e, 0x01, 0xf8, 0x30,
 				0xff, 0xff, 0xff, 0xff, 0xff));
 
+	define_test("/TP/ICC/BV-01-I/TG", test_server,
+			raw_pdu(0x00, 0x11, 0x0e, 0x01, 0xf8, 0x30,
+				0xff, 0xff, 0xff, 0xff, 0xff),
+			raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0xf8, 0x30,
+				0x07, 0x48, 0xff, 0xff, 0xff));
+
 	return g_test_run();
 }
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH] android/tester: Fix slang "never used" warning
From: Andrei Emeltchenko @ 2014-02-21 15:46 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

The patch fixes following warning:
...
android/android-tester.c:2185:2: warning: Value stored to
'adapter_status' is never read
        adapter_status = data->if_bluetooth->set_adapter_property(prop);
        ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
---
 android/android-tester.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index 84c6ca9..47f918c 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -2190,6 +2190,10 @@ static void test_getprop_bdname_success(const void *test_data)
 	init_test_conditions(data);
 
 	adapter_status = data->if_bluetooth->set_adapter_property(prop);
+	if (adapter_status != BT_STATUS_SUCCESS) {
+		tester_setup_failed();
+		return;
+	}
 
 	adapter_status = data->if_bluetooth->get_adapter_property((*prop).type);
 	check_expected_status(adapter_status);
-- 
1.8.3.2


^ permalink raw reply related

* Re: [PATCH] android/tester: Fix slang "never used" warning
From: Szymon Janc @ 2014-02-21 16:00 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1392997607-21896-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Friday 21 of February 2014 17:46:47 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> The patch fixes following warning:
> ...
> android/android-tester.c:2185:2: warning: Value stored to
> 'adapter_status' is never read
>         adapter_status = data->if_bluetooth->set_adapter_property(prop);
>         ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ...
> ---
>  android/android-tester.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/android/android-tester.c b/android/android-tester.c
> index 84c6ca9..47f918c 100644
> --- a/android/android-tester.c
> +++ b/android/android-tester.c
> @@ -2190,6 +2190,10 @@ static void test_getprop_bdname_success(const void *test_data)
>  	init_test_conditions(data);
>  
>  	adapter_status = data->if_bluetooth->set_adapter_property(prop);
> +	if (adapter_status != BT_STATUS_SUCCESS) {
> +		tester_setup_failed();

This should be tester_test_failed().

> +		return;
> +	}
>  
>  	adapter_status = data->if_bluetooth->get_adapter_property((*prop).type);
>  	check_expected_status(adapter_status);
> 

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* [PATCH 1/2] android/bluetooth: Don't set remote name to empty string
From: Szymon Janc @ 2014-02-21 16:49 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

If remote device has name but it is empty (0 bytes) just ignore it and
continue using address as name. This will avoid sending remote device
property notification with empty name.
---
 android/bluetooth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index 31092e3..e225264 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -1096,7 +1096,7 @@ static void update_new_device(struct device *dev, int8_t rssi,
 		ev->num_props++;
 	}
 
-	if (eir->name) {
+	if (eir->name && strlen(eir->name)) {
 		g_free(dev->name);
 		dev->name = g_strdup(eir->name);
 		size += fill_hal_prop(buf + size, HAL_PROP_DEVICE_NAME,
@@ -1136,7 +1136,7 @@ static void update_device(struct device *dev, int8_t rssi,
 		ev->num_props++;
 	}
 
-	if (eir->name && strcmp(dev->name, eir->name)) {
+	if (eir->name && strlen(eir->name) && strcmp(dev->name, eir->name)) {
 		g_free(dev->name);
 		dev->name = g_strdup(eir->name);
 		size += fill_hal_prop(buf + size, HAL_PROP_DEVICE_NAME,
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH 2/2] android/hal-ipc: Fix race condition when closing IPC
From: Szymon Janc @ 2014-02-21 16:49 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1393001393-1160-1-git-send-email-szymon.janc@tieto.com>

Protect command socket cleanup with mutex to avoid bogus exit when
stopping notification thread.
---
 android/hal-ipc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/android/hal-ipc.c b/android/hal-ipc.c
index 99ba38e..1ba03f5 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -159,8 +159,12 @@ static void *notification_handler(void *data)
 
 		/* socket was shutdown */
 		if (ret == 0) {
-			if (cmd_sk == -1)
+			pthread_mutex_lock(&cmd_sk_mutex);
+			if (cmd_sk == -1) {
+				pthread_mutex_unlock(&cmd_sk_mutex);
 				break;
+			}
+			pthread_mutex_unlock(&cmd_sk_mutex);
 
 			error("Notification socket closed, aborting");
 			exit(EXIT_FAILURE);
@@ -299,8 +303,10 @@ bool hal_ipc_init(void)
 
 void hal_ipc_cleanup(void)
 {
+	pthread_mutex_lock(&cmd_sk_mutex);
 	close(cmd_sk);
 	cmd_sk = -1;
+	pthread_mutex_unlock(&cmd_sk_mutex);
 
 	shutdown(notif_sk, SHUT_RD);
 
-- 
1.8.5.3


^ permalink raw reply related

* Re: [PATCH] android/pts: PTS test results for A2DP
From: Szymon Janc @ 2014-02-21 16:58 UTC (permalink / raw)
  To: Sebastian Chlad; +Cc: linux-bluetooth
In-Reply-To: <1392987204-13621-1-git-send-email-sebastian.chlad@tieto.com>

Hi Sebastian,

On Friday 21 of February 2014 13:53:24 Sebastian Chlad wrote:
> ---
>  android/pts-a2dp.txt | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/android/pts-a2dp.txt b/android/pts-a2dp.txt
> index 301b1e7..c407130 100644
> --- a/android/pts-a2dp.txt
> +++ b/android/pts-a2dp.txt
> @@ -1,7 +1,7 @@
>  PTS test results for A2DP
>  
>  PTS version: 5.0
> -Tested: 28.01.2014
> +Tested: 21.02.2014
>  Android version: 4.4.2
>  
>  Results:
> @@ -14,7 +14,7 @@ N/A	test is disabled due to PICS setup
>  -------------------------------------------------------------------------------
>  Test Name		Result	Notes
>  -------------------------------------------------------------------------------
> -TC_SRC_CC_BV_09_I	INC
> +TC_SRC_CC_BV_09_I	PASS	Start streaming
>  TC_SRC_CC_BV_10_I	N/A
>  TC_SRC_REL_BV_01_I	PASS	Connect to PTS from IUT. When requested
>  				disconnect from IUT
> @@ -22,11 +22,11 @@ TC_SRC_REL_BV_02_I	PASS
>  TC_SRC_SET_BV_01_I	PASS	Connect to PTS (open a2dp)
>  TC_SRC_SET_BV_02_I	PASS
>  TC_SRC_SET_BV_03_I	PASS	Start streaming
> -TC_SRC_SET_BV_04_I	INC	Start streaming
> -TC_SRC_SET_BV_05_I	INC	IUT must be moved out of range
> -TC_SRC_SET_BV_06_I	INC	IUT must be moved out of range
> +TC_SRC_SET_BV_04_I	PASS	Start streaming
> +TC_SRC_SET_BV_05_I	PASS	IUT must be moved out of range
> +TC_SRC_SET_BV_06_I	PASS	IUT must be moved out of range
>  TC_SRC_SUS_BV_01_I	PASS	Stop streaming
> -TC_SRC_SUS_BV_02_I	INC
> +TC_SRC_SUS_BV_02_I	PASS
>  TC_SRC_SDP_BV_01_I	PASS
>  TC_SRC_AS_BV_01_I	PASS	Requires checking if the output on the IUT is
>  				correct
> 

Applied, thanks.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* pull request: bluetooth-next 2014-02-21
From: Gustavo Padovan @ 2014-02-22  2:47 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, linux-bluetooth, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 11393 bytes --]

Hi John,

This is our first pull request for 3.15, the main feature here is the addition of
the privacy feature for low energy devices. Other than that we have a bunch of small
improvements, fixes, and clean ups all over the tree.

Please pull or let me know of any concerns you may have. Thanks.

	Gustavo

---
The following changes since commit e57f1734d87aa0e9a00905ed08888f0c62f56227:

  mwifiex: add key material v2 support (2014-02-12 15:36:26 -0500)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git for-upstream

for you to fetch changes up to 668b7b19820b0801c425d31cc27fd6f499050e5c:

  Bluetooth: Fix iterating wrong list in hci_remove_irk() (2014-02-21 11:07:46 -0300)

----------------------------------------------------------------
Andre Guedes (5):
      Bluetooth: Save connection interval parameters in hci_conn
      Bluetooth: Group list_head fields from strcut hci_dev together
      Bluetooth: Introduce le_conn_failed() helper
      Bluetooth: Introduce connection parameters list
      Bluetooth: Use connection parameters if any

Andrzej Kaczmarek (1):
      Bluetooth: Fix channel check when binding RFCOMM sock

Andy Shevchenko (2):
      Bluetooth: sort the list of IDs in the source code
      Bluetooth: append new supported device to the list [0b05:17d0]

Johan Hedberg (53):
      Bluetooth: Fix outgoing authentication requirement check
      Bluetooth: Fix mgmt error code for negative PIN response
      Bluetooth: Reorder L2CAP functions to avoid forward declarations
      Bluetooth: Queue incoming ACL data until BT_CONNECTED state is reached
      Bluetooth: Remove useless l2cap_seq_list_remove function
      Bluetooth: Rename L2CAP_CHAN_CONN_FIX_A2MP to L2CAP_CHAN_FIXED
      Bluetooth: Switch ATT channels to use L2CAP_CHAN_FIXED
      Bluetooth: Fix BT_SECURITY socket option for fixed channels (ATT)
      Bluetooth: Fix CID initialization for fixed channels
      Bluetooth: Fix respecting le_default_mps value
      Bluetooth: Fix disconnecting L2CAP channel for credits violation
      Bluetooth: Fix disconnecting L2CAP when a credits overflow occurs
      Bluetooth: Free up l2cap_chan->sport when initiating a connection
      Bluetooth: Refuse peer L2CAP address reading when not connected
      Bluetooth: Refuse peer RFCOMM address reading when not connected
      Bluetooth: Always use l2cap_chan->psm for returning PSM to user space
 2     Bluetooth: Remove unnecessary check for chan->psm
      Bluetooth: Enable LTK distribution to slave devices
      Bluetooth: Remove Simultaneous LE & BR/EDR flags from AD
      Bluetooth: Fix long_term_keys debugfs output
      Bluetooth: Make LTK key type check more readable
      Bluetooth: Remove unnecessary LTK type check from hci_add_ltk
      Bluetooth: Fix differentiating stored master vs slave LTK types
      Bluetooth: Enable LE L2CAP CoC support by default
      Bluetooth: Fix missing PDU length checks for SMP
      Bluetooth: Fix minor whitespace issues in SMP code
      Bluetooth: Add smp_irk_matches helper function
      Bluetooth: Add AES crypto context for each HCI device
      Bluetooth: Add basic IRK management support
      Bluetooth: Add hci_bdaddr_is_rpa convenience function
      Bluetooth: Implement mgmt_load_irks command
      Bluetooth: Enable support for remote IRK distribution
      Bluetooth: Fix properly ignoring unexpected SMP PDUs
      Bluetooth: Fix missing address type check for removing LTKs
      Bluetooth: Remove return values from functions that don't need them
      Bluetooth: Fix hci_remove_ltk failure when no match is found
      Bluetooth: Fix completing SMP as peripheral when no keys are expected
      Bluetooth: Fix removing any IRKs when unpairing devices
      Bluetooth: Add convenience function for fetching IRKs
      Bluetooth: Remove SMP data specific crypto context
      Bluetooth: Track the LE Identity Address in struct hci_conn
      Bluetooth: Fix updating Identity Address in L2CAP channels
      Bluetooth: Wait for SMP key distribution completion when pairing
      Bluetooth: Don't try to look up private addresses as Identity Address
      Bluetooth: Look up RPA for connection requests with Identity Address
      Bluetooth: Use Identity Address in Device Found event
      Bluetooth: Avoid using GFP_ATOMIC where not necessary
      Bluetooth: Return added key when adding LTKs and IRKs
      Bluetooth: Move New LTK store hint evaluation into mgmt_new_ltk
      Bluetooth: Track SMP keys in the SMP context
      Bluetooth: Move SMP LTK notification after key distribution
      Bluetooth: Add support for sending New IRK event
      Bluetooth: Fix iterating wrong list in hci_remove_irk()

Jurgen Kramer (1):
      Bluetooth: btusb: Add IMC Networks (Broadcom based)

Lucas De Marchi (1):
      Bluetooth: allocate static minor for vhci

Marcel Holtmann (48):
      Bluetooth: Add LMP feature definitions for Secure Connections support
      Bluetooth: Add HCI command definition for Secure Connections enabling
      Bluetooth: Add HCI command definition for extended OOB data
      Bluetooth: Add definitions for new link key types
      Bluetooth: Add support for handling P-256 derived link keys
      Bluetooth: Enable Authenticated Payload Timeout Expired event
      Bluetooth: Add flags and setting for Secure Connections support
      Bluetooth: Add management command for enabling Secure Connections
      Bluetooth: Enable Secure Connection during power on if configured
      Bluetooth: Limit acceptable link key types to only supported ones
      Bluetooth: Add support for local OOB data with Secure Connections
      Bluetooth: Add debugfs quirk for forcing Secure Connections support
      Bluetooth: Provide remote OOB data for Secure Connections
      Bluetooth: Add internal function for storing P-192 and P-256 data
      Bluetooth: Add support for remote OOB input of P-256 data
      Bluetooth: Track Secure Connections support of remote devices
      Bluetooth: Introduce requirements for security level 4
      Bluetooth: Handle security level 4 for L2CAP connections
      Bluetooth: Handle security level 4 for RFCOMM connections
      Bluetooth: Add debugfs entry to show Secure Connections Only mode
      Bluetooth: Increment management interface revision
      Bluetooth: Add management setting for use of debug keys
      Bluetooth: Add management command to allow use of debug keys
      Bluetooth: Remove use_debug_keys debugfs entry
      Bluetooth: Remove one level of indentation from hci_encrypt_change_evt
      Bluetooth: Track the AES-CCM encryption status of LE and BR/EDR links
      Bluetooth: Remove check for valid LTK authenticated parameter
      Bluetooth: Rename authentication to key_type in mgmt_ltk_info
      Bluetooth: Remove __packed from struct smp_ltk
      Bluetooth: Add management command for Secure Connection Only Mode
      Bluetooth: Include security level 4 in connections check
      Bluetooth: Track if link is using P-256 authenticated combination key
      Bluetooth: Add constants for LTK key types
      Bluetooth: Restrict long term keys to public and static addresses
      Bluetooth: Fix sending wrong store hint for new long term keys
      Bluetooth: Add missing index added event on user channel failure
      Bluetooth: Allow HCI User Channel usage for controllers without address
      Bluetooth: Report identity address when remote device connects
      Bluetooth: Use connection address for reporting connection failures
      Bluetooth: Fix wrong identity address during connection failures
      Bluetooth: Expose current list of identity resolving keys via debugfs
      Bluetooth: Use same LE min/max connection event length during update
      Bluetooth: Don't send store hint for devices using identity addresses
      Bluetooth: Add comment explainging store hint for long term keys
      Bluetooth: Replace own_address_type with force_static_address debugfs
      Bluetooth: Track the current configured random address
      Bluetooth: Provide option for changing LE advertising channel map
      Bluetooth: Increase minor version of core module

Oliver Neukum (2):
      Bluetooth: Enable Atheros 0cf3:311e for firmware upload
      Bluetooth: Add firmware update for Atheros 0cf3:311f

Peter Hurley (24):
      Revert "Bluetooth: Remove rfcomm_carrier_raised()"
      Revert "Bluetooth: Always wait for a connection on RFCOMM open()"
      Revert "Bluetooth: Move rfcomm_get_device() before rfcomm_dev_activate()"
      tty: Fix ref counting for port krefs
      Bluetooth: Fix racy acquire of rfcomm_dev reference
      Bluetooth: Exclude released devices from RFCOMMGETDEVLIST ioctl
      Bluetooth: Release rfcomm_dev only once
      Bluetooth: Fix unreleased rfcomm_dev reference
      Bluetooth: Fix RFCOMM tty teardown race
      Bluetooth: Verify dlci not in use before rfcomm_dev create
      Bluetooth: Simplify RFCOMM session state eval
      Bluetooth: Refactor deferred setup test in rfcomm_dlc_close()
      Bluetooth: Refactor dlc disconnect logic in rfcomm_dlc_close()
      Bluetooth: Directly close dlc for not yet started RFCOMM session
      Bluetooth: Fix unsafe RFCOMM device parenting
      Bluetooth: Fix RFCOMM parent device for reused dlc
      Bluetooth: Rename __rfcomm_dev_get() to __rfcomm_dev_lookup()
      Bluetooth: Serialize RFCOMMCREATEDEV and RFCOMMRELEASEDEV ioctls
      Bluetooth: Refactor rfcomm_dev_add()
      Bluetooth: Cleanup RFCOMM device registration error handling
      Bluetooth: Force -EIO from tty read/write if .activate() fails
      Bluetooth: Don't fail RFCOMM tty writes
      Bluetooth: Refactor write_room() calculation
      Bluetooth: Fix write_room() calculation

Szymon Janc (1):
      Bluetooth: Print error when dropping L2CAP data

Wei Yongjun (1):
      Bluetooth: Convert to use ATTRIBUTE_GROUPS macro

 Documentation/devices.txt         |   1 +
 drivers/bluetooth/ath3k.c         |  84 ++++----
 drivers/bluetooth/btusb.c         |  58 +++---
 drivers/bluetooth/hci_vhci.c      |   3 +-
 include/linux/miscdevice.h        |   1 +
 include/linux/tty.h               |   6 +-
 include/net/bluetooth/bluetooth.h |   1 +
 include/net/bluetooth/hci.h       |  49 ++++-
 include/net/bluetooth/hci_core.h  | 129 +++++++++---
 include/net/bluetooth/l2cap.h     |   8 +-
 include/net/bluetooth/mgmt.h      |  41 +++-
 include/net/bluetooth/rfcomm.h    |  10 +-
 net/bluetooth/a2mp.c              |   8 +-
 net/bluetooth/af_bluetooth.c      |   2 +-
 net/bluetooth/hci_conn.c          | 106 +++++++---
 net/bluetooth/hci_core.c          | 578 ++++++++++++++++++++++++++++++++++++++++++--------
 net/bluetooth/hci_event.c         | 206 ++++++++++++++----
 net/bluetooth/hci_sock.c          |   1 +
 net/bluetooth/hci_sysfs.c         |  18 +-
 net/bluetooth/l2cap_core.c        | 591 +++++++++++++++++++++++++++-------------------------
 net/bluetooth/l2cap_sock.c        |  62 +++---
 net/bluetooth/mgmt.c              | 492 ++++++++++++++++++++++++++++++++++++++-----
 net/bluetooth/rfcomm/core.c       |  92 ++++++--
 net/bluetooth/rfcomm/sock.c       |  33 ++-
 net/bluetooth/rfcomm/tty.c        | 262 ++++++++++++-----------
 net/bluetooth/smp.c               | 250 +++++++++++++++++++---
 net/bluetooth/smp.h               |  13 +-
 27 files changed, 2282 insertions(+), 823 deletions(-)

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply

* Chrome OS (BlueZ 5.x) qualified as a Host Subsystem for Bluetooth 4.0 & Low Energy
From: Scott James Remnant @ 2014-02-22  4:42 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org

I wanted to share with the rest of the community that the Chrome OS
team have successfully completed qualification of BlueZ 5.x as a
Bluetooth 4.0 & Low Energy Host Subsystem:

https://www.bluetooth.org/tpg/QLI_viewQDL.cfm?qid=22333


The specific versions we qualified were BlueZ 5.4, plus patches, on
Linux 3.8 and 3.4 with the entire Bluetooth stack backported to it.

Scott

^ permalink raw reply


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