diff --git a/android/adapter.c b/android/adapter.c
index de3660d..059a5be 100644
--- a/android/adapter.c
+++ b/android/adapter.c
#include "ipc.h"
#include "adapter.h"
+static GIOChannel *notification_io = NULL;
+
struct bt_adapter {
uint16_t index;
struct mgmt *mgmt;
ipc_send_error(io, HAL_SERVICE_ID_BLUETOOTH, status);
}
+
+bool bt_adapter_register(GIOChannel *io)
+{
+ DBG("");
+
+ notification_io = g_io_channel_ref(io);
+
+ return true;
+}
+
+void bt_adapter_unregister(void)
+{
+ DBG("");
+
+ g_io_channel_unref(notification_io);
+ notification_io = NULL;
+}
diff --git a/android/adapter.h b/android/adapter.h
index bfd4932..194950b 100644
--- a/android/adapter.h
+++ b/android/adapter.h
void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
uint16_t len);
+
+bool bt_adapter_register(GIOChannel *io);
+void bt_adapter_unregister(void);
diff --git a/android/main.c b/android/main.c
index 73ff3ee..b18b8d4 100644
--- a/android/main.c
+++ b/android/main.c
goto error;
switch (m->service_id) {
+ case HAL_SERVICE_ID_BLUETOOTH:
+ if (!bt_adapter_register(hal_notif_io))
+ goto error;
+
+ break;
default:
DBG("service %u not supported", m->service_id);
goto error;
goto error;
switch (m->service_id) {
+ case HAL_SERVICE_ID_BLUETOOTH:
+ bt_adapter_unregister();
+ break;
default:
/* This would indicate bug in HAL, as unregister should not be
* called in init failed */