Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] all: Use G_SOURCE_REMOVE/G_SOURCE_CONTINUE macros
From: Bastien Nocera @ 2013-11-20  8:56 UTC (permalink / raw)
  To: linux-bluetooth


Instead of TRUE/FALSE. This makes the source more readable.
---
 attrib/gattrib.c                     |  2 +-
 attrib/gatttool.c                    |  2 +-
 configure.ac                         |  8 ++++++++
 gdbus/mainloop.c                     |  6 +++---
 gdbus/object.c                       |  2 +-
 gdbus/watch.c                        |  2 +-
 gobex/gobex.c                        |  4 ++--
 obexd/client/session.c               |  4 ++--
 obexd/client/transfer.c              |  6 +++---
 obexd/plugins/messages-dummy.c       |  2 +-
 obexd/plugins/messages-tracker.c     |  2 +-
 obexd/plugins/phonebook-dummy.c      |  6 +++---
 plugins/policy.c                     |  6 +++---
 profiles/audio/a2dp.c                | 16 ++++++++--------
 profiles/audio/avctp.c               | 12 ++++++------
 profiles/audio/avdtp.c               | 14 +++++++-------
 profiles/audio/avrcp.c               |  2 +-
 profiles/audio/player.c              |  4 ++--
 profiles/cyclingspeed/cyclingspeed.c |  2 +-
 profiles/health/hdp.c                |  4 ++--
 profiles/health/mcap.c               |  2 +-
 profiles/health/mcap_sync.c          | 18 +++++++++---------
 profiles/input/device.c              | 10 +++++-----
 profiles/network/connection.c        |  2 +-
 profiles/proximity/monitor.c         |  4 ++--
 profiles/sap/server.c                |  4 ++--
 src/adapter.c                        | 20 ++++++++++----------
 src/device.c                         | 16 ++++++++--------
 src/main.c                           |  4 ++--
 src/sdp-client.c                     |  2 +-
 src/shared/hciemu.c                  |  2 +-
 src/shared/tester.c                  | 18 +++++++++---------
 tools/btiotest.c                     |  6 +++---
 unit/test-gdbus-client.c             |  4 ++--
 unit/test-gobex-transfer.c           |  2 +-
 unit/test-gobex.c                    |  4 ++--
 unit/test-sdp.c                      |  2 +-
 37 files changed, 117 insertions(+), 109 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 609b908..4d93902 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -284,7 +284,7 @@ done:
 
 	g_attrib_unref(attrib);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean can_write_data(GIOChannel *io, GIOCondition cond,
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index f211dcd..7ef26aa 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -116,7 +116,7 @@ static gboolean listen_start(gpointer user_data)
 	g_attrib_register(attrib, ATT_OP_HANDLE_IND, GATTRIB_ALL_HANDLES,
 						events_handler, attrib, NULL);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
diff --git a/configure.ac b/configure.ac
index 949846e..5373545 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,6 +54,14 @@ PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28, dummy=yes,
 AC_SUBST(GLIB_CFLAGS)
 AC_SUBST(GLIB_LIBS)
 
+# Remove when glib dep is bumped
+PKG_CHECK_MODULES(SOURCE_CHECK, glib-2.0 >= 2.32,
+			has_source_macro=yes, has_source_macro=no)
+if (test "${has_source_macro}" = "no"); then
+	AC_DEFINE(G_SOURCE_REMOVE, 0, [Macro available from glib 2.32])
+	AC_DEFINE(G_SOURCE_CONTINUE, 1, [Macro available from glib 2.32])
+fi
+
 if (test "${enable_threads}" = "yes"); then
 	AC_DEFINE(NEED_THREADS, 1, [Define if threading support is required])
 	PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
diff --git a/gdbus/mainloop.c b/gdbus/mainloop.c
index 099b67f..d00db33 100644
--- a/gdbus/mainloop.c
+++ b/gdbus/mainloop.c
@@ -77,7 +77,7 @@ static gboolean message_dispatch(void *data)
 
 	dbus_connection_unref(conn);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static inline void queue_dispatch(DBusConnection *conn,
@@ -186,11 +186,11 @@ static gboolean timeout_handler_dispatch(gpointer data)
 
 	/* if not enabled should not be polled by the main loop */
 	if (!dbus_timeout_get_enabled(handler->timeout))
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	dbus_timeout_handle(handler->timeout);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void timeout_handler_free(void *data)
diff --git a/gdbus/object.c b/gdbus/object.c
index b248cbb..72c542e 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -1008,7 +1008,7 @@ static gboolean process_changes(gpointer user_data)
 
 	data->process_id = 0;
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void generic_unregister(DBusConnection *connection, void *user_data)
diff --git a/gdbus/watch.c b/gdbus/watch.c
index 0f99f4f..f357cd1 100644
--- a/gdbus/watch.c
+++ b/gdbus/watch.c
@@ -599,7 +599,7 @@ static gboolean update_service(void *user_data)
 
 	dbus_connection_unref(conn);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void service_reply(DBusPendingCall *call, void *user_data)
diff --git a/gobex/gobex.c b/gobex/gobex.c
index 8c08b1e..e107c0c 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -253,7 +253,7 @@ static gboolean req_timeout(gpointer user_data)
 	g_error_free(err);
 	pending_pkt_free(p);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean write_stream(GObex *obex, GError **err)
@@ -720,7 +720,7 @@ static gboolean cancel_complete(gpointer user_data)
 
 	pending_pkt_free(p);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 gboolean g_obex_cancel_req(GObex *obex, guint req_id, gboolean remove_callback)
diff --git a/obexd/client/session.c b/obexd/client/session.c
index 8138b1e..72fcc6d 100644
--- a/obexd/client/session.c
+++ b/obexd/client/session.c
@@ -435,7 +435,7 @@ static gboolean connection_complete(gpointer data)
 
 	g_free(cb);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static int session_connect(struct obc_session *session,
@@ -730,7 +730,7 @@ static gboolean session_process(gpointer data)
 
 	session_process_queue(session);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void session_queue(struct pending_request *p)
diff --git a/obexd/client/transfer.c b/obexd/client/transfer.c
index 5a8d4f2..54713a9 100644
--- a/obexd/client/transfer.c
+++ b/obexd/client/transfer.c
@@ -680,13 +680,13 @@ static gboolean report_progress(gpointer data)
 	struct obc_transfer *transfer = data;
 
 	if (transfer->transferred == transfer->progress)
-		return TRUE;
+		return G_SOURCE_CONTINUE;
 
 	transfer->progress = transfer->transferred;
 
 	if (transfer->transferred == transfer->size) {
 		transfer->progress_id = 0;
-		return FALSE;
+		return G_SOURCE_REMOVE;
 	}
 
 	if (transfer->status != TRANSFER_STATUS_ACTIVE)
@@ -695,7 +695,7 @@ static gboolean report_progress(gpointer data)
 	g_dbus_emit_property_changed(transfer->conn, transfer->path,
 					TRANSFER_INTERFACE, "Transferred");
 
-	return TRUE;
+	return G_SOURCE_CONTINUE;
 }
 
 static gboolean transfer_start_get(struct obc_transfer *transfer, GError **err)
diff --git a/obexd/plugins/messages-dummy.c b/obexd/plugins/messages-dummy.c
index bb0627f..439ea95 100644
--- a/obexd/plugins/messages-dummy.c
+++ b/obexd/plugins/messages-dummy.c
@@ -198,7 +198,7 @@ static gboolean get_folder_listing(void *d)
 	return_folder_listing(fld, list);
 	g_slist_free_full(list, g_free);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 int messages_init(void)
diff --git a/obexd/plugins/messages-tracker.c b/obexd/plugins/messages-tracker.c
index 60f3a80..6df57ad 100644
--- a/obexd/plugins/messages-tracker.c
+++ b/obexd/plugins/messages-tracker.c
@@ -282,7 +282,7 @@ static gboolean async_get_folder_listing(void *s)
 	g_free(path);
 	g_free(session->name);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 int messages_get_folder_listing(void *s, const char *name,
diff --git a/obexd/plugins/phonebook-dummy.c b/obexd/plugins/phonebook-dummy.c
index 6b9d040..ca266ef 100644
--- a/obexd/plugins/phonebook-dummy.c
+++ b/obexd/plugins/phonebook-dummy.c
@@ -252,7 +252,7 @@ done:
 
 	g_string_free(buffer, TRUE);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void entry_notify(const char *filename, VObject *v, void *user_data)
@@ -326,7 +326,7 @@ static gboolean create_cache(void *user_data)
 
 	query->ready_cb(query->user_data);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean read_entry(void *user_data)
@@ -348,7 +348,7 @@ static gboolean read_entry(void *user_data)
 
 	dummy->cb(buffer, count, 1, 0, TRUE, dummy->user_data);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean is_dir(const char *dir)
diff --git a/plugins/policy.c b/plugins/policy.c
index 0292482..787371f 100644
--- a/plugins/policy.c
+++ b/plugins/policy.c
@@ -90,7 +90,7 @@ static gboolean policy_connect_ct(gpointer user_data)
 	if (service != NULL)
 		policy_connect(data, service);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void policy_set_ct_timer(struct policy_data *data)
@@ -163,7 +163,7 @@ static gboolean policy_connect_sink(gpointer user_data)
 	if (service != NULL)
 		policy_connect(data, service);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void policy_set_sink_timer(struct policy_data *data)
@@ -272,7 +272,7 @@ static gboolean policy_connect_source(gpointer user_data)
 	if (service != NULL)
 		policy_connect(data, service);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void policy_set_source_timer(struct policy_data *data)
diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index 29a1593..6689d72 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -224,7 +224,7 @@ static gboolean finalize_config(gpointer data)
 		setup_cb_free(cb);
 	}
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean finalize_resume(gpointer data)
@@ -244,7 +244,7 @@ static gboolean finalize_resume(gpointer data)
 		setup_cb_free(cb);
 	}
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean finalize_suspend(gpointer data)
@@ -264,7 +264,7 @@ static gboolean finalize_suspend(gpointer data)
 		setup_cb_free(cb);
 	}
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void finalize_select(struct a2dp_setup *s)
@@ -384,7 +384,7 @@ static gboolean auto_config(gpointer data)
 
 	/* Check if configuration was aborted */
 	if (setup->sep->stream == NULL)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	if (setup->err != NULL)
 		goto done;
