aboutsummaryrefslogtreecommitdiffstats
path: root/bluetooth-manager.c
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-05-17 13:55:56 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-05-18 23:56:53 -0700
commitd64ef459722a9da065c8045dfa92c222871f1f3f (patch)
treeb73f242baa3a8df2785a9bead2c9d69f57b1d270 /bluetooth-manager.c
parent50092f916c339e4e2b3b133abd00560b8ace8283 (diff)
binding: bluetooth: add initial avrcp controls
These avrcp controls only work at the application level for the settings application. The bluetooth binding at some point needs to be converted to system level binding. Change-Id: I5959c3939874b53c2b21115fb2a3e6a652ec0ffd Bug-AGL: SPEC-596 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'bluetooth-manager.c')
-rw-r--r--bluetooth-manager.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/bluetooth-manager.c b/bluetooth-manager.c
index a6c4472..35c770f 100644
--- a/bluetooth-manager.c
+++ b/bluetooth-manager.c
@@ -1519,6 +1519,65 @@ int device_set_property(const char * bdaddr, const char *property_name,
return 0;
}
+/*
+ * call remote device avrcp method
+ * Only support controls (Play, Pause, Stop, Previous, Next)
+ * If success return 0, else return -1;
+ */
+int device_call_avrcp_method(const gchar* bdaddr, const gchar* method)
+{
+ LOGD("device:%s,value:%d\n", bdaddr, method);
+
+ struct btd_device * device;
+ GError *error = NULL;
+ GVariant *value;
+ gchar *path;
+
+ if (FALSE == BluetoothManage_InitFlag_Get()) {
+ LOGW("BluetoothManage Not Init\n");
+ return -1;
+ }
+
+ if ((0!=g_strcmp0 (method, "Play"))&&
+ (0!=g_strcmp0 (method, "Pause"))&&
+ (0!=g_strcmp0 (method, "Stop"))&&
+ (0!=g_strcmp0 (method, "Previous"))&&
+ (0!=g_strcmp0 (method, "Next")))
+ {
+ LOGD("Invalid method\n");
+ return -1;
+ }
+
+ devices_list_lock();
+ device = devices_list_find_device_by_bdaddr(bdaddr);
+
+ if (NULL == device) {
+ devices_list_unlock();
+ LOGD("not find device\n");
+ return -1;
+ }
+ path = g_strdup(device->path);
+ devices_list_unlock();
+
+ value = g_dbus_connection_call_sync(cli.system_conn, BLUEZ_SERVICE,
+ path, MEDIA_CONTROL1_INTERFACE,
+ method, NULL, NULL,
+ G_DBUS_CALL_FLAGS_NONE, DBUS_REPLY_TIMEOUT,
+ NULL, &error);
+
+ g_free(path);
+
+ if (NULL == value) {
+ LOGW ("Error : %s", error->message);
+ g_error_free(error);
+ return -1;
+ }
+
+ g_variant_unref(value);
+
+ return 0;
+}
+
/*
* Stops the GMainLoop