All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] android: Add missing adapter state values to IPC documentation
@ 2013-10-23 13:46 Szymon Janc
  2013-10-23 13:46 ` [PATCH 2/6] android: Add missing adapter state values to IPC header Szymon Janc
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Szymon Janc @ 2013-10-23 13:46 UTC (permalink / raw
  To: linux-bluetooth; +Cc: Szymon Janc

---
 android/hal-ipc-api.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index dcd1553..a5437c1 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -314,6 +314,9 @@ Notifications:
 
 		Notifications parameters: State (1 octect)
 
+		Valid state values: 0x00 = Off
+		                    0x01 = On
+
 	Opcode 0x82 - Adapter Properties Changed notification
 
 		Notification parameters: Status (1 octect)
-- 
1.8.4


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

* [PATCH 2/6] android: Add missing adapter state values to IPC header
  2013-10-23 13:46 [PATCH 1/6] android: Add missing adapter state values to IPC documentation Szymon Janc
@ 2013-10-23 13:46 ` Szymon Janc
  2013-10-23 13:46 ` [PATCH 3/6] android/hal: Fix crash while receiving notification Szymon Janc
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Szymon Janc @ 2013-10-23 13:46 UTC (permalink / raw
  To: linux-bluetooth; +Cc: Szymon Janc

---
 android/hal-msg.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 9ff0510..2840a92 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -252,6 +252,9 @@ struct hal_msg_cmd_bt_hid_send_data {
 /* Notifications and confirmations */
 
 
+#define HAL_BT_ADAPTER_STATE_OFF	0x00
+#define HAL_BT_ADAPTER_STATE_ON		0x01
+
 #define HAL_MSG_EV_BT_ADAPTER_STATE_CHANGED	0x81
 struct hal_msg_ev_bt_adapter_state_changed {
 	uint8_t state;
-- 
1.8.4


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

* [PATCH 3/6] android/hal: Fix crash while receiving notification
  2013-10-23 13:46 [PATCH 1/6] android: Add missing adapter state values to IPC documentation Szymon Janc
  2013-10-23 13:46 ` [PATCH 2/6] android: Add missing adapter state values to IPC header Szymon Janc
