" </method>"
" <method name='CheckPrivilege'>"
" </method>"
+" <method name='SwapHeadset'>"
+" <arg type='s' name='remote_addr' direction='in'/>"
+" </method>"
" </interface>"
"</node>";
if (!is_companion_device)
return FALSE;
}
-
return TRUE;
}
#endif /* TIZEN_SUPPORT_DUAL_HF */
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");
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("-");