From 4056566559c1f5ace7a2369bc1322965898bc568 Mon Sep 17 00:00:00 2001 From: Lukasz Rymanowski Date: Mon, 15 Sep 2014 13:51:16 +0200 Subject: [PATCH] android/handsfree-client: Add handsfree-client daemon skeleton --- android/Android.mk | 1 + android/Makefile.am | 1 + android/handsfree-client.c | 69 ++++++++++++++++++++++++++++++++++++++ android/handsfree-client.h | 25 ++++++++++++++ android/main.c | 11 ++++++ 5 files changed, 107 insertions(+) create mode 100644 android/handsfree-client.c create mode 100644 android/handsfree-client.h diff --git a/android/Android.mk b/android/Android.mk index b2b55f723..aae426db1 100644 --- a/android/Android.mk +++ b/android/Android.mk @@ -49,6 +49,7 @@ LOCAL_SRC_FILES := \ bluez/android/avrcp-lib.c \ bluez/android/pan.c \ bluez/android/handsfree.c \ + bluez/android/handsfree-client.c \ bluez/android/gatt.c \ bluez/android/health.c \ bluez/android/mcap-lib.c \ diff --git a/android/Makefile.am b/android/Makefile.am index 49fbddcd0..70b9c3a45 100644 --- a/android/Makefile.am +++ b/android/Makefile.am @@ -52,6 +52,7 @@ android_bluetoothd_SOURCES = android/main.c \ android/socket.h android/socket.c \ android/pan.h android/pan.c \ android/handsfree.h android/handsfree.c \ + android/handsfree-client.c android/handsfree-client.h \ android/gatt.h android/gatt.c \ android/health.h android/health.c \ android/mcap-lib.h android/mcap-lib.c \ diff --git a/android/handsfree-client.c b/android/handsfree-client.c new file mode 100644 index 000000000..c3ff55527 --- /dev/null +++ b/android/handsfree-client.c @@ -0,0 +1,69 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2014 Intel Corporation. All rights reserved. + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include "lib/bluetooth.h" +#include "ipc.h" +#include "ipc-common.h" +#include "src/log.h" +#include "utils.h" + +#include "hal-msg.h" +#include "handsfree-client.h" + +static bdaddr_t adapter_addr; + +static struct ipc *hal_ipc = NULL; + +static const struct ipc_handler cmd_handlers[] = { +}; + +bool bt_hf_client_register(struct ipc *ipc, const bdaddr_t *addr) +{ + DBG(""); + + bacpy(&adapter_addr, addr); + + hal_ipc = ipc; + ipc_register(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT, cmd_handlers, + G_N_ELEMENTS(cmd_handlers)); + + return true; +} + +void bt_hf_client_unregister(void) +{ + DBG(""); + + ipc_unregister(hal_ipc, HAL_SERVICE_ID_HANDSFREE); + hal_ipc = NULL; +} diff --git a/android/handsfree-client.h b/android/handsfree-client.h new file mode 100644 index 000000000..1eb69ff36 --- /dev/null +++ b/android/handsfree-client.h @@ -0,0 +1,25 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2014 Intel Corporation. All rights reserved. + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +bool bt_hf_client_register(struct ipc *ipc, const bdaddr_t *addr); +void bt_hf_client_unregister(void); diff --git a/android/main.c b/android/main.c index b03a2df81..5652331e2 100644 --- a/android/main.c +++ b/android/main.c @@ -60,6 +60,7 @@ #include "handsfree.h" #include "gatt.h" #include "health.h" +#include "handsfree-client.h" #define STARTUP_GRACE_SECONDS 5 #define SHUTDOWN_GRACE_SECONDS 10 @@ -144,6 +145,13 @@ static void service_register(const void *buf, uint16_t len) goto failed; } + break; + case HAL_SERVICE_ID_HANDSFREE_CLIENT: + if (!bt_hf_client_register(hal_ipc, &adapter_bdaddr)) { + status = HAL_STATUS_FAILED; + goto failed; + } + break; default: DBG("service %u not supported", m->service_id); @@ -200,6 +208,9 @@ static void service_unregister(const void *buf, uint16_t len) case HAL_SERVICE_ID_HEALTH: bt_health_unregister(); break; + case HAL_SERVICE_ID_HANDSFREE_CLIENT: + bt_hf_client_unregister(); + break; default: /* * This would indicate bug in HAL, as unregister should not be -- 2.47.3