2013-11-15 10:13:53

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 1/3] android/hal: Merge bluetooth and sock register/unregister

From: Andrei Emeltchenko <[email protected]>

Bluetooth and Socket HAL are registered and unregistered at the
same time.
---
android/main.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/android/main.c b/android/main.c
index a4f5e84..f72004c 100644
--- a/android/main.c
+++ b/android/main.c
@@ -87,10 +87,11 @@ static void service_register(void *buf, uint16_t len)
if (!bt_bluetooth_register(sk))
goto failed;

- break;
- case HAL_SERVICE_ID_SOCK:
- if (!bt_socket_register(sk, &adapter_bdaddr))
+ if (!bt_socket_register(sk, &adapter_bdaddr)) {
+ bt_bluetooth_unregister();
goto failed;
+ }
+ services[HAL_SERVICE_ID_SOCK] = true;

break;
case HAL_SERVICE_ID_HIDHOST:
@@ -135,8 +136,6 @@ static void service_unregister(void *buf, uint16_t len)
switch (m->service_id) {
case HAL_SERVICE_ID_BLUETOOTH:
bt_bluetooth_unregister();
- break;
- case HAL_SERVICE_ID_SOCK:
bt_socket_unregister();
break;
case HAL_SERVICE_ID_HIDHOST:
--
1.7.10.4



2013-11-15 10:13:55

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 3/3] android/hal: Unregister Bluetooth on cleanup

From: Andrei Emeltchenko <[email protected]>

---
This is more like RFC. Shall we send this event or this will be cleaned up itself.

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

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 8cd4327..4bf1183 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -379,11 +379,18 @@ static int disable(void)

static void cleanup(void)
{
+ struct hal_cmd_register_module cmd;
+
DBG("");

if (!interface_ready())
return;

+ cmd.service_id = HAL_SERVICE_ID_BLUETOOTH;
+
+ hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE,
+ sizeof(cmd), &cmd, NULL, NULL, NULL);
+
hal_ipc_cleanup();

bt_hal_cbacks = NULL;
--
1.7.10.4


2013-11-15 10:13:54

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 2/3] android/hal: Remove unneeded code

From: Andrei Emeltchenko <[email protected]>

Socket HAL always registers with Bluetooth HAL and there is no sense
to send 2 commands over IPC.
---
android/hal-bluetooth.c | 9 ---------
1 file changed, 9 deletions(-)

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 078d537..8cd4327 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -347,15 +347,6 @@ static int init(bt_callbacks_t *callbacks)
goto fail;
}

- cmd.service_id = HAL_SERVICE_ID_SOCK;
-
- status = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
- sizeof(cmd), &cmd, NULL, NULL, NULL);
- if (status != BT_STATUS_SUCCESS) {
- error("Failed to register 'socket' service");
- goto fail;
- }
-
return status;

fail:
--
1.7.10.4