diff --git a/android/Makefile.am b/android/Makefile.am
index 5850aa3..883856f 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
src/shared/queue.h src/shared/queue.c \
src/shared/util.h src/shared/util.c \
src/shared/mgmt.h src/shared/mgmt.c \
+ src/shared/ringbuf.h src/shared/ringbuf.c \
+ src/shared/hfp.h src/shared/hfp.c \
android/bluetooth.h android/bluetooth.c \
android/hidhost.h android/hidhost.c \
android/ipc.h android/ipc.c \
diff --git a/android/handsfree.c b/android/handsfree.c
index ad4c0ff..a4ce398 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
#include "lib/uuid.h"
#include "src/sdp-client.h"
#include "src/uuid-helper.h"
+#include "src/shared/hfp.h"
#include "btio/btio.h"
#include "handsfree.h"
#include "bluetooth.h"
uint8_t state;
GIOChannel *io;
guint watch;
+ struct hfp_gw *gw;
} device;
static bdaddr_t adapter_addr;
static void device_cleanup(void)
{
+ if (device.gw) {
+ hfp_gw_unref(device.gw);
+ device.gw = NULL;
+ }
+
if (device.watch) {
g_source_remove(device.watch);
device.watch = 0;
return FALSE;
}
+static void at_command_handler(const char *command, void *user_data)
+{
+ hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+
+ g_io_channel_shutdown(device.io, TRUE, NULL);
+}
+
static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
{
DBG("");
g_io_channel_set_close_on_unref(chan, TRUE);
+ device.gw = hfp_gw_new(g_io_channel_unix_get_fd(chan));
+ if (!device.gw)
+ goto failed;
+
+ hfp_gw_set_close_on_unref(device.gw, true);
+ hfp_gw_set_command_handler(device.gw, at_command_handler, NULL, NULL);
+
device.watch = g_io_add_watch(chan,
G_IO_HUP | G_IO_ERR | G_IO_NVAL,
watch_cb, NULL);