diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-11-24 16:57:24 -0800 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-11-29 05:11:05 -0800 |
commit | 547a7b88de739d6cf12fdc951cac106250aaca25 (patch) | |
tree | 8b36fd01878c79663eaa8afbaa652e1b07789fab /binding | |
parent | 8f05128deaec01a9a65b940d2073b9f2ab5c31f3 (diff) |
binding: bluetooth: add connect/disconnect actions to avrcp_controls
Allow subscribers to connect/disconnect to a2dp/avrcp Bluetoothp profiles
Bug-AGL: SPEC-1630
Change-Id: I5c4c2a2f06636b2b74cb453a3af576beb8026ab1
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding')
-rw-r--r-- | binding/bluetooth-api.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/binding/bluetooth-api.c b/binding/bluetooth-api.c index a1f37e8..23ce55d 100644 --- a/binding/bluetooth-api.c +++ b/binding/bluetooth-api.c @@ -65,6 +65,25 @@ static void mediaplayer1_set_path(struct bluetooth_state *ns, const char *path) ns->mediaplayer_path = g_strdup(path); } +static void mediaplayer1_connect_disconnect(struct bluetooth_state *ns, + const gchar *player, int state) +{ + GVariant *reply; + gchar *path = g_strdup(player); + const char *uuids[] = { "0000110a-0000-1000-8000-00805f9b34fb", "0000110e-0000-1000-8000-00805f9b34fb", NULL }; + const char **tmp = (const char **) uuids; + + *g_strrstr(path, "/") = '\0'; + + for (; *tmp; tmp++) { + reply = bluez_call(ns, "device", path, state ? "ConnectProfile" : "DisconnectProfile", g_variant_new("(&s)", *tmp), NULL); + if (!reply) + break; + } + + g_free(path); +} + struct call_work *call_work_lookup_unlocked( struct bluetooth_state *ns, const char *access_type, const char *type_arg, @@ -328,7 +347,7 @@ static void bluez_devices_signal_callback( if (is_mediaplayer1_interface(path)) { json_object_object_add(jresp, "connected", json_object_new_boolean(FALSE)); - mediaplayer1_set_path(ns, NULL); + //mediaplayer1_set_path(ns, NULL); event = ns->media_event; } else if (split_length(path) == 5) { json_object_object_add(jresp, "action", @@ -1166,6 +1185,11 @@ static void bluetooth_avrcp_controls(afb_req_t request) return; } + if (!g_strcmp0(action, "connect") || !g_strcmp0(action, "disconnect")) { + mediaplayer1_connect_disconnect(ns, player, !!g_strcmp0(action, "disconnect")); + goto out_success; + } + reply = mediaplayer_call(ns, player, action, NULL, &error); if (!reply) { @@ -1177,6 +1201,7 @@ static void bluetooth_avrcp_controls(afb_req_t request) return; } +out_success: g_free(player); afb_req_success(request, NULL, "Bluetooth - AVRCP controls"); } |