Apply tizen 3.0 based product patchsets 23/147923/1
authorDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 6 Sep 2017 05:20:48 +0000 (14:20 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 6 Sep 2017 05:21:41 +0000 (14:21 +0900)
--------------------------------------------------
commit 0aa1d3f208f07e30fda9f16ee0b7325faf772939
Author: Deokhyun Kim <dukan.kim@samsung.com>
Date:   Fri Sep 1 10:16:27 2017 +0900

    Fix mem leak.
--------------------------------------------------

Change-Id: I28105e3f701c81f044b45f9348c9560d18a640df
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
25 files changed:
bt-api/bt-common.c
bt-api/bt-device.c
bt-api/bt-gatt-client.c
bt-api/bt-gatt-service.c
bt-api/bt-hid-device.c
bt-core/bt-core-adapter.c
bt-httpproxy/bt-httpproxy.c
bt-service-emul/bt-service-dpm.c
bt-service/bt-request-handler.c
bt-service/bt-service-adapter.c
bt-service/bt-service-agent.c
bt-service/bt-service-audio.c
bt-service/bt-service-common.c
bt-service/bt-service-device.c
bt-service/bt-service-dpm.c
bt-service/bt-service-event-receiver.c
bt-service/bt-service-gap-agent.c
bt-service/bt-service-hid.c
bt-service/bt-service-map-client.c
bt-service/bt-service-obex-server.c
bt-service/bt-service-pbap.c
bt-service/include/bt-service-common.h
bt-service/include/bt-service-device.h
include/bluetooth-api.h
include/bt-internal-types.h

index f70f5a4..b4e5ccb 100644 (file)
@@ -439,8 +439,6 @@ const char *_bt_convert_service_function_to_string(int function)
                {BT_UPDATE_LE_CONNECTION_MODE, "BT_UPDATE_LE_CONNECTION_MODE"},
                {BT_SET_PROFILE_TRUSTED, "BT_SET_PROFILE_TRUSTED"},
                {BT_GET_PROFILE_TRUSTED, "BT_GET_PROFILE_TRUSTED"},
-               {BT_SET_PROFILE_RESTRICTED, "BT_SET_PROFILE_RESTRICTED"},
-               {BT_GET_PROFILE_RESTRICTED, "BT_GET_PROFILE_RESTRICTED"},
                {BT_HID_CONNECT, "BT_HID_CONNECT"},
                {BT_HID_DISCONNECT, "BT_HID_DISCONNECT"},
                {BT_HID_DEVICE_ACTIVATE, "BT_HID_DEVICE_ACTIVATE"},
@@ -864,7 +862,7 @@ static GDBusProxy *__bt_gdbus_get_device_proxy(char *object_path)
                                                BT_DEVICE_INTERFACE,
                                                NULL, &err);
 
-       if (err) {
+       if (device_gproxy == NULL && err) {
                BT_ERR("Unable to create proxy: %s", err->message);
                g_clear_error(&err);
                return NULL;
@@ -1467,54 +1465,35 @@ int _bt_discover_service_uuids(char *address, char *remote_uuid)
                BT_ERR("DBus Error: [%s]", err->message);
                g_clear_error(&err);
        }
-       ret = g_dbus_proxy_call_sync(proxy, "GetAll",
-                       g_variant_new("(s)", BT_DEVICE_INTERFACE),
-                       G_DBUS_CALL_FLAGS_NONE,
-                       DBUS_TIMEOUT, NULL,
-                       &err);
+       ret = g_dbus_proxy_call_sync(proxy, "Get",
+                       g_variant_new("(ss)", BT_DEVICE_INTERFACE, "UUIDs"),
+                       G_DBUS_CALL_FLAGS_NONE, DBUS_TIMEOUT, NULL, &err);
        if (err) {
                result = BLUETOOTH_ERROR_INTERNAL;
                BT_ERR("DBus Error : %s", err->message);
                g_clear_error(&err);
                goto done;
-       }
-       if (ret == NULL) {
-               BT_ERR("g_dbus_proxy_call_sync function return NULL");
-               result = BLUETOOTH_ERROR_INTERNAL;
-               goto done;
+       } else {
+               g_variant_get(ret, "(v)", &value);
+               uuid_value = (char **)g_variant_get_strv(value, &size);
+               BT_DBG("Size items %d", size);
+               g_variant_unref(value);
+               g_variant_unref(ret);
        }
 
-       g_variant_get(ret, "(@a{sv})", &value);
-       g_variant_unref(ret);
-       if (value) {
-               GVariant *temp_value = g_variant_lookup_value(value, "UUIDs",
-                       G_VARIANT_TYPE_STRING_ARRAY);
-
-               if (temp_value) {
-                       size = g_variant_get_size(temp_value);
-                       if (size > 0) {
-                               uuid_value = (char **)g_variant_get_strv(temp_value, &size);
-                               BT_DBG("Size items %d", size);
-
-                               if (uuid_value) {
-                                       for (i = 0; uuid_value[i] != NULL; i++) {
-                                               BT_DBG("Remote uuids %s", uuid_value[i]);
-                                               if (strcasecmp(uuid_value[i], remote_uuid) == 0) {
-                                                       result = BLUETOOTH_ERROR_NONE;
-                                                       g_variant_unref(temp_value);
-                                                       goto done;
-                                               }
-                                       }
-                               }
+       if (uuid_value) {
+               for (i = 0; uuid_value[i] != NULL; i++) {
+                       BT_DBG("Remote uuids %s", uuid_value[i]);
+                       if (g_ascii_strcasecmp(uuid_value[i], remote_uuid) == 0) {
+                               result = BLUETOOTH_ERROR_NONE;
+                               goto done;
                        }
-                       g_variant_unref(temp_value);
                }
        }
+
 done:
        if (proxy)
                g_object_unref(proxy);
-       if (value)
-               g_variant_unref(value);
        if (uuid_value)
                g_free(uuid_value);
 
@@ -1551,38 +1530,25 @@ int _bt_get_cod_by_address(char *address, bluetooth_device_class_t *dev_class)
                g_clear_error(&err);
        }
 
-       result = g_dbus_proxy_call_sync(proxy, "GetAll",
-                       g_variant_new("(s)", BT_DEVICE_INTERFACE),
-                       G_DBUS_CALL_FLAGS_NONE,
-                       DBUS_TIMEOUT, NULL,
-                       &err);
+       result = g_dbus_proxy_call_sync(proxy, "Get",
+                       g_variant_new("(ss)", BT_DEVICE_INTERFACE, "Class"),
+                       G_DBUS_CALL_FLAGS_NONE, DBUS_TIMEOUT, NULL, &err);
        if (err) {
                ret = BLUETOOTH_ERROR_INTERNAL;
                BT_ERR("DBus Error : %s", err->message);
                g_clear_error(&err);
                goto done;
-       }
-       if (result == NULL) {
-               BT_ERR("g_dbus_proxy_call_sync function return NULL");
-               ret = BLUETOOTH_ERROR_INTERNAL;
-               goto done;
-       }
-       g_variant_get(result, "(@a{sv})", &value);
-       g_variant_unref(result);
-       if (value) {
-               GVariant *temp_value = g_variant_lookup_value(value, "Class",
-                       G_VARIANT_TYPE_UINT32);
-               class = g_variant_get_uint32(temp_value);
+       } else {
+               g_variant_get(result, "(v)", &value);
+               class = g_variant_get_uint32(value);
                _bt_divide_device_class(dev_class, class);
-               if (temp_value)
-                       g_variant_unref(temp_value);
+               g_variant_unref(value);
+               g_variant_unref(result);
        }
 
 done:
        if (proxy)
                g_object_unref(proxy);
-       if (value)
-               g_variant_unref(value);
 
        BT_DBG("-");
        return ret;
@@ -1943,7 +1909,7 @@ GVariant *_bt_get_managed_objects(void)
                        BT_MANAGER_INTERFACE,
                        NULL, &error);
 
-       if (error) {
+       if (manager_proxy == NULL && error) {
                BT_ERR("Unable to create proxy: %s", error->message);
                g_clear_error(&error);
                return NULL;
index 8bb283d..815f8dc 100644 (file)
@@ -739,62 +739,6 @@ BT_EXPORT_API int bluetooth_get_profile_trusted(
        return result;
 }
 
-BT_EXPORT_API int bluetooth_set_profile_restricted(
-               const bluetooth_device_address_t *device_address,
-               int profile, int restricted)
-{
-       int result;
-
-       BT_CHECK_PARAMETER(device_address, return);
-       BT_CHECK_ENABLED(return);
-
-       BT_INIT_PARAMS();
-       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
-
-       g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
-       g_array_append_vals(in_param2, &profile, sizeof(int));
-       g_array_append_vals(in_param3, &restricted, sizeof(int));
-
-       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_SET_PROFILE_RESTRICTED,
-                       in_param1, in_param2, in_param3, in_param4, &out_param);
-
-       if (result == BLUETOOTH_ERROR_NONE)
-               BT_DBG("SUCCESSFUL");
-
-       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
-
-       return result;
-}
-
-BT_EXPORT_API int bluetooth_get_profile_restricted(
-               const bluetooth_device_address_t *device_address,
-               int profile, int *restricted)
-{
-       int result;
-       int restrict_profile = 0;
-       BT_CHECK_PARAMETER(device_address, return);
-       BT_CHECK_ENABLED(return);
-
-       BT_INIT_PARAMS();
-       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
-
-       g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
-       g_array_append_vals(in_param2, &profile, sizeof(int));
-
-       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_PROFILE_RESTRICTED,
-                       in_param1, in_param2, in_param3, in_param4, &out_param);
-
-       if (result == BLUETOOTH_ERROR_NONE) {
-               restrict_profile = g_array_index(out_param, guint, 0);
-               BT_DBG("SUCCESSFUL");
-       }
-       BT_DBG("Restricted %d", restrict_profile);
-       *restricted = restrict_profile;
-       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
-
-       return result;
-}
-
 BT_EXPORT_API int bluetooth_passkey_reply(char *passkey, gboolean reply)
 {
        int result;
index f9dd7dc..ba8f797 100644 (file)
@@ -229,31 +229,35 @@ BT_EXPORT_API int bluetooth_gatt_get_service_property(const char *service_handle
 
                } else if (!g_strcmp0(key, "Includes")) {
                        g_variant_get(value, "ao", &char_iter);
-                       gp_array = g_ptr_array_new();
-                       while (g_variant_iter_loop(char_iter, "&o", &char_handle))
-                               g_ptr_array_add(gp_array, (gpointer)char_handle);
-
-                       if (gp_array->len != 0) {
-                               service->include_handles.count = gp_array->len;
-                               service->include_handles.handle =
-                                               __get_string_array_from_gptr_array(gp_array);
+                       if (char_iter != NULL) {
+                               gp_array = g_ptr_array_new();
+                               while (g_variant_iter_loop(char_iter, "&o", &char_handle))
+                                       g_ptr_array_add(gp_array, (gpointer)char_handle);
+
+                               if (gp_array->len != 0) {
+                                       service->include_handles.count = gp_array->len;
+                                       service->include_handles.handle =
+                                                       __get_string_array_from_gptr_array(gp_array);
+                               }
+                               g_ptr_array_free(gp_array, TRUE);
+                               g_variant_iter_free(char_iter);
                        }
-                       g_ptr_array_free(gp_array, TRUE);
-                       g_variant_iter_free(char_iter);
                } else if (!g_strcmp0(key, "Characteristics")) {
                        g_variant_get(value, "ao", &char_iter);
-                       gp_array = g_ptr_array_new();
-                       while (g_variant_iter_loop(char_iter, "&o", &char_handle))
-                               g_ptr_array_add(gp_array, (gpointer)char_handle);
-
-                       if (gp_array->len != 0) {
-                               service->char_handle.count = gp_array->len;
-                               service->char_handle.handle =
-                                               __get_string_array_from_gptr_array(gp_array);
+                       if (char_iter != NULL) {
+                               gp_array = g_ptr_array_new();
+                               while (g_variant_iter_loop(char_iter, "&o", &char_handle))
+                                       g_ptr_array_add(gp_array, (gpointer)char_handle);
+
+                               if (gp_array->len != 0) {
+                                       service->char_handle.count = gp_array->len;
+                                       service->char_handle.handle =
+                                                       __get_string_array_from_gptr_array(gp_array);
+                               }
+                               g_ptr_array_free(gp_array, TRUE);
+                               g_variant_iter_free(char_iter);
                        }
                        BT_DBG("Characteristics count : %d", service->char_handle.count);
-                       g_ptr_array_free(gp_array, TRUE);
-                       g_variant_iter_free(char_iter);
                }
        }
 
index c3bfc49..7eee5ba 100644 (file)
@@ -270,7 +270,7 @@ static int __bt_send_event_to_hps(int event, GVariant *var)
                parameters = g_variant_new("(a{sv}as)", inner_builder, invalidated_builder);
                g_variant_builder_unref(invalidated_builder);
                g_variant_builder_unref(inner_builder);
-       } else if (BLUETOOTH_EVENT_GATT_SERVER_READ_REQUESTED) {
+       } else if (event == BLUETOOTH_EVENT_GATT_SERVER_READ_REQUESTED) {
                GVariantBuilder *inner_builder;
                GVariantBuilder *invalidated_builder;
 
@@ -284,6 +284,8 @@ static int __bt_send_event_to_hps(int event, GVariant *var)
                parameters = g_variant_new("(a{sv}as)", inner_builder, invalidated_builder);
                g_variant_builder_unref(invalidated_builder);
                g_variant_builder_unref(inner_builder);
+       } else {
+               g_varaiant_unref(var);
        }
 
        msg = g_dbus_message_new_signal(BT_HPS_OBJECT_PATH, BT_HPS_INTERFACE_NAME, PROPERTIES_CHANGED);
@@ -911,6 +913,8 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
 #endif
                        }
                }
+               g_object_unref(invocation);
+               return;
        } else if (g_strcmp0(method_name, "StopNotify") == 0) {
                bt_user_info_t *user_info = NULL;
                bt_gatt_char_notify_change_t notify_change = {0, };
@@ -939,6 +943,8 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
 #endif
                        }
                }