@@ -413,7 +413,7 @@ done:
 
 	setup_unref(setup);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void endpoint_setconf_cb(struct a2dp_setup *setup, gboolean ret)
@@ -727,7 +727,7 @@ static gboolean suspend_timeout(struct a2dp_sep *sep)
 	avdtp_unref(sep->session);
 	sep->session = NULL;
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean start_ind(struct avdtp *session, struct avdtp_local_sep *sep,
@@ -928,11 +928,11 @@ static gboolean a2dp_reconfigure(gpointer data)
 		goto failed;
 	}
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 
 failed:
 	finalize_setup_errno(setup, posix_err, finalize_config, NULL);
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void close_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index 476f61a..4f688c8 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -299,7 +299,7 @@ static gboolean auto_release(gpointer user_data)
 
 	send_key(session->uinput, session->key.op, 0);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static size_t handle_panel_passthrough(struct avctp *session,
@@ -697,7 +697,7 @@ static gboolean req_timeout(gpointer user_data)
 	if (chan->process_id == 0)
 		chan->process_id = g_idle_add(process_queue, chan);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static int process_control(void *data)
@@ -727,7 +727,7 @@ static gboolean process_queue(void *user_data)
 	chan->process_id = 0;
 
 	if (p != NULL)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	while ((p = g_queue_pop_head(chan->queue))) {
 
@@ -738,12 +738,12 @@ static gboolean process_queue(void *user_data)
 	}
 
 	if (p == NULL)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	chan->p = p;
 	p->timeout = g_timeout_add_seconds(2, req_timeout, chan);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 
 }
 
@@ -1653,7 +1653,7 @@ static gboolean repeat_timeout(gpointer user_data)
 	avctp_passthrough_release(session, session->key.op);
 	avctp_passthrough_press(session, session->key.op);
 
-	return TRUE;
+	return G_SOURCE_CONTINUE;
 }
 
 static void release_pressed(struct avctp *session)
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index b7a7d9c..f1815cb 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -627,7 +627,7 @@ static gboolean stream_close_timeout(gpointer user_data)
 
 	close_stream(stream);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean stream_open_timeout(gpointer user_data)
@@ -642,7 +642,7 @@ static gboolean stream_open_timeout(gpointer user_data)
 
 	avdtp_abort(stream->session, stream);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 void avdtp_error_init(struct avdtp_error *err, uint8_t category, int id)
@@ -1178,18 +1178,18 @@ static gboolean disconnect_timeout(gpointer user_data)
 	service = btd_device_get_service(session->device, A2DP_SINK_UUID);
 	if (service && stream_setup) {
 		sink_setup_stream(service, session);
-		return FALSE;
+		return G_SOURCE_REMOVE;
 	}
 
 	service = btd_device_get_service(session->device, A2DP_SOURCE_UUID);
 	if (service && stream_setup) {
 		source_setup_stream(service, session);
-		return FALSE;
+		return G_SOURCE_REMOVE;
 	}
 
 	connection_lost(session, ETIMEDOUT);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void set_disconnect_timer(struct avdtp *session)
