[Audio] Handle switching between mutiple headsets 25/108025/1
authorGowtham Anandha Babu <gowtham.ab@samsung.com>
Thu, 29 Dec 2016 13:56:22 +0000 (19:26 +0530)
committerGowtham Anandha Babu <gowtham.ab@samsung.com>
Mon, 2 Jan 2017 10:23:17 +0000 (15:53 +0530)
Change-Id: I642e96a9fc91eb2f06755027d6af5bd7da1b8126
Signed-off-by: Gowtham Anandha Babu <gowtham.ab@samsung.com>
ag-agent/bluetooth-ag-agent.c
packaging/bluetooth-agent.spec

index 809577c..7bfdb17 100755 (executable)
@@ -172,6 +172,9 @@ static const gchar ag_agent_app_introspection_xml[] =
 "      </method>"
 "      <method name='CheckPrivilege'>"
 "      </method>"
+"     <method name='SwapHeadset'>"
+"          <arg type='s' name='remote_addr' direction='in'/>"
+"     </method>"
 "  </interface>"
 "</node>";
 
@@ -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("-");
index f8579bf..cf639a8 100644 (file)
@@ -47,6 +47,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