@ 2013-10-23 13:46 ` Szymon Janc
  2013-10-23 13:46 ` [PATCH 4/6] android: Send notification on adapter power state change Szymon Janc
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Szymon Janc @ 2013-10-23 13:46 UTC (permalink / raw
  To: linux-bluetooth; +Cc: Szymon Janc

This fix following crash:
Invalid read of size 8
   at 0x408B33: notification_handler (hal-ipc.c:122)
   by 0x4E39E99: start_thread (pthread_create.c:308)
 Address 0x8 is not stack'd, malloc'd or (recently) free'd
---
 android/hal-ipc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/hal-ipc.c b/android/hal-ipc.c
index e8bba11..97a3d29 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -118,7 +118,7 @@ static void *notification_handler(void *data)
 		fd = -1;
 
 		/* Receive auxiliary data in msg */
-		for (cmsg = CMSG_FIRSTHDR(&msg); !cmsg;
+		for (cmsg = CMSG_FIRSTHDR(&msg); cmsg;
 					cmsg = CMSG_NXTHDR(&msg, cmsg)) {
 			if (cmsg->cmsg_level == SOL_SOCKET
 					&& cmsg->cmsg_type == SCM_RIGHTS) {
-- 
1.8.4


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

* [PATCH 4/6] android: Send notification on adapter power state change
  2013-10-23 13:46 [PATCH 1/6] android: Add missing adapter state values to IPC documentation Szymon Janc
  2013-10-23 13:46 ` [PATCH 2/6] android: Add missing adapter state values to IPC header Szymon Janc
  2013-10-23 13:46 ` [PATCH 3/6] android/hal: Fix crash while receiving notification Szymon Janc
@ 2013-10-23 13:46 ` Szymon Janc
  2013-10-23 13:46 ` [PATCH 5/6] android/hal: Verify if command response service ID match Szymon Janc
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Szymon Janc @ 2013-10-23 13:46 UTC (permalink / raw
  To: linux-bluetooth; +Cc: Szymon Janc

---
 android/adapter.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index f9843d1..7a219df 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -74,6 +74,20 @@ static void mgmt_local_name_changed_event(uint16_t index, uint16_t length,
 	/* TODO Update services if needed */
 }
 
+static void settings_changed_powered(struct bt_adapter *adapter)
+{
+	struct hal_msg_ev_bt_adapter_state_changed ev;
+
+	ev.state = (adapter->current_settings & MGMT_SETTING_POWERED) ?
+			HAL_BT_ADAPTER_STATE_ON : HAL_BT_ADAPTER_STATE_OFF;
+
+	DBG("%u", ev.state);
+
+	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
+					HAL_MSG_EV_BT_ADAPTER_STATE_CHANGED,
+					sizeof(ev), &ev, -1);
+}
+
 static void settings_changed_connectable(struct bt_adapter *adapter)
 {
 	/* TODO */
@@ -94,16 +108,8 @@ static void settings_changed(struct bt_adapter *adapter, uint32_t settings)
 
 	DBG("0x%08x", changed_mask);
 
-	if (changed_mask & MGMT_SETTING_POWERED) {
-		info("Powered");
-
-		/*
-		if (adapter->current_settings & MGMT_SETTING_POWERED)
-			start_adapter()
-		else
-			stop_adapter()
-		*/
-	}
+	if (changed_mask & MGMT_SETTING_POWERED)
+		settings_changed_powered(adapter);
 
 	if (changed_mask & MGMT_SETTING_CONNECTABLE) {
 		DBG("Connectable");
-- 
1.8.4


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

* [PATCH 5/6] android/hal: Verify if command response service ID match
  2013-10-23 13:46 [PATCH 1/6] android: Add missing adapter state values to IPC documentation Szymon Janc
                   ` (2 preceding siblings ...)
  2013-10-23 13:46 ` [PATCH 4/6] android: Send notification on adapter power state change Szymon Janc
@ 2013-10-23 13:46 ` Szymon Janc
  2013-10-23 13:46 ` [PATCH 6/6] android: Fix use of invalid service ID in response Szymon Janc
  2013-10-23 16:34 ` [PATCH 1/6] android: Add missing adapter state values to IPC documentation Johan Hedberg
  5 siblings, 0 replies; 7+ messages in thread
From: Szymon Janc @ 2013-10-23 13:46 UTC (permalink / raw
  To: linux-bluetooth; +Cc: Szymon Janc

Received response service ID should match command service ID in
command, abort if it doesn't.
---
 android/hal-ipc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/android/hal-ipc.c b/android/hal-ipc.c
index 97a3d29..8f13e88 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -335,6 +335,12 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
 		exit(EXIT_FAILURE);
 	}
 
+	if (hal_msg.service_id != service_id) {
+		error("Invalid service id (%u vs %u), aborting",
+					hal_msg.service_id, service_id);
+		exit(EXIT_FAILURE);
+	}
+
 	if (ret != (ssize_t) (sizeof(hal_msg) + hal_msg.len)) {
 		error("Malformed response received(%zd bytes), aborting", ret);
 		exit(EXIT_FAILURE);
-- 
1.8.4


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

* [PATCH 6/6] android: Fix use of invalid service ID in response
  2013-10-23 13:46 [PATCH 1/6] android: Add missing adapter state values to IPC documentation Szymon Janc
                   ` (3 preceding siblings ...)
  2013-10-23 13:46 ` [PATCH 5/6] android/hal: Verify if command response service ID match Szymon Janc
@ 2013-10-23 13:46 ` Szymon Janc
  2013-10-23 16:34 ` [PATCH 1/6] android: Add missing adapter state values to IPC documentation Johan Hedberg
  5 siblings, 0 replies; 7+ messages in thread
From: Szymon Janc @ 2013-10-23 13:46 UTC (permalink / raw
  To: linux-bluetooth; +Cc: Szymon Janc

Adapter should use HAL_SERVICE_ID_BLUETOOTH service ID.
---
 android/adapter.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index 7a219df..6b0fab2 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -347,7 +347,8 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 		}
 
 		if (set_mode(MGMT_OP_SET_POWERED, 0x01)) {
-			ipc_send(io, HAL_SERVICE_ID_CORE, opcode, 0, NULL, -1);
+			ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL,
+									-1);
 			return;
 		}
 		break;
@@ -358,7 +359,8 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 		}
 
 		if (set_mode(MGMT_OP_SET_POWERED, 0x00)) {
-			ipc_send(io, HAL_SERVICE_ID_CORE, opcode, 0, NULL, -1);
+			ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL,
+									-1);
 			return;
 		}
 		break;
-- 
1.8.4


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

* Re: [PATCH 1/6] android: Add missing adapter state values to IPC documentation
  2013-10-23 13:46 [PATCH 1/6] android: Add missing adapter state values to IPC documentation Szymon Janc
                   ` (4 preceding siblings ...)
  2013-10-23 13:46 ` [PATCH 6/6] android: Fix use of invalid service ID in response Szymon Janc
@ 2013-10-23 16:34 ` Johan Hedberg
  5 siblings, 0 replies; 7+ messages in thread
From: Johan Hedberg @ 2013-10-23 16:34 UTC (permalink / raw
  To: Szymon Janc; +Cc: linux-bluetooth

Hi Szymon,

On Wed, Oct 23, 2013, Szymon Janc wrote:
> ---
>  android/hal-ipc-api.txt | 3 +++
>  1 file changed, 3 insertions(+)

All six patches have been applied. Thanks.

Johan

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

end of thread, other threads:[~2013-10-23 16:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-23 13:46 [PATCH 1/6] android: Add missing adapter state values to IPC documentation Szymon Janc
2013-10-23 13:46 ` [PATCH 2/6] android: Add missing adapter state values to IPC header Szymon Janc
2013-10-23 13:46 ` [PATCH 3/6] android/hal: Fix crash while receiving notification Szymon Janc
2013-10-23 13:46 ` [PATCH 4/6] android: Send notification on adapter power state change Szymon Janc
2013-10-23 13:46 ` [PATCH 5/6] android/hal: Verify if command response service ID match Szymon Janc
2013-10-23 13:46 ` [PATCH 6/6] android: Fix use of invalid service ID in response Szymon Janc
2013-10-23 16:34 ` [PATCH 1/6] android: Add missing adapter state values to IPC documentation Johan Hedberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.