From c466e79d6bb6cc6942baa564ffdb46ffd83da0ec Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 23 Jan 2014 15:04:12 +0200 Subject: [PATCH] android: Add initial skeleton for AVRCP in the daemon --- android/Android.mk | 1 + android/Makefile.am | 1 + android/avrcp.c | 59 +++++++++++++++++++++++++++++++++++++++++++++ android/avrcp.h | 25 +++++++++++++++++++ android/main.c | 11 +++++++++ 5 files changed, 97 insertions(+) create mode 100644 android/avrcp.c create mode 100644 android/avrcp.h diff --git a/android/Android.mk b/android/Android.mk index 507b23bb2..e341349b4 100644 --- a/android/Android.mk +++ b/android/Android.mk @@ -30,6 +30,7 @@ LOCAL_SRC_FILES := \ bluez/android/avdtp.c \ bluez/android/a2dp.c \ bluez/android/avctp.c \ + bluez/android/avrcp.c \ bluez/android/pan.c \ bluez/src/log.c \ bluez/src/shared/mgmt.c \ diff --git a/android/Makefile.am b/android/Makefile.am index 88fe667b4..d4a76bbf2 100644 --- a/android/Makefile.am +++ b/android/Makefile.am @@ -34,6 +34,7 @@ android_bluetoothd_SOURCES = android/main.c \ android/avdtp.h android/avdtp.c \ android/a2dp.h android/a2dp.c \ android/avctp.h android/avctp.c \ + android/avrcp.h android/avrcp.c \ android/socket.h android/socket.c \ android/pan.h android/pan.c \ btio/btio.h btio/btio.c \ diff --git a/android/avrcp.c b/android/avrcp.c new file mode 100644 index 000000000..a6fb5f5a4 --- /dev/null +++ b/android/avrcp.c @@ -0,0 +1,59 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2014 Intel Corporation. All rights reserved. + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; 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 "lib/bluetooth.h" +#include "src/log.h" +#include "avrcp.h" +#include "hal-msg.h" +#include "ipc.h" + +static bdaddr_t adapter_addr; + +static const struct ipc_handler cmd_handlers[] = { +}; + +bool bt_avrcp_register(const bdaddr_t *addr) +{ + DBG(""); + + bacpy(&adapter_addr, addr); + + ipc_register(HAL_SERVICE_ID_AVRCP, cmd_handlers, + G_N_ELEMENTS(cmd_handlers)); + + return true; +} + +void bt_avrcp_unregister(void) +{ + DBG(""); + + ipc_unregister(HAL_SERVICE_ID_AVRCP); +} diff --git a/android/avrcp.h b/android/avrcp.h new file mode 100644 index 000000000..6fe7fbf0c --- /dev/null +++ b/android/avrcp.h @@ -0,0 +1,25 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2014 Intel Corporation. All rights reserved. + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +bool bt_avrcp_register(const bdaddr_t *addr); +void bt_avrcp_unregister(void); diff --git a/android/main.c b/android/main.c index cdeb4203f..c6ada62be 100644 --- a/android/main.c +++ b/android/main.c @@ -55,6 +55,7 @@ #include "ipc.h" #include "a2dp.h" #include "pan.h" +#include "avrcp.h" #define STARTUP_GRACE_SECONDS 5 #define SHUTDOWN_GRACE_SECONDS 10 @@ -106,6 +107,13 @@ static void service_register(const void *buf, uint16_t len) goto failed; } + break; + case HAL_SERVICE_ID_AVRCP: + if (!bt_avrcp_register(&adapter_bdaddr)) { + status = HAL_STATUS_FAILED; + goto failed; + } + break; default: DBG("service %u not supported", m->service_id); @@ -149,6 +157,9 @@ static void service_unregister(const void *buf, uint16_t len) case HAL_SERVICE_ID_PAN: bt_pan_unregister(); break; + case HAL_SERVICE_ID_AVRCP: + bt_avrcp_unregister(); + break; default: /* This would indicate bug in HAL, as unregister should not be * called in init failed */ -- 2.47.3