Change the name of dbus property of EIR manufacturer data
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-service-device.c
index 9a8b1e3..4f19add 100644 (file)
@@ -84,12 +84,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 +217,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;
 
@@ -350,7 +358,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 +397,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);
@@ -447,7 +455,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, "ManufacturerDataLen", G_VARIANT_TYPE_UINT16);
+               tmp_value = g_variant_lookup_value(value, "LegacyManufacturerDataLen", G_VARIANT_TYPE_UINT16);
                if (tmp_value) {
                        dev_info->manufacturer_data_len = g_variant_get_uint16(tmp_value);
                        if (dev_info->manufacturer_data_len > BLUETOOTH_MANUFACTURER_DATA_LENGTH_MAX) {
@@ -458,7 +466,7 @@ bt_remote_dev_info_t *_bt_get_remote_device_info_by_object_path(
                } else
                        dev_info->manufacturer_data_len = 0;
 
-               tmp_value = g_variant_lookup_value(value, "ManufacturerData", G_VARIANT_TYPE_ARRAY);
+               tmp_value = g_variant_lookup_value(value, "LegacyManufacturerData", G_VARIANT_TYPE_ARRAY);
                if (tmp_value) {
                        if ((dev_info->manufacturer_data_len == 0) ||
                                        dev_info->manufacturer_data_len != g_variant_get_size(tmp_value)) {
@@ -701,6 +709,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 +720,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 +778,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 +857,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 +956,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 +1064,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;
 
@@ -1147,7 +1161,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 +1225,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 +1236,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 +1258,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 +1281,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 +1376,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 +1455,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 +1509,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 +1554,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 +1589,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);
@@ -1628,6 +1644,7 @@ int _bt_is_device_connected(bluetooth_device_address_t *device_address,
 {
        char *object_path = NULL;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+       char secure_address[BT_ADDRESS_STRING_SIZE] = { 0 };
        GDBusProxy *device_proxy = NULL;
        GDBusProxy *adapter_proxy = NULL;
        GDBusConnection *conn;
@@ -1640,18 +1657,24 @@ int _bt_is_device_connected(bluetooth_device_address_t *device_address,
        retv_if(device_address == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
        retv_if(is_connected == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
 
+       _bt_convert_addr_type_to_string(address, device_address->addr);
+       _bt_convert_addr_string_to_secure_string(secure_address, address);
+
        *is_connected = FALSE;
-       BT_DBG("connection_type: %d", connection_type);
+       BT_DBG("%s connection_type: 0x%02x", secure_address, connection_type);
+
        if (connection_type == BLUETOOTH_RFCOMM_SERVICE)
                return _bt_rfcomm_is_device_connected(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 +1703,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);
@@ -1702,11 +1726,10 @@ int _bt_is_device_connected(bluetooth_device_address_t *device_address,
        } else {
                uuid = _bt_get_profile_uuid128(connection_type);
                if (uuid == NULL) {
-                       BT_ERR("uuid is NULL");
+                       BT_ERR("connection_type: %d, uuid is NULL", connection_type);
                        return BLUETOOTH_ERROR_INTERNAL;
                }
-
-               BT_DBG("uuid: %s", uuid);
+               BT_DBG("uuid %s [%s]", uuid, _bt_convert_uuid_to_string(uuid));
 
                object_path = _bt_get_device_object_path(address);
                retv_if(object_path == NULL, BLUETOOTH_ERROR_NOT_PAIRED);
@@ -1729,16 +1752,17 @@ int _bt_is_device_connected(bluetooth_device_address_t *device_address,
                                        &error);
 
                if (result == NULL) {
-                       int ret = BLUETOOTH_ERROR_INTERNAL;
                        BT_ERR("[IsConnectedProfile] Error occured in Proxy call");
                        if (error) {
                                BT_ERR("%s", error->message);
                                if (g_strrstr(error->message, "Not Connected"))
-                                       ret = BLUETOOTH_ERROR_NOT_CONNECTED;
+                                       BT_DBG("Not connected");
                                g_error_free(error);
                        }
+                       *is_connected = FALSE;
                        g_object_unref(device_proxy);
-                       return ret;
+                       g_free(uuid);
+                       return BLUETOOTH_ERROR_NONE;
                }
                g_variant_get(result, "(b)", is_connected);
                g_free(uuid);
@@ -1764,7 +1788,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);
@@ -1871,10 +1895,11 @@ 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 };
+       char secure_address[BT_ADDRESS_STRING_SIZE] = { 0 };
        gchar *device_path = NULL;
        GDBusProxy *device_proxy = NULL;
        GDBusConnection *conn;
@@ -1883,7 +1908,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,
@@ -1902,6 +1927,12 @@ 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");
@@ -1909,12 +1940,10 @@ int _bt_connect_le_device(int req_id, const bluetooth_device_address_t *bd_addr,
                goto fail;
        }
 
-       func_data->req_id = req_id;
+       _bt_convert_addr_string_to_secure_string(secure_address, device_address);
+       BT_INFO("Connect LE [%s]", secure_address);
 
-       ret = _bt_hold_current_advertising();
-       if (ret != BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Unable to hold advertising");
-       }
+       func_data->req_id = req_id;
 
        g_dbus_proxy_call(device_proxy, "ConnectLE",
                        g_variant_new("(b)", auto_connect),
@@ -1935,10 +1964,62 @@ 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)
 {
        char device_address[BT_ADDRESS_STRING_SIZE] = { 0 };
+       char secure_address[BT_ADDRESS_STRING_SIZE] = { 0 };
        gchar *device_path;
        GDBusProxy *device_proxy;
        GDBusConnection *conn;
@@ -1947,7 +2028,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,
@@ -1968,6 +2049,12 @@ 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");
@@ -1975,6 +2062,9 @@ int _bt_disconnect_le_device(int req_id,
                goto fail;
        }
 
+       _bt_convert_addr_string_to_secure_string(secure_address, device_address);
+       BT_INFO("Disconnect LE [%s]", secure_address);
+
        func_data->req_id = req_id;
 
        g_dbus_proxy_call(device_proxy, "DisconnectLE",
@@ -2010,7 +2100,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();
@@ -2064,7 +2154,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();
@@ -2113,7 +2203,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);
@@ -2165,7 +2255,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);
@@ -2329,7 +2419,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;
@@ -2589,13 +2679,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 */
 }
 
@@ -2618,7 +2708,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);
@@ -2680,7 +2770,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);
@@ -2744,7 +2834,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);
@@ -2806,7 +2896,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);
@@ -2900,8 +2990,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);
@@ -2958,7 +3048,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();
@@ -3016,7 +3106,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);
@@ -3080,7 +3170,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);
@@ -3107,7 +3197,7 @@ int _bt_get_device_ida(bluetooth_device_address_t *device_address,
        if (result == NULL) {
                BT_ERR("Failed to get device ID address");
                if (error != NULL) {
-                       BT_ERR("Error occured in Proxy call [%s]\n", error->message);
+                       BT_ERR("Error occured in Proxy call [%s]", error->message);
                        g_error_free(error);
                }
                g_object_unref(device_proxy);
@@ -3125,11 +3215,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);