diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-11-24 16:57:24 -0800 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-12-07 02:28:38 -0800 |
commit | 1fb7a01eb655bbe1c72a3502c2aa59f27dd3d8dc (patch) | |
tree | 831e3743913ee067198edc308441d9de90d88c85 | |
parent | 631fd85b9c6cbc9b77d79318cc83eb00b426c59b (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>
-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 0000d9b..bc2a4a4 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", @@ -1136,6 +1155,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) { @@ -1147,6 +1171,7 @@ static void bluetooth_avrcp_controls(afb_req_t request) return; } +out_success: g_free(player); afb_req_success(request, NULL, "Bluetooth - AVRCP controls"); } |