diff options
author | Szymon Janc <szymon.janc@tieto.com> | 2014-02-18 14:05:14 +0100 |
---|---|---|
committer | Szymon Janc <szymon.janc@tieto.com> | 2014-02-28 15:22:45 +0100 |
commit | 5862f2f6a58866e4c4321020e23c082821be3e00 (patch) | |
tree | 7e3123bbb6f8f84cdf86172641d3bef1d6dcad29 /android/main.c | |
parent | dd1e44fce160c1883d8600ff2816a3403c967b12 (diff) | |
download | bluez-5862f2f6a58866e4c4321020e23c082821be3e00.tar.gz |
android: Add support for registering disconnect callback in IPC
Allow to register callback which is called in case of IPC failure
(eg malformed message) or disconnection. This makes caller responsible
for performing expected action in such case.
Diffstat (limited to 'android/main.c')
-rw-r--r-- | android/main.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/android/main.c b/android/main.c index 9f224869c..01f0b9212 100644 --- a/android/main.c +++ b/android/main.c @@ -228,6 +228,11 @@ static void stop_bluetooth(void) g_timeout_add_seconds(SHUTDOWN_GRACE_SECONDS, quit_eventloop, NULL); } +static void ipc_disconnected(void *data) +{ + stop_bluetooth(); +} + static void adapter_ready(int err, const bdaddr_t *addr) { if (err < 0) { @@ -245,7 +250,7 @@ static void adapter_ready(int err, const bdaddr_t *addr) info("Adapter initialized"); hal_ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH), - HAL_SERVICE_ID_MAX); + HAL_SERVICE_ID_MAX, ipc_disconnected, NULL); if (!hal_ipc) { error("Failed to initialize IPC"); exit(EXIT_FAILURE); |