From f9df86e937aafb7d5dfac8db2536eab32bbfc9b1 Mon Sep 17 00:00:00 2001 From: Gowtham Anandha Babu Date: Thu, 29 Dec 2016 19:26:22 +0530 Subject: [PATCH] Handle switching between mutiple headsets Change-Id: I26351ad6959ce12b201839d446a54aea688c78f8 Signed-off-by: Gowtham Anandha Babu --- ag-agent/bluetooth-ag-agent.c | 48 ++++++++++++++++++++++++++++++++++++++++-- packaging/bluetooth-agent.spec | 1 + 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/ag-agent/bluetooth-ag-agent.c b/ag-agent/bluetooth-ag-agent.c index 809577c..7bfdb17 100755 --- a/ag-agent/bluetooth-ag-agent.c +++ b/ag-agent/bluetooth-ag-agent.c @@ -172,6 +172,9 @@ static const gchar ag_agent_app_introspection_xml[] = " " " " " " +" " +" " +" " " " ""; @@ -467,7 +470,6 @@ gboolean __bt_ag_agent_check_dual_hf_condition(const gchar *device_path) if (!is_companion_device) return FALSE; } - return TRUE; } #endif /* TIZEN_SUPPORT_DUAL_HF */ @@ -2952,7 +2954,12 @@ static void __bt_ag_agent_method(GDBusConnection *connection, g_variant_get(parameters, "(oha{sv})", &device_path, &index, &options); -#if defined(TIZEN_SUPPORT_DUAL_HF) + +#if defined(TIZEN_SUPPORT_DUAL_HF) && defined(TIZEN_PROFILE_WEARABLE) + /* + * Below code is not required for dual HF support for + * mobile devices + */ if (device_count && __bt_ag_agent_check_dual_hf_condition(device_path) == FALSE) { INFO("not allow to connect 2nd HF connection"); @@ -3422,6 +3429,43 @@ static void __bt_ag_agent_method(GDBusConnection *connection, DBG("Already pass dbus SMACK for bt-service::platform"); /* Return success */ g_dbus_method_invocation_return_value(invocation, NULL); + } else if (g_strcmp0(method_name, "SwapHeadset") == 0) { + GSList *l; + gchar *addr = NULL; + char address[BT_ADDRESS_STRING_SIZE]; + char remote_addr[BT_ADDRESS_STRING_SIZE]; + gboolean device_found = FALSE; + + g_variant_get(parameters, "(s)", &addr); + g_strlcpy(address, addr, sizeof(address)); + DBG("Sender = %s", sender); + + /* Loop through connected headset list + * If found, update the remote_dev_path. + */ + for (l = active_devices ; l; l = l->next) { + bt_ag_info_t *data = l->data; + g_strlcpy(remote_addr, data->remote_addr, sizeof(remote_addr)); + if (g_strcmp0(remote_addr, address) == 0) { + DBG("Active device found"); + if (data->path == NULL) { + DBG("device path is null"); + ret = BT_HFP_AGENT_ERROR_INTERNAL; + goto fail; + } + remote_dev_path = g_strdup(data->path); + DBG("Setting device path %s as active device path", remote_dev_path); + device_found = TRUE; + break; + } + } + + if (!device_found) { + ret = BT_HFP_AGENT_ERROR_NOT_CONNECTED; + goto fail; + } + + g_dbus_method_invocation_return_value(invocation, NULL); } INFO("-"); diff --git a/packaging/bluetooth-agent.spec b/packaging/bluetooth-agent.spec index 2fe1339..dde49cf 100644 --- a/packaging/bluetooth-agent.spec +++ b/packaging/bluetooth-agent.spec @@ -85,6 +85,7 @@ export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" #export CFLAGS="$CFLAGS -DTIZEN_FEATURE_BT_MEDIA_ENHANCE" export CFLAGS="$CFLAGS -DTIZEN_FEATURE_BT_HFP_AG" +export CFLAGS="$CFLAGS -DTIZEN_SUPPORT_DUAL_HF" %ifarch aarch64 echo arch64 -- 2.7.4