@@ -2667,7 +2667,7 @@ static gboolean request_timeout(gpointer user_data)
 
 	cancel_request(session, ETIMEDOUT);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static int send_req(struct avdtp *session, gboolean priority,
@@ -3298,7 +3298,7 @@ static gboolean process_discover(gpointer data)
 
 	finalize_discovery(session, 0);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 int avdtp_discover(struct avdtp *session, avdtp_discover_cb_t cb,
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index cd027c6..b3a1873 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -3323,7 +3323,7 @@ static gboolean connect_browsing(gpointer user_data)
 
 	avctp_connect_browsing(session->conn);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void avrcp_connect_browsing(struct avrcp *session)
diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index 6150c8a..bce72e9 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -1306,13 +1306,13 @@ static gboolean process_metadata_changed(void *user_data)
 
 	item = g_hash_table_lookup(mp->track, "Item");
 	if (item == NULL)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	g_dbus_emit_property_changed(btd_get_dbus_connection(),
 					item, MEDIA_ITEM_INTERFACE,
 					"Metadata");
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 void media_player_set_metadata(struct media_player *mp,
diff --git a/profiles/cyclingspeed/cyclingspeed.c b/profiles/cyclingspeed/cyclingspeed.c
index 6ecc985..3ad9e75 100644
--- a/profiles/cyclingspeed/cyclingspeed.c
+++ b/profiles/cyclingspeed/cyclingspeed.c
@@ -307,7 +307,7 @@ static gboolean controlpoint_timeout(gpointer user_data)
 	req->csc->pending_req = NULL;
 	g_free(req);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void controlpoint_write_cb(guint8 status, const guint8 *pdu, guint16 len,
diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c
index 7b4e799..d7d0699 100644
--- a/profiles/health/hdp.c
+++ b/profiles/health/hdp.c
@@ -1536,12 +1536,12 @@ static gboolean echo_timeout(gpointer data)
 
 	fd = mcap_mdl_get_fd(chan->mdl);
 	if (fd < 0)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	io = g_io_channel_unix_new(fd);
 	g_io_channel_shutdown(io, TRUE, NULL);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void hdp_echo_connect_cb(struct mcap_mdl *mdl, GError *err,
diff --git a/profiles/health/mcap.c b/profiles/health/mcap.c
index 6d821f3..37b5789 100644
--- a/profiles/health/mcap.c
+++ b/profiles/health/mcap.c
@@ -463,7 +463,7 @@ static gboolean wait_response_timer(gpointer data)
 	mcl->mi->mcl_disconnected_cb(mcl, mcl->mi->user_data);
 	mcap_cache_mcl(mcl);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 gboolean mcap_create_mdl(struct mcap_mcl *mcl,
diff --git a/profiles/health/mcap_sync.c b/profiles/health/mcap_sync.c
index 0d9f17d..aea0202 100644
--- a/profiles/health/mcap_sync.c
+++ b/profiles/health/mcap_sync.c
@@ -517,15 +517,15 @@ static gboolean sync_send_indication(gpointer user_data)
 	int sent;
 
 	if (!user_data)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	mcl = user_data;
 
 	if (!caps(mcl))
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	if (!get_all_clocks(mcl, &btclock, &base_time, &tmstamp))
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	cmd = g_new0(mcap_md_sync_info_ind, 1);
 
@@ -557,12 +557,12 @@ static gboolean proc_sync_set_req_phase2(gpointer user_data)
 	int delay;
 
 	if (!user_data)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	mcl = user_data;
 
 	if (!mcl->csp->set_data)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	data = mcl->csp->set_data;
 	update = data->update;
@@ -573,17 +573,17 @@ static gboolean proc_sync_set_req_phase2(gpointer user_data)
 
 	if (!caps(mcl)) {
 		send_sync_set_rsp(mcl, MCAP_UNSPECIFIED_ERROR, 0, 0, 0);
-		return FALSE;
+		return G_SOURCE_REMOVE;
 	}
 
 	if (!get_all_clocks(mcl, &btclock, &base_time, &tmstamp)) {
 		send_sync_set_rsp(mcl, MCAP_UNSPECIFIED_ERROR, 0, 0, 0);
-		return FALSE;
+		return G_SOURCE_REMOVE;
 	}
 
 	if (get_btrole(mcl) != role) {
 		send_sync_set_rsp(mcl, MCAP_INVALID_OPERATION, 0, 0, 0);
-		return FALSE;
+		return G_SOURCE_REMOVE;
 	}
 
 	reset = (new_tmstamp != MCAP_TMSTAMP_DONTSET);
@@ -624,7 +624,7 @@ static gboolean proc_sync_set_req_phase2(gpointer user_data)
 	if (update)
 		sync_send_indication(mcl);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void proc_sync_set_req(struct mcap_mcl *mcl, uint8_t *cmd, uint32_t len)
diff --git a/profiles/input/device.c b/profiles/input/device.c
index 6523161..bd0886e 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -668,23 +668,23 @@ static gboolean input_device_auto_reconnect(gpointer user_data)
 	 * or is marked for removal. */
 	if (device_is_temporary(idev->device) ||
 					device_is_connected(idev->device))
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	/* Only attempt an auto-reconnect for at most 3 minutes (6 * 30s). */
 	if (idev->reconnect_attempt >= 6)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	/* Check if the profile is already connected. */
 	if (idev->ctrl_io)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	if (is_connected(idev))
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	idev->reconnect_attempt++;
 	dev_connect(idev);
 
-	return TRUE;
+	return G_SOURCE_CONTINUE;
 }
 
 static const char * const _reconnect_mode_str[] = {
diff --git a/profiles/network/connection.c b/profiles/network/connection.c
index 960a1fe..5008ea1 100644
--- a/profiles/network/connection.c
+++ b/profiles/network/connection.c
@@ -354,7 +354,7 @@ static gboolean bnep_conn_req_to(gpointer user_data)
 
 	cancel_connection(nc, -ETIMEDOUT);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static int bnep_connect(struct network_conn *nc)
diff --git a/profiles/proximity/monitor.c b/profiles/proximity/monitor.c
index eaa5b0d..a894235 100644
--- a/profiles/proximity/monitor.c
+++ b/profiles/proximity/monitor.c
@@ -304,7 +304,7 @@ static gboolean immediate_timeout(gpointer user_data)
 	monitor->immediateto = 0;
 
 	if (g_strcmp0(monitor->immediatelevel, "none") == 0)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	if (monitor->attrib) {
 		uint8_t value = ALERT_NONE;
@@ -319,7 +319,7 @@ static gboolean immediate_timeout(gpointer user_data)
 	g_dbus_emit_property_changed(btd_get_dbus_connection(), path,
 				PROXIMITY_INTERFACE, "ImmediateAlertLevel");
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void immediate_written(gpointer user_data)
diff --git a/profiles/sap/server.c b/profiles/sap/server.c
index 63314a7..81a5c58 100644
--- a/profiles/sap/server.c
+++ b/profiles/sap/server.c
@@ -583,7 +583,7 @@ static gboolean guard_timeout(gpointer data)
 	struct sap_connection *conn = server->conn;
 
 	if (!conn)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	DBG("conn %p state %d pr 0x%02x", conn, conn->state,
 						conn->processing_req);
@@ -613,7 +613,7 @@ static gboolean guard_timeout(gpointer data)
 		break;
 	}
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void sap_set_connected(struct sap_server *server)
diff --git a/src/adapter.c b/src/adapter.c
index d904a56..80e7903 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -542,7 +542,7 @@ static gboolean pairable_timeout_handler(gpointer user_data)
 
 	set_mode(adapter, MGMT_OP_SET_PAIRABLE, 0x00);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void trigger_pairable_timeout(struct btd_adapter *adapter)
@@ -1125,7 +1125,7 @@ static gboolean passive_scanning_timeout(gpointer user_data)
 				adapter->dev_id, sizeof(cp), &cp,
 				passive_scanning_complete, adapter, NULL);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void trigger_passive_scanning(struct btd_adapter *adapter)
@@ -1300,12 +1300,12 @@ static gboolean start_discovery_timeout(gpointer user_data)
 		 */
 		if (adapter->discovery_type == new_type) {
 			if (adapter->discovering)
-				return FALSE;
+				return G_SOURCE_REMOVE;
 
 			adapter->discovering = true;
 			g_dbus_emit_property_changed(dbus_conn, adapter->path,
 					ADAPTER_INTERFACE, "Discovering");
-			return FALSE;
+			return G_SOURCE_REMOVE;
 		}
 
 		/*
@@ -1328,7 +1328,7 @@ static gboolean start_discovery_timeout(gpointer user_data)
 				adapter->dev_id, sizeof(cp), &cp,
 				start_discovery_complete, adapter, NULL);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void trigger_start_discovery(struct btd_adapter *adapter, guint delay)
@@ -1534,7 +1534,7 @@ static gboolean remove_temp_devices(gpointer user_data)
 			adapter_remove_device(adapter, dev);
 	}
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void discovery_destroy(void *user_data)
@@ -2381,7 +2381,7 @@ static gboolean load_ltks_timeout(gpointer user_data)
 	mgmt_cancel(adapter->mgmt, adapter->load_ltks_id);
 	adapter->load_ltks_id = 0;
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void load_ltks_complete(uint8_t status, uint16_t length,
@@ -4006,7 +4006,7 @@ static gboolean confirm_name_timeout(gpointer user_data)
 	mgmt_cancel(adapter->mgmt, adapter->confirm_name_id);
 	adapter->confirm_name_id = 0;
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void confirm_name_complete(uint8_t status, uint16_t length,
@@ -4412,7 +4412,7 @@ next:
 
 	dbus_error_free(&err);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static int adapter_authorize(struct btd_adapter *adapter, const bdaddr_t *dst,
@@ -5029,7 +5029,7 @@ static gboolean pair_device_timeout(gpointer user_data)
 
 	adapter_cancel_bonding(adapter, &data->bdaddr, data->addr_type);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void pair_device_complete(uint8_t status, uint16_t length,
diff --git a/src/device.c b/src/device.c
index 82b66e6..183c4bf 100644
--- a/src/device.c
+++ b/src/device.c
@@ -364,7 +364,7 @@ static gboolean store_device_info_cb(gpointer user_data)
 	g_key_file_free(key_file);
 	g_free(uuids);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static bool device_address_is_private(struct btd_device *dev)
@@ -966,7 +966,7 @@ static gboolean do_disconnect(gpointer user_data)
 	btd_adapter_disconnect_device(device->adapter, &device->bdaddr,
 							device->bdaddr_type);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 int device_block(struct btd_device *device, gboolean update_only)
@@ -3680,7 +3680,7 @@ static gboolean start_discovery(gpointer user_data)
 
 	device->discov_timer = 0;
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 void device_set_paired(struct btd_device *device, gboolean value)
@@ -3794,7 +3794,7 @@ static gboolean svc_idle_cb(gpointer user_data)
 
 	g_free(cb);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 unsigned int device_wait_for_svc_complete(struct btd_device *dev,
@@ -3867,7 +3867,7 @@ static gboolean device_bonding_retry(gpointer data)
 	int err;
 
 	if (!bonding)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	DBG("retrying bonding");
 	bonding->retry_timer = 0;
@@ -3888,7 +3888,7 @@ static gboolean device_bonding_retry(gpointer data)
 	if (err < 0)
 		device_bonding_complete(device, bonding->status);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 int device_bonding_attempt_retry(struct btd_device *device)
@@ -4381,13 +4381,13 @@ static gboolean notify_attios(gpointer user_data)
 	struct btd_device *device = user_data;
 
 	if (device->attrib == NULL)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	g_slist_foreach(device->attios_offline, attio_connected, device->attrib);
 	device->attios = g_slist_concat(device->attios, device->attios_offline);
 	device->attios_offline = NULL;
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 guint btd_device_add_attio_callback(struct btd_device *device,
diff --git a/src/main.c b/src/main.c
index 91d90b4..d88b1d5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -298,7 +298,7 @@ void btd_exit(void)
 static gboolean quit_eventloop(gpointer user_data)
 {
 	btd_exit();
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
@@ -446,7 +446,7 @@ static gboolean watchdog_callback(gpointer user_data)
 {
 	sd_notify(0, "WATCHDOG=1");
 
-	return TRUE;
+	return G_SOURCE_CONTINUE;
 }
 
 static gboolean parse_debug(const char *key, const char *value,
diff --git a/src/sdp-client.c b/src/sdp-client.c
index 51f3048..35e2bfd 100644
--- a/src/sdp-client.c
+++ b/src/sdp-client.c
@@ -59,7 +59,7 @@ static gboolean cached_session_expired(gpointer user_data)
 
 	g_free(cached);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static sdp_session_t *get_cached_sdp_session(const bdaddr_t *src, const bdaddr_t *dst)
diff --git a/src/shared/hciemu.c b/src/shared/hciemu.c
index 0ea191f..5cae951 100644
--- a/src/shared/hciemu.c
+++ b/src/shared/hciemu.c
@@ -284,7 +284,7 @@ static gboolean start_stack(gpointer user_data)
 
 	bthost_start(hciemu->host_stack);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 struct hciemu *hciemu_new(enum hciemu_type type)
diff --git a/src/shared/tester.c b/src/shared/tester.c
index f3edd74..24d5bb9 100644
--- a/src/shared/tester.c
+++ b/src/shared/tester.c
@@ -311,7 +311,7 @@ static gboolean teardown_callback(gpointer user_data)
 	print_progress(test->name, COLOR_MAGENTA, "teardown");
 	test->teardown_func(test->test_data);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean test_timeout(gpointer user_data)
@@ -321,14 +321,14 @@ static gboolean test_timeout(gpointer user_data)
 	test->timeout_id = 0;
 
 	if (!test_current)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	test->result = TEST_RESULT_TIMED_OUT;
 	print_progress(test->name, COLOR_RED, "test timed out");
 
 	g_idle_add(teardown_callback, test);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void next_test_case(void)
@@ -372,7 +372,7 @@ static gboolean setup_callback(gpointer user_data)
 	print_progress(test->name, COLOR_BLUE, "setup");
 	test->setup_func(test->test_data);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean run_callback(gpointer user_data)
@@ -384,7 +384,7 @@ static gboolean run_callback(gpointer user_data)
 	print_progress(test->name, COLOR_BLACK, "run");
 	test->test_func(test->test_data);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean done_callback(gpointer user_data)
@@ -396,7 +396,7 @@ static gboolean done_callback(gpointer user_data)
 	print_progress(test->name, COLOR_BLACK, "done");
 	next_test_case();
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 void tester_pre_setup_complete(void)
@@ -585,7 +585,7 @@ static gboolean start_tester(gpointer user_data)
 
 	next_test_case();
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 struct wait_data {
@@ -605,7 +605,7 @@ static gboolean wait_callback(gpointer user_data)
 	if (wait->seconds > 0) {
 		print_progress(test->name, COLOR_BLACK, "%u seconds left",
 								wait->seconds);
-		return TRUE;
+		return G_SOURCE_CONTINUE;
 	}
 
 	print_progress(test->name, COLOR_BLACK, "waiting done");
@@ -614,7 +614,7 @@ static gboolean wait_callback(gpointer user_data)
 
 	g_free(wait);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 void tester_wait(unsigned int seconds, tester_wait_func_t func,
diff --git a/tools/btiotest.c b/tools/btiotest.c
index a77eba1..562de58 100644
--- a/tools/btiotest.c
+++ b/tools/btiotest.c
@@ -96,7 +96,7 @@ static gboolean disconn_timeout(gpointer user_data)
 
 	g_io_channel_shutdown(data->io, TRUE, NULL);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void update_sec_level(struct io_data *data)
@@ -199,7 +199,7 @@ static gboolean confirm_timeout(gpointer user_data)
 	if (data->reject >= 0) {
 		printf("Rejecting connection\n");
 		g_io_channel_shutdown(data->io, TRUE, NULL);
-		return FALSE;
+		return G_SOURCE_REMOVE;
 	}
 
 	printf("Accepting connection\n");
@@ -215,7 +215,7 @@ static gboolean confirm_timeout(gpointer user_data)
 		io_data_unref(data);
 	}
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void confirm_cb(GIOChannel *io, gpointer user_data)
diff --git a/unit/test-gdbus-client.c b/unit/test-gdbus-client.c
index 685729a..6353b59 100644
--- a/unit/test-gdbus-client.c
+++ b/unit/test-gdbus-client.c
@@ -715,7 +715,7 @@ static gboolean timeout_test(gpointer user_data)
 
 	g_assert_not_reached();
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean emit_string_change(void *user_data)
@@ -730,7 +730,7 @@ static gboolean emit_string_change(void *user_data)
 	context->timeout_source = g_timeout_add_seconds(2, timeout_test,
 								context);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void proxy_string_changed(GDBusProxy *proxy, void *user_data)
diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index ef05047..171e663 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
@@ -464,7 +464,7 @@ static gboolean cancel_transfer(gpointer user_data)
 	if (d->id > 0)
 		g_obex_cancel_transfer(d->id, transfer_complete, user_data);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gssize abort_data(void *buf, gsize len, gpointer user_data)
diff --git a/unit/test-gobex.c b/unit/test-gobex.c
index 66307c2..cd51009 100644
--- a/unit/test-gobex.c
+++ b/unit/test-gobex.c
@@ -92,13 +92,13 @@ static gboolean timeout(gpointer user_data)
 	GError **err = user_data;
 
 	if (!g_main_loop_is_running(mainloop))
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	g_set_error(err, TEST_ERROR, TEST_ERROR_TIMEOUT, "Timed out");
 
 	g_main_loop_quit(mainloop);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void connect_rsp(GObex *obex, GError *err, GObexPacket *rsp,
diff --git a/unit/test-sdp.c b/unit/test-sdp.c
index 6d699e2..03046d7 100644
--- a/unit/test-sdp.c
+++ b/unit/test-sdp.c
@@ -209,7 +209,7 @@ static gboolean send_pdu(gpointer user_data)
 
 	g_assert(len == pdu_len);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void context_increment(struct context *context)
-- 
1.8.4.2



^ permalink raw reply related

* Re: [PATCH] android/hal-pan: Fix order of event handler registration
From: Johan Hedberg @ 2013-11-20  7:42 UTC (permalink / raw)
  To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1384896258-12789-1-git-send-email-ravikumar.veeramally@linux.intel.com>

Hi Ravi,

On Tue, Nov 19, 2013, Ravi kumar Veeramally wrote:
> IPC message handler determines handler offset with
> opcode = msg->opcode - HAL_MINIMUM_EVENT. But here order is misplaced.
> ---
>  android/hal-pan.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH] android/hal-a2dp: Fix expected size of hal_ev_a2dp conn_state and audio_state
From: Johan Hedberg @ 2013-11-20  7:42 UTC (permalink / raw)
  To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1384894763-3925-1-git-send-email-ravikumar.veeramally@linux.intel.com>

Hi Ravi,

On Tue, Nov 19, 2013, Ravi kumar Veeramally wrote:
> ---
>  android/hal-a2dp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH_v2 2/4] android: Handle multiple init(register) and cleanup(unregister) calls properly
From: Szymon Janc @ 2013-11-20  7:02 UTC (permalink / raw)
  To: Ravi kumar Veeramally; +Cc: BlueZ development
In-Reply-To: <1384872988-19914-2-git-send-email-ravikumar.veeramally@linux.intel.com>

Hi Ravi,

On Tue, Nov 19, 2013 at 3:56 PM, Ravi kumar Veeramally
<ravikumar.veeramally@linux.intel.com> wrote:
> This can be tested with haltest.

I think this should be already handled by Core service. Were you able
to get success response from daemon on multiple sequent init or
cleanup calls?

btw: I think we should fix this on hal side as well, currently only
bluetooth hal is handling error from daemon correctly. There is also
question if we should return success on second init call...

-- 
BR
Szymon Janc

^ permalink raw reply

* [PATCH] android/hal-pan: Fix order of event handler registration
From: Ravi kumar Veeramally @ 2013-11-19 21:24 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally

IPC message handler determines handler offset with
opcode = msg->opcode - HAL_MINIMUM_EVENT. But here order is misplaced.
---
 android/hal-pan.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/android/hal-pan.c b/android/hal-pan.c
index e12eac8..e7b8a20 100644
--- a/android/hal-pan.c
+++ b/android/hal-pan.c
@@ -54,14 +54,14 @@ static void handle_ctrl_state(void *buf, uint16_t len)
  * index in table equals to 'opcode - HAL_MINIMUM_EVENT' */
 static const struct hal_ipc_handler ev_handlers[] = {
 	{	/* HAL_EV_PAN_CTRL_STATE */
-		.handler = handle_conn_state,
+		.handler = handle_ctrl_state,
 		.var_len = false,
-		.data_len = sizeof(struct hal_ev_pan_conn_state),
+		.data_len = sizeof(struct hal_ev_pan_ctrl_state),
 	},
 	{	/* HAL_EV_PAN_CONN_STATE */
-		.handler = handle_ctrl_state,
+		.handler = handle_conn_state,
 		.var_len = false,
-		.data_len = sizeof(struct hal_ev_pan_ctrl_state),
+		.data_len = sizeof(struct hal_ev_pan_conn_state),
 	},
 };
 
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH] android/hal-a2dp: Fix expected size of hal_ev_a2dp conn_state and audio_state
From: Ravi kumar Veeramally @ 2013-11-19 20:59 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally

---
 android/hal-a2dp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/android/hal-a2dp.c b/android/hal-a2dp.c
index 7d91151..cf39ba2 100644
--- a/android/hal-a2dp.c
+++ b/android/hal-a2dp.c
@@ -54,12 +54,12 @@ static const struct hal_ipc_handler ev_handlers[] = {
 	{	/* HAL_EV_A2DP_CONN_STATE */
 		.handler = handle_conn_state,
 		.var_len = false,
-		.data_len = sizeof(struct hal_ev_pan_conn_state),
+		.data_len = sizeof(struct hal_ev_a2dp_conn_state),
 	},
 	{	/* HAL_EV_A2DP_AUDIO_STATE */
 		.handler = handle_audio_state,
 		.var_len = false,
-		.data_len = sizeof(struct hal_ev_pan_ctrl_state),
+		.data_len = sizeof(struct hal_ev_a2dp_audio_state),
 	},
 };
 
-- 
1.8.3.2


^ permalink raw reply related

* Re: [PATCHv3 0/2] PICS for GAP and HID
From: Johan Hedberg @ 2013-11-19 16:35 UTC (permalink / raw)
  To: Jakub Tyszkowski; +Cc: linux-bluetooth
In-Reply-To: <1384871775-8348-1-git-send-email-jakub.tyszkowski@tieto.com>

Hi Jakub,

On Tue, Nov 19, 2013, Jakub Tyszkowski wrote:
> Please note that some PICS marked as mandatory for LE were not
> selected because of Android 4.4 not supporting some LE Roles.
> 
> v3: layout changed, added: mandatory/optional/conditional
> 	markings and descriptions, # - not implemented mark
> v2: layout changed, each parameter description added
> v1: initial documents with PICS targeting Android 4.4
> 
> Jakub Tyszkowski (2):
>   android: Add PTS PICS for GAP
>   android: Add PTS PICS for HID
> 
>  android/pics-gap.txt | 708 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  android/pics-hid.txt | 285 +++++++++++++++++++++
>  2 files changed, 993 insertions(+)
>  create mode 100644 android/pics-gap.txt
>  create mode 100644 android/pics-hid.txt

Both patches have been applied. Thanks.

I did need to push an extra patch on top of these though since you
forgot to add the files to EXTRA_DIST in android/Makefile.am.

Johan

^ permalink raw reply

* Re: [PATCH 10/10] android/hal-bluetooth: Remove not needed check in get_adapter_property
From: Johan Hedberg @ 2013-11-19 16:29 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1384876314-31347-10-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Tue, Nov 19, 2013, Szymon Janc wrote:
> Properties types are verified on daemon side and proper error is
> returned on wrong type. No need to double check that on HAL side.
> ---
>  android/hal-bluetooth.c | 15 ---------------
>  1 file changed, 15 deletions(-)

All patches in this set have been applied. Thanks.

> --- a/android/hal-bluetooth.c
> +++ b/android/hal-bluetooth.c
> @@ -476,21 +476,6 @@ static int get_adapter_property(bt_property_type_t type)
>  	if (!interface_ready())
>  		return BT_STATUS_NOT_READY;
>  
> -	switch (type) {
> -	case BT_PROPERTY_BDNAME:
> -	case BT_PROPERTY_BDADDR:
> -	case BT_PROPERTY_UUIDS:
> -	case BT_PROPERTY_CLASS_OF_DEVICE:
> -	case BT_PROPERTY_TYPE_OF_DEVICE:
> -	case BT_PROPERTY_SERVICE_RECORD:
> -	case BT_PROPERTY_ADAPTER_SCAN_MODE:
> -	case BT_PROPERTY_ADAPTER_BONDED_DEVICES:
> -	case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
> -		break;
> -	default:
> -		return BT_STATUS_PARM_INVALID;
> -	}
> -

We should be consistent about this across all HALs. I just applied
patches from Ravi that added validity check to the HAL side, however now
it seems these should actually be on the daemon side (and now that I
think about it the daemon must in the name of robustness check them
anyway).

Johan

^ permalink raw reply

* Re: [PATCH_v2 1/4] android/hal-pan: Return error in case of unsupported PAN roles
From: Johan Hedberg @ 2013-11-19 16:20 UTC (permalink / raw)
  To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1384872988-19914-1-git-send-email-ravikumar.veeramally@linux.intel.com>

Hi Ravi,

On Tue, Nov 19, 2013, Ravi kumar Veeramally wrote:
> ---
>  android/hal-pan.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)

All four patches have been applied. Thanks.

Johan

^ permalink raw reply

* [PATCH 10/10] android/hal-bluetooth: Remove not needed check in get_adapter_property
From: Szymon Janc @ 2013-11-19 15:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1384876314-31347-1-git-send-email-szymon.janc@tieto.com>

Properties types are verified on daemon side and proper error is
returned on wrong type. No need to double check that on HAL side.
---
 android/hal-bluetooth.c | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 68f1bd5..b04939e 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -476,21 +476,6 @@ static int get_adapter_property(bt_property_type_t type)
 	if (!interface_ready())
 		return BT_STATUS_NOT_READY;
 
-	switch (type) {
-	case BT_PROPERTY_BDNAME:
-	case BT_PROPERTY_BDADDR:
-	case BT_PROPERTY_UUIDS:
-	case BT_PROPERTY_CLASS_OF_DEVICE:
-	case BT_PROPERTY_TYPE_OF_DEVICE:
-	case BT_PROPERTY_SERVICE_RECORD:
-	case BT_PROPERTY_ADAPTER_SCAN_MODE:
-	case BT_PROPERTY_ADAPTER_BONDED_DEVICES:
-	case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
-		break;
-	default:
-		return BT_STATUS_PARM_INVALID;
-	}
-
 	/* type match IPC type */
 	cmd.type = type;
 
-- 
1.8.4.3


^ permalink raw reply related

* [PATCH 09/10] android/hal-bluetooth: Remove not needed check in set_adapter_property
From: Szymon Janc @ 2013-11-19 15:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1384876314-31347-1-git-send-email-szymon.janc@tieto.com>

Properties types are verified on daemon side and proper error is
returned on wrong type. No need to double check that on HAL side.
---
 android/hal-bluetooth.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index b8ffce6..68f1bd5 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -508,15 +508,6 @@ static int set_adapter_property(const bt_property_t *property)
 	if (!interface_ready())
 		return BT_STATUS_NOT_READY;
 
-	switch (property->type) {
-	case BT_PROPERTY_BDNAME:
-	case BT_PROPERTY_ADAPTER_SCAN_MODE:
-	case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
-		break;
-	default:
-		return BT_STATUS_PARM_INVALID;
-	}
-
 	/* type match IPC type */
 	cmd->type = property->type;
 	cmd->len = property->len;
-- 
1.8.4.3


^ permalink raw reply related

* [PATCH 08/10] android/hal-bluetooth: Handle dut mode receive event
From: Szymon Janc @ 2013-11-19 15:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1384876314-31347-1-git-send-email-szymon.janc@tieto.com>

Pass received data to callback if it is present.
---
 android/hal-bluetooth.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 18e805b..b8ffce6 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -300,9 +300,17 @@ static void handle_acl_state_changed(void *buf, uint16_t len)
 
 static void handle_dut_mode_receive(void *buf, uint16_t len)
 {
+	struct hal_ev_dut_mode_receive *ev = buf;
+
 	DBG("");
 
-	/* TODO */
+	if (len != sizeof(*ev) + ev->len) {
+		error("invalid dut mode receive event (%u), aborting", len);
+		exit(EXIT_FAILURE);
+	}
+
+	if (bt_hal_cbacks->dut_mode_recv_cb)
+		bt_hal_cbacks->dut_mode_recv_cb(ev->opcode, ev->data, ev->len);
 }
 
 /* handlers will be called from notification thread context,
-- 
1.8.4.3


^ permalink raw reply related

* [PATCH 07/10] android/hal-bluetooth: Remove not needed __func__ from debug print
From: Szymon Janc @ 2013-11-19 15:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1384876314-31347-1-git-send-email-szymon.janc@tieto.com>

DBG macro already adds function name to print output.
---
 android/hal-bluetooth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 4689bf2..18e805b 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -724,7 +724,7 @@ static int ssp_reply(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
 
 static const void *get_profile_interface(const char *profile_id)
 {
-	DBG("%s: %s", __func__, profile_id);
+	DBG("%s", profile_id);
 
 	if (!interface_ready())
 		return NULL;
-- 
1.8.4.3


^ permalink raw reply related

* [PATCH 06/10] android/hal-bluetooth: Add support for dut mode send command
From: Szymon Janc @ 2013-11-19 15:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1384876314-31347-1-git-send-email-szymon.janc@tieto.com>

This is used to send test HCI commands when DUT mode is enabled.
---
 android/hal-bluetooth.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index bd7d257..4689bf2 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -761,12 +761,20 @@ static int dut_mode_configure(uint8_t enable)
 
 static int dut_mode_send(uint16_t opcode, uint8_t *buf, uint8_t len)
 {
-	DBG("");
+	uint8_t cmd_buf[sizeof(struct hal_cmd_dut_mode_send) + len];
+	struct hal_cmd_dut_mode_send *cmd = (void *) cmd_buf;
+
+	DBG("opcode %u len %u", opcode, len);
 
 	if (!interface_ready())
 		return BT_STATUS_NOT_READY;
 
-	return BT_STATUS_UNSUPPORTED;
+	cmd->opcode = opcode;
+	cmd->len = len;
+	memcpy(cmd->data, buf, cmd->len);
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_DUT_MODE_SEND,
+					sizeof(cmd_buf), cmd, 0, NULL, NULL);
 }
 
 static const bt_interface_t bluetooth_if = {
-- 
1.8.4.3


^ permalink raw reply related

* [PATCH 05/10] android/hal-bluetooth: Add support for dut mode configure command
From: Szymon Janc @ 2013-11-19 15:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1384876314-31347-1-git-send-email-szymon.janc@tieto.com>

This command is used to enter or exit DUT mode.
---
 android/hal-bluetooth.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index c74a9b3..bd7d257 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -746,12 +746,17 @@ static const void *get_profile_interface(const char *profile_id)
 
 static int dut_mode_configure(uint8_t enable)
 {
-	DBG("");
+	struct hal_cmd_dut_mode_conf cmd;
+
+	DBG("enable %u", enable);
 
 	if (!interface_ready())
 		return BT_STATUS_NOT_READY;
 
-	return BT_STATUS_UNSUPPORTED;
+	cmd.enable = enable;
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_DUT_MODE_CONF,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
 }
 
 static int dut_mode_send(uint16_t opcode, uint8_t *buf, uint8_t len)
-- 
1.8.4.3


^ permalink raw reply related

* [PATCH 04/10] android/hal-bluetooth: Add support for get remote service record cmd
From: Szymon Janc @ 2013-11-19 15:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1384876314-31347-1-git-send-email-szymon.janc@tieto.com>

---
 android/hal-bluetooth.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index b496995..c74a9b3 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -583,12 +583,19 @@ static int set_remote_device_property(bt_bdaddr_t *remote_addr,
 
 static int get_remote_service_record(bt_bdaddr_t *remote_addr, bt_uuid_t *uuid)
 {
+	struct hal_cmd_get_remote_service_rec cmd;
+
 	DBG("bdaddr: %s", bdaddr2str(remote_addr));
 
 	if (!interface_ready())
 		return BT_STATUS_NOT_READY;
 
-	return BT_STATUS_UNSUPPORTED;
+	memcpy(cmd.bdaddr, remote_addr, sizeof(cmd.bdaddr));
+	memcpy(cmd.uuid, uuid, sizeof(cmd.uuid));
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH,
+					HAL_OP_GET_REMOTE_SERVICE_REC,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
 }
 
 static int get_remote_services(bt_bdaddr_t *remote_addr)
-- 
1.8.4.3


^ permalink raw reply related

* [PATCH 03/10] android/hal-bluetooth: Add support for set remote device property cmd
From: Szymon Janc @ 2013-11-19 15:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1384876314-31347-1-git-send-email-szymon.janc@tieto.com>

This command is used to set remote device property of specified type.
---
 android/hal-bluetooth.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index e2a9ab3..b496995 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -558,13 +558,27 @@ static int get_remote_device_property(bt_bdaddr_t *remote_addr,
 static int set_remote_device_property(bt_bdaddr_t *remote_addr,
 						const bt_property_t *property)
 {
+	struct hal_cmd_set_remote_device_prop *cmd;
+	uint8_t buf[sizeof(*cmd) + property->len];
+
 	DBG("bdaddr: %s prop: %s", bdaddr2str(remote_addr),
-						btproperty2str(property));
+				bt_property_type_t2str(property->type));
 
 	if (!interface_ready())
 		return BT_STATUS_NOT_READY;
 
-	return BT_STATUS_UNSUPPORTED;
+	cmd = (void *) buf;
+
+	memcpy(cmd->bdaddr, remote_addr, sizeof(cmd->bdaddr));
+
+	/* type match IPC type */
+	cmd->type = property->type;
+	cmd->len = property->len;
+	memcpy(cmd->val, property->val, property->len);
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH,
+					HAL_OP_SET_REMOTE_DEVICE_PROP,
+					sizeof(buf), cmd, 0, NULL, NULL);
 }
 
 static int get_remote_service_record(bt_bdaddr_t *remote_addr, bt_uuid_t *uuid)
-- 
1.8.4.3


^ permalink raw reply related

* [PATCH 02/10] android/hal-bluetooth: Add support for get remote device properties cmd
From: Szymon Janc @ 2013-11-19 15:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1384876314-31347-1-git-send-email-szymon.janc@tieto.com>

This command is used to get all properties of remote device.
---
 android/hal-bluetooth.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 4a09a5c..e2a9ab3 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -520,12 +520,18 @@ static int set_adapter_property(const bt_property_t *property)
 
 static int get_remote_device_properties(bt_bdaddr_t *remote_addr)
 {
+	struct hal_cmd_get_remote_device_props cmd;
+
 	DBG("bdaddr: %s", bdaddr2str(remote_addr));
 
 	if (!interface_ready())
 		return BT_STATUS_NOT_READY;
 
-	return BT_STATUS_UNSUPPORTED;
+	memcpy(cmd.bdaddr, remote_addr, sizeof(cmd.bdaddr));
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH,
+					HAL_OP_GET_REMOTE_DEVICE_PROPS,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
 }
 
 static int get_remote_device_property(bt_bdaddr_t *remote_addr,
-- 
1.8.4.3


^ permalink raw reply related

* [PATCH 01/10] android/hal-bluetooth: Add support for get remote device property cmd
From: Szymon Janc @ 2013-11-19 15:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

This command is used to get remote device property of specifided type.
---
 android/hal-bluetooth.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 69c304a..4a09a5c 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -531,13 +531,22 @@ static int get_remote_device_properties(bt_bdaddr_t *remote_addr)
 static int get_remote_device_property(bt_bdaddr_t *remote_addr,
 						bt_property_type_t type)
 {
+	struct hal_cmd_get_remote_device_prop cmd;
+
 	DBG("bdaddr: %s prop: %s", bdaddr2str(remote_addr),
 						bt_property_type_t2str(type));
 
 	if (!interface_ready())
 		return BT_STATUS_NOT_READY;
 
-	return BT_STATUS_UNSUPPORTED;
+	memcpy(cmd.bdaddr, remote_addr, sizeof(cmd.bdaddr));
+
+	/* type match IPC type */
+	cmd.type = type;
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH,
+					HAL_OP_GET_REMOTE_DEVICE_PROP,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
 }
 
 static int set_remote_device_property(bt_bdaddr_t *remote_addr,
-- 
1.8.4.3


^ permalink raw reply related

* [PATCH_v2 4/4] android/hidhost: Free all connected devices in profile cleanup call
From: Ravi kumar Veeramally @ 2013-11-19 14:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1384872988-19914-1-git-send-email-ravikumar.veeramally@linux.intel.com>

This can be easily verified with haltest tool.
---
 android/hidhost.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/android/hidhost.c b/android/hidhost.c
index 049dd6d..502b10b 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -1226,6 +1226,14 @@ bool bt_hid_register(int sk, const bdaddr_t *addr)
 	return true;
 }
 
+static void free_hid_devices(gpointer data, gpointer user_data)
+{
+	struct hid_device *dev = data;
+
+	bt_hid_notify_state(dev, HAL_HIDHOST_STATE_DISCONNECTED);
+	hid_device_free(dev);
+}
+
 void bt_hid_unregister(void)
 {
 	DBG("");
@@ -1233,6 +1241,8 @@ void bt_hid_unregister(void)
 	if (notification_sk < 0)
 		return;
 
+	g_slist_foreach(devices, free_hid_devices, NULL);
+	devices = NULL;
 	notification_sk = -1;
 
 	if (ctrl_io) {
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH_v2 3/4] android/hidhost: Handle error case properly in interrupt_connect_cb
From: Ravi kumar Veeramally @ 2013-11-19 14:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1384872988-19914-1-git-send-email-ravikumar.veeramally@linux.intel.com>

In case of conn_err in interrupt_connect_cb, device is freed but
connection status is not notified. Declared a local variable and
handled error case properly in case of conn_err and uhid failures.
Now connection status notified before freeing device.
---
 android/hidhost.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/android/hidhost.c b/android/hidhost.c
index df21f81..049dd6d 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -522,7 +522,6 @@ static int uhid_create(struct hid_device *dev)
 	dev->uhid_fd = open(UHID_DEVICE_FILE, O_RDWR | O_CLOEXEC);
 	if (dev->uhid_fd < 0) {
 		error("Failed to open uHID device: %s", strerror(errno));
-		bt_hid_notify_state(dev, HAL_HIDHOST_STATE_NO_HID);
 		return -errno;
 	}
 
@@ -541,7 +540,6 @@ static int uhid_create(struct hid_device *dev)
 		error("Failed to create uHID device: %s", strerror(errno));
 		close(dev->uhid_fd);
 		dev->uhid_fd = -1;
-		bt_hid_notify_state(dev, HAL_HIDHOST_STATE_NO_HID);
 		return -errno;
 	}
 
@@ -559,16 +557,20 @@ static void interrupt_connect_cb(GIOChannel *chan, GError *conn_err,
 							gpointer user_data)
 {
 	struct hid_device *dev = user_data;
+	uint8_t state;
 
 	DBG("");
 
 	if (conn_err) {
 		error("%s", conn_err->message);
+		state = HAL_HIDHOST_STATE_FAILED;
 		goto failed;
 	}
 
-	if (uhid_create(dev) < 0)
+	if (uhid_create(dev) < 0) {
+		state = HAL_HIDHOST_STATE_NO_HID;
 		goto failed;
+	}
 
 	dev->intr_watch = g_io_add_watch(dev->intr_io,
 				G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
@@ -579,6 +581,7 @@ static void interrupt_connect_cb(GIOChannel *chan, GError *conn_err,
 	return;
 
 failed:
+	bt_hid_notify_state(dev, state);
 	hid_device_free(dev);
 }
 
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH_v2 2/4] android: Handle multiple init(register) and cleanup(unregister) calls properly
From: Ravi kumar Veeramally @ 2013-11-19 14:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1384872988-19914-1-git-send-email-ravikumar.veeramally@linux.intel.com>

This can be tested with haltest.
---
 android/a2dp.c      | 6 ++++++
 android/bluetooth.c | 6 ++++++
 android/hidhost.c   | 6 ++++++
 android/pan.c       | 6 ++++++
 4 files changed, 24 insertions(+)

diff --git a/android/a2dp.c b/android/a2dp.c
index 74d0082..a9e7c65 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -332,6 +332,9 @@ bool bt_a2dp_register(int sk, const bdaddr_t *addr)
 
 	DBG("");
 
+	if (notification_sk >= 0)
+		return false;
+
 	bacpy(&adapter_addr, addr);
 
 	server = bt_io_listen(connect_cb, NULL, NULL, NULL, &err,
@@ -365,6 +368,9 @@ void bt_a2dp_unregister(void)
 {
 	DBG("");
 
+	if (notification_sk < 0)
+		return;
+
 	notification_sk = -1;
 
 	bt_adapter_remove_record(record_id);
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 7dc2ec3..11b9d76 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -2275,6 +2275,9 @@ bool bt_bluetooth_register(int sk)
 {
 	DBG("");
 
+	if (notification_sk >= 0)
+		return false;
+
 	notification_sk = sk;
 
 	return true;
@@ -2284,5 +2287,8 @@ void bt_bluetooth_unregister(void)
 {
 	DBG("");
 
+	if (notification_sk < 0)
+		return;
+
 	notification_sk = -1;
 }
diff --git a/android/hidhost.c b/android/hidhost.c
index 842b8ad..df21f81 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -1190,6 +1190,9 @@ bool bt_hid_register(int sk, const bdaddr_t *addr)
 
 	DBG("");
 
+	if (notification_sk >= 0)
+		return false;
+
 	bacpy(&adapter_addr, addr);
 
 	ctrl_io = bt_io_listen(connect_cb, NULL, NULL, NULL, &err,
@@ -1224,6 +1227,9 @@ void bt_hid_unregister(void)
 {
 	DBG("");
 
+	if (notification_sk < 0)
+		return;
+
 	notification_sk = -1;
 
 	if (ctrl_io) {
diff --git a/android/pan.c b/android/pan.c
index fba86b8..ada458a 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -95,6 +95,9 @@ bool bt_pan_register(int sk, const bdaddr_t *addr)
 {
 	DBG("");
 
+	if (notification_sk >= 0)
+		return false;
+
 	notification_sk = sk;
 
 	return true;
@@ -104,5 +107,8 @@ void bt_pan_unregister(void)
 {
 	DBG("");
 
+	if (notification_sk < 0)
+		return;
+
 	notification_sk = -1;
 }
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH_v2 1/4] android/hal-pan: Return error in case of unsupported PAN roles
From: Ravi kumar Veeramally @ 2013-11-19 14:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally

---
 android/hal-pan.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/android/hal-pan.c b/android/hal-pan.c
index 2bc560e..a2e6060 100644
--- a/android/hal-pan.c
+++ b/android/hal-pan.c
@@ -77,6 +77,9 @@ static bt_status_t pan_enable(int local_role)
 	if (!interface_ready())
 		return BT_STATUS_NOT_READY;
 
+	if (!(local_role == BTPAN_ROLE_PANU || local_role == BTPAN_ROLE_PANNAP))
+		return BT_STATUS_UNSUPPORTED;
+
 	cmd.local_role = local_role;
 
 	return hal_ipc_cmd(HAL_SERVICE_ID_PAN, HAL_OP_PAN_ENABLE,
@@ -112,6 +115,20 @@ static bt_status_t pan_connect(const bt_bdaddr_t *bd_addr, int local_role,
 	if (!interface_ready())
 		return BT_STATUS_NOT_READY;
 
+	switch (local_role) {
+	case BTPAN_ROLE_PANNAP:
+		if (remote_role != BTPAN_ROLE_PANU)
+			return BT_STATUS_UNSUPPORTED;
+		break;
+	case BTPAN_ROLE_PANU:
+		if (remote_role != BTPAN_ROLE_PANNAP &&
+						remote_role != BTPAN_ROLE_PANU)
+			return BT_STATUS_UNSUPPORTED;
+		break;
+	default:
+		return BT_STATUS_UNSUPPORTED;
+	}
+
 	memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
 	cmd.local_role = local_role;
 	cmd.remote_role = remote_role;
-- 
1.8.3.2


^ permalink raw reply related

* Re: [PATCH v3 0/6] android: IPC improvements
From: Luiz Augusto von Dentz @ 2013-11-19 14:44 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1384869762-3097-1-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Tue, Nov 19, 2013 at 4:02 PM, Szymon Janc <szymon.janc@tieto.com> wrote:
> v3:
>  - fixed compilation on android 4.2
>
> Szymon Janc (6):
>   android/hal: Add initial code for IPC message handlers
>   android/hal-bluetooth: Register IPC message handlers
>   android/hal-hidhost: Use generic IPC message handling for events
>   android/hal-pan: Use generic IPC message handling for events
>   android/hal-a2dp: Use generic IPC message handling for events
>   android/hal: Check if command socket was shutdown by peer
>
>  android/hal-a2dp.c      |  41 +++++-----
>  android/hal-bluetooth.c | 208 ++++++++++++++++++++++++++++++------------------
>  android/hal-hidhost.c   |  76 ++++++++++--------
>  android/hal-ipc.c       | 123 +++++++++++++++++++---------
>  android/hal-ipc.h       |  10 +++
>  android/hal-pan.c       |  40 +++++-----
>  android/hal.h           |   4 -
>  7 files changed, 310 insertions(+), 192 deletions(-)
>
> --
> 1.8.4.3

Pushed, thanks.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* [PATCHv3 2/2] android: Add PTS PICS for HID
From: Jakub Tyszkowski @ 2013-11-19 14:36 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1384871775-8348-1-git-send-email-jakub.tyszkowski@tieto.com>

PTS PICS for HID, targeting Android 4.4.

---
 android/pics-hid.txt | 285 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 285 insertions(+)
 create mode 100644 android/pics-hid.txt

diff --git a/android/pics-hid.txt b/android/pics-hid.txt
new file mode 100644
index 0000000..b0b7d52
--- /dev/null
+++ b/android/pics-hid.txt
@@ -0,0 +1,285 @@
+HID PICS for the PTS tool.
+
+* - different than PTS defaults
+# - not yet implemented/supported
+
+M - mandatory
+O - optional
+
+		Roles
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_HID_1_1	True (*)	Role: Host, Report protocol (O.1)
+TSPC_HID_1_2	False		Role: HID Role (O.1)
+TSPC_HID_1_3	False		Role: Host, Boot protocol (O.1)
+-------------------------------------------------------------------------------
+O.1: It is Mandatory to support One of these roles.
+-------------------------------------------------------------------------------
+
+
+		Application Procedures
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_HID_2_1	True		Host: Establish HID connection (M.1)
+TSPC_HID_2_2	True		Host: Accept HID connection (M.1)
+TSPC_HID_2_3	True		Host: Terminate HID connection (M.1)
+TSPC_HID_2_4	True		Host: Accept termination of HID connection (M.1)
+TSPC_HID_2_5	True		Host: Support for virtual cables (M.1)
+TSPC_HID_2_6	True		Host: HID initiated connection (M.1)
+TSPC_HID_2_7	True		Host: Host initiated connection (M.1)
+TSPC_HID_2_8	True		Host: Host data transfer to HID (C.1)
+TSPC_HID_2_9	True		Host: HID data transfer to Host (C.1)
+TSPC_HID_2_10	False		Host: Boot mode data transfer to Host (C.2)
+TSPC_HID_2_11	False		Host : Boot mode data transfer to HID (C.2)
+TSPC_HID_2_12	False		Host : Support for Application to send
+					GET_Report (O)
+TSPC_HID_2_13	False		Host : Support for Application to send
+					SET_REPORT (O)
+TSPC_HID_2_14	False		Host : Support for sending HCI_CONTROL with
+					VIRTUAL_CABLE_UNPLUG (C.3)
+TSPC_HID_2_15	False		Host : Support for receiving HCI_CONTROL with
+					VIRTUAL_CABLE_UNPLUG (C.2)
+-------------------------------------------------------------------------------
+M.1: Mandatory to support IF (TSPC_HID_1_1) supported.
+C.1: Optional for Boot Mode Only Hosts (TSPC_HID_1_3); otherwise Mandatory
+	for Host Role (TSPC_HID_1_1).
+C.2: Mandatory for Boot Mode Only Hosts (TSPC_HID_1_3); otherwise Optional.
+C.3: Optional IF (TSPC_HID_2_5) supported, otherwise excluded.
+-------------------------------------------------------------------------------
+
+
+		Device to Host Transfers
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_HID_3_1	False		Host : Data reports larger than host MTU on
+					Control channel (O)
+TSPC_HID_3_2	True (*)	Host : Data reports larger than host MTU on
+					Interrupt channel (C.1)
+TSPC_HID_3_3	True (*)	Host : Data reports to host (C.1)
+TSPC_HID_3_4	False		Host : Boot mode reports to host (C.2)
+-------------------------------------------------------------------------------
+C.1: Excluded for Boot Mode Only Hosts (TSPC_HID_1_3); otherwise Mandatory if
+	(TSPC_HID_2_12), otherwise Optional.
+C.2: Mandatory for Boot Mode Only Hosts (TSPC_HID_1_3); otherwise Optional.
+-------------------------------------------------------------------------------
+
+
+		Host to Device Transfers
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_HID_4_1	False		Host : Data reports larger than device MTU on
+					Control channel (C.1)
+TSPC_HID_4_2	False		Host : Data reports larger than device MTU on
+					Interrupt channel (C.1)
+TSPC_HID_4_3	True (*)	Host : Data reports to device (C.2)
+TSPC_HID_4_4	False		Host : Boot mode reports to device (O)
+-------------------------------------------------------------------------------
+C.1: Excluded for Boot Mode Only Hosts (TSPC_HID_1_3); otherwise Optional
+C.2: Excluded for Boot Mode Only Hosts (TSPC_HID_1_3); otherwise Mandatory for
+	Host Role (TSPC_HID_1_1).
+-------------------------------------------------------------------------------
+
+
+		HID Control Commands
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_HID_5_1	False		Host : Set_Protocol command (C.1)
+TSPC_HID_5_2	False		Host : Get_Protocol command (C.1)
+TSPC_HID_5_3	False		Host : Set_Idle command (O)
+TSPC_HID_5_4	False		Host : Get_Idle command (O)
+TSPC_HID_5_5	False (*)	Host : Set_Report command (M.1)
+TSPC_HID_5_6	False (*)	Host : Get_Report command (M.2)
+-------------------------------------------------------------------------------
+M.1: Mandatory IF (TSPC_HID_1_1) supported AND (TSPC_HID_2_13) supported.
+C.1: Mandatory for Boot Mode Only Hosts (TSPC_HID_1_3); otherwise Optional.
+	If either Set_Protocol or Get_Protocol supported, both are Mandatory.
+M.2: Mandatory IF (TSPC_HID_1_1) Supported AND (TSPC_HID_2_12) Supported
+-------------------------------------------------------------------------------
+
+
+		Host Link Manager Procedures
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_HID_6_1	False		Host : Initiate Authentication before
+					connection completed (C.1)
+TSPC_HID_6_2	False		Host : Initiate Authentication after connection
+					completed (C.1)
+TSPC_HID_6_3	False		Host : Initiate pairing before connection
+					completed (C.2)
+TSPC_HID_6_4	False		Host : Initiate pairing after connection
+					completed (C.2)
+TSPC_HID_6_5	False		Host : Encryption (O)
+TSPC_HID_6_6	False		Host : Initiate encryption (C.3)
+TSPC_HID_6_7	False		Host : Accept encryption requests (C.3)
+TSPC_HID_6_8	True		Host : Role switch (Master/Slave) (M.1)
+TSPC_HID_6_9	True		Host : Request Master Slave switch (M.1)
+TSPC_HID_6_10	True		Host : Accept Master Slave switch requests (M.1)
+TSPC_HID_6_11	False		Host : Hold mode (O)
+TSPC_HID_6_12	True		Host : Sniff mode (M.1)
+TSPC_HID_6_13	False		Host : Park mode (O)
+-------------------------------------------------------------------------------
+C.1: If Host Authentication supported, both (TSPC_HID_6_1) AND (TSPC_HID_6_2)
+	must be supported.
+C.2: If Pairing supported both (TSPC_HID_6_3) AND (TSPC_HID_6_4) must
+	be supported.
+M.1: Mandatory IF (TSPC_HID_1_1) supported.
+C.3: Mandatory IF (TSPC_HID_6_5) encryption supported.
+-------------------------------------------------------------------------------
+
+
+		Host Link Control Requirements
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_HID_7_1	True		Host : Supports inquiry, 79 channel (M.1)
+TSPC_HID_7_2	False (*)	Host : Supports inquiry scan, 79 channel (X)
+-------------------------------------------------------------------------------
+M.1: Mandatory to support IF (TSPC_HID_1_1) supported.
+X: Feature should not be used by a Host, but can be supported in LM.
+-------------------------------------------------------------------------------
+
+
+		HID Device Roles
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_HID_8_1	False		Hid : Pointing HID (O.1)
+TSPC_HID_8_2	False		Hid : Keyboard HID (O.1)
+TSPC_HID_8_3	False		Hid : Identification HID (O.1)
+TSPC_HID_8_4	False		Hid : Other HID (O.1)
+-------------------------------------------------------------------------------
+O.1: It is Mandatory to support One of these roles IF (TSPC_HID_1_2)
+	is selected
+-------------------------------------------------------------------------------
+
+
+		HID Application Procedures
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_HID_9_1	False		Hid : Establish HID connection (O)
+TSPC_HID_9_2	False (*)	Hid : Accept HID connection (M.1)
+TSPC_HID_9_3	False		Hid : Terminate HID connection (O)
+TSPC_HID_9_4	False (*)	Hid : Accept Termination of HID connection (M.1)
+TSPC_HID_9_5	False		Hid : Support for virtual cables (O)
+TSPC_HID_9_6	False		Hid : HID initiated reconnection (C.1)
+TSPC_HID_9_7	False		Hid : Host initiated reconnection (C.1)
+TSPC_HID_9_8	False		Hid : Host data transfer to HID (C.2)
+TSPC_HID_9_9	False		Hid : HID data transfer to Host (C.2)
+TSPC_HID_9_10	False		Hid : HID Boot mode data transfer to Host (C.3)
+TSPC_HID_9_11	False		Hid : Host Boot mode data transfer to HID (C.4)
+TSPC_HID_9_12	False		Hid : Output reports declared (C.4)
+TSPC_HID_9_13	False		Hid : Input reports declared (C.3)
+TSPC_HID_9_14	False		Hid : Feature reports declared (O)
+TSPC_HID_9_15	False		Hid : Support for sending HCI_CONTROL with
+					VIRTUAL_CABLE_UNPLUG (C.5)
+TSPC_HID_9_16	False		Hid : Support for receiving HCI_CONTROL with
+					VIRTUAL_CABLE_UNPLUG (C.5)
+-------------------------------------------------------------------------------
+M.1: Mandatory IF (TSPC_HID_1_2) supported.
+C.1: One of these is Mandatory IF (TSPC_HID_9_5) is supported
+	(SDP attribute 0x204=True)
+C.2: One of these is Mandatory.
+C.3: Mandatory IF (TSPC_HID_8_1) OR (TSPC_HID_8_2) is selected
+C.4: Mandatory IF (TSPC_HID_8_2) is supported (for status indicators)
+C.5: Optional IF (TSPC_HID_9_2) supported, otherwise excluded.
+-------------------------------------------------------------------------------
+
+
+		Device to Host Transfers
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_HID_10_1	False		Hid : Data reports larger than host MTU on
+					Control channel (O)
+TSPC_HID_10_2	False		Hid : Data reports larger than host MTU on
+					Interrupt channel (O)
+TSPC_HID_10_3	False		Hid : Data reports to host (O)
+TSPC_HID_10_4	False		Hid : Boot mode reports to host (C.1)
+-------------------------------------------------------------------------------
+C.1: Mandatory IF (TSPC_HID_8_1) OR (TSPC_HID_8_2) is supported.
+	Optional for other HIDs.
+-------------------------------------------------------------------------------
+
+
+		Host to Device Transfers
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_HID_11_1	False		Hid : Data reports larger than device MTU on
+					Control channel (O)
+TSPC_HID_11_2	False		Hid : Data reports larger than device MTU on
+					Interrupt channel (O)
+TSPC_HID_11_3	False		Hid : Data reports to device (O)
+TSPC_HID_11_4	False		Hid : Boot mode reports to device (C.1)
+-------------------------------------------------------------------------------
+C.1: Mandatory IF (TSPC_HID_8_2) is supported. Optional for other HIDs.
+-------------------------------------------------------------------------------
+
+
+		HID Control Commands
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_HID_12_1	False		Hid : Set_Protocol command (C.1)
+TSPC_HID_12_2	False		Hid : Get_Protocol command (C.1)
+TSPC_HID_12_3	False		Hid : Set_Idle command (C.2)
+TSPC_HID_12_4	False		Hid : Get_Idle command (C.2)
+TSPC_HID_12_5	False		Hid : Set_Report command (C.3)
+TSPC_HID_12_6	False		Hid : Get_Report command (C.4)
+-------------------------------------------------------------------------------
+C.1: Mandatory IF (TSPC_HID_8_1) OR (TSPC_HID_8_2) is supported.
+	Optional for other HIDs. If either Set_Protocol or Get_Protocol
+	supported, both are Mandatory.
+C.2: Mandatory IF (TSPC_HID_8_2) Keyboard is selected. Optional for other HIDs.
+C.3: Mandatory IF (TSPC_HID_9_12) or (TSPC_HID_9_14) supported.
+C.4: Mandatory IF (TSPC_HID_9_13) or (TSPC_HID_9_14) supported
+-------------------------------------------------------------------------------
+
+
+		HID Link Manager Procedures
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_HID_13_1	False		Hid : Host initiated Authentication before
+					connection completed (C.1)
+TSPC_HID_13_2	False		Hid : Host initiated Authentication after
+					connection completed (C.1)
+TSPC_HID_13_3	False		Hid : Initiate pairing before connection
+					completed (X)
+TSPC_HID_13_4	False		Hid : Initiate pairing after connection
+					completed (X)
+TSPC_HID_13_5	False		Hid : Encryption (C.1)
+TSPC_HID_13_6	False		Hid : Initiate encryption (O)
+TSPC_HID_13_7	False		Hid : Accept encryption requests (C.2)
+TSPC_HID_13_8	False		Hid : Role switch (Master/Slave) (C.3)
+TSPC_HID_13_9	False		Hid : Request Master Slave switch (O)
+TSPC_HID_13_10	False		Hid : Accept Master Slave switch requests (C.3)
+TSPC_HID_13_11	False		Hid : Hold mode (O)
+TSPC_HID_13_12	False		Hid : Sniff mode (O)
+TSPC_HID_13_13	False		Hid : Park mode (O)
+-------------------------------------------------------------------------------
+C.1: Mandatory IF (TSPC_HID_8_2) OR (TSPC_HID_8_3) is selected. Optional
+	for other HIDs.
+C.2: Mandatory IF (TSPC_HID_13_5) supported.
+C.3: Mandatory IF (TSPC_HID_9_6) is supported.
+X: Feature should not be used by a HID device, but can be supported in LM.
+-------------------------------------------------------------------------------
+
+
+		HID Link Control Requirements
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_HID_14_1	False		Hid : Supports inquiry, 79 channel (O)
+TSPC_HID_14_2	False (*)	Hid : Supports inquiry scan, 79 channel (M.1)
+TSPC_ALL	False		Enables all test cases when set to true.
+-------------------------------------------------------------------------------
+M.1: Mandatory IF (TSPC_HID_1_2) is supported.
+-------------------------------------------------------------------------------
-- 
1.8.4.1


^ permalink raw reply related


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