diff options
author | Szymon Janc <szymon.janc@tieto.com> | 2014-02-24 13:44:12 +0100 |
---|---|---|
committer | Szymon Janc <szymon.janc@tieto.com> | 2014-02-28 15:22:45 +0100 |
commit | dd1e44fce160c1883d8600ff2816a3403c967b12 (patch) | |
tree | 8c55cd6a12e9be1669174074190e16ab6aaf3311 /android/test-ipc.c | |
parent | a7471c5334595ff4de1fe5aab17ad9ce8a90bae0 (diff) | |
download | bluez-dd1e44fce160c1883d8600ff2816a3403c967b12.tar.gz |
android: Refactor IPC init
This allows to pass socket path and max service ID while initializaing
IPC. This is first step to allow use it both for BT and Audio HALs.
Diffstat (limited to 'android/test-ipc.c')
-rw-r--r-- | android/test-ipc.c | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/android/test-ipc.c b/android/test-ipc.c index 8dd53a1c6..054af84e0 100644 --- a/android/test-ipc.c +++ b/android/test-ipc.c @@ -43,6 +43,8 @@ #include "android/hal-msg.h" #include "android/ipc.h" +static struct ipc *ipc = NULL; + struct test_data { uint32_t expected_signal; const void *cmd; @@ -283,11 +285,15 @@ static void test_init(gconstpointer data) { struct context *context = create_context(data); - ipc_init(); + ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH), + HAL_SERVICE_ID_MAX); + + g_assert(ipc); execute_context(context); - ipc_cleanup(); + ipc_cleanup(ipc); + ipc = NULL; } static gboolean send_cmd(gpointer user_data) @@ -310,7 +316,7 @@ static gboolean register_service(gpointer user_data) struct context *context = user_data; const struct test_data *test_data = context->data; - ipc_register(test_data->service, test_data->handlers, + ipc_register(ipc, test_data->service, test_data->handlers, test_data->handlers_size); return FALSE; @@ -321,7 +327,7 @@ static gboolean unregister_service(gpointer user_data) struct context *context = user_data; const struct test_data *test_data = context->data; - ipc_unregister(test_data->service); + ipc_unregister(ipc, test_data->service); return FALSE; } @@ -330,13 +336,17 @@ static void test_cmd(gconstpointer data) { struct context *context = create_context(data); - ipc_init(); + ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH), + HAL_SERVICE_ID_MAX); + + g_assert(ipc); g_idle_add(send_cmd, context); execute_context(context); - ipc_cleanup(); + ipc_cleanup(ipc); + ipc = NULL; } static void test_cmd_reg(gconstpointer data) @@ -344,23 +354,30 @@ static void test_cmd_reg(gconstpointer data) struct context *context = create_context(data); const struct test_data *test_data = context->data; - ipc_init(); + ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH), + HAL_SERVICE_ID_MAX); + + g_assert(ipc); g_idle_add(register_service, context); g_idle_add(send_cmd, context); execute_context(context); - ipc_unregister(test_data->service); + ipc_unregister(ipc, test_data->service); - ipc_cleanup(); + ipc_cleanup(ipc); + ipc = NULL; } static void test_cmd_reg_1(gconstpointer data) { struct context *context = create_context(data); - ipc_init(); + ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH), + HAL_SERVICE_ID_MAX); + + g_assert(ipc); g_idle_add(register_service, context); g_idle_add(unregister_service, context); @@ -368,17 +385,18 @@ static void test_cmd_reg_1(gconstpointer data) execute_context(context); - ipc_cleanup(); + ipc_cleanup(ipc); + ipc = NULL; } static void test_cmd_handler_1(const void *buf, uint16_t len) { - ipc_send_rsp(0, 1, 0); + ipc_send_rsp(ipc, 0, 1, 0); } static void test_cmd_handler_2(const void *buf, uint16_t len) { - ipc_send_rsp(0, 2, 0); + ipc_send_rsp(ipc, 0, 2, 0); } static void test_cmd_handler_invalid(const void *buf, uint16_t len) |