Patchset contains changes related to AVRCP CTRL. Moving AVRCP CTRL
HAL and Client related changes to it's own file (agreed on IRC to
maintain separate file for each HAL).
Ravi kumar Veeramally (2):
android/hal-avrcp-ctrl: Create separate HAL for AVRCP CTRL
android/client: Create separate file for AVRCP CTRL
android/Android.mk | 2 +
android/Makefile.am | 2 +
android/client/haltest.c | 2 +
android/client/if-rc-ctrl.c | 112 ++++++++++++++++++++++++++++++++++
android/client/if-rc.c | 88 ---------------------------
android/hal-avrcp-ctrl.c | 144 ++++++++++++++++++++++++++++++++++++++++++++
android/hal-avrcp.c | 121 -------------------------------------
7 files changed, 262 insertions(+), 209 deletions(-)
create mode 100644 android/client/if-rc-ctrl.c
create mode 100644 android/hal-avrcp-ctrl.c
--
2.1.0
Hi Ravi,
On Tuesday 18 of November 2014 14:54:49 Ravi kumar Veeramally wrote:
> Moving AVRCP CTRL interface client related code to if-rc-ctrl.c.
> ---
> android/Android.mk | 1 +
> android/Makefile.am | 1 +
> android/client/haltest.c | 2 +
> android/client/if-rc-ctrl.c | 112 ++++++++++++++++++++++++++++++++++++++++++++
> android/client/if-rc.c | 88 ----------------------------------
> 5 files changed, 116 insertions(+), 88 deletions(-)
> create mode 100644 android/client/if-rc-ctrl.c
>
> diff --git a/android/Android.mk b/android/Android.mk
> index 39f03bc..e2179fa 100644
> --- a/android/Android.mk
> +++ b/android/Android.mk
> @@ -174,6 +174,7 @@ LOCAL_SRC_FILES := \
> bluez/android/client/if-sco.c \
> bluez/android/client/if-av.c \
> bluez/android/client/if-rc.c \
> + bluez/android/client/if-rc-ctrl.c \
Should be build only for Android 5.
> bluez/android/client/if-bt.c \
> bluez/android/client/if-hf.c \
> bluez/android/client/if-hh.c \
> diff --git a/android/Makefile.am b/android/Makefile.am
> index d807aaa..3787489 100644
> --- a/android/Makefile.am
> +++ b/android/Makefile.am
> @@ -116,6 +116,7 @@ android_haltest_SOURCES = android/client/haltest.c \
> android/client/if-main.h \
> android/client/if-av.c \
> android/client/if-rc.c \
> + android/client/if-rc-ctrl.c \
> android/client/if-bt.c \
> android/client/if-gatt.c \
> android/client/if-hf.c \
> diff --git a/android/client/haltest.c b/android/client/haltest.c
> index c8cfdc4..add1978 100644
> --- a/android/client/haltest.c
> +++ b/android/client/haltest.c
> @@ -51,6 +51,7 @@ const struct interface *interfaces[] = {
> #if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
> &hf_client_if,
> &mce_if,
> + &ctrl_rc_if,
> #endif
> NULL
> };
> @@ -399,6 +400,7 @@ static void init(void)
> #if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
> BT_PROFILE_HANDSFREE_CLIENT_ID,
> BT_PROFILE_MAP_CLIENT_ID,
> + BT_PROFILE_AV_RC_CTRL_ID,
> #endif
> };
> const struct method *m;
> diff --git a/android/client/if-rc-ctrl.c b/android/client/if-rc-ctrl.c
> new file mode 100644
> index 0000000..52573a0
> --- /dev/null
> +++ b/android/client/if-rc-ctrl.c
> @@ -0,0 +1,112 @@
> +/*
> + * Copyright (C) 2014 Intel Corporation
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + */
> +
> +#include <stdio.h>
> +#include <ctype.h>
> +#include <string.h>
> +
> +#include <hardware/bluetooth.h>
> +#include <hardware/bt_rc.h>
> +
> +#include "if-main.h"
> +#include "pollhandler.h"
> +#include "../hal-utils.h"
> +
> +const btrc_ctrl_interface_t *if_rc_ctrl = NULL;
> +static char last_addr[MAX_ADDR_STR_LEN];
> +
> +static void passthrough_rsp_cb(int id, int key_state)
> +{
> + haltest_info("%s: id=%d key_state=%d\n", __func__, id, key_state);
> +}
> +
> +static void connection_state_cb(bool state, bt_bdaddr_t *bd_addr)
> +{
> + haltest_info("%s: state=%s bd_addr=%s\n", __func__,
> + state ? "true" : "false",
> + bt_bdaddr_t2str(bd_addr, last_addr));
> +}
> +
> +static btrc_ctrl_callbacks_t rc_ctrl_cbacks = {
> + .size = sizeof(rc_ctrl_cbacks),
> + .passthrough_rsp_cb = passthrough_rsp_cb,
> + .connection_state_cb = connection_state_cb,
> +};
> +
> +/* init */
> +
> +static void init_p(int argc, const char **argv)
> +{
> + RETURN_IF_NULL(if_rc_ctrl);
> +
> + EXEC(if_rc_ctrl->init, &rc_ctrl_cbacks);
> +}
> +
> +/* cleanup */
> +
> +static void cleanup_p(int argc, const char **argv)
> +{
> + RETURN_IF_NULL(if_rc_ctrl);
> +
> + EXECV(if_rc_ctrl->cleanup);
> + if_rc_ctrl = NULL;
> +}
> +
> +/* send_pass_through_cmd */
> +
> +static void send_pass_through_cmd_c(int argc, const char **argv,
> + enum_func *enum_func, void **user)
> +{
> +}
> +
> +static void send_pass_through_cmd_p(int argc, const char **argv)
> +{
> + bt_bdaddr_t addr;
> + uint8_t key_code, key_state;
> +
> + RETURN_IF_NULL(if_rc);
> + VERIFY_ADDR_ARG(2, &addr);
> +
> + if (argc <= 4) {
> + haltest_error("No key code specified");
> + return;
> + }
> +
> + key_code = (uint8_t) atoi(argv[3]);
> +
> + if (argc <= 5) {
> + haltest_error("No key state specified");
> + return;
> + }
> +
> + key_state = (uint8_t) atoi(argv[4]);
> +
> + EXEC(if_rc_ctrl->send_pass_through_cmd, &addr, key_code, key_state);
> +}
> +
> +static struct method methods[] = {
> + STD_METHOD(init),
> + STD_METHODCH(send_pass_through_cmd,
> + "<bd_addr> <key_code> <key_state>"),
> + STD_METHOD(cleanup),
> + END_METHOD
> +};
> +
> +const struct interface ctrl_rc_if = {
> + .name = "rc-ctrl",
> + .methods = methods
> +};
> diff --git a/android/client/if-rc.c b/android/client/if-rc.c
> index b42b8c6..ed65600 100644
> --- a/android/client/if-rc.c
> +++ b/android/client/if-rc.c
> @@ -28,10 +28,6 @@
>
> const btrc_interface_t *if_rc = NULL;
>
> -#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
> -const btrc_ctrl_interface_t *if_rc_ctrl = NULL;
> -#endif
> -
> SINTMAP(btrc_play_status_t, -1, "(unknown)")
> DELEMENT(BTRC_PLAYSTATE_STOPPED),
> DELEMENT(BTRC_PLAYSTATE_PLAYING),
> @@ -402,87 +398,3 @@ const struct interface rc_if = {
> .name = "rc",
> .methods = methods
> };
> -
> -#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
> -static void passthrough_rsp_cb(int id, int key_state)
> -{
> - haltest_info("%s: id=%d key_state=%d\n", __func__, id, key_state);
> -}
> -
> -static void connection_state_cb(bool state, bt_bdaddr_t *bd_addr)
> -{
> - haltest_info("%s: state=%s bd_addr=%s\n", __func__,
> - state ? "true" : "false",
> - bt_bdaddr_t2str(bd_addr, last_addr));
> -}
> -
> -static btrc_ctrl_callbacks_t rc_ctrl_cbacks = {
> - .size = sizeof(rc_ctrl_cbacks),
> - .passthrough_rsp_cb = passthrough_rsp_cb,
> - .connection_state_cb = connection_state_cb,
> -};
> -
> -/* ctrl_init */
> -
> -static void ctrl_init_p(int argc, const char **argv)
> -{
> - RETURN_IF_NULL(if_rc_ctrl);
> -
> - EXEC(if_rc_ctrl->init, &rc_ctrl_cbacks);
> -}
> -
> -/* ctrl_cleanup */
> -
> -static void ctrl_cleanup_p(int argc, const char **argv)
> -{
> - RETURN_IF_NULL(if_rc_ctrl);
> -
> - EXECV(if_rc_ctrl->cleanup);
> - if_rc_ctrl = NULL;
> -}
> -
> -/* send_pass_through_cmd */
> -
> -static void send_pass_through_cmd_c(int argc, const char **argv,
> - enum_func *enum_func, void **user)
> -{
> -}
> -
> -static void send_pass_through_cmd_p(int argc, const char **argv)
> -{
> - bt_bdaddr_t addr;
> - uint8_t key_code, key_state;
> -
> - RETURN_IF_NULL(if_rc);
> - VERIFY_ADDR_ARG(2, &addr);
> -
> - if (argc <= 4) {
> - haltest_error("No key code specified");
> - return;
> - }
> -
> - key_code = (uint8_t) atoi(argv[3]);
> -
> - if (argc <= 5) {
> - haltest_error("No key state specified");
> - return;
> - }
> -
> - key_state = (uint8_t) atoi(argv[4]);
> -
> - EXEC(if_rc_ctrl->send_pass_through_cmd, &addr, key_code, key_state);
> -}
> -
> -static struct method ctrl_methods[] = {
> - STD_METHOD(ctrl_init),
> - STD_METHODCH(send_pass_through_cmd,
> - "<bd_addr> <key_code> <key_state>"),
> - STD_METHOD(ctrl_cleanup),
> - END_METHOD
> -};
> -
> -const struct interface ctrl_rc_if = {
> - .name = "rc-ctrl",
> - .methods = ctrl_methods
> -};
> -#endif
>
--
Best regards,
Szymon Janc
Hi Ravi,
On Tuesday 18 of November 2014 14:54:48 Ravi kumar Veeramally wrote:
> Moving AVRCP CTRL interface HAL related code to hal-avrcp-ctrl.c.
> Separate HAL for every interface.
> ---
> android/Android.mk | 1 +
> android/Makefile.am | 1 +
> android/hal-avrcp-ctrl.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++
> android/hal-avrcp.c | 121 ---------------------------------------
> 4 files changed, 146 insertions(+), 121 deletions(-)
> create mode 100644 android/hal-avrcp-ctrl.c
>
> diff --git a/android/Android.mk b/android/Android.mk
> index ffbc943..39f03bc 100644
> --- a/android/Android.mk
> +++ b/android/Android.mk
> @@ -129,6 +129,7 @@ LOCAL_SRC_FILES := \
> bluez/android/hal-pan.c \
> bluez/android/hal-a2dp.c \
> bluez/android/hal-avrcp.c \
> + bluez/android/hal-avrcp-ctrl.c \
This should be under Android >= 0 check so just move to same place as map
and hfp client.
> bluez/android/hal-handsfree.c \
> bluez/android/hal-gatt.c \
> bluez/android/hal-utils.c \
> diff --git a/android/Makefile.am b/android/Makefile.am
> index 8085fb5..d807aaa 100644
> --- a/android/Makefile.am
> +++ b/android/Makefile.am
> @@ -65,6 +65,7 @@ android_bluetooth_default_la_SOURCES = android/hal.h android/hal-bluetooth.c \
> android/hal-pan.c \
> android/hal-a2dp.c \
> android/hal-avrcp.c \
> + android/hal-avrcp-ctrl.c \
> android/hal-handsfree.c \
> android/hal-handsfree-client.c \
> android/hal-gatt.c \
> diff --git a/android/hal-avrcp-ctrl.c b/android/hal-avrcp-ctrl.c
> new file mode 100644
> index 0000000..e289fcd
> --- /dev/null
> +++ b/android/hal-avrcp-ctrl.c
> @@ -0,0 +1,144 @@
> +/*
> + * Copyright (C) 2014 Intel Corporation
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + */
> +
> +#include <stdbool.h>
> +#include <stddef.h>
> +#include <string.h>
> +#include <stdlib.h>
> +
> +#include "hal-utils.h"
> +#include "hal-log.h"
> +#include "hal.h"
> +#include "hal-msg.h"
> +#include "ipc-common.h"
> +#include "hal-ipc.h"
> +
> +static const btrc_ctrl_callbacks_t *cbs = NULL;
> +
> +static bool interface_ready(void)
> +{
> + return cbs != NULL;
> +}
> +
> +static void handle_connection_state(void *buf, uint16_t len, int fd)
> +{
> + struct hal_ev_avrcp_ctrl_conn_state *ev = buf;
> +
> + if (cbs->connection_state_cb)
> + cbs->connection_state_cb(ev->state,
> + (bt_bdaddr_t *) (ev->bdaddr));
> +}
> +
> +static void handle_passthrough_rsp(void *buf, uint16_t len, int fd)
> +{
> + struct hal_ev_avrcp_ctrl_passthrough_rsp *ev = buf;
> +
> + if (cbs->passthrough_rsp_cb)
> + cbs->passthrough_rsp_cb(ev->id, ev->key_state);
> +}
> +
> +/*
> + * handlers will be called from notification thread context,
> + * index in table equals to 'opcode - HAL_MINIMUM_EVENT'
> + */
> +static const struct hal_ipc_handler ev_handlers[] = {
> + /* HAL_EV_AVRCP_CTRL_CONN_STATE */
> + { handle_connection_state, false,
> + sizeof(struct hal_ev_avrcp_ctrl_conn_state) },
> + /* HAL_EV_AVRCP_CTRL_PASSTHROUGH_RSP */
> + { handle_passthrough_rsp, false,
> + sizeof(struct hal_ev_avrcp_ctrl_passthrough_rsp) },
> +};
> +
> +static bt_status_t init(btrc_ctrl_callbacks_t *callbacks)
> +{
> + struct hal_cmd_register_module cmd;
> + int ret;
> +
> + DBG("");
> +
> + if (interface_ready())
> + return BT_STATUS_DONE;
> +
> + cbs = callbacks;
> +
> + hal_ipc_register(HAL_SERVICE_ID_AVRCP_CTRL, ev_handlers,
> + sizeof(ev_handlers) / sizeof(ev_handlers[0]));
> +
> + cmd.service_id = HAL_SERVICE_ID_AVRCP_CTRL;
> + cmd.mode = HAL_MODE_DEFAULT;
> +
> + ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
> + sizeof(cmd), &cmd, NULL, NULL, NULL);
> +
> + if (ret != BT_STATUS_SUCCESS) {
> + cbs = NULL;
> + hal_ipc_unregister(HAL_SERVICE_ID_AVRCP_CTRL);
> + }
> +
> + return ret;
> +}
> +
> +static bt_status_t send_pass_through_cmd(bt_bdaddr_t *bd_addr, uint8_t key_code,
> + uint8_t key_state)
> +{
> + struct hal_cmd_avrcp_ctrl_send_passthrough cmd;
> +
> + DBG("");
> +
> + if (!interface_ready())
> + return BT_STATUS_NOT_READY;
> +
> + memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
> + cmd.key_code = key_code;
> + cmd.key_state = key_state;
> +
> + return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP_CTRL,
> + HAL_OP_AVRCP_CTRL_SEND_PASSTHROUGH,
> + sizeof(cmd), &cmd, NULL, NULL, NULL);
> +}
> +
> +static void cleanup(void)
> +{
> + struct hal_cmd_unregister_module cmd;
> +
> + DBG("");
> +
> + if (!interface_ready())
> + return;
> +
> + cbs = NULL;
> +
> + cmd.service_id = HAL_SERVICE_ID_AVRCP_CTRL;
> +
> + hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE,
> + sizeof(cmd), &cmd, NULL, NULL, NULL);
> +
> + hal_ipc_unregister(HAL_SERVICE_ID_AVRCP_CTRL);
> +}
> +
> +static btrc_ctrl_interface_t iface = {
> + .size = sizeof(iface),
> + .init = init,
> + .send_pass_through_cmd = send_pass_through_cmd,
> + .cleanup = cleanup
> +};
> +
> +btrc_ctrl_interface_t *bt_get_avrcp_ctrl_interface(void)
> +{
> + return &iface;
> +}
> diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
> index b9b8ab9..6c7f195 100644
> --- a/android/hal-avrcp.c
> +++ b/android/hal-avrcp.c
> @@ -29,10 +29,6 @@
>
> static const btrc_callbacks_t *cbs = NULL;
>
> -#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
> -static const btrc_ctrl_callbacks_t *ctrl_cbs = NULL;
> -#endif
> -
> static bool interface_ready(void)
> {
> return cbs != NULL;
> @@ -690,120 +686,3 @@ btrc_interface_t *bt_get_avrcp_interface(void)
> {
> return &iface;
> }
> -
> -#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
> -
> -static bool ctrl_interface_ready(void)
> -{
> - return ctrl_cbs != NULL;
> -}
> -
> -static void handle_connection_state(void *buf, uint16_t len, int fd)
> -{
> - struct hal_ev_avrcp_ctrl_conn_state *ev = buf;
> -
> - if (ctrl_cbs->connection_state_cb)
> - ctrl_cbs->connection_state_cb(ev->state,
> - (bt_bdaddr_t *) (ev->bdaddr));
> -}
> -
> -static void handle_passthrough_rsp(void *buf, uint16_t len, int fd)
> -{
> - struct hal_ev_avrcp_ctrl_passthrough_rsp *ev = buf;
> -
> - if (ctrl_cbs->passthrough_rsp_cb)
> - ctrl_cbs->passthrough_rsp_cb(ev->id, ev->key_state);
> -}
> -
> -/*
> - * handlers will be called from notification thread context,
> - * index in table equals to 'opcode - HAL_MINIMUM_EVENT'
> - */
> -static const struct hal_ipc_handler ctrl_ev_handlers[] = {
> - /* HAL_EV_AVRCP_CTRL_CONN_STATE */
> - { handle_connection_state, false,
> - sizeof(struct hal_ev_avrcp_ctrl_conn_state) },
> - /* HAL_EV_AVRCP_CTRL_PASSTHROUGH_RSP */
> - { handle_passthrough_rsp, false,
> - sizeof(struct hal_ev_avrcp_ctrl_passthrough_rsp) },
> -};
> -
> -static bt_status_t ctrl_init(btrc_ctrl_callbacks_t *callbacks)
> -{
> - struct hal_cmd_register_module cmd;
> - int ret;
> -
> - DBG("");
> -
> - if (ctrl_interface_ready())
> - return BT_STATUS_DONE;
> -
> - ctrl_cbs = callbacks;
> -
> - hal_ipc_register(HAL_SERVICE_ID_AVRCP_CTRL, ctrl_ev_handlers,
> - sizeof(ctrl_ev_handlers) / sizeof(ctrl_ev_handlers[0]));
> -
> - cmd.service_id = HAL_SERVICE_ID_AVRCP_CTRL;
> - cmd.mode = HAL_MODE_DEFAULT;
> -
> - ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
> - sizeof(cmd), &cmd, NULL, NULL, NULL);
> -
> - if (ret != BT_STATUS_SUCCESS) {
> - cbs = NULL;
> - hal_ipc_unregister(HAL_SERVICE_ID_AVRCP_CTRL);
> - }
> -
> - return ret;
> -}
> -
> -static bt_status_t send_pass_through_cmd(bt_bdaddr_t *bd_addr, uint8_t key_code,
> - uint8_t key_state)
> -{
> - struct hal_cmd_avrcp_ctrl_send_passthrough cmd;
> -
> - DBG("");
> -
> - if (!ctrl_interface_ready())
> - return BT_STATUS_NOT_READY;
> -
> - memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
> - cmd.key_code = key_code;
> - cmd.key_state = key_state;
> -
> - return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP_CTRL,
> - HAL_OP_AVRCP_CTRL_SEND_PASSTHROUGH,
> - sizeof(cmd), &cmd, NULL, NULL, NULL);
> -}
> -
> -static void ctrl_cleanup(void)
> -{
> - struct hal_cmd_unregister_module cmd;
> -
> - DBG("");
> -
> - if (!ctrl_interface_ready())
> - return;
> -
> - ctrl_cbs = NULL;
> -
> - cmd.service_id = HAL_SERVICE_ID_AVRCP_CTRL;
> -
> - hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE,
> - sizeof(cmd), &cmd, NULL, NULL, NULL);
> -
> - hal_ipc_unregister(HAL_SERVICE_ID_AVRCP_CTRL);
> -}
> -
> -static btrc_ctrl_interface_t ctrl_iface = {
> - .size = sizeof(ctrl_iface),
> - .init = ctrl_init,
> - .send_pass_through_cmd = send_pass_through_cmd,
> - .cleanup = ctrl_cleanup
> -};
> -
> -btrc_ctrl_interface_t *bt_get_avrcp_ctrl_interface(void)
> -{
> - return &ctrl_iface;
> -}
> -#endif
>
--
Best regards,
Szymon Janc
Moving AVRCP CTRL interface client related code to if-rc-ctrl.c.
---
android/Android.mk | 1 +
android/Makefile.am | 1 +
android/client/haltest.c | 2 +
android/client/if-rc-ctrl.c | 112 ++++++++++++++++++++++++++++++++++++++++++++
android/client/if-rc.c | 88 ----------------------------------
5 files changed, 116 insertions(+), 88 deletions(-)
create mode 100644 android/client/if-rc-ctrl.c
diff --git a/android/Android.mk b/android/Android.mk
index 39f03bc..e2179fa 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -174,6 +174,7 @@ LOCAL_SRC_FILES := \
bluez/android/client/if-sco.c \
bluez/android/client/if-av.c \
bluez/android/client/if-rc.c \
+ bluez/android/client/if-rc-ctrl.c \
bluez/android/client/if-bt.c \
bluez/android/client/if-hf.c \
bluez/android/client/if-hh.c \
diff --git a/android/Makefile.am b/android/Makefile.am
index d807aaa..3787489 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -116,6 +116,7 @@ android_haltest_SOURCES = android/client/haltest.c \
android/client/if-main.h \
android/client/if-av.c \
android/client/if-rc.c \
+ android/client/if-rc-ctrl.c \
android/client/if-bt.c \
android/client/if-gatt.c \
android/client/if-hf.c \
diff --git a/android/client/haltest.c b/android/client/haltest.c
index c8cfdc4..add1978 100644
--- a/android/client/haltest.c
+++ b/android/client/haltest.c
@@ -51,6 +51,7 @@ const struct interface *interfaces[] = {
#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
&hf_client_if,
&mce_if,
+ &ctrl_rc_if,
#endif
NULL
};
@@ -399,6 +400,7 @@ static void init(void)
#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
BT_PROFILE_HANDSFREE_CLIENT_ID,
BT_PROFILE_MAP_CLIENT_ID,
+ BT_PROFILE_AV_RC_CTRL_ID,
#endif
};
const struct method *m;
diff --git a/android/client/if-rc-ctrl.c b/android/client/if-rc-ctrl.c
new file mode 100644
index 0000000..52573a0
--- /dev/null
+++ b/android/client/if-rc-ctrl.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+
+#include <hardware/bluetooth.h>
+#include <hardware/bt_rc.h>
+
+#include "if-main.h"
+#include "pollhandler.h"
+#include "../hal-utils.h"
+
+const btrc_ctrl_interface_t *if_rc_ctrl = NULL;
+static char last_addr[MAX_ADDR_STR_LEN];
+
+static void passthrough_rsp_cb(int id, int key_state)
+{
+ haltest_info("%s: id=%d key_state=%d\n", __func__, id, key_state);
+}
+
+static void connection_state_cb(bool state, bt_bdaddr_t *bd_addr)
+{
+ haltest_info("%s: state=%s bd_addr=%s\n", __func__,
+ state ? "true" : "false",
+ bt_bdaddr_t2str(bd_addr, last_addr));
+}
+
+static btrc_ctrl_callbacks_t rc_ctrl_cbacks = {
+ .size = sizeof(rc_ctrl_cbacks),
+ .passthrough_rsp_cb = passthrough_rsp_cb,
+ .connection_state_cb = connection_state_cb,
+};
+
+/* init */
+
+static void init_p(int argc, const char **argv)
+{
+ RETURN_IF_NULL(if_rc_ctrl);
+
+ EXEC(if_rc_ctrl->init, &rc_ctrl_cbacks);
+}
+
+/* cleanup */
+
+static void cleanup_p(int argc, const char **argv)
+{
+ RETURN_IF_NULL(if_rc_ctrl);
+
+ EXECV(if_rc_ctrl->cleanup);
+ if_rc_ctrl = NULL;
+}
+
+/* send_pass_through_cmd */
+
+static void send_pass_through_cmd_c(int argc, const char **argv,
+ enum_func *enum_func, void **user)
+{
+}
+
+static void send_pass_through_cmd_p(int argc, const char **argv)
+{
+ bt_bdaddr_t addr;
+ uint8_t key_code, key_state;
+
+ RETURN_IF_NULL(if_rc);
+ VERIFY_ADDR_ARG(2, &addr);
+
+ if (argc <= 4) {
+ haltest_error("No key code specified");
+ return;
+ }
+
+ key_code = (uint8_t) atoi(argv[3]);
+
+ if (argc <= 5) {
+ haltest_error("No key state specified");
+ return;
+ }
+
+ key_state = (uint8_t) atoi(argv[4]);
+
+ EXEC(if_rc_ctrl->send_pass_through_cmd, &addr, key_code, key_state);
+}
+
+static struct method methods[] = {
+ STD_METHOD(init),
+ STD_METHODCH(send_pass_through_cmd,
+ "<bd_addr> <key_code> <key_state>"),
+ STD_METHOD(cleanup),
+ END_METHOD
+};
+
+const struct interface ctrl_rc_if = {
+ .name = "rc-ctrl",
+ .methods = methods
+};
diff --git a/android/client/if-rc.c b/android/client/if-rc.c
index b42b8c6..ed65600 100644
--- a/android/client/if-rc.c
+++ b/android/client/if-rc.c
@@ -28,10 +28,6 @@
const btrc_interface_t *if_rc = NULL;
-#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
-const btrc_ctrl_interface_t *if_rc_ctrl = NULL;
-#endif
-
SINTMAP(btrc_play_status_t, -1, "(unknown)")
DELEMENT(BTRC_PLAYSTATE_STOPPED),
DELEMENT(BTRC_PLAYSTATE_PLAYING),
@@ -402,87 +398,3 @@ const struct interface rc_if = {
.name = "rc",
.methods = methods
};
-
-#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
-static void passthrough_rsp_cb(int id, int key_state)
-{
- haltest_info("%s: id=%d key_state=%d\n", __func__, id, key_state);
-}
-
-static void connection_state_cb(bool state, bt_bdaddr_t *bd_addr)
-{
- haltest_info("%s: state=%s bd_addr=%s\n", __func__,
- state ? "true" : "false",
- bt_bdaddr_t2str(bd_addr, last_addr));
-}
-
-static btrc_ctrl_callbacks_t rc_ctrl_cbacks = {
- .size = sizeof(rc_ctrl_cbacks),
- .passthrough_rsp_cb = passthrough_rsp_cb,
- .connection_state_cb = connection_state_cb,
-};
-
-/* ctrl_init */
-
-static void ctrl_init_p(int argc, const char **argv)
-{
- RETURN_IF_NULL(if_rc_ctrl);
-
- EXEC(if_rc_ctrl->init, &rc_ctrl_cbacks);
-}
-
-/* ctrl_cleanup */
-
-static void ctrl_cleanup_p(int argc, const char **argv)
-{
- RETURN_IF_NULL(if_rc_ctrl);
-
- EXECV(if_rc_ctrl->cleanup);
- if_rc_ctrl = NULL;
-}
-
-/* send_pass_through_cmd */
-
-static void send_pass_through_cmd_c(int argc, const char **argv,
- enum_func *enum_func, void **user)
-{
-}
-
-static void send_pass_through_cmd_p(int argc, const char **argv)
-{
- bt_bdaddr_t addr;
- uint8_t key_code, key_state;
-
- RETURN_IF_NULL(if_rc);
- VERIFY_ADDR_ARG(2, &addr);
-
- if (argc <= 4) {
- haltest_error("No key code specified");
- return;
- }
-
- key_code = (uint8_t) atoi(argv[3]);
-
- if (argc <= 5) {
- haltest_error("No key state specified");
- return;
- }
-
- key_state = (uint8_t) atoi(argv[4]);
-
- EXEC(if_rc_ctrl->send_pass_through_cmd, &addr, key_code, key_state);
-}
-
-static struct method ctrl_methods[] = {
- STD_METHOD(ctrl_init),
- STD_METHODCH(send_pass_through_cmd,
- "<bd_addr> <key_code> <key_state>"),
- STD_METHOD(ctrl_cleanup),
- END_METHOD
-};
-
-const struct interface ctrl_rc_if = {
- .name = "rc-ctrl",
- .methods = ctrl_methods
-};
-#endif
--
2.1.0
Moving AVRCP CTRL interface HAL related code to hal-avrcp-ctrl.c.
Separate HAL for every interface.
---
android/Android.mk | 1 +
android/Makefile.am | 1 +
android/hal-avrcp-ctrl.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++
android/hal-avrcp.c | 121 ---------------------------------------
4 files changed, 146 insertions(+), 121 deletions(-)
create mode 100644 android/hal-avrcp-ctrl.c
diff --git a/android/Android.mk b/android/Android.mk
index ffbc943..39f03bc 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -129,6 +129,7 @@ LOCAL_SRC_FILES := \
bluez/android/hal-pan.c \
bluez/android/hal-a2dp.c \
bluez/android/hal-avrcp.c \
+ bluez/android/hal-avrcp-ctrl.c \
bluez/android/hal-handsfree.c \
bluez/android/hal-gatt.c \
bluez/android/hal-utils.c \
diff --git a/android/Makefile.am b/android/Makefile.am
index 8085fb5..d807aaa 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -65,6 +65,7 @@ android_bluetooth_default_la_SOURCES = android/hal.h android/hal-bluetooth.c \
android/hal-pan.c \
android/hal-a2dp.c \
android/hal-avrcp.c \
+ android/hal-avrcp-ctrl.c \
android/hal-handsfree.c \
android/hal-handsfree-client.c \
android/hal-gatt.c \
diff --git a/android/hal-avrcp-ctrl.c b/android/hal-avrcp-ctrl.c
new file mode 100644
index 0000000..e289fcd
--- /dev/null
+++ b/android/hal-avrcp-ctrl.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "hal-utils.h"
+#include "hal-log.h"
+#include "hal.h"
+#include "hal-msg.h"
+#include "ipc-common.h"
+#include "hal-ipc.h"
+
+static const btrc_ctrl_callbacks_t *cbs = NULL;
+
+static bool interface_ready(void)
+{
+ return cbs != NULL;
+}
+
+static void handle_connection_state(void *buf, uint16_t len, int fd)
+{
+ struct hal_ev_avrcp_ctrl_conn_state *ev = buf;
+
+ if (cbs->connection_state_cb)
+ cbs->connection_state_cb(ev->state,
+ (bt_bdaddr_t *) (ev->bdaddr));
+}
+
+static void handle_passthrough_rsp(void *buf, uint16_t len, int fd)
+{
+ struct hal_ev_avrcp_ctrl_passthrough_rsp *ev = buf;
+
+ if (cbs->passthrough_rsp_cb)
+ cbs->passthrough_rsp_cb(ev->id, ev->key_state);
+}
+
+/*
+ * handlers will be called from notification thread context,
+ * index in table equals to 'opcode - HAL_MINIMUM_EVENT'
+ */
+static const struct hal_ipc_handler ev_handlers[] = {
+ /* HAL_EV_AVRCP_CTRL_CONN_STATE */
+ { handle_connection_state, false,
+ sizeof(struct hal_ev_avrcp_ctrl_conn_state) },
+ /* HAL_EV_AVRCP_CTRL_PASSTHROUGH_RSP */
+ { handle_passthrough_rsp, false,
+ sizeof(struct hal_ev_avrcp_ctrl_passthrough_rsp) },
+};
+
+static bt_status_t init(btrc_ctrl_callbacks_t *callbacks)
+{
+ struct hal_cmd_register_module cmd;
+ int ret;
+
+ DBG("");
+
+ if (interface_ready())
+ return BT_STATUS_DONE;
+
+ cbs = callbacks;
+
+ hal_ipc_register(HAL_SERVICE_ID_AVRCP_CTRL, ev_handlers,
+ sizeof(ev_handlers) / sizeof(ev_handlers[0]));
+
+ cmd.service_id = HAL_SERVICE_ID_AVRCP_CTRL;
+ cmd.mode = HAL_MODE_DEFAULT;
+
+ ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
+ sizeof(cmd), &cmd, NULL, NULL, NULL);
+
+ if (ret != BT_STATUS_SUCCESS) {
+ cbs = NULL;
+ hal_ipc_unregister(HAL_SERVICE_ID_AVRCP_CTRL);
+ }
+
+ return ret;
+}
+
+static bt_status_t send_pass_through_cmd(bt_bdaddr_t *bd_addr, uint8_t key_code,
+ uint8_t key_state)
+{
+ struct hal_cmd_avrcp_ctrl_send_passthrough cmd;
+
+ DBG("");
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+ cmd.key_code = key_code;
+ cmd.key_state = key_state;
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP_CTRL,
+ HAL_OP_AVRCP_CTRL_SEND_PASSTHROUGH,
+ sizeof(cmd), &cmd, NULL, NULL, NULL);
+}
+
+static void cleanup(void)
+{
+ struct hal_cmd_unregister_module cmd;
+
+ DBG("");
+
+ if (!interface_ready())
+ return;
+
+ cbs = NULL;
+
+ cmd.service_id = HAL_SERVICE_ID_AVRCP_CTRL;
+
+ hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE,
+ sizeof(cmd), &cmd, NULL, NULL, NULL);
+
+ hal_ipc_unregister(HAL_SERVICE_ID_AVRCP_CTRL);
+}
+
+static btrc_ctrl_interface_t iface = {
+ .size = sizeof(iface),
+ .init = init,
+ .send_pass_through_cmd = send_pass_through_cmd,
+ .cleanup = cleanup
+};
+
+btrc_ctrl_interface_t *bt_get_avrcp_ctrl_interface(void)
+{
+ return &iface;
+}
diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index b9b8ab9..6c7f195 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -29,10 +29,6 @@
static const btrc_callbacks_t *cbs = NULL;
-#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
-static const btrc_ctrl_callbacks_t *ctrl_cbs = NULL;
-#endif
-
static bool interface_ready(void)
{
return cbs != NULL;
@@ -690,120 +686,3 @@ btrc_interface_t *bt_get_avrcp_interface(void)
{
return &iface;
}
-
-#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
-
-static bool ctrl_interface_ready(void)
-{
- return ctrl_cbs != NULL;
-}
-
-static void handle_connection_state(void *buf, uint16_t len, int fd)
-{
- struct hal_ev_avrcp_ctrl_conn_state *ev = buf;
-
- if (ctrl_cbs->connection_state_cb)
- ctrl_cbs->connection_state_cb(ev->state,
- (bt_bdaddr_t *) (ev->bdaddr));
-}
-
-static void handle_passthrough_rsp(void *buf, uint16_t len, int fd)
-{
- struct hal_ev_avrcp_ctrl_passthrough_rsp *ev = buf;
-
- if (ctrl_cbs->passthrough_rsp_cb)
- ctrl_cbs->passthrough_rsp_cb(ev->id, ev->key_state);
-}
-
-/*
- * handlers will be called from notification thread context,
- * index in table equals to 'opcode - HAL_MINIMUM_EVENT'
- */
-static const struct hal_ipc_handler ctrl_ev_handlers[] = {
- /* HAL_EV_AVRCP_CTRL_CONN_STATE */
- { handle_connection_state, false,
- sizeof(struct hal_ev_avrcp_ctrl_conn_state) },
- /* HAL_EV_AVRCP_CTRL_PASSTHROUGH_RSP */
- { handle_passthrough_rsp, false,
- sizeof(struct hal_ev_avrcp_ctrl_passthrough_rsp) },
-};
-
-static bt_status_t ctrl_init(btrc_ctrl_callbacks_t *callbacks)
-{
- struct hal_cmd_register_module cmd;
- int ret;
-
- DBG("");
-
- if (ctrl_interface_ready())
- return BT_STATUS_DONE;
-
- ctrl_cbs = callbacks;
-
- hal_ipc_register(HAL_SERVICE_ID_AVRCP_CTRL, ctrl_ev_handlers,
- sizeof(ctrl_ev_handlers) / sizeof(ctrl_ev_handlers[0]));
-
- cmd.service_id = HAL_SERVICE_ID_AVRCP_CTRL;
- cmd.mode = HAL_MODE_DEFAULT;
-
- ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
- sizeof(cmd), &cmd, NULL, NULL, NULL);
-
- if (ret != BT_STATUS_SUCCESS) {
- cbs = NULL;
- hal_ipc_unregister(HAL_SERVICE_ID_AVRCP_CTRL);
- }
-
- return ret;
-}
-
-static bt_status_t send_pass_through_cmd(bt_bdaddr_t *bd_addr, uint8_t key_code,
- uint8_t key_state)
-{
- struct hal_cmd_avrcp_ctrl_send_passthrough cmd;
-
- DBG("");
-
- if (!ctrl_interface_ready())
- return BT_STATUS_NOT_READY;
-
- memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
- cmd.key_code = key_code;
- cmd.key_state = key_state;
-
- return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP_CTRL,
- HAL_OP_AVRCP_CTRL_SEND_PASSTHROUGH,
- sizeof(cmd), &cmd, NULL, NULL, NULL);
-}
-
-static void ctrl_cleanup(void)
-{
- struct hal_cmd_unregister_module cmd;
-
- DBG("");
-
- if (!ctrl_interface_ready())
- return;
-
- ctrl_cbs = NULL;
-
- cmd.service_id = HAL_SERVICE_ID_AVRCP_CTRL;
-
- hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE,
- sizeof(cmd), &cmd, NULL, NULL, NULL);
-
- hal_ipc_unregister(HAL_SERVICE_ID_AVRCP_CTRL);
-}
-
-static btrc_ctrl_interface_t ctrl_iface = {
- .size = sizeof(ctrl_iface),
- .init = ctrl_init,
- .send_pass_through_cmd = send_pass_through_cmd,
- .cleanup = ctrl_cleanup
-};
-
-btrc_ctrl_interface_t *bt_get_avrcp_ctrl_interface(void)
-{
- return &ctrl_iface;
-}
-#endif
--
2.1.0