Fix incorrect memory validation for g_malloc*()
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-service-device.c
index a5bfb0f..b3ec8b5 100644 (file)
@@ -37,6 +37,7 @@
 #include "bt-service-network.h"
 #include "bt-service-adapter.h"
 #include "bt-service-gap-agent.h"
+#include "bt-service-pbap.h"
 
 #define BT_SYSPOPUP_IPC_RESPONSE_OBJECT "/org/projectx/bt_syspopup_res"
 #define BT_SYSPOPUP_INTERFACE "User.Bluetooth.syspopup"
@@ -84,12 +85,20 @@ typedef struct {
        char *pin_code;
 } bt_pin_code_info_t;
 
+typedef struct {
+       int req_id;
+       bluetooth_device_address_t bd_addr;
+       gboolean auto_connect;
+} bt_pending_le_conn_info_s;
+
 gboolean is_device_creating;
 bt_funcion_data_t *bonding_info;
 bt_funcion_data_t *searching_info;
 bt_funcion_data_t *att_mtu_req_info;
 
 static GSList *pin_info_list = NULL;
+static bt_pending_le_conn_info_s *pending_le_conn_info = NULL;
+static guint pending_le_conn_timer_id = 0;
 
 /* This HID Mouse does not support pairing precedure. need to skip it. */
 #define SMB_MOUSE_LAP_ADDR "00:12:A1"
@@ -209,7 +218,7 @@ static gboolean __bt_launch_unable_to_pairing_syspopup(int result)
        bundle *b = NULL;
        GDBusConnection *conn;
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        if (conn == NULL)
                return FALSE;
 
@@ -309,7 +318,7 @@ static void __bt_get_uuids(GVariant *value, bt_remote_dev_info_t *info)
        ret_if(info == NULL);
 
        info->uuid_count = g_variant_get_size(value);
-       info->uuids = g_variant_dup_strv(value, &info->uuid_count);
+       info->uuids = g_variant_dup_strv(value, (gsize *)&info->uuid_count);
 }
 
 bt_remote_dev_info_t *_bt_get_remote_device_info(char *address)
