diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2017-05-17 13:55:56 -0700 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2017-05-18 23:56:53 -0700 |
commit | 2c43f450ffff7ed1beca03bf9d024a883f857d58 (patch) | |
tree | f4c5e6a35e931cdc6e1eac2c3ce5f210508457a2 /binding-bluetooth/bluetooth-manager.c | |
parent | 1010598ea02c995e6332cc6164c159809a11c80d (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 'binding-bluetooth/bluetooth-manager.c')
-rw-r--r-- | binding-bluetooth/bluetooth-manager.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/binding-bluetooth/bluetooth-manager.c b/binding-bluetooth/bluetooth-manager.c index a6c4472..35c770f 100644 --- a/binding-bluetooth/bluetooth-manager.c +++ b/binding-bluetooth/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 |