+               g_object_unref(invocation);
+               return;
        } else if (g_strcmp0(method_name, "IndicateConfirm") == 0) {
                gchar *addr = NULL;
                bt_gatt_indicate_confirm_t confirm = {0, };
index 23942fa..db0f6bb 100644 (file)
 #define BT_HID_HSHK_ERR_UNKNOWN        0x0E
 #define BT_HID_HSHK_ERR_FATAL  0x0F
 
-typedef struct {
-       guint object_id;
-       gchar *path;
-       int id;
-       char *uuid;
-       GSList *device_list;
-} hid_info_t;
+#define BT_HID_SERVICE_NAME "org.bluez.hid_agent"
+#define BT_HID_AGENT_OBJECT_PATH "/org/bluez/hid_agent"
+#define BT_HID_SERVICE_INTERFACE "org.tizen.HidApp"
 
 typedef struct {
        int ctrl_fd;
@@ -81,7 +77,7 @@ struct reports {
        guint8 rep_data[20];
 } __attribute__((__packed__));
 
-static hid_info_t *hid_info = NULL;
+static GSList *device_list;
 
 /* Variable for privilege, only for write API,
   before we should reduce time to bt-service dbus calling
@@ -156,11 +152,36 @@ int _bt_hid_device_get_fd(const char *address, int *ctrl, int *intr)
        return ret;
 }
 
+static GVariant* __bt_hid_agent_dbus_send(const char *path,
+                               const char *interface,  const char *method,
+                               GError **err, GVariant *parameters)
+{
+       GVariant *reply = NULL;
+       GDBusProxy *proxy = NULL;
+       GDBusConnection *conn = NULL;
+
+       conn = _bt_gdbus_get_system_gconn();
+       retv_if(conn == NULL, NULL);
+
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+               NULL, BT_HID_SERVICE_NAME, path, interface, NULL, err);
+       if (proxy == NULL) {
+               BT_ERR("Unable to allocate new proxy");
+               return NULL;
+       }
+
+       reply = g_dbus_proxy_call_sync(proxy, method, parameters,
+                               G_DBUS_CALL_FLAGS_NONE, -1, NULL, err);
+
+       g_object_unref(proxy);
+       return reply;
+}
+
 static hid_connected_device_info_t *__find_hid_info_with_address(const char *remote_addr)
 {
        GSList *l;
 
-       for (l = hid_info->device_list; l != NULL; l = l->next) {
+       for (l = device_list; l != NULL; l = l->next) {
                hid_connected_device_info_t *info = l->data;
                if (g_strcmp0((const char *)info->address, (const char *)remote_addr) == 0)
                        return info;
@@ -245,7 +266,7 @@ static gboolean __hid_disconnect(hid_connected_device_info_t *info)
        bt_event_info_t *event_info;
 
        BT_INFO_C("Disconnected [HID Device]");
-       hid_info->device_list = g_slist_remove(hid_info->device_list, info);
+       device_list = g_slist_remove(device_list, info);
        if (info->ctrl_data_id > 0) {
                g_source_remove(info->ctrl_data_id);
                info->ctrl_data_id = 0;
@@ -290,29 +311,6 @@ static gboolean __hid_disconnect(hid_connected_device_info_t *info)
        return FALSE;
 }
 
-void __free_hid_info(hid_info_t *info)
-{
-       BT_DBG("");
-
-       _bt_unregister_gdbus(info->object_id);
-
-       while (info->device_list) {
-               hid_connected_device_info_t *dev_info = NULL;
-               dev_info = (hid_connected_device_info_t *)info->device_list->data;
-
-               if (dev_info->disconnect_idle_id > 0) {
-                       BT_INFO("Disconnect idle still not process remove source");
-                       g_source_remove(dev_info->disconnect_idle_id);
-                       dev_info->disconnect_idle_id = 0;
-               }
-               __hid_disconnect(dev_info);
-       }
-
-       g_free(info->path);
-       g_free(info->uuid);
-       g_free(info);
-}
-
 static gboolean __is_error_by_disconnect(GError *err)
 {
        return !g_strcmp0(err->message, "Connection reset by peer") ||
@@ -519,13 +517,9 @@ static gboolean __received_cb(GIOChannel *chan, GIOCondition cond,
 
 int new_hid_connection(const char *path, int fd, bluetooth_device_address_t *addr)
 {
-       hid_info_t *info = NULL;
        hid_connected_device_info_t *dev_info = NULL;
        char address[18];
-       info = hid_info;
 
-       if (info == NULL)
-               return -1;
        _bt_convert_addr_type_to_string((char *)address, addr->addr);
        BT_INFO("Address [%s]", address);
        dev_info = __find_hid_info_with_address(address);
@@ -544,7 +538,7 @@ int new_hid_connection(const char *path, int fd, bluetooth_device_address_t *add
                dev_info->intr_data_id = g_io_add_watch(dev_info->intr_data_io,
                                G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
                                __received_cb, dev_info);
-               hid_info->device_list = g_slist_append(hid_info->device_list, dev_info);
+               device_list = g_slist_append(device_list, dev_info);
        } else {
                dev_info->ctrl_fd = fd;
                dev_info->ctrl_data_io = g_io_channel_unix_new(dev_info->ctrl_fd);
@@ -561,35 +555,26 @@ int new_hid_connection(const char *path, int fd, bluetooth_device_address_t *add
 
        return 0;
 }
-static hid_info_t *__register_method()
-{
-       int object_id;
-       hid_info_t *info = NULL;
-       char *path = NULL;
-       path = g_strdup_printf("/org/socket/server/%d", getpid());
 
-       object_id = _bt_register_new_conn(path, new_hid_connection);
-       if (object_id < 0)
-               return NULL;
+static void __free_hid_info(void *data)
+{
+       BT_DBG("");
 
-       info = g_new(hid_info_t, 1);
-       info->object_id = (guint)object_id;
-       info->path = path;
-       info->id = 0;
-       info->device_list = NULL;
+       hid_connected_device_info_t *dev_info = (hid_connected_device_info_t *)data;
 
-       return info;
+       if (dev_info->disconnect_idle_id > 0) {
+               BT_INFO("Disconnect idle still not process remove source");
+               g_source_remove(dev_info->disconnect_idle_id);
+               dev_info->disconnect_idle_id = 0;
+       }
+       __hid_disconnect(dev_info);
 }
 
 void _bluetooth_hid_free_hid_info(void)
 {
-       if (hid_info == NULL) {
-               BT_DBG("hid_info is already NULL");
-               return;
-       }
+       g_slist_free_full(device_list, __free_hid_info);
 
-       __free_hid_info(hid_info);
-       hid_info = NULL;
+       device_list = NULL;
 }
 
 BT_EXPORT_API int bluetooth_hid_device_init(hid_cb_func_ptr callback_ptr, void *user_data)
@@ -629,8 +614,8 @@ BT_EXPORT_API int bluetooth_hid_device_deinit(void)
 
 BT_EXPORT_API int bluetooth_hid_device_activate(void)
 {
-       bt_register_profile_info_t profile_info;
-       int result = BLUETOOTH_ERROR_NONE;
+       GVariant *reply;
+       GError *err = NULL;
 
        BT_CHECK_ENABLED(return);
 
@@ -640,32 +625,34 @@ BT_EXPORT_API int bluetooth_hid_device_activate(void)
                return BLUETOOTH_ERROR_PERMISSION_DEINED;
        }
 
-       if (hid_info != NULL)
-               return BLUETOOTH_ERROR_IN_PROGRESS;
-
-       hid_info = __register_method();
-       if (hid_info == NULL)
-               return BLUETOOTH_ERROR_INTERNAL;
+       reply = __bt_hid_agent_dbus_send(BT_HID_AGENT_OBJECT_PATH,
+                       BT_HID_SERVICE_INTERFACE,
+                       "RegisterApplication", &err, NULL);
 
-       hid_info->uuid = g_strdup(HID_DEVICE_UUID);
-
-       profile_info.authentication = TRUE;
-       profile_info.authorization = TRUE;
-       profile_info.obj_path = hid_info->path;
-       profile_info.role = g_strdup("Hid");
-       profile_info.service = hid_info->uuid;
-       profile_info.uuid = hid_info->uuid;
-
-       BT_INFO("uuid %s", profile_info.uuid);
-       result = _bt_register_profile(&profile_info, FALSE);
+       if (!reply) {
+               int ret = BLUETOOTH_ERROR_INTERNAL;
+               BT_ERR("Error returned in method call");
+               if (err) {
+                       BT_ERR("Error = %s", err->message);
+                       if (strcmp(err->message, BT_ERROR_ALREADY_EXIST) == 0)
+                               ret = BLUETOOTH_ERROR_IN_PROGRESS;
+                       else
+                               ret = BLUETOOTH_ERROR_INTERNAL;
+                       g_clear_error(&err);
+               }
+               return ret;
+       }
 
-       g_free(profile_info.role);
+       g_variant_unref(reply);
 
-       return result;
+       return BLUETOOTH_ERROR_NONE;
 }
 
 BT_EXPORT_API int bluetooth_hid_device_deactivate(void)
 {
+       GVariant *reply;
+       GError *err = NULL;
+
        BT_CHECK_ENABLED(return);
 
        if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_HID_DEVICE_DEACTIVATE)
@@ -674,10 +661,25 @@ BT_EXPORT_API int bluetooth_hid_device_deactivate(void)
                return BLUETOOTH_ERROR_PERMISSION_DEINED;
        }
 
-       if (hid_info == NULL)
-               return BLUETOOTH_ERROR_NOT_IN_OPERATION;
+       reply = __bt_hid_agent_dbus_send(BT_HID_AGENT_OBJECT_PATH,
+                       BT_HID_SERVICE_INTERFACE,
+                       "UnregisterApplication", &err, NULL);
+
+       if (!reply) {
+               int ret = BLUETOOTH_ERROR_INTERNAL;
+               BT_ERR("Error returned in method call");
+               if (err) {
+                       BT_ERR("Error = %s", err->message);
+                       if (strcmp(err->message, BT_ERROR_NOT_AVAILABLE) == 0)
+                               ret = BLUETOOTH_ERROR_NOT_IN_OPERATION;
+                       else
+                               ret = BLUETOOTH_ERROR_INTERNAL;
+                       g_clear_error(&err);
+               }
+               return ret;
+       }
 
-       _bt_unregister_profile(hid_info->path);
+       g_variant_unref(reply);
 
        _bluetooth_hid_free_hid_info();
 
index a98b5c9..247bfef 100644 (file)
@@ -432,13 +432,15 @@ int _bt_core_service_request_adapter(int service_function)
        return ret;
 }
 
-static gboolean __bt_core_check_the_adapter_path(GDBusConnection *conn)
+static gboolean __bt_core_check_the_adapter_path(void)
 {
        GError *err = NULL;
        GDBusProxy *manager_proxy = NULL;
        GVariant *result = NULL;
        char *adapter_path = NULL;
+       GDBusConnection *conn = NULL;
 
+       conn = _bt_core_get_gdbus_connection();
        if (conn == NULL)
                return FALSE;
 
@@ -460,7 +462,7 @@ static gboolean __bt_core_check_the_adapter_path(GDBusConnection *conn)
        }
 
        result = g_dbus_proxy_call_sync(manager_proxy, "DefaultAdapter", NULL,
-                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+                       G_DBUS_CALL_FLAGS_NONE, 1000, NULL, &err);
        if (!result) {
                if (err != NULL) {
                        BT_ERR("Fail to get DefaultAdapter (Error: %s)", err->message);
@@ -505,7 +507,7 @@ void _bt_core_update_status(void)
        int bt_le_status = VCONFKEY_BT_LE_STATUS_OFF;
        gboolean ret = FALSE;
 
-       ret = __bt_core_check_the_adapter_path(_bt_core_get_gdbus_connection());
+       ret = __bt_core_check_the_adapter_path();
        BT_INFO("check the real status of bt_adapter");
 
        if (ret != TRUE) {
@@ -551,18 +553,27 @@ static gboolean __bt_core_terminate_cb(gpointer data)
 gboolean _bt_core_disable_adapter(void)
 {
        int ret;
+       gboolean adapter_state;
 
        _bt_set_flightmode_request(FALSE);
        if (vconf_set_int(BT_OFF_DUE_TO_FLIGHT_MODE, 0) != 0)
                BT_ERR("Set vconf failed");
 
-       g_idle_add((GSourceFunc)__bt_core_terminate_cb, NULL);
+       adapter_state = __bt_core_check_the_adapter_path();
+       if (adapter_state == FALSE)
+               BT_INFO("Default adapter is NOT normal.");
 
        ret = _bt_disable_adapter();
-       if (ret < 0)
-               return FALSE;
-       else
+       if (adapter_state == FALSE) {
+               g_timeout_add(BT_CORE_IDLE_TERM_TIME,
+                             __bt_core_terminate_cb, NULL);
                return TRUE;
+       } else {
+               if (ret < 0)
+                       return FALSE;
+               else
+                       return TRUE;
+       }
 }
 
 gboolean _bt_core_recover_adapter(void)
index 4d23471..daab5aa 100644 (file)
@@ -1148,11 +1148,6 @@ void _bt_hps_gatt_char_property_changed_event(GVariant *msg,
 
        while ((g_variant_iter_loop(&value_iter, "{sv}", &property, &var))) {
 
-               if (property == NULL) {
-                       BT_ERR("Property NULL");
-                       return;
-               }
-
                if (!g_strcmp0(property, "WriteValue")) {
                        int len = 0;
                        BT_INFO("WriteValue");
@@ -1253,7 +1248,7 @@ void _bt_hps_gatt_char_property_changed_event(GVariant *msg,
 
                if (property == NULL) {
                        BT_ERR("Property NULL");
-                       return;
+                       break;
                }
 
                if (strcasecmp(property, "ChangedValue") == 0) {
@@ -1269,15 +1264,6 @@ void _bt_hps_gatt_char_property_changed_event(GVariant *msg,
                                g_byte_array_append(gp_byte_array,
                                        (const guint8 *)g_variant_get_data(val), len);
                                if (gp_byte_array->len != 0) {
-                                       GVariant *byte_array = NULL;
-                                       byte_array = g_variant_new_from_data(
-                                                               G_VARIANT_TYPE_BYTESTRING,
-                                                               gp_byte_array->data,
-                                                               gp_byte_array->len,
-                                                               TRUE, NULL, NULL);
-                                       param = g_variant_new("(is@ay)", result, char_handle,
-                                                               byte_array);
-
                                        if (strcmp(path, http_uri_obj_path)) {
                                                //Retrive URI
                                                _bt_hps_uri_write_cb(NULL, len);
index 71e43df..96c44b8 100644 (file)
@@ -161,7 +161,7 @@ dpm_result_t _bt_dpm_add_bluetooth_devices_to_blacklist(bluetooth_device_address
 dpm_result_t _bt_dpm_get_bluetooth_devices_from_blacklist(GArray **out_param1)
 {
        dpm_result_t ret = DPM_RESULT_FAIL;
-       bt_dpm_device_list_t device_list;
+       bt_dpm_device_list_t device_list = { 0, };
        GSList *list = policy_table[DPM_POLICY_BLUETOOTH_DEVICES_BLACKLIST].list;
        int i = 0;
 
@@ -211,7 +211,7 @@ dpm_result_t _bt_dpm_add_bluetooth_devices_to_whitelist(bluetooth_device_address
 dpm_result_t _bt_dpm_get_bluetooth_devices_from_whitelist(GArray **out_param1)
 {
        dpm_result_t ret = DPM_RESULT_FAIL;
-       bt_dpm_device_list_t device_list;
+       bt_dpm_device_list_t device_list = { 0, };
        GSList *list = policy_table[DPM_POLICY_BLUETOOTH_DEVICES_WHITELIST].list;
        int i = 0;
 
index 4095abd..a6fb1e4 100644 (file)
@@ -1028,37 +1028,6 @@ int __bt_bluez_request(int function_name,
 
                break;
        }
-       case BT_SET_PROFILE_RESTRICTED: {
-               bluetooth_device_address_t bd_addr = { {0} };
-               int profile;
-               int restricted;
-
-               __bt_service_get_parameters(in_param1, &bd_addr,
-                               sizeof(bluetooth_device_address_t));
-               __bt_service_get_parameters(in_param2, &profile, sizeof(int));
-               __bt_service_get_parameters(in_param3, &restricted, sizeof(int));
-
-               result = _bt_set_restrict_profile(&bd_addr, profile, restricted);
-               break;
-       }
-       case BT_GET_PROFILE_RESTRICTED: {
-               bluetooth_device_address_t bd_addr = { {0} };
-               int profile;
-               guint restricted_profile = 0;
-
-               __bt_service_get_parameters(in_param1, &bd_addr,
-                               sizeof(bluetooth_device_address_t));
-               __bt_service_get_parameters(in_param2, &profile, sizeof(int));
-
-               result = _bt_get_restrict_profile(&bd_addr, profile, &restricted_profile);
-               BT_DBG("Restricted %d", restricted_profile);
-               if (result == BLUETOOTH_ERROR_NONE) {
-                       g_array_append_vals(*out_param1, &restricted_profile,
-                                       sizeof(guint));
-               }
-
-               break;
-       }
        case BT_HID_CONNECT: {
                bluetooth_device_address_t address = { {0} };
 
@@ -3266,7 +3235,6 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_REMOVE_WHITE_LIST:
        case BT_CLEAR_WHITE_LIST:
        case BT_SET_MANUFACTURER_DATA:
-       case BT_SET_PROFILE_RESTRICTED:
 
        case BT_CANCEL_SEARCH_SERVICE:
        case BT_ENABLE_RSSI:
@@ -3275,6 +3243,8 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_RFCOMM_REJECT_CONNECTION:
        case BT_RFCOMM_LISTEN:
 
+       case BT_HID_ENABLE_BARCODE_FEATURE:
+
        case BT_AVRCP_CONTROL_GET_PROPERTY:
        case BT_AVRCP_GET_TRACK_INFO:
        case BT_AVRCP_TRANSPORT_SET_PROPERTY:
@@ -3376,7 +3346,6 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_GET_ADVERTISING_DATA:
        case BT_GET_SCAN_RESPONSE_DATA:
        case BT_IS_ADVERTISING:
-       case BT_GET_PROFILE_RESTRICTED:
        case BT_REGISTER_SCAN_FILTER:
        case BT_UNREGISTER_SCAN_FILTER:
        case BT_UNREGISTER_ALL_SCAN_FILTERS:
index fb44cea..5d00193 100644 (file)
@@ -1458,12 +1458,12 @@ int _bt_recover_adapter(void)
        BT_DBG("+");
 
        if (_bt_adapter_get_status() == BT_DEACTIVATING) {
-               BT_DBG("Disabling in progress");
+               BT_ERR("Disabling in progress");
                return BLUETOOTH_ERROR_IN_PROGRESS;
        }
 
        if (_bt_adapter_get_status() == BT_DEACTIVATED) {
-               BT_DBG("Already disabled");
+               BT_ERR("Already disabled");
                return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
        }
 
index 88db75a..6e39de7 100644 (file)
@@ -73,7 +73,7 @@
 
 extern guint nap_connected_device_count;
 
-static char *passkey_watcher = NULL;
+static char *passkey_watcher;
 
 #define G_VARIANT_UNREF(variant) \
        g_variant_unref(variant); \
@@ -482,6 +482,37 @@ static gboolean __a2dp_authorize_request_check(void)
        return _bt_is_headset_type_connected(BT_AUDIO_A2DP, NULL);
 }
 
+static gboolean __bt_agent_is_hid_device_connectable(void)
+{
+       GDBusProxy *proxy = NULL;
+       GVariant *reply = NULL;
+       GError *err = NULL;
+       gboolean connectable = FALSE;
+
+       proxy = _bt_gdbus_get_hid_agent_proxy();
+       retv_if(proxy == NULL, FALSE);
+
+       reply = g_dbus_proxy_call_sync(proxy, "IsHidConnectable", NULL,
+                               G_DBUS_CALL_FLAGS_NONE, 2000, NULL, &err);
+       if (reply == NULL) {
+               BT_ERR("Error returned in method call");
+               if (err != NULL) {
+                       BT_ERR("Error message = %s", err->message);
+                       g_error_free(err);
+               }
+               connectable = FALSE;
+       } else {
+               g_variant_get(reply, "(b)", &connectable);
+               g_variant_unref(reply);
+       }
+       g_object_unref(proxy);
+
+       BT_INFO("HID Device is %s",
+                       connectable ? "Connectable" : "Non-connectable");
+
+       return connectable;
+}
+
 static gboolean __authorize_request(GapAgentPrivate *agent, GDBusProxy *device,
                                                        const char *uuid)
 {
@@ -512,12 +543,22 @@ static gboolean __authorize_request(GapAgentPrivate *agent, GDBusProxy *device,
        }
        /* Check completed */
 
+       if (!strcasecmp(uuid, HID_UUID)) {
+               gboolean is_connectable = __bt_agent_is_hid_device_connectable();
+               BT_DBG("Automatically %s authorization for HID",
+                       is_connectable ? "accept" : "reject");
+               if (is_connectable == TRUE)
+                       gap_agent_reply_authorize(agent, GAP_AGENT_ACCEPT, NULL);
+               else
+                       gap_agent_reply_authorize(agent, GAP_AGENT_REJECT, NULL);
+               goto done;
+       }
+
        if (!strcasecmp(uuid, HFP_AUDIO_GATEWAY_UUID) ||
             !strcasecmp(uuid, HSP_AUDIO_GATEWAY_UUID) ||
             !strcasecmp(uuid, HFP_HS_UUID) ||
             !strcasecmp(uuid, HSP_HS_UUID) ||
             !strcasecmp(uuid, A2DP_UUID) ||
-            !strcasecmp(uuid, HID_UUID) ||
             !strcasecmp(uuid, HID_DEVICE_UUID) ||
             !strcasecmp(uuid, SAP_UUID_OLD) ||
             !strcasecmp(uuid, SAP_UUID_NEW) ||
index 1cadaab..e611731 100644 (file)
@@ -728,8 +728,8 @@ int _bt_audio_connect(int request_id, int type,
        char *uuid = NULL;
        int value = BLUETOOTH_ERROR_NONE;
        bt_audio_function_data_t *func_data;
-       guint hfp_hs_restricted = 0x0; /* set default "allowed" */
-       guint a2dp_restricted = 0x0;
+       guint hfp_hs_trusted = TRUE; /* set default "allowed" */
+       guint a2dp_trusted = TRUE;
 
        BT_CHECK_PARAMETER(device_address, return);
 
@@ -747,11 +747,11 @@ int _bt_audio_connect(int request_id, int type,
        func_data->type = type;
        func_data->pending = BT_PENDING_NONE;
 
-       result = _bt_get_restrict_profile(device_address, RESTRICTED_PROFILE_HFP_HS, &hfp_hs_restricted);
+       result = _bt_get_trust_profile(device_address, TRUSTED_PROFILE_HFP_HF, &hfp_hs_trusted);
        if (result != BLUETOOTH_ERROR_NONE)
                BT_ERR("Can't get hfp_hs restriction info");
 
-       result = _bt_get_restrict_profile(device_address, RESTRICTED_PROFILE_A2DP, &a2dp_restricted);
+       result = _bt_get_trust_profile(device_address, TRUSTED_PROFILE_A2DP, &a2dp_trusted);
        if (result != BLUETOOTH_ERROR_NONE)
                BT_ERR("Can't get a2dp restriction info");
 
@@ -769,7 +769,7 @@ int _bt_audio_connect(int request_id, int type,
                uuid = A2DP_SOURCE_UUID;
                break;
        case BT_AUDIO_ALL:
-               if ((hfp_hs_restricted == 0x0) && (a2dp_restricted == 0x0)) { /* in case of both profiles are not restricted */
+               if ((hfp_hs_trusted == TRUE) && (a2dp_trusted == TRUE)) { /* in case of both profiles are not restricted */
                        if (__bt_device_support_uuid(address, BT_AUDIO_HSP)) {
                                uuid = HFP_HS_UUID;
                                func_data->pending = BT_PENDING_CONNECT;
@@ -782,11 +782,11 @@ int _bt_audio_connect(int request_id, int type,
                                result = BLUETOOTH_ERROR_SERVICE_NOT_FOUND;
                                goto fail;
                        }
-               } else if ((hfp_hs_restricted == 0x1) && (a2dp_restricted == 0x1)) { /* in case of both profiles are restricted */
+               } else if ((hfp_hs_trusted == FALSE) && (a2dp_trusted == FALSE)) { /* in case of both profiles are restricted */
                        BT_ERR("All profiles are restricted");
                        result = BLUETOOTH_ERROR_INTERNAL;
                        goto fail;
-               } else if (a2dp_restricted == 0x01) { /* in case of a2dp is restricted, only connection for hfp_hs */
+               } else if (a2dp_trusted == FALSE) { /* in case of a2dp is restricted, only connection for hfp_hs */
                        if (__bt_device_support_uuid(address, BT_AUDIO_HSP)) {
                                uuid = HFP_HS_UUID;
                                type = BT_AUDIO_HSP;
@@ -795,7 +795,7 @@ int _bt_audio_connect(int request_id, int type,
                                result = BLUETOOTH_ERROR_SERVICE_NOT_FOUND;
                                goto fail;
                        }
-               } else if (hfp_hs_restricted == 0x01) { /* in case of hfp_hs is restricted, only connection for a2dp */
+               } else if (hfp_hs_trusted == FALSE) { /* in case of hfp_hs is restricted, only connection for a2dp */
                        if (__bt_device_support_uuid(address, BT_AUDIO_A2DP)) {
                                uuid = A2DP_SINK_UUID;
                                type = BT_AUDIO_A2DP;
index 32f8ce8..75c6c1d 100644 (file)
@@ -403,6 +403,29 @@ void _bt_deinit_proxys(void)
        }
 }
 
+GDBusProxy *_bt_gdbus_get_hid_agent_proxy(void)
+{
+       GDBusConnection *conn;
+       GDBusProxy *proxy;
+       GError *err = NULL;
+
+       conn = _bt_gdbus_get_system_gconn();
+       retv_if(conn == NULL, NULL);
+
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE, NULL,
+                                       BT_HID_SERVICE_NAME, BT_HID_AGENT_OBJECT_PATH,
+                                       BT_HID_SERVICE_INTERFACE, NULL, &err);
+       if (proxy == NULL) {
+               if (err != NULL) {
+                       ERR("Unable to create proxy: %s", err->message);
+                       g_clear_error(&err);
+               }
+               return NULL;
+       }
+
+       return proxy;
+}
+
 void _bt_convert_device_path_to_address(const char *device_path,
                                                char *device_address)
 {
@@ -1093,8 +1116,6 @@ const char *_bt_convert_service_function_to_string(int function)
                {BT_UPDATE_LE_CONNECTION_MODE, "BT_UPDATE_LE_CONNECTION_MODE"},
                {BT_SET_PROFILE_TRUSTED, "BT_SET_PROFILE_TRUSTED"},
                {BT_GET_PROFILE_TRUSTED, "BT_GET_PROFILE_TRUSTED"},
-               {BT_SET_PROFILE_RESTRICTED, "BT_SET_PROFILE_RESTRICTED"},
-               {BT_GET_PROFILE_RESTRICTED, "BT_GET_PROFILE_RESTRICTED"},
                {BT_HID_CONNECT, "BT_HID_CONNECT"},
                {BT_HID_DISCONNECT, "BT_HID_DISCONNECT"},
                {BT_HID_DEVICE_ACTIVATE, "BT_HID_DEVICE_ACTIVATE"},
index e9ce2f1..d2f939c 100644 (file)
@@ -66,6 +66,9 @@
 #define BT_LE_CONN_PARAM_LOW_POWER_SLAVE_LATENCY       2       /* event */
 
 #define PROFILE_SUPPORTED 0x3 /* This corresponds to binary 0b11*/
+#define PROFILE_TRUSTED 0x2 /* This corresponds to binary 0b10*/
+#define PROFILE_BLOCKED 0x1 /* This corresponds to binary 0b01*/
+#define PROFILE_SHOW_AUTH 0x0 /* This corresponds to binary 0b00*/
 
 typedef struct {
        int req_id;
@@ -467,20 +470,70 @@ bt_remote_dev_info_t *_bt_get_remote_device_info_by_object_path(
        return dev_info;
 }
 
-char *_bt_get_bonded_device_name(char *address)
+char *_bt_get_device_name(const char *bdaddress)
 {
-       bluetooth_device_address_t device_address = { {0} };
-       bluetooth_device_info_t dev_info;
+       char *device_path = NULL;
+       const gchar *name = NULL;
+       gchar *dev_name = NULL;
+       gsize name_len = 0;
+       GVariant *result = NULL;
+       GError *err = NULL;
+       GDBusProxy *device_proxy;
+       GDBusConnection *conn;
 
-       retv_if(address == NULL, strdup(""));
+       retv_if(bdaddress == NULL, NULL);
 
-       _bt_convert_addr_string_to_type(device_address.addr, address);
+       device_path = _bt_get_device_object_path((char *)bdaddress);
+       retv_if(device_path == NULL, NULL);
 
-       memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
+       conn = _bt_gdbus_get_system_gconn();
+       retv_if(conn == NULL, NULL);
+       INFO_SECURE("Device_path %s", device_path);
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                               NULL, BT_BLUEZ_NAME, device_path,
+                               BT_PROPERTIES_INTERFACE, NULL, &err);
+
+       g_free(device_path);
+       retv_if(device_proxy == NULL, NULL);
+
+       result = g_dbus_proxy_call_sync(device_proxy, "Get",
+                       g_variant_new("(ss)", BT_DEVICE_INTERFACE, "Alias"),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+       if (err) {
+               BT_ERR("DBus Error : %s", err->message);
+               g_clear_error(&err);
+       } else {
+               GVariant *value;
+               g_variant_get(result, "(v)", &value);
+               name = g_variant_get_string(value, &name_len);
+               INFO_SECURE("Alias Name [%s]", name);
+               if (name_len)
+                       dev_name = g_strdup(name);
+               g_variant_unref(value);
+               g_variant_unref(result);
+       }
 
-       _bt_get_bonded_device_info(&device_address, &dev_info);
+       if (name_len == 0) {
+               GVariant *value;
+               result = g_dbus_proxy_call_sync(device_proxy, "Get",
+                       g_variant_new("(ss)", BT_DEVICE_INTERFACE, "Name"),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+               if (err) {
+                       ERR("DBus Error : %s", err->message);
+                       g_clear_error(&err);
+               } else {
+                       g_variant_get(result, "(v)", &value);
+                       name = g_variant_get_string(value, &name_len);
+                       INFO_SECURE("Name = %s", name);
+                       if (name_len)
+                               dev_name = g_strdup(name);
+                       g_variant_unref(value);
+                       g_variant_unref(result);
+               }
+       }
 
-       return g_strdup(dev_info.device_name.name);
+       g_object_unref(device_proxy);
+       return dev_name;
 }
 
 static gboolean __ignore_auto_pairing_request(const char *address)
@@ -1537,7 +1590,6 @@ int _bt_is_gatt_connected(bluetooth_device_address_t *device_address,
        GDBusProxy *device_proxy;
        GError *error = NULL;
        GVariant *value;
-       GVariant *tmp_value;
        GDBusConnection *conn;
        GVariant *result = NULL;
        int ret = BLUETOOTH_ERROR_NONE;
@@ -1558,8 +1610,9 @@ int _bt_is_gatt_connected(bluetooth_device_address_t *device_address,
        g_free(object_path);
        retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       result = g_dbus_proxy_call_sync(device_proxy, "GetAll",
-                       g_variant_new("(s)", BT_DEVICE_INTERFACE),
+       result = g_dbus_proxy_call_sync(device_proxy, "Get",
+                       g_variant_new("(ss)", BT_DEVICE_INTERFACE,
+                               "GattConnected"),
                        G_DBUS_CALL_FLAGS_NONE,
                        -1,
                        NULL,
@@ -1573,21 +1626,12 @@ int _bt_is_gatt_connected(bluetooth_device_address_t *device_address,
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       g_variant_get(result , "(@a{sv})", &value);
+       g_variant_get(result, "(v)", &value);
+       *is_connected = g_variant_get_boolean(value);
        g_variant_unref(result);
 
-       tmp_value = g_variant_lookup_value(value, "GattConnected", G_VARIANT_TYPE_BOOLEAN);
-       if (tmp_value == NULL) {
-               g_object_unref(device_proxy);
-               g_variant_unref(value);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       *is_connected = g_variant_get_boolean(tmp_value);
-
        BT_DBG("gatt is connected : %d", *is_connected);
 
-       g_variant_unref(tmp_value);
        g_variant_unref(value);
        g_object_unref(device_proxy);
 
@@ -1741,7 +1785,6 @@ int _bt_get_connected_link(bluetooth_device_address_t *device_address,
        GDBusProxy *device_proxy;
        GError *error = NULL;
        GDBusConnection *conn;
-       GVariant *tmp_value = NULL;
        GVariant *value = NULL;
        GVariant *result = NULL;
 
@@ -1764,33 +1807,24 @@ int _bt_get_connected_link(bluetooth_device_address_t *device_address,
                return BLUETOOTH_ERROR_NONE;
        }
 
-       result = g_dbus_proxy_call_sync(device_proxy, "GetAll",
-                                       g_variant_new("(s)", BT_DEVICE_INTERFACE),
-                                       G_DBUS_CALL_FLAGS_NONE,
-                                       -1,
-                                       NULL,
-                                       &error);
+       result = g_dbus_proxy_call_sync(device_proxy, "Get",
+                       g_variant_new("(ss)", BT_DEVICE_INTERFACE, "Connected"),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
 
        if (error != NULL) {
                BT_ERR("Error occured in Proxy call [%s]\n", error->message);
                g_error_free(error);
                g_object_unref(device_proxy);
                return BLUETOOTH_ERROR_INTERNAL;
+       } else {
+               g_variant_get(result, "(v)", &value);
+               *connected = g_variant_get_byte(value);
+               g_variant_unref(value);
+               g_variant_unref(result);
        }
 
-       g_variant_get(result , "(@a{sv})", &value);
-       g_variant_unref(result);
-
-       tmp_value = g_variant_lookup_value(value, "Connected", G_VARIANT_TYPE_BYTE);
-       if (tmp_value != NULL) {
-               *connected = g_variant_get_byte(tmp_value);
-               g_variant_unref(tmp_value);
-               g_object_unref(device_proxy);
-               return BLUETOOTH_ERROR_NONE;
-       } else  {
-               BT_ERR("g_variant value is NULL");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
+       g_object_unref(device_proxy);
+       return BLUETOOTH_ERROR_NONE;
 }
 
 static void __le_connection_req_cb(GDBusProxy *proxy, GAsyncResult *res,
@@ -2880,7 +2914,7 @@ int _bt_get_le_connection_parameter(bluetooth_le_connection_mode_t mode,
 int _bt_get_trusted_profile_from_flag(bluetooth_trusted_profile_t profile,
                guint trusted_profile_flag, guint *trusted)
 {
-       int trust_profile;
+       int trust_profile = FALSE;
        *trusted = FALSE;
 
        switch (profile) {
@@ -2902,6 +2936,24 @@ int _bt_get_trusted_profile_from_flag(bluetooth_trusted_profile_t profile,
                else
                        return BLUETOOTH_ERROR_NOT_SUPPORT;
                break;
+       case TRUSTED_PROFILE_HFP_HF: {
+               guint flag = (trusted_profile_flag & (PROFILE_SUPPORTED << 6)) >> 6;
+               BT_DBG("trusted_profile_flag %x", trusted_profile_flag);
+               if (flag != PROFILE_BLOCKED)
+                       trust_profile = TRUE;
+               else
+                       *trusted = FALSE;
+               break;
+       }
+       case TRUSTED_PROFILE_A2DP: {
+               guint flag = (trusted_profile_flag & (PROFILE_SUPPORTED << 8)) >> 8;
+               BT_DBG("trusted_profile_flag %x", trusted_profile_flag);
+               if (flag != PROFILE_BLOCKED)
+                       trust_profile = TRUE;
+               else
+                       *trusted = FALSE;
+               break;
+       }
        case TRUSTED_PROFILE_ALL: /* Return Flag for All profiles*/
                *trusted = trusted_profile_flag;
                return BLUETOOTH_ERROR_NONE;
@@ -2915,29 +2967,6 @@ int _bt_get_trusted_profile_from_flag(bluetooth_trusted_profile_t profile,
        return BLUETOOTH_ERROR_NONE;
 }
 
-int _bt_get_restricted_profile_from_flag(bluetooth_restricted_profile_t profile,
-               guint restricted_profile_flag, guint *restricted)
-{
-       int restrict_profile;
-       *restricted = FALSE;
-
-       switch (profile) {
-       case RESTRICTED_PROFILE_HFP_HS:
-                       restrict_profile = restricted_profile_flag & (1 << 0);
-               break;
-       case RESTRICTED_PROFILE_A2DP:
-                       restrict_profile = restricted_profile_flag & (1 << 2);
-               break;
-       default:
-               return BLUETOOTH_ERROR_NOT_SUPPORT;
-       }
-
-       if (restrict_profile)
-               *restricted = TRUE;
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
 char *_bt_get_trusted_profile_uuid(bluetooth_trusted_profile_t profile)
 {
        switch (profile) {
@@ -2947,20 +2976,12 @@ char *_bt_get_trusted_profile_uuid(bluetooth_trusted_profile_t profile)
                return g_strdup("00001134-0000-1000-8000-00805f9b34fb");
        case TRUSTED_PROFILE_SAP:
                return g_strdup("0000112D-0000-1000-8000-00805f9b34fb");
-       case TRUSTED_PROFILE_ALL:
-               return NULL;
-       }
-
-       return NULL;
-}
-
-char *_bt_get_restricted_profile_uuid(bluetooth_restricted_profile_t profile)
-{
-       switch (profile) {
-       case RESTRICTED_PROFILE_HFP_HS:
+       case TRUSTED_PROFILE_HFP_HF:
                return g_strdup("0000111e-0000-1000-8000-00805f9b34fb");
-       case RESTRICTED_PROFILE_A2DP:
+       case TRUSTED_PROFILE_A2DP:
                return g_strdup("0000110b-0000-1000-8000-00805f9b34fb");
+       case TRUSTED_PROFILE_ALL:
+               return NULL;
        }
 
        return NULL;
@@ -3104,132 +3125,6 @@ int _bt_get_trust_profile(bluetooth_device_address_t *bd_addr,
        return ret;
 }
 
-int _bt_set_restrict_profile(bluetooth_device_address_t *bd_addr,
-               bluetooth_restricted_profile_t profile, gboolean restricted)
-{
-       int ret = BLUETOOTH_ERROR_NONE;
-       GDBusConnection *conn;
-       GDBusProxy *proxy;
-       GError *error = NULL;
-       char *device_path = NULL;
-       char *uuid = NULL;
-       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
-       GVariant *reply;
-
-       BT_CHECK_PARAMETER(bd_addr, return);
-       BT_DBG("BD Address [%2.2X %2.2X %2.2X %2.2X %2.2X %2.2X] profile[%d] restricted[%d]",
-                       bd_addr->addr[0], bd_addr->addr[1],
-                       bd_addr->addr[2], bd_addr->addr[3],
-                       bd_addr->addr[4], bd_addr->addr[5],
-                       profile, restricted);
-
-       conn = _bt_gdbus_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       _bt_convert_addr_type_to_string(address, bd_addr->addr);
-
-       device_path = _bt_get_device_object_path(address);
-       retv_if(device_path == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
-                       NULL, BT_BLUEZ_NAME, device_path,
-                       BT_DEVICE_INTERFACE, NULL, NULL);
-
-       g_free(device_path);
-       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       uuid = _bt_get_restricted_profile_uuid(profile);
-       if (uuid == NULL) {
-               g_object_unref(proxy);
-               return BLUETOOTH_ERROR_NOT_SUPPORT;
-       }
-
-       reply = g_dbus_proxy_call_sync(proxy, "SetRestrictedProfile",
-                       g_variant_new("(sb)", uuid, restricted),
-                       G_DBUS_CALL_FLAGS_NONE, -1,
-                       NULL, &error);
-       g_object_unref(proxy);
-
-       if (reply == NULL) {
-               BT_ERR("Failed to Set Profile Restricted");
-               ret = BLUETOOTH_ERROR_INTERNAL;
-               if (error) {
-                       BT_ERR("Error %s[%s]", error->message, address);
-                       g_error_free(error);
-               }
-               goto finish;
-       }
-       g_variant_unref(reply);
-
-finish:
-       g_free(uuid);
-       return ret;
-}
-
-int _bt_get_restrict_profile(bluetooth_device_address_t *bd_addr,
-               bluetooth_restricted_profile_t profile, guint *restricted)
-{
-       int ret = BLUETOOTH_ERROR_NONE;
-       GDBusConnection *conn;
-       GDBusProxy *proxy;
-       GError *error = NULL;
-       char *device_path = NULL;
-       guint restricted_profile_flag;
-       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
-       GVariant *reply;
-
-       BT_CHECK_PARAMETER(bd_addr, return);
-       BT_DBG("BD Address [%2.2X %2.2X %2.2X %2.2X %2.2X %2.2X] profile[%d] restricted[%d]",
-                       bd_addr->addr[0], bd_addr->addr[1],
-                       bd_addr->addr[2], bd_addr->addr[3],
-                       bd_addr->addr[4], bd_addr->addr[5],
-                       profile, *restricted);
-
-       conn = _bt_gdbus_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       _bt_convert_addr_type_to_string(address, bd_addr->addr);
-
-       device_path = _bt_get_device_object_path(address);
-       retv_if(device_path == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
-                       NULL, BT_BLUEZ_NAME, device_path,
-                       BT_PROPERTIES_INTERFACE, NULL, NULL);
-
-       g_free(device_path);
-       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       reply = g_dbus_proxy_call_sync(proxy, "Get",
-                       g_variant_new("(ss)", BT_DEVICE_INTERFACE, "RestrictedProfiles"),
-                       G_DBUS_CALL_FLAGS_NONE, -1,
-                       NULL, &error);
-       g_object_unref(proxy);
-
-       if (reply == NULL) {
-               BT_ERR("Failed to Get Profile Restricted");
-               ret = BLUETOOTH_ERROR_INTERNAL;
-               if (error) {
-                       BT_ERR("Error %s[%s]", error->message, address);
-                       g_error_free(error);
-               }
-               *restricted = 0;
-       } else {
-               GVariant *temp;
-               g_variant_get(reply, "(v)", &temp);
-               restricted_profile_flag = g_variant_get_uint32(temp);
-               BT_DBG("Restricted_FLAG %d", restricted_profile_flag);
-
-               ret = _bt_get_restricted_profile_from_flag(profile,
-                               restricted_profile_flag, restricted);
-               g_variant_unref(temp);
-               g_variant_unref(reply);
-       }
-
-       BT_DBG("TRUST %d", *restricted);
-       return ret;
-}
-
 static void __bt_request_att_mtu_device_cb(GDBusProxy *proxy, GAsyncResult *res,
                                        gpointer user_data)
 {
@@ -3382,10 +3277,8 @@ int _bt_get_att_mtu(bluetooth_device_address_t *device_address,
        GDBusProxy *device_proxy;
        GError *error = NULL;
        GVariant *value;
-       GVariant *tmp_value;
        GDBusConnection *conn;
        GVariant *result = NULL;
-       int ret = BLUETOOTH_ERROR_NONE;
 
        BT_CHECK_PARAMETER(device_address, return);
 
@@ -3403,40 +3296,24 @@ int _bt_get_att_mtu(bluetooth_device_address_t *device_address,
        g_free(object_path);
        retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       result = g_dbus_proxy_call_sync(device_proxy, "GetAll",
-                       g_variant_new("(s)", BT_DEVICE_INTERFACE),
-                       G_DBUS_CALL_FLAGS_NONE,
-                       -1,
-                       NULL,
-                       &error);
-       if (result == NULL) {
-               if (error != NULL) {
-                       BT_ERR("Error occured in Proxy call [%s]\n", error->message);
-                       g_error_free(error);
-               }
+       result = g_dbus_proxy_call_sync(device_proxy, "Get",
+                       g_variant_new("(ss)", BT_DEVICE_INTERFACE, "AttMtu"),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+       if (error) {
+               ERR("DBus Error : %s", error->message);
+               g_clear_error(&error);
                g_object_unref(device_proxy);
                return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       g_variant_get(result , "(@a{sv})", &value);
-       g_variant_unref(result);
-
-       tmp_value = g_variant_lookup_value(value, "AttMtu", G_VARIANT_TYPE_UINT16);
-       if (tmp_value == NULL) {
-               g_object_unref(device_proxy);
+       } else {
+               g_variant_get(result, "(v)", &value);
+               *mtu = g_variant_get_uint16(value);
+               BT_DBG("ATT MTU : %d", *mtu);
                g_variant_unref(value);
-               return BLUETOOTH_ERROR_INTERNAL;
+               g_variant_unref(result);
        }
 
-       *mtu = g_variant_get_uint16(tmp_value);
-
-       BT_DBG("ATT MTU : %d", *mtu);
-
-       g_variant_unref(tmp_value);
-       g_variant_unref(value);
        g_object_unref(device_proxy);
-
-       return ret;
+       return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_get_device_ida(bluetooth_device_address_t *device_address,
index d218d34..62aa9d4 100644 (file)
@@ -184,7 +184,7 @@ int _bt_dpm_get_bluetooth_devices_from_blacklist(GArray **out_param1)
 {
        int ret = BLUETOOTH_ERROR_INTERNAL;
        int allow_bt = DPM_BT_ERROR;
-       bt_dpm_device_list_t device_list;
+       bt_dpm_device_list_t device_list = { 0, };
        GSList *list = policy_table[DPM_POLICY_BLUETOOTH_DEVICES_BLACKLIST].list;
        int i = 0;
 
@@ -238,7 +238,7 @@ int _bt_dpm_get_bluetooth_devices_from_whitelist(GArray **out_param1)
 {
        dpm_result_t ret = BLUETOOTH_ERROR_INTERNAL;
        int allow_bt = DPM_BT_ERROR;
-       bt_dpm_device_list_t device_list;
+       bt_dpm_device_list_t device_list = { 0, };
        GSList *list = policy_table[DPM_POLICY_BLUETOOTH_DEVICES_WHITELIST].list;
        int i = 0;
 
index a90803b..bb453f0 100644 (file)
@@ -1829,7 +1829,7 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
 
                _bt_convert_device_path_to_address(path, address);
-               dev_name = _bt_get_bonded_device_name(address);
+               dev_name = _bt_get_device_name(address);
 
                _bt_convert_addr_string_to_secure_string(secure_address, address);
                BT_INFO("Address : %s Type : %d", secure_address, addr_type);
@@ -1945,17 +1945,17 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                        gboolean connected;
 #endif
                        bt_headset_wait_t *wait_list;
-                       guint restricted = 0x0;
+                       guint trusted = TRUE;
 
                        __bt_set_device_values(TRUE,
                                VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED);
 
                        __bt_connection_manager_set_state(address, event);
 
-                       _bt_get_restrict_profile(&bd_addr, RESTRICTED_PROFILE_HFP_HS, &restricted);
+                       _bt_get_trust_profile(&bd_addr, TRUSTED_PROFILE_HFP_HF, &trusted);
 
                        if (_bt_headset_get_local_connection() == FALSE) {
-                               if (restricted == 0x0) /* not restricted*/
+                               if (trusted == TRUE) /* not restricted*/
                                        _bt_start_timer_for_connection(address, BT_AUDIO_HSP);
                        } else {
                                /* Connection Started from local device therefore no need to
@@ -2251,6 +2251,8 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                param = g_variant_new("(iss)", result, address, ifname);
                ipsp_param = g_variant_new("(ss)", ifname, address);
 
+               g_free(ifname);
+
                /* Set Ipv6 Addr */
                GDBusProxy *ipsp_proxy;
                if (connected) {
@@ -2259,6 +2261,8 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                        if (ipsp_proxy == NULL) {
                                BT_ERR("can not get ipsp proxy");
                                g_free(address);
+                               g_variant_unref(param);
+                               g_variant_unref(ipsp_param);
                                return;
                        }
 
@@ -2266,11 +2270,13 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                                        ipsp_param, G_DBUS_CALL_FLAGS_NONE,
                                        -1, NULL, NULL, NULL);
                } else {
+                       g_variant_unref(ipsp_param);
                        BT_DBG("IPSP disconnected");
                        ipsp_proxy = _bt_get_ipsp_proxy();
                        if (ipsp_proxy == NULL) {
                                BT_ERR("can not get ipsp proxy");
                                g_free(address);
+                               g_variant_unref(param);
                                return;
                        }
 
@@ -2280,9 +2286,7 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                }
 
                /* Send event to application */
-               _bt_send_event(BT_DEVICE_EVENT,
-                                               event,
-                                               param);
+               _bt_send_event(BT_DEVICE_EVENT, event, param);
                g_free(address);
        } else if (strcasecmp(member, "AttMtuChanged") == 0) {
                int result = BLUETOOTH_ERROR_NONE;
@@ -2334,7 +2338,7 @@ void __bt_set_audio_values(gboolean connected, char *address)
 
        /*  Set the headset name */
        if (connected == TRUE)
-               name = _bt_get_bonded_device_name(address);
+               name = _bt_get_device_name(address);
        else
                name = g_strdup("");
 
@@ -2386,7 +2390,7 @@ void _bt_handle_headset_event(GVariant *msg, const char *path)
                int event = BLUETOOTH_EVENT_NONE;
                bt_headset_wait_t *wait_list;
                char *address;
-               guint restricted = 0x0;
+               guint trusted = TRUE;
                g_variant_get(value, "b", &property_flag);
 
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
@@ -2396,10 +2400,10 @@ void _bt_handle_headset_event(GVariant *msg, const char *path)
 
                if (property_flag == TRUE) {
                        event = BLUETOOTH_EVENT_AG_CONNECTED;
-                       _bt_get_restrict_profile(&bd_addr, RESTRICTED_PROFILE_A2DP, &restricted);
+                       _bt_get_trust_profile(&bd_addr, TRUSTED_PROFILE_A2DP, &trusted);
 
                        if (_bt_headset_get_local_connection() == FALSE) {
-                               if (restricted == 0x0) /* not restricted*/
+                               if (trusted == TRUE) /* not restricted*/
                                        _bt_start_timer_for_connection(address, BT_AUDIO_A2DP);
                        } else
                                _bt_headset_set_local_connection(FALSE);
index a747ad5..dccf480 100644 (file)
@@ -1114,8 +1114,8 @@ void _gap_agent_setup_dbus(GapAgentPrivate *agent, GAP_AGENT_FUNC_CB *func_cb,
                priv->busname = NULL;
        } else {
                priv->busname = g_strdup(g_dbus_proxy_get_name(proxy));
-               g_object_unref(proxy);
                BT_DBG("Busname: %s", priv->busname);
+               g_object_unref(proxy);
        }
 
 }
index 60fe60d..2587a15 100644 (file)
@@ -235,7 +235,7 @@ int _bt_hid_disconnect(int request_id,
 
 int _bt_hid_enable_barcode_feature(void)
 {
-       if (vconf_set_int(BT_HID_BARCODE_SUPPORT, 1) != 0) {
+       if (vconf_set_bool(BT_HID_BARCODE_SUPPORT, true) != 0) {
                BT_ERR("Set vconf failed\n");
                return BLUETOOTH_ERROR_INTERNAL;
        }
index 0939bf0..3139075 100644 (file)
@@ -97,12 +97,11 @@ int _bt_create_session_sync(const char* address, char** session_id)
                                                BT_OBEX_CLIENT_PATH,
                                                BT_OBEX_CLIENT_INTERFACE,
                                                NULL, &err);
-       if (err) {
+       if (session_proxy == NULL && err) {
                BT_ERR("Unable to create session_proxy: %s", err->message);
                g_clear_error(&err);
                return BLUETOOTH_ERROR_INTERNAL;
        }
-       retv_if(session_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        GVariantBuilder* builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
        g_variant_builder_add(builder, "{sv}", "Target",
@@ -113,6 +112,9 @@ int _bt_create_session_sync(const char* address, char** session_id)
 
        GVariant *value = g_dbus_proxy_call_sync(session_proxy, "CreateSession", param,
                        G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+
+       g_object_unref(session_proxy);
+
        if (err != NULL) {
                BT_ERR("Could not create session: %s\n", err->message);
                g_error_free(err);
@@ -149,17 +151,19 @@ int _bt_destroy_session_sync(const char* session_id)
                                                BT_OBEX_CLIENT_PATH,
                                                BT_OBEX_CLIENT_INTERFACE,
                                                NULL, &err);
-       if (err) {
+       if (session_proxy == NULL && err) {
                BT_ERR("Unable to create session_proxy: %s", err->message);
                g_clear_error(&err);
                return BLUETOOTH_ERROR_INTERNAL;
        }
-       retv_if(session_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        GVariant *param = g_variant_new("(o)", session_id);
 
        g_dbus_proxy_call_sync(session_proxy, "RemoveSession", param,
                        G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+
+       g_object_unref(session_proxy);
+
        if (err != NULL) {
                BT_ERR("Could not remove session: %s\n", err->message);
                g_error_free(err);
@@ -577,10 +581,8 @@ static void __bt_push_message_cb(GDBusProxy *proxy,
                g_clear_error(&error);
        }
 
-       if (value) {
+       if (value)
                g_variant_get(value, "(oa{sv})", &transfer_object_path, &iter);
-               g_variant_unref(value);
-       }
 
        BT_DBG("transfer object path: [%s]", transfer_object_path);
 
@@ -684,10 +686,8 @@ static void __bt_get_message_cb(GDBusProxy *proxy,
                g_clear_error(&error);
        }
 
-       if (value) {
+       if (value)
                g_variant_get(value, "(oa{sv})", &transfer_object_path, &iter);
-               g_variant_unref(value);
-       }
 
        BT_DBG("transfer object path: [%s]", transfer_object_path);
 
index af30019..6b0a7ff 100644 (file)
@@ -247,8 +247,9 @@ void _bt_obex_check_pending_transfer(const char *address)
 static char *__bt_get_remote_device_name(const char *bdaddress)
 {
        char *device_path = NULL;
-       char *name = NULL;
-       GVariant *value;
+       const gchar *name = NULL;
+       gchar *dev_name = NULL;
+       gsize name_len = 0;
        GVariant *result = NULL;
        GError *err = NULL;
        GDBusProxy *device_proxy;
@@ -271,42 +272,44 @@ static char *__bt_get_remote_device_name(const char *bdaddress)
        g_free(device_path);
        retv_if(device_proxy == NULL, NULL);
 
-       result = g_dbus_proxy_call_sync(device_proxy, "GetAll",
-                       g_variant_new("(s)", BT_DEVICE_INTERFACE),
-                       G_DBUS_CALL_FLAGS_NONE,
-                       DBUS_TIMEOUT, NULL,
-                       &err);
+       result = g_dbus_proxy_call_sync(device_proxy, "Get",
+                       g_variant_new("(ss)", BT_DEVICE_INTERFACE, "Alias"),
+                       G_DBUS_CALL_FLAGS_NONE, DBUS_TIMEOUT, NULL, &err);
        if (err) {
                BT_ERR("DBus Error : %s", err->message);
                g_clear_error(&err);
-               return NULL;
-       }
-       if (result == NULL) {
-               BT_ERR("g_dbus_proxy_call_sync function return NULL");
-               return NULL;
+       } else {
+               GVariant *value;
+               g_variant_get(result, "(v)", &value);
+               name = g_variant_get_string(value, &name_len);
+               INFO_SECURE("Alias Name [%s]", name);
+               if (name_len)
+                       dev_name = g_strdup(name);
+               g_variant_unref(value);
+               g_variant_unref(result);
        }
-       g_variant_get(result, "(@a{sv})", &value);
 
-       if (value) {
-               GVariant *temp_value = g_variant_lookup_value(value, "Alias",
-                       G_VARIANT_TYPE_STRING);
-               g_variant_get(temp_value, "s", &name);
-               if (temp_value)
-                       g_variant_unref(temp_value);
-
-               if (name != NULL)
-                       DBG_SECURE("Alias Name [%s]", name);
-               else {
-                       temp_value = g_variant_lookup_value(value, "Name", G_VARIANT_TYPE_STRING);
-                       g_variant_get(temp_value, "s", &name);
-                       if (temp_value)
-                               g_variant_unref(temp_value);
-                       DBG_SECURE("Name = %s", name);
+       if (name_len == 0) {
+               result = g_dbus_proxy_call_sync(device_proxy, "Get",
+                       g_variant_new("(ss)", BT_DEVICE_INTERFACE, "Name"),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+               if (err) {
+                       ERR("DBus Error : %s", err->message);
+                       g_clear_error(&err);
+               } else {
+                       GVariant *value;
+                       g_variant_get(result, "(v)", &value);
+                       name = g_variant_get_string(value, &name_len);
+                       INFO_SECURE("Name = %s", name);
+                       if (name_len)
+                               dev_name = g_strdup(name);
+                       g_variant_unref(value);
+                       g_variant_unref(result);
                }
        }
-       g_variant_unref(result);
+
        g_object_unref(device_proxy);
-       return name;
+       return dev_name;
 }
 
 static void __bt_get_remote_device_name_authinfo(const char *bdaddress,
@@ -416,7 +419,7 @@ static GDBusProxy *__bt_get_transfer_proxy(const char *transfer_path)
                                        BT_OBEX_TRANSFER_INTERFACE,
                                        NULL, &err);
 
-       if (err) {
+       if (proxy == NULL && err) {
                BT_ERR("Error : %s", err->message);
                g_clear_error(&err);
                return NULL;
@@ -438,7 +441,7 @@ static GDBusProxy *__bt_get_transfer_properties_proxy(const char *transfer_path)
                                        transfer_path,
                                        BT_PROPERTIES_INTERFACE,
                                        NULL, &err);
-       if (err) {
+       if (proxy == NULL && err) {
                BT_ERR("Error : %s", err->message);
                g_clear_error(&err);
                return NULL;
index fa9e27b..2a1b196 100644 (file)
@@ -933,7 +933,7 @@ int __bt_pbap_call_get_vcards_list(GDBusProxy *proxy, bt_pbap_data_t *pbap_data)
 
        g_free(folder);
        g_free(order_str);
-       g_hash_table_unref((GHashTable *)filters);
+
        /* In _bt_pbap_get_list(), path(type) is set to "nil", but current type is not null.
             The path should be reset here */
        selected_path.type = -1;
index b8b5c3d..b0c2c8a 100644 (file)
@@ -205,6 +205,9 @@ extern "C" {
 #define BT_NAME_OWNER_CHANGED "NameOwnerChanged"
 #define BT_PROPERTIES_CHANGED "PropertiesChanged"
 
+#define BT_HID_SERVICE_NAME "org.bluez.hid_agent"
+#define BT_HID_AGENT_OBJECT_PATH "/org/bluez/hid_agent"
+#define BT_HID_SERVICE_INTERFACE "org.tizen.HidApp"
 
 
 #define BT_SESSION_BASEPATH_SERVER "/org/bluez/obex/server"
@@ -389,6 +392,8 @@ char *_bt_get_adapter_path(void);
 
 void _bt_deinit_proxys(void);
 
+GDBusProxy *_bt_gdbus_get_hid_agent_proxy(void);
+
 void _bt_convert_device_path_to_address(const char *device_path,
                                                char *device_address);
 
index 477d055..4a07f0f 100644 (file)
@@ -76,7 +76,7 @@ bt_remote_dev_info_t *_bt_get_remote_device_info(char *address);
 
 bt_remote_dev_info_t *_bt_get_remote_device_info_by_object_path(const char *object_path);
 
-char *_bt_get_bonded_device_name(char *address);
+char *_bt_get_device_name(const char *address);
 
 gboolean _bt_is_bonding_device_address(const char *address);
 
@@ -123,12 +123,6 @@ int _bt_set_trust_profile(bluetooth_device_address_t *bd_addr,
 int _bt_get_trust_profile(bluetooth_device_address_t *bd_addr,
                bluetooth_trusted_profile_t profile, guint *trust);
 
-int _bt_set_restrict_profile(bluetooth_device_address_t *bd_addr,
-               bluetooth_restricted_profile_t profile, gboolean restricted);
-
-int _bt_get_restrict_profile(bluetooth_device_address_t *bd_addr,
-               bluetooth_restricted_profile_t profile, guint *restricted);
-
 bluetooth_trusted_profile_t _bt_get_trusted_profile_enum(const char *uuid);
 
 int _bt_connect_le_ipsp_device(const bluetooth_device_address_t *bd_addr);
index 99d6634..003563c 100644 (file)
@@ -1831,18 +1831,12 @@ typedef enum {
        TRUSTED_PROFILE_PBAP = 1,
        TRUSTED_PROFILE_MAP,
        TRUSTED_PROFILE_SAP,
+       TRUSTED_PROFILE_HFP_HF,
+       TRUSTED_PROFILE_A2DP,
        TRUSTED_PROFILE_ALL = 0xFFFFFFFF,
 } bluetooth_trusted_profile_t;
 
 /**
- * Restricted Profile types
- */
-typedef enum {
-       RESTRICTED_PROFILE_HFP_HS = 1,
-       RESTRICTED_PROFILE_A2DP,
-} bluetooth_restricted_profile_t;
-
-/**
  * Structure for LE data length change params
  */
 typedef struct {
@@ -2644,52 +2638,6 @@ int bluetooth_get_profile_trusted(
                int profile, int *trust);
 
 /**
- * @fn int bluetooth_set_profile_restricted(const bluetooth_device_address_t *device_address, int profile, int restricted)
- * @brief Sets a profile restricted connection for a device
- *
- * This function is used to Set a profile as restricted for a device
- *
- * This function is a synchronous call.
- *
- * @param[in]  device_address  a device address of remote bluetooth device
- * @param[in]  profile profile which is to be set as restricted[1-HFP_HS, 2-A2DP]
- * @param[in]  restricted      to set as restricted or not[1-restricted 0-permitted]
- *
- * @return     BLUETOOTH_ERROR_NONE - Success \n
- *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
- *             BLUETOOTH_ERROR_INVALID_PARAM - Bluetooth name parameter is incorrect \n
- *             BLUETOOTH_ERROR_INTERNAL - The dbus method call is fail \n
- *
- * @remark      None
- */
-int bluetooth_set_profile_restricted(
-               const bluetooth_device_address_t *device_address,
-               int profile, int restricted);
-
-/**
- * @fn int bluetooth_get_profile_restricted(const bluetooth_device_address_t *device_address, int profile, int *restricted)
- * @brief Gets a restricted connection state
- *
- * This function is used to Get a profile is restricted or not for a device
- *
- * This function is a synchronous call.
- *
- * @param[in]  device_address  a device address of remote bluetooth device
- * @param[in]  profile profile whose restricted status is needed[1-HFP_HS, 2-A2DP]
- * @param[out] restricted      profile is set as restricted or not[1-restricted 0-permitted]
- *
- * @return     BLUETOOTH_ERROR_NONE - Success \n
- *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
- *             BLUETOOTH_ERROR_INVALID_PARAM - Bluetooth name parameter is incorrect \n
- *             BLUETOOTH_ERROR_INTERNAL - The dbus method call is fail \n
- *
- * @remark      None
- */
-int bluetooth_get_profile_restricted(
-               const bluetooth_device_address_t *device_address,
-               int profile, int *restricted);
-
-/**
  * @fn int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t *discoverable_mode_ptr)
  * @brief Get the visibility mode
  *
index 1592689..ebed2f2 100644 (file)
@@ -210,8 +210,6 @@ typedef enum {
        BT_UPDATE_LE_CONNECTION_MODE,
        BT_SET_PROFILE_TRUSTED,
        BT_GET_PROFILE_TRUSTED,
-       BT_SET_PROFILE_RESTRICTED,
-       BT_GET_PROFILE_RESTRICTED,
        BT_HID_CONNECT = BT_FUNC_HID_BASE,
        BT_HID_DISCONNECT,
        BT_HID_DEVICE_ACTIVATE,