summaryrefslogtreecommitdiff
path: root/android/client
diff options
context:
space:
mode:
authorRavi kumar Veeramally <ravikumar.veeramally@linux.intel.com>2014-11-18 15:34:43 +0200
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-11-20 10:56:32 +0200
commit7644d111bf23636f7205882476d1b3a65a594e89 (patch)
treeb7157e08712cb00da39b767481140f706a716173 /android/client
parentd33838d1fbcab38008ce138dbbaf1da1ba9fb11f (diff)
downloadbluez-7644d111bf23636f7205882476d1b3a65a594e89.tar.gz
android/client: Create separate file for AVRCP CTRL
Moving AVRCP CTRL interface client related code to if-rc-ctrl.c.
Diffstat (limited to 'android/client')
-rw-r--r--android/client/haltest.c2
-rw-r--r--android/client/if-rc-ctrl.c112
-rw-r--r--android/client/if-rc.c88
3 files changed, 114 insertions, 88 deletions
diff --git a/android/client/haltest.c b/android/client/haltest.c
index c8cfdc495..add197894 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 000000000..52573a09d
--- /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 b42b8c6b0..ed65600fe 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