Disconnect service connection using object path 82/125382/2
authorSeungyoun Ju <sy39.ju@samsung.com>
Tue, 11 Apr 2017 09:20:17 +0000 (18:20 +0900)
committerPyun DoHyun <dh79.pyun@samsung.com>
Tue, 18 Apr 2017 07:16:38 +0000 (00:16 -0700)
[Model] COMMON
[BinType] AP
[Customer] OPEN

[Issue#] P170328-03204
[Request] PLM
[Occurrence Version] R360XXE1CQC1

[Problem] RFCOMM socket is not disconnected when
 bt_socket_disconnect_rfcomm() is called.
[Cause & Measure] Bluez finds the service connection only using profile
 uuid. So when there are two service connections which have same uuid,
 wrong one could be selected. In order to select intended one, object
 path is required. New method call is added to Bluez to get object path
 for RFCOMM socket connection and this patch uses that method call.
[Checking Method] Make client / server RFCOMM connections using same
 uuid at the same time -> Disconnect server connection

[Team] Basic connection
[Developer] Seungyoun Ju
[Solution company] Samsung
[Change Type] Specification change

Change-Id: Ia139b43ff5d1bfc95af84256c6fea750e3eae817

bt-api/bt-common.c [changed mode: 0644->0755]
bt-api/bt-rfcomm-client.c
bt-api/bt-rfcomm-server.c
bt-api/include/bt-common.h

old mode 100644 (file)
new mode 100755 (executable)
index 5b48930..1dffec7
@@ -1615,6 +1615,30 @@ int _bt_disconnect_profile(char *address, char *uuid, void *cb,
        return BLUETOOTH_ERROR_NONE;
 }
 
+int _bt_disconnect_ext_profile(char *address, char *path)
+{
+       GDBusProxy *proxy;
+       char *object_path;
+
+       object_path = _bt_get_device_object_path(address);
+       if (object_path == NULL)
+               return BLUETOOTH_ERROR_INTERNAL;
+
+       proxy = __bt_gdbus_get_device_proxy(object_path);
+       g_free(object_path);
+       if (proxy == NULL) {
+               BT_ERR("Error while getting proxy");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       g_dbus_proxy_call(proxy, "DisconnectExtProfile",
+                       g_variant_new("(o)", path),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       DBUS_TIMEOUT, NULL, NULL, NULL);
+       BT_DBG("-");
+       return BLUETOOTH_ERROR_NONE;
+}
+
 int _bt_get_adapter_path(GDBusConnection *conn, char *path)
 {
        GError *err = NULL;
index ec57e1e..de4411b 100644 (file)
@@ -451,9 +451,8 @@ void _bt_rfcomm_client_disconnect_all(void)
                        close(conn_info->fd);
                        conn_info->disconnected = TRUE;
 
-                       _bt_disconnect_profile(conn_info->bt_addr, info->uuid,
-                                       NULL, NULL);
-
+                       _bt_disconnect_ext_profile(conn_info->bt_addr,
+                                                  info->obj_path);
                }
 
                client = client->next;
@@ -873,7 +872,7 @@ BT_EXPORT_API int bluetooth_rfcomm_disconnect(int socket_fd)
        conn_info->disconnected = TRUE;
 
        BT_INFO("conn_info %s", conn_info->bt_addr);
-       _bt_disconnect_profile(conn_info->bt_addr, info->uuid, NULL, NULL);
+       _bt_disconnect_ext_profile(conn_info->bt_addr, info->obj_path);
 
        if (info->idle_id == 0)
                info->idle_id = g_idle_add(__rfcomm_client_disconnect, info);
index aa59276..d29f93c 100644 (file)
@@ -367,7 +367,7 @@ int new_server_connection(const char *path, int fd, bluetooth_device_address_t *
 
                close(fd);
                _bt_convert_addr_type_to_string(addr_str, addr->addr);
-               _bt_disconnect_profile(addr_str, info->uuid, NULL, NULL);
+               _bt_disconnect_ext_profile(addr_str, info->path);
 
                return -1;
        }
@@ -505,7 +505,7 @@ void _bt_rfcomm_server_disconnect_all(void)
 
                        _bt_convert_addr_type_to_string(addr,
                                                        conn_info->addr.addr);
-                       _bt_disconnect_profile(addr, info->uuid, NULL, NULL);
+                       _bt_disconnect_ext_profile(addr, info->path);
                }
 
                server = server->next;
@@ -729,7 +729,7 @@ BT_EXPORT_API int bluetooth_rfcomm_server_disconnect(int socket_fd)
        _bt_convert_addr_type_to_string(address, conn->addr.addr);
 
        BT_DBG("Address %s", address);
-       _bt_disconnect_profile(address, info->uuid, NULL, NULL);
+       _bt_disconnect_ext_profile(address, info->path);
 
        if (info->disconnect_idle_id == 0)
                info->disconnect_idle_id = g_idle_add(
index e3a2af4..d591893 100644 (file)
@@ -314,6 +314,7 @@ int _bt_connect_profile(char *address, char *uuid, void *cb,
                                                        gpointer func_data);
 int _bt_disconnect_profile(char *address, char *uuid, void *cb,
                                                        gpointer func_data);
+int _bt_disconnect_ext_profile(char *address, char *path);
 
 int _bt_cancel_discovers(char *address);
 int _bt_discover_services(char *address, char *uuid, void *cb,