@@ -350,7 +359,7 @@ bt_remote_dev_info_t *_bt_get_remote_device_info_by_object_path(
 
        retv_if(object_path == NULL, NULL);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        if (conn == NULL) {
                BT_ERR("conn == NULL");
                return NULL;
@@ -389,7 +398,7 @@ bt_remote_dev_info_t *_bt_get_remote_device_info_by_object_path(
                        g_variant_unref(tmp_value);
                }
 
-               tmp_value = g_variant_lookup_value (value, "IsAliasSet", G_VARIANT_TYPE_BOOLEAN);
+               tmp_value = g_variant_lookup_value(value, "IsAliasSet", G_VARIANT_TYPE_BOOLEAN);
                if (tmp_value) {
                        dev_info->is_alias_set = g_variant_get_boolean(tmp_value);
                        g_variant_unref(tmp_value);
@@ -550,12 +559,6 @@ static gboolean __ignore_auto_pairing_request(const char *address)
        }
 
        buffer = g_malloc0(sizeof(char) * size);
-       /* Fix : NULL_RETURNS */
-       if (buffer == NULL) {
-               BT_ERR("Memory allocation error\n");
-               fclose(fp);
-               return FALSE;
-       }
        result = fread((char *)buffer, 1, size, fp);
        fclose(fp);
        if (result != size) {
@@ -701,6 +704,7 @@ static void __bt_bond_device_cb(GDBusProxy *proxy, GAsyncResult *res,
 {
        int result = BLUETOOTH_ERROR_NONE;
        GError *err = NULL;
+       GVariant *reply;
        GVariant *out_param1;
        request_info_t *req_info;
        bluetooth_device_info_t dev_info;
@@ -711,7 +715,9 @@ static void __bt_bond_device_cb(GDBusProxy *proxy, GAsyncResult *res,
        /* Terminate ALL system popup */
        syspopup_destroy_all();
 
-       g_dbus_proxy_call_finish(proxy, res, &err);
+       reply = g_dbus_proxy_call_finish(proxy, res, &err);
+       if (reply)
+               g_variant_unref(reply);
 
        is_device_creating = FALSE;
 
@@ -767,7 +773,7 @@ static void __bt_bond_device_cb(GDBusProxy *proxy, GAsyncResult *res,
                        result = BLUETOOTH_ERROR_HOST_DOWN;
                } else if (g_strrstr(err->message, BT_DBUS_TIMEOUT_MESSAGE)) {
                        BT_INFO("Cancel already running bonding");
-                       if(__bt_cancel_bonding() != BLUETOOTH_ERROR_NONE) {
+                       if (__bt_cancel_bonding() != BLUETOOTH_ERROR_NONE) {
                                BT_INFO("Error while Cancelling bonding");
                                /* we need to unref proxy so continue */
                        }
@@ -846,7 +852,7 @@ static void __bt_bond_device_cb(GDBusProxy *proxy, GAsyncResult *res,
        }
 
        remote_dev_info = _bt_get_remote_device_info(bonding_info->addr);
-       if(!remote_dev_info)
+       if (!remote_dev_info)
                goto dbus_return;
 
        GVariant *uuids = NULL;
@@ -945,7 +951,7 @@ int _bt_bond_device(int request_id,
                return BLUETOOTH_ERROR_DEVICE_BUSY;
        }
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
@@ -1053,13 +1059,16 @@ static void __bt_unbond_cb(GDBusProxy *proxy, GAsyncResult *res,
                                        gpointer user_data)
 {
        GError *err = NULL;
+       GVariant *reply;
        GVariant *out_param1;
        int result = BLUETOOTH_ERROR_NONE;
        bt_funcion_data_t *unbonding_info;
        bluetooth_device_info_t dev_info;
        request_info_t *req_info;
 
-       g_dbus_proxy_call_finish(proxy, res, &err);
+       reply = g_dbus_proxy_call_finish(proxy, res, &err);
+       if (reply)
+               g_variant_unref(reply);
 
        unbonding_info = user_data;
 
@@ -1127,12 +1136,6 @@ int _bt_unbond_device(int request_id,
 
        /* allocate user data so that it can be retrieved in callback */
        unbonding_info = g_malloc0(sizeof(bt_funcion_data_t));
-       /* Fix : NULL_RETURNS */
-       if (unbonding_info == NULL) {
-               BT_ERR("Memory not allocated !");
-               return BLUETOOTH_ERROR_MEMORY_ALLOCATION;
-       }
-
        unbonding_info->addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
        unbonding_info->req_id = request_id;
 
@@ -1147,7 +1150,7 @@ int _bt_unbond_device(int request_id,
                goto fail;
        }
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        if (conn == NULL) {
                BT_ERR("conn is NULL");
                result = BLUETOOTH_ERROR_INTERNAL;
@@ -1211,6 +1214,7 @@ static void __bt_discover_cb(GDBusProxy *proxy, GAsyncResult *res,
                                        gpointer user_data)
 {
        GError *err = NULL;
+       GVariant *reply;
        GVariant *out_param1;
        int result = BLUETOOTH_ERROR_NONE;
        bluetooth_device_info_t dev_info;
@@ -1221,7 +1225,9 @@ static void __bt_discover_cb(GDBusProxy *proxy, GAsyncResult *res,
        GVariantBuilder *builder = NULL;
        int i = 0;
 
-       g_dbus_proxy_call_finish(proxy, res, &err);
+       reply = g_dbus_proxy_call_finish(proxy, res, &err);
+       if (reply)
+               g_variant_unref(reply);
 
        g_object_unref(proxy);
 
@@ -1241,15 +1247,14 @@ static void __bt_discover_cb(GDBusProxy *proxy, GAsyncResult *res,
                g_dbus_error_strip_remote_error(err);
                BT_ERR("Error occured in Proxy call [%s]\n", err->message);
 
-               if (g_strrstr("Operation canceled", err->message)) {
+               if (g_strrstr("Operation canceled", err->message))
                        result = BLUETOOTH_ERROR_CANCEL_BY_USER;
-               } else if (g_strrstr("In Progress", err->message)) {
+               else if (g_strrstr("In Progress", err->message))
                        result = BLUETOOTH_ERROR_IN_PROGRESS;
-               } else if (g_strrstr("Host is down", err->message)) {
+               else if (g_strrstr("Host is down", err->message))
                        result = BLUETOOTH_ERROR_HOST_DOWN;
-               } else {
+               else
                        result = BLUETOOTH_ERROR_CONNECTION_ERROR;
-               }
 
                if (result == BLUETOOTH_ERROR_HOST_DOWN ||
                     result == BLUETOOTH_ERROR_CONNECTION_ERROR) {
@@ -1265,7 +1270,7 @@ static void __bt_discover_cb(GDBusProxy *proxy, GAsyncResult *res,
        }
 
        remote_dev_info = _bt_get_remote_device_info(searching_info->addr);
-       if(!remote_dev_info)
+       if (!remote_dev_info)
                goto dbus_return;
 
 event:
@@ -1360,7 +1365,7 @@ int _bt_search_device(int request_id,
        _bt_convert_addr_type_to_string(searching_info->addr,
                                        device_address->addr);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
 
@@ -1439,7 +1444,7 @@ int _bt_set_alias(bluetooth_device_address_t *device_address,
        adapter_proxy = _bt_get_adapter_proxy();
        retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
@@ -1493,7 +1498,7 @@ int _bt_set_authorization(bluetooth_device_address_t *device_address,
 
        BT_CHECK_PARAMETER(device_address, return);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
@@ -1538,7 +1543,7 @@ int _bt_set_authorization(bluetooth_device_address_t *device_address,
        }
 
        result = g_dbus_proxy_call_sync(device_proxy, "Set",
-                                g_variant_new("(ssv)", BT_DEVICE_INTERFACE, "Trusted", g_variant_new("b",authorize)),
+                                g_variant_new("(ssv)", BT_DEVICE_INTERFACE, "Trusted", g_variant_new("b", authorize)),
                                 G_DBUS_CALL_FLAGS_NONE,
                                 -1,
                                 NULL,
@@ -1573,7 +1578,7 @@ int _bt_is_gatt_connected(bluetooth_device_address_t *device_address,
 
        BT_CHECK_PARAMETER(device_address, return);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
@@ -1647,11 +1652,13 @@ int _bt_is_device_connected(bluetooth_device_address_t *device_address,
                                                is_connected);
        else if (connection_type == BLUETOOTH_GATT_SERVICE)
                return _bt_is_gatt_connected(device_address, is_connected);
+       else if (connection_type == BLUETOOTH_PBAP_SERVICE)
+               return _bt_pbap_is_connected(device_address, is_connected);
 
        adapter_proxy = _bt_get_adapter_proxy();
        retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
@@ -1680,8 +1687,9 @@ int _bt_is_device_connected(bluetooth_device_address_t *device_address,
                                BT_ERR("%s", error->message);
                                g_error_free(error);
                        }
+                       *is_connected = FALSE;
                        g_object_unref(device_proxy);
-                       return BLUETOOTH_ERROR_INTERNAL;
+                       return BLUETOOTH_ERROR_NONE;
                }
                g_variant_get(result , "(@a{sv})", &value);
                g_variant_unref(result);
@@ -1765,7 +1773,7 @@ int _bt_get_connected_link(bluetooth_device_address_t *device_address,
 
        BT_CHECK_PARAMETER(device_address, return);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
@@ -1872,8 +1880,8 @@ done:
        }
 }
 
-int _bt_connect_le_device(int req_id, const bluetooth_device_address_t *bd_addr,
-               gboolean auto_connect)
+static int __bt_connect_le_device_internal(int req_id, const bluetooth_device_address_t *bd_addr,
+       gboolean auto_connect)
 {
        char device_address[BT_ADDRESS_STRING_SIZE] = { 0 };
        gchar *device_path = NULL;
@@ -1884,7 +1892,7 @@ int _bt_connect_le_device(int req_id, const bluetooth_device_address_t *bd_addr,
 
        BT_CHECK_PARAMETER(bd_addr, return);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(device_address,
@@ -1903,12 +1911,6 @@ int _bt_connect_le_device(int req_id, const bluetooth_device_address_t *bd_addr,
        retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        func_data = g_malloc0(sizeof(bt_function_data_t));
-       if (func_data == NULL) {
-               BT_ERR("Unable to allocate memory for address");
-               ret = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
-               goto fail;
-       }
-
        func_data->address = g_strdup(device_address);
        if (func_data->address == NULL) {
                BT_ERR("Unable to allocate memory for address");
@@ -1918,11 +1920,6 @@ int _bt_connect_le_device(int req_id, const bluetooth_device_address_t *bd_addr,
 
        func_data->req_id = req_id;
 
-       ret = _bt_hold_current_advertising();
-       if (ret != BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Unable to hold advertising");
-       }
-
        g_dbus_proxy_call(device_proxy, "ConnectLE",
                        g_variant_new("(b)", auto_connect),
                        G_DBUS_CALL_FLAGS_NONE,
@@ -1942,6 +1939,57 @@ fail:
        return ret;
 }
 
+static gboolean __bt_connect_le_timer_cb(gpointer user_data)
+{
+       BT_INFO("Try to initiate pending LE connection");
+
+       pending_le_conn_timer_id = 0;
+
+       __bt_connect_le_device_internal(pending_le_conn_info->req_id,
+               &pending_le_conn_info->bd_addr,
+               pending_le_conn_info->auto_connect);
+
+       g_free(pending_le_conn_info);
+       pending_le_conn_info = NULL;
+
+       return FALSE;
+}
+
+void _bt_pending_connect_le_device(void)
+{
+       if (pending_le_conn_timer_id > 0) {
+               g_source_remove(pending_le_conn_timer_id);
+               __bt_connect_le_timer_cb(NULL);
+       }
+}
+
+int _bt_connect_le_device(int req_id, const bluetooth_device_address_t *bd_addr,
+               gboolean auto_connect)
+{
+       int ret = BLUETOOTH_ERROR_NONE;
+
+       BT_CHECK_PARAMETER(bd_addr, return);
+
+       ret = _bt_hold_current_advertising();
+       if (ret == BLUETOOTH_ERROR_NONE) {
+               BT_INFO("Current advertising is held");
+               pending_le_conn_info = g_malloc0(sizeof(bt_pending_le_conn_info_s));
+               pending_le_conn_info->req_id = req_id;
+               memcpy(pending_le_conn_info->bd_addr.addr, bd_addr->addr,
+                               BLUETOOTH_ADDRESS_LENGTH);
+               pending_le_conn_info->auto_connect = auto_connect;
+
+               pending_le_conn_timer_id =
+                       g_timeout_add(1000, __bt_connect_le_timer_cb, NULL);
+
+               return BLUETOOTH_ERROR_NONE;
+       }
+
+       BT_ERR("Unable to hold advertising");
+
+       return __bt_connect_le_device_internal(req_id, bd_addr, auto_connect);
+}
+
 int _bt_disconnect_le_device(int req_id,
                const bluetooth_device_address_t *bd_addr)
 {
@@ -1954,7 +2002,7 @@ int _bt_disconnect_le_device(int req_id,
 
        BT_CHECK_PARAMETER(bd_addr, return);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(device_address,
@@ -1975,12 +2023,6 @@ int _bt_disconnect_le_device(int req_id,
        retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        func_data = g_malloc0(sizeof(bt_function_data_t));
-       if (func_data == NULL) {
-               BT_ERR("Unable to allocate memory for address");
-               ret = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
-               goto fail;
-       }
-
        func_data->address = g_strdup(device_address);
        if (func_data->address == NULL) {
                BT_ERR("Unable to allocate memory for address");
@@ -2023,7 +2065,7 @@ int _bt_connect_le_ipsp_device(const bluetooth_device_address_t *bd_addr)
        _bt_convert_addr_type_to_string(device_address,
                        (unsigned char *)bd_addr->addr);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        adapter_proxy = _bt_get_adapter_proxy();
@@ -2077,7 +2119,7 @@ int _bt_disconnect_le_ipsp_device(const bluetooth_device_address_t *bd_addr)
        _bt_convert_addr_type_to_string(device_address,
                        (unsigned char *)bd_addr->addr);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        adapter_proxy = _bt_get_adapter_proxy();
@@ -2126,7 +2168,7 @@ int _bt_connect_profile(char *address, char *uuid,
        GVariant *result = NULL;
        GError *error = NULL;
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        object_path = _bt_get_device_object_path(address);
@@ -2171,6 +2213,47 @@ int _bt_connect_profile(char *address, char *uuid,
        return BLUETOOTH_ERROR_NONE;
 }
 
+int _bt_disconnect_all(char *address)
+{
+       int ret = BLUETOOTH_ERROR_NONE;
+       char *object_path;
+       GDBusProxy *proxy;
+       GDBusConnection *conn;
+       GVariant *result = NULL;
+       GError *err = NULL;
+
+       BT_DBG("");
+       conn = _bt_gdbus_get_system_gconn();
+       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       object_path = _bt_get_device_object_path(address);
+       retv_if(object_path == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                       NULL, BT_BLUEZ_NAME,
+                                       object_path, BT_DEVICE_INTERFACE,  NULL, NULL);
+       g_free(object_path);
+       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       result = g_dbus_proxy_call_sync(proxy, "Disconnect",
+               NULL,
+               G_DBUS_CALL_FLAGS_NONE,
+               -1, NULL,
+               &err);
+
+       if (err != NULL) {
+               BT_ERR("Dbus Call Error:[%s]", err->message);
+               g_error_free(err);
+               ret = BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       g_object_unref(proxy);
+       if (result)
+               g_variant_unref(result);
+
+       return ret;
+}
+
 int _bt_disconnect_profile(char *address, char *uuid,
                                                void *cb, gpointer func_data)
 {
@@ -2178,7 +2261,7 @@ int _bt_disconnect_profile(char *address, char *uuid,
        GDBusProxy *proxy;
        GDBusConnection *conn;
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        object_path = _bt_get_device_object_path(address);
@@ -2342,7 +2425,7 @@ int _bt_le_conn_update(unsigned char *device_address,
                goto fail;
        }
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        if (conn == NULL) {
                BT_ERR("conn NULL");
                ret = BLUETOOTH_ERROR_INTERNAL;
@@ -2602,13 +2685,13 @@ char *_bt_get_restricted_profile_uuid(bluetooth_restricted_profile_t profile)
 
 bluetooth_trusted_profile_t _bt_get_trusted_profile_enum(const char *uuid)
 {
-       if (g_strcmp0("0000112f-0000-1000-8000-00805f9b34fb", uuid) == 0) {
+       if (g_strcmp0("0000112f-0000-1000-8000-00805f9b34fb", uuid) == 0)
                return TRUSTED_PROFILE_PBAP;
-       } else if (g_strcmp0("00001132-0000-1000-8000-00805f9b34fb", uuid) == 0) {
+       else if (g_strcmp0("00001132-0000-1000-8000-00805f9b34fb", uuid) == 0)
                return TRUSTED_PROFILE_MAP;
-       } else if (g_strcmp0("0000112D-0000-1000-8000-00805f9b34fb", uuid) == 0) {
+       else if (g_strcmp0("0000112D-0000-1000-8000-00805f9b34fb", uuid) == 0)
                return TRUSTED_PROFILE_SAP;
-       }
+
        return 0; /* 0 - Unknown Profile */
 }
 
@@ -2631,7 +2714,7 @@ int _bt_set_trust_profile(bluetooth_device_address_t *bd_addr,
                        bd_addr->addr[4], bd_addr->addr[5],
                        profile, trust);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(address, bd_addr->addr);
@@ -2693,7 +2776,7 @@ int _bt_get_trust_profile(bluetooth_device_address_t *bd_addr,
                        bd_addr->addr[4], bd_addr->addr[5],
                        profile, *trust);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(address, bd_addr->addr);
@@ -2757,7 +2840,7 @@ int _bt_set_restrict_profile(bluetooth_device_address_t *bd_addr,
                        bd_addr->addr[4], bd_addr->addr[5],
                        profile, restricted);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(address, bd_addr->addr);
@@ -2819,7 +2902,7 @@ int _bt_get_restrict_profile(bluetooth_device_address_t *bd_addr,
                        bd_addr->addr[4], bd_addr->addr[5],
                        profile, *restricted);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(address, bd_addr->addr);
@@ -2913,8 +2996,8 @@ static void __bt_request_att_mtu_device_cb(GDBusProxy *proxy, GAsyncResult *res,
                goto dbus_return;
 
        if (val) {
-                g_variant_get (val, "(qy)", &mtu, &status);
-                g_variant_unref (val);
+                g_variant_get(val, "(qy)", &mtu, &status);
+                g_variant_unref(val);
        }
 
        BT_DBG("MTU %d, Status %d, %s", mtu, status, att_mtu_req_info->addr);
@@ -2971,7 +3054,7 @@ int _bt_request_att_mtu(int request_id, bluetooth_device_address_t *device_addre
                return BLUETOOTH_ERROR_DEVICE_BUSY;
        }
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        adapter_proxy = _bt_get_adapter_proxy();
@@ -3029,7 +3112,7 @@ int _bt_get_att_mtu(bluetooth_device_address_t *device_address,
 
        BT_CHECK_PARAMETER(device_address, return);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
@@ -3093,7 +3176,7 @@ int _bt_get_device_ida(bluetooth_device_address_t *device_address,
 
        BT_CHECK_PARAMETER(device_address, return);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
@@ -3138,11 +3221,10 @@ int _bt_get_device_ida(bluetooth_device_address_t *device_address,
 
        BT_DBG("ID Address:%s", idaddress);
 
-       if (idaddress) {
+       if (idaddress)
                _bt_convert_addr_string_to_type(id_address->addr, idaddress);
-       } else {
+       else
                ret = BLUETOOTH_ERROR_INTERNAL;
-       }
 
        g_object_unref(device_proxy);