diff --git a/android/ipc.c b/android/ipc.c
index a996935..fa44e3f 100644
--- a/android/ipc.c
+++ b/android/ipc.c
GIOChannel *cmd_io;
guint cmd_watch;
+ bool notifications;
GIOChannel *notif_io;
guint notif_watch;
ipc->cmd_watch = g_io_add_watch(ipc->cmd_io, cond, cmd_watch_cb, ipc);
- info("IPC: successfully connected");
+ info("IPC: successfully connected (with notifications)");
return FALSE;
}
if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
error("IPC: command socket connect failed");
- goto failed;
+ ipc_disconnect(ipc, false);
+
+ return FALSE;
}
- ipc->notif_io = ipc_connect(ipc->path, ipc->size, notif_connect_cb,
- ipc);
- if (!ipc->notif_io)
- goto failed;
+ if (ipc->notifications) {
+ ipc->notif_io = ipc_connect(ipc->path, ipc->size,
+ notif_connect_cb, ipc);
+ if (!ipc->notif_io)
+ ipc_disconnect(ipc, false);
- return FALSE;
+ return FALSE;
+ }
-failed:
- ipc_disconnect(ipc, false);
+ cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
+
+ ipc->cmd_watch = g_io_add_watch(ipc->cmd_io, cond, cmd_watch_cb, ipc);
+
+ info("IPC: successfully connected (without notifications)");
return FALSE;
}
struct ipc *ipc_init(const char *path, size_t size, int max_service_id,
+ bool notifications,
ipc_disconnect_cb cb, void *cb_data)
{
struct ipc *ipc;
ipc->path = path;
ipc->size = size;
+ ipc->notifications = notifications;
+
ipc->cmd_io = ipc_connect(path, size, cmd_connect_cb, ipc);
if (!ipc->cmd_io) {
g_free(ipc->services);
diff --git a/android/ipc.h b/android/ipc.h
index 63b751d..d46dbbf 100644
--- a/android/ipc.h
+++ b/android/ipc.h
typedef void (*ipc_disconnect_cb) (void *data);
struct ipc *ipc_init(const char *path, size_t size, int max_service_id,
+ bool notifications,
ipc_disconnect_cb cb, void *cb_data);
void ipc_cleanup(struct ipc *ipc);
diff --git a/android/main.c b/android/main.c
index 01f0b92..bd1bcb9 100644
--- a/android/main.c
+++ b/android/main.c
info("Adapter initialized");
hal_ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH),
- HAL_SERVICE_ID_MAX, ipc_disconnected, NULL);
+ HAL_SERVICE_ID_MAX, true,
+ ipc_disconnected, NULL);
if (!hal_ipc) {
error("Failed to initialize IPC");
exit(EXIT_FAILURE);
diff --git a/android/test-ipc.c b/android/test-ipc.c
index 2f211fd..6172991 100644
--- a/android/test-ipc.c
+++ b/android/test-ipc.c
struct context *context = create_context(data);
ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH),
- HAL_SERVICE_ID_MAX, NULL, NULL);
+ HAL_SERVICE_ID_MAX, true, NULL, NULL);
g_assert(ipc);
struct context *context = create_context(data);
ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH),
- HAL_SERVICE_ID_MAX, disconnected, context);
+ HAL_SERVICE_ID_MAX, true, disconnected, context);
g_assert(ipc);
const struct test_data *test_data = context->data;
ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH),
- HAL_SERVICE_ID_MAX, disconnected, context);
+ HAL_SERVICE_ID_MAX, true, disconnected, context);
g_assert(ipc);
struct context *context = create_context(data);
ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH),
- HAL_SERVICE_ID_MAX, disconnected, context);
+ HAL_SERVICE_ID_MAX, true, disconnected, context);
g_assert(ipc);