From: Seungyoun Ju Date: Tue, 11 Apr 2017 09:20:17 +0000 (+0900) Subject: Disconnect service connection using object path X-Git-Tag: accepted/tizen/3.0/common/20170508.152944~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F82%2F125382%2F2;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git Disconnect service connection using object path [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 --- diff --git a/bt-api/bt-common.c b/bt-api/bt-common.c old mode 100644 new mode 100755 index 5b48930..1dffec7 --- a/bt-api/bt-common.c +++ b/bt-api/bt-common.c @@ -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; diff --git a/bt-api/bt-rfcomm-client.c b/bt-api/bt-rfcomm-client.c index ec57e1e..de4411b 100644 --- a/bt-api/bt-rfcomm-client.c +++ b/bt-api/bt-rfcomm-client.c @@ -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); diff --git a/bt-api/bt-rfcomm-server.c b/bt-api/bt-rfcomm-server.c index aa59276..d29f93c 100644 --- a/bt-api/bt-rfcomm-server.c +++ b/bt-api/bt-rfcomm-server.c @@ -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( diff --git a/bt-api/include/bt-common.h b/bt-api/include/bt-common.h index e3a2af4..d591893 100644 --- a/bt-api/include/bt-common.h +++ b/bt-api/include/bt-common.h @@ -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,