Apply latest changes in tizen branch 43/162543/1 tizen_next
authorDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 4 Dec 2017 07:03:43 +0000 (16:03 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 4 Dec 2017 07:04:41 +0000 (16:04 +0900)
-----------------------------------------------------------
commit 6b1b7c6441ff19fdf870866c431410387b552c38
Author: Seungyoun Ju <sy39.ju@samsung.com>
Date:   Wed Nov 29 18:02:07 2017 +0900

    Fix : Visibility timer is not cancelled when PSCAN off
-----------------------------------------------------------

Change-Id: I5714b1fd0a7cc12a6a44b67dfaf5698649514cdc
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
12 files changed:
bt-api/bt-common.c
bt-api/bt-event-handler.c
bt-api/bt-hid-device.c [changed mode: 0755->0644]
bt-api/bt-telephony.c
bt-api/include/bt-common.h [changed mode: 0755->0644]
bt-api/include/bt-event-handler.h [changed mode: 0755->0644]
bt-oal/bluez_hal/src/bt-hal-adapter-le.c
bt-oal/bluez_hal/src/bt-hal-event-receiver.c
bt-service-adaptation/services/adapter/bt-service-core-adapter.c
bt-service-adaptation/services/obex/bt-service-obex-event-receiver.c
include/bluetooth-api.h
packaging/bluetooth-frwk.spec

index 7d59c18..cbf31d5 100644 (file)
@@ -1501,8 +1501,6 @@ int _bt_discover_service_uuids(char *address, char *remote_uuid)
                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);
        }
 
        if (uuid_value) {
@@ -1524,6 +1522,12 @@ done:
        if (uuid_value)
                g_free(uuid_value);
 
+       if (value)
+               g_variant_unref(value);
+
+       if (ret)
+               g_variant_unref(ret);
+
        BT_DBG("-");
        return result;
 }
index c47905e..f8cdf8a 100644 (file)
@@ -379,7 +379,7 @@ gboolean __bt_reliable_disable_cb(gpointer user_data)
         _bt_rfcomm_server_free_all();
 #endif
 
-       _bluetooth_hid_free_hid_info();
+       _bt_hid_free_hid_info();
 
        BT_DBG("-");
        return FALSE;
@@ -1305,10 +1305,10 @@ void __bt_hid_device_event_filter(GDBusConnection *connection,
                                                address);
                int ctrl = -1, intr = -1;
                _bt_hid_device_get_fd(address, &ctrl, &intr);
-               if (ctrl != -1 && intr != -1) {
-                       new_hid_connection(NULL, ctrl, &dev_address);
-                       new_hid_connection(NULL, intr, &dev_address);
-               }
+               if (ctrl != -1 && intr != -1)
+                       _bt_hid_new_connection(&dev_address, ctrl, intr);
+               else
+                       BT_ERR("fd is invalid.(ctrl=%d, intr=%d)", ctrl, intr);
        } else if (strcasecmp(signal_name, BT_INPUT_HID_DEVICE_DISCONNECTED) == 0) {
                const char *address = NULL;
                g_variant_get(parameters, "(i&s)", &result, &address);
@@ -2721,14 +2721,14 @@ void __bt_hf_agent_event_filter(GDBusConnection *connection,
        if (strcasecmp(signal_name, "Connected") == 0) {
                char *address = NULL;
 
-               g_variant_get(parameters, "(s)", &address);
+               g_variant_get(parameters, "(&s)", &address);
                _bt_hf_event_cb(BLUETOOTH_EVENT_HF_CONNECTED,
                                result, address,
                                event_info->cb, event_info->user_data);
        } else if (strcasecmp(signal_name, "Disconnected") == 0) {
                char *address = NULL;
 
-               g_variant_get(parameters, "(s)", &address);
+               g_variant_get(parameters, "(&s)", &address);
                _bt_hf_event_cb(BLUETOOTH_EVENT_HF_DISCONNECTED,
                                result, address,
                                event_info->cb, event_info->user_data);
@@ -3799,6 +3799,46 @@ void _bt_unregister_name_owner_changed(void)
        }
 }
 
+static void __bt_gatt_get_uuid_from_path(char *path, char **service_uuid)
+{
+       GDBusProxy *proxy = NULL;
+       GError *err = NULL;
+       GDBusConnection *g_conn;
+       GVariant *ret = NULL;
+       GVariant *value = NULL;
+
+       g_conn = _bt_gdbus_get_system_gconn();
+       ret_if(g_conn == NULL);
+
+       proxy = g_dbus_proxy_new_sync(g_conn,
+                               G_DBUS_PROXY_FLAGS_NONE, NULL,
+                               BT_BLUEZ_NAME,
+                               path,
+                               BT_PROPERTIES_INTERFACE,
+                               NULL, &err);
+
+       ret_if(proxy == NULL);
+
+       ret = g_dbus_proxy_call_sync(proxy, "Get",
+                       g_variant_new("(ss)", GATT_SERV_INTERFACE, "UUID"),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+       if (err) {
+               BT_ERR("DBus Error : %s", err->message);
+               g_clear_error(&err);
+       } else {
+               g_variant_get(ret, "(v)", &value);
+               *service_uuid = g_variant_dup_string(value, NULL);
+               g_variant_unref(value);
+               g_variant_unref(ret);
+       }
+
+       if (proxy)
+               g_object_unref(proxy);
+
+       return;
+}
+
+
 static void __bt_manager_event_filter(GDBusConnection *connection,
                                        const gchar *sender_name,
                                        const gchar *object_path,
@@ -3832,9 +3872,17 @@ static void __bt_manager_event_filter(GDBusConnection *connection,
                        BT_INFO("GATT Service [%s] added, but no watcher for %s",
                                                        path, secure_address);
                        return;
-               } else
+               } else {
+                       char *uuid = NULL;
+                       char *name = NULL;
+                       __bt_gatt_get_uuid_from_path(path, &uuid);
+                       bluetooth_get_uuid_name(uuid, &name);
+
                        BT_INFO(" ### GATT Service added [%s] [%s]",
-                                                       path, secure_address);
+                                                       path, name);
+                       g_free(name);
+                       g_free(uuid);
+               }
 
                change.svc_path = g_strdup(path);
                change.change_type = BLUETOOTH_GATT_SERVICE_CHANGE_TYPE_ADD;
@@ -3860,10 +3908,7 @@ static void __bt_manager_event_filter(GDBusConnection *connection,
                        if (g_strcmp0(interface_str, GATT_SERV_INTERFACE) != 0)
                                continue;
 
-                       _bt_convert_addr_type_to_secure_string(secure_address,
-                                                              change.device_addr.addr);
-                       BT_INFO(" ### GATT Service removed [%s] [%s]",
-                                                       path, secure_address);
+                       BT_INFO(" ### GATT Service removed [%s]", path);
 
                        change.svc_path = g_strdup(path);
                        change.change_type = BLUETOOTH_GATT_SERVICE_CHANGE_TYPE_REMOVE;
old mode 100755 (executable)
new mode 100644 (file)
index db0f6bb..b287ca7
@@ -89,69 +89,6 @@ static int privilege_token_send_mouse = 0;
 static int privilege_token_send_key = 0;
 static int privilege_token_reply = 0;
 
-static gboolean __hid_disconnect(hid_connected_device_info_t *info);
-
-int _bt_hid_device_get_fd(const char *address, int *ctrl, int *intr)
-{
-
-       int ret = BLUETOOTH_ERROR_NONE;
-       char *adapter_path;
-       GVariant *result = NULL;
-       GError *err = NULL;
-       GDBusConnection *conn;
-       GDBusProxy *server_proxy;
-       int index1 = 0;
-       int index2 = 0;
-       GUnixFDList *out_fd_list = NULL;
-       conn = _bt_gdbus_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       adapter_path = _bt_get_device_object_path((char *)address);
-       retv_if(adapter_path == NULL, BLUETOOTH_ERROR_INTERNAL);
-       BT_INFO_C("Device : %s", adapter_path);
-       server_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
-                       NULL, BT_BLUEZ_NAME,
-                       adapter_path, "org.bluez.Input1",  NULL, NULL);
-       g_free(adapter_path);
-
-       if (server_proxy == NULL) {
-               BT_ERR("Failed to get the network server proxy\n");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       result = g_dbus_proxy_call_with_unix_fd_list_sync(server_proxy, "GetFD",
-                                NULL,
-                                G_DBUS_CALL_FLAGS_NONE,
-                                -1,
-                                NULL,
-                                &out_fd_list,
-                                NULL,
-                                &err);
-       if (result == NULL) {
-               if (err != NULL) {
-                       g_dbus_error_strip_remote_error(err);
-                       BT_ERR("INPUT server register Error: %s\n", err->message);
-                       if (g_strcmp0(err->message, "Already Exists") == 0)
-                               ret = BLUETOOTH_ERROR_ALREADY_INITIALIZED;
-                       else
-                               ret = BLUETOOTH_ERROR_INTERNAL;
-
-                       g_error_free(err);
-               }
-       } else {
-               g_variant_get(result, "(hh)", &index1, &index2);
-               int fd1 = g_unix_fd_list_get(out_fd_list, index1, NULL);
-               int fd2 = g_unix_fd_list_get(out_fd_list, index2, NULL);
-
-               *ctrl = fd1;
-               *intr = fd2;
-               g_object_unref(out_fd_list);
-               g_variant_unref(result);
-       }
-       g_object_unref(server_proxy);
-       return ret;
-}
-
 static GVariant* __bt_hid_agent_dbus_send(const char *path,
                                const char *interface,  const char *method,
                                GError **err, GVariant *parameters)
@@ -192,25 +129,21 @@ static hid_connected_device_info_t *__find_hid_info_with_address(const char *rem
 static void __hid_connected_cb(hid_connected_device_info_t *info,
                        int result)
 {
-       bluetooth_hid_request_t conn_info;
+       bluetooth_device_address_t bd_addr;
        bt_event_info_t *event_info = NULL;
 
        event_info = _bt_event_get_cb_data(BT_HID_DEVICE_EVENT);
        if (event_info == NULL)
                return;
 
-       memset(&conn_info, 0x00, sizeof(bluetooth_hid_request_t));
-       if (info->intr_fd != -1 && info->ctrl_fd == -1)
-               conn_info.socket_fd = info->intr_fd;
-       else
-               conn_info.socket_fd = info->ctrl_fd;
-       _bt_convert_addr_string_to_type(conn_info.device_addr.addr, info->address);
+       memset(&bd_addr, 0x00, sizeof(bluetooth_device_address_t));
+       _bt_convert_addr_string_to_type(bd_addr.addr, info->address);
 
        if (result == BLUETOOTH_ERROR_NONE)
                BT_INFO_C("Connected [HID Device]");
 
        _bt_common_event_cb(BLUETOOTH_HID_DEVICE_CONNECTED,
-                       result, &conn_info,
+                       result, &bd_addr,
                        event_info->cb, event_info->user_data);
 }
 
@@ -231,11 +164,6 @@ static void __hid_connect_response_cb(GDBusProxy *proxy, GAsyncResult *res,
                g_dbus_error_strip_remote_error(error);
                BT_ERR("Error : %s \n", error->message);
 
-               if (g_strcmp0(error->message, "In Progress") == 0)
-                       result = BLUETOOTH_ERROR_DEVICE_BUSY;
-               else
-                       result = BLUETOOTH_ERROR_INTERNAL;
-
                info.ctrl_fd = -1;
                info.intr_fd = -1;
 
@@ -244,10 +172,27 @@ static void __hid_connect_response_cb(GDBusProxy *proxy, GAsyncResult *res,
                path = g_dbus_proxy_get_object_path(proxy);
                _bt_convert_device_path_to_address(path, info.address);
 
-               __hid_connected_cb(&info, result);
+               if (g_strcmp0(error->message, "Already Connected") == 0) {
+                       bluetooth_device_address_t dev_address = { {0} };
+                       int ctrl = -1, intr = -1;
 
-               g_free(info.address);
+                       _bt_convert_addr_string_to_type(dev_address.addr,
+                                                       info.address);
+                       _bt_hid_device_get_fd(info.address, &ctrl, &intr);
+                       if (ctrl != -1 && intr != -1)
+                               _bt_hid_new_connection(&dev_address, ctrl, intr);
+                       else
+                               BT_ERR("fd is invalid.(ctrl=%d, intr=%d)", ctrl, intr);
+               } else {
+                       if (g_strcmp0(error->message, "In Progress") == 0)
+                               result = BLUETOOTH_ERROR_IN_PROGRESS;
+                       else
+                               result = BLUETOOTH_ERROR_INTERNAL;
 
+                       __hid_connected_cb(&info, result);
+               }
+
+               g_free(info.address);
                g_error_free(error);
        } else {
                g_variant_unref(ret);
@@ -261,8 +206,7 @@ static void __hid_connect_response_cb(GDBusProxy *proxy, GAsyncResult *res,
 
 static gboolean __hid_disconnect(hid_connected_device_info_t *info)
 {
-       bluetooth_hid_request_t disconn_info;
-       int fd = info->ctrl_fd;
+       bluetooth_device_address_t bd_addr;
        bt_event_info_t *event_info;
 
        BT_INFO_C("Disconnected [HID Device]");
@@ -294,20 +238,17 @@ static gboolean __hid_disconnect(hid_connected_device_info_t *info)
        }
        info->disconnect_idle_id = 0;
        event_info = _bt_event_get_cb_data(BT_HID_DEVICE_EVENT);
-       if (event_info == NULL)
-               return FALSE;
+       if (event_info != NULL) {
+               memset(&bd_addr, 0x00, sizeof(bluetooth_device_address_t));
+               _bt_convert_addr_string_to_type(bd_addr.addr , info->address);
+               _bt_common_event_cb(BLUETOOTH_HID_DEVICE_DISCONNECTED,
+                               BLUETOOTH_ERROR_NONE, &bd_addr,
+                               event_info->cb, event_info->user_data);
+       }
 
-       memset(&disconn_info, 0x00, sizeof(bluetooth_hid_request_t));
-       disconn_info.socket_fd = fd;
-       _bt_convert_addr_string_to_type(disconn_info.device_addr.addr , info->address);
-       _bt_common_event_cb(BLUETOOTH_HID_DEVICE_DISCONNECTED,
-                       BLUETOOTH_ERROR_NONE, &disconn_info,
-                       event_info->cb, event_info->user_data);
-       if (info->address)
-               g_free(info->address);
+       g_free(info->address);
        g_free(info);
-       info = NULL;
-       BT_DBG("-");
+
        return FALSE;
 }
 
@@ -515,47 +456,6 @@ static gboolean __received_cb(GIOChannel *chan, GIOCondition cond,
        return TRUE;
 }
 
-int new_hid_connection(const char *path, int fd, bluetooth_device_address_t *addr)
-{
-       hid_connected_device_info_t *dev_info = NULL;
-       char address[18];
-
-       _bt_convert_addr_type_to_string((char *)address, addr->addr);
-       BT_INFO("Address [%s]", address);
-       dev_info = __find_hid_info_with_address(address);
-       if (dev_info == NULL) {
-               dev_info = (hid_connected_device_info_t *)
-                       g_malloc0(sizeof(hid_connected_device_info_t));
-
-               dev_info->intr_fd = -1;
-               dev_info->ctrl_fd = -1;
-               dev_info->intr_fd = fd;
-               dev_info->address = g_strdup(address);
-               dev_info->intr_data_io = g_io_channel_unix_new(dev_info->intr_fd);
-               g_io_channel_set_encoding(dev_info->intr_data_io, NULL, NULL);
-               g_io_channel_set_flags(dev_info->intr_data_io, G_IO_FLAG_NONBLOCK, NULL);
-               g_io_channel_set_close_on_unref(dev_info->intr_data_io, TRUE);
-               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);
-               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);
-               g_io_channel_set_encoding(dev_info->ctrl_data_io, NULL, NULL);
-               g_io_channel_set_flags(dev_info->ctrl_data_io, G_IO_FLAG_NONBLOCK, NULL);
-               g_io_channel_set_close_on_unref(dev_info->ctrl_data_io, TRUE);
-               dev_info->ctrl_data_id = g_io_add_watch(dev_info->ctrl_data_io,
-                               G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
-                               __received_cb, dev_info);
-       }
-
-       if (dev_info->ctrl_fd != -1 && dev_info->intr_fd != -1)
-               __hid_connected_cb(dev_info, BLUETOOTH_ERROR_NONE);
-
-       return 0;
-}
-
 static void __free_hid_info(void *data)
 {
        BT_DBG("");
@@ -570,7 +470,109 @@ static void __free_hid_info(void *data)
        __hid_disconnect(dev_info);
 }
 
-void _bluetooth_hid_free_hid_info(void)
+int _bt_hid_device_get_fd(const char *address, int *ctrl, int *intr)
+{
+
+       int ret = BLUETOOTH_ERROR_NONE;
+       char *adapter_path;
+       GVariant *result = NULL;
+       GError *err = NULL;
+       GDBusConnection *conn;
+       GDBusProxy *server_proxy;
+       int index1 = 0;
+       int index2 = 0;
+       GUnixFDList *out_fd_list = NULL;
+       conn = _bt_gdbus_get_system_gconn();
+       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       adapter_path = _bt_get_device_object_path((char *)address);
+       retv_if(adapter_path == NULL, BLUETOOTH_ERROR_INTERNAL);
+       BT_INFO_C("Device : %s", adapter_path);
+       server_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                       NULL, BT_BLUEZ_NAME,
+                       adapter_path, "org.bluez.Input1",  NULL, NULL);
+       g_free(adapter_path);
+
+       if (server_proxy == NULL) {
+               BT_ERR("Failed to get the network server proxy\n");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       result = g_dbus_proxy_call_with_unix_fd_list_sync(server_proxy, "GetFD",
+                                NULL,
+                                G_DBUS_CALL_FLAGS_NONE,
+                                -1,
+                                NULL,
+                                &out_fd_list,
+                                NULL,
+                                &err);
+       if (result == NULL) {
+               if (err != NULL) {
+                       g_dbus_error_strip_remote_error(err);
+                       BT_ERR("INPUT server register Error: %s\n", err->message);
+                       if (g_strcmp0(err->message, "Already Exists") == 0)
+                               ret = BLUETOOTH_ERROR_ALREADY_INITIALIZED;
+                       else
+                               ret = BLUETOOTH_ERROR_INTERNAL;
+
+                       g_error_free(err);
+               }
+       } else {
+               g_variant_get(result, "(hh)", &index1, &index2);
+               int fd1 = g_unix_fd_list_get(out_fd_list, index1, NULL);
+               int fd2 = g_unix_fd_list_get(out_fd_list, index2, NULL);
+
+               *ctrl = fd1;
+               *intr = fd2;
+               g_object_unref(out_fd_list);
+               g_variant_unref(result);
+       }
+       g_object_unref(server_proxy);
+       return ret;
+}
+
+int _bt_hid_new_connection(bluetooth_device_address_t *addr,
+                               int ctrl_fd, int intr_fd)
+{
+       hid_connected_device_info_t *dev_info = NULL;
+       char address[18];
+       char secure_addr[BT_ADDRESS_STRING_SIZE] = { 0 };
+
+       _bt_convert_addr_type_to_string((char *)address, addr->addr);
+       _bt_convert_addr_string_to_secure_string(secure_addr, address);
+       BT_INFO("Address [%s]", secure_addr);
+       dev_info = __find_hid_info_with_address(address);
+       if (dev_info != NULL)
+               __free_hid_info(dev_info);
+
+       dev_info = (hid_connected_device_info_t *)
+               g_malloc0(sizeof(hid_connected_device_info_t));
+
+       dev_info->ctrl_fd = ctrl_fd;
+       dev_info->intr_fd = intr_fd;
+       dev_info->address = g_strdup(address);
+       dev_info->ctrl_data_io = g_io_channel_unix_new(dev_info->ctrl_fd);
+       dev_info->intr_data_io = g_io_channel_unix_new(dev_info->intr_fd);
+       g_io_channel_set_encoding(dev_info->ctrl_data_io, NULL, NULL);
+       g_io_channel_set_flags(dev_info->ctrl_data_io, G_IO_FLAG_NONBLOCK, NULL);
+       g_io_channel_set_close_on_unref(dev_info->ctrl_data_io, TRUE);
+       g_io_channel_set_encoding(dev_info->intr_data_io, NULL, NULL);
+       g_io_channel_set_flags(dev_info->intr_data_io, G_IO_FLAG_NONBLOCK, NULL);
+       g_io_channel_set_close_on_unref(dev_info->intr_data_io, TRUE);
+       dev_info->ctrl_data_id = g_io_add_watch(dev_info->ctrl_data_io,
+                       G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+                       __received_cb, dev_info);
+       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);
+       device_list = g_slist_append(device_list, dev_info);
+
+       __hid_connected_cb(dev_info, BLUETOOTH_ERROR_NONE);
+
+       return 0;
+}
+
+void _bt_hid_free_hid_info(void)
 {
        g_slist_free_full(device_list, __free_hid_info);
 
@@ -681,7 +683,7 @@ BT_EXPORT_API int bluetooth_hid_device_deactivate(void)
 
        g_variant_unref(reply);
 
-       _bluetooth_hid_free_hid_info();
+       _bt_hid_free_hid_info();
 
        return BLUETOOTH_ERROR_NONE;
 }
@@ -775,14 +777,14 @@ BT_EXPORT_API int bluetooth_hid_device_send_mouse_event(const char *remote_addr,
                BT_ERR("Connection Information not found");
                return BLUETOOTH_ERROR_INVALID_PARAM;
        }
-       int socket_fd;
-
-       if (info->intr_fd != -1 && info->ctrl_fd == -1)
-               socket_fd = info->intr_fd;
-       else
-               socket_fd = info->ctrl_fd;
 
-       written = write(socket_fd, &send_event, sizeof(send_event));
+       if (info->intr_fd >= 0) {
+               written = write(info->intr_fd, &send_event, sizeof(send_event));
+       } else {
+               BT_ERR("intr_fd(%d) is invalid.", info->intr_fd);
+               __free_hid_info(info);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
 
        return written;
 }
@@ -826,14 +828,14 @@ BT_EXPORT_API int bluetooth_hid_device_send_key_event(const char *remote_addr,
                return BLUETOOTH_ERROR_INVALID_PARAM;
        }
 
-       int socket_fd;
-
-       if (info->intr_fd != -1 && info->ctrl_fd == -1)
-               socket_fd = info->intr_fd;
-       else
-               socket_fd = info->ctrl_fd;
+       if (info->intr_fd >= 0) {
+               written = write(info->intr_fd, &send_event, sizeof(send_event));
+       } else {
+               BT_ERR("intr_fd(%d) is invalid.", info->intr_fd);
+               __free_hid_info(info);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
 
-       written = write(socket_fd, &send_event, sizeof(send_event));
        return written;
 }
 
@@ -843,7 +845,6 @@ BT_EXPORT_API int bluetooth_hid_device_send_custom_event(const char *remote_addr
 {
        int result;
        int written = 0;
-       int socket_fd;
        hid_connected_device_info_t *info = NULL;
        char *send_event = NULL;
 
@@ -880,20 +881,20 @@ BT_EXPORT_API int bluetooth_hid_device_send_custom_event(const char *remote_addr
                return BLUETOOTH_ERROR_INVALID_PARAM;
        }
 
-       if (info->intr_fd != -1 && info->ctrl_fd == -1)
-               socket_fd = info->intr_fd;
-       else
-               socket_fd = info->ctrl_fd;
-
-       send_event = g_malloc0(data_len + 2);
-
-       send_event[0] = (char)btcode;
-       send_event[1] = (char)report_id;
-       memcpy(send_event + 2, data, data_len);
+       if (info->intr_fd >= 0) {
+               send_event = g_malloc0(data_len + 2);
 
-       written = write(socket_fd, send_event, data_len + 2);
+               send_event[0] = (char)btcode;
+               send_event[1] = (char)report_id;
+               memcpy(send_event + 2, data, data_len);
 
-       g_free(send_event);
+               written = write(info->intr_fd, send_event, data_len + 2);
+               g_free(send_event);
+       } else {
+               BT_ERR("intr_fd(%d) is invalid.", info->intr_fd);
+               __free_hid_info(info);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
 
        return written;
 }
@@ -906,15 +907,22 @@ BT_EXPORT_API int bluetooth_hid_device_reply_to_report(const char *remote_addr,
 {
        int result;
        struct reports output_report = { 0 };
-       int bytes = BLUETOOTH_ERROR_INTERNAL;
+       int bytes = -1;
        hid_connected_device_info_t *info = NULL;
+
+       BT_CHECK_PARAMETER(remote_addr, return);
+
        info = __find_hid_info_with_address(remote_addr);
        if (info == NULL) {
                BT_ERR("Connection Information not found");
                return BLUETOOTH_ERROR_INVALID_PARAM;
        }
 
-       BT_CHECK_PARAMETER(remote_addr, return);
+       if (info->ctrl_fd < 0) {
+               BT_ERR("ctrl_fd(%d) is invalid.", info->ctrl_fd);
+               __free_hid_info(info);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
 
        switch (privilege_token_reply) {
        case 0:
@@ -948,7 +956,7 @@ BT_EXPORT_API int bluetooth_hid_device_reply_to_report(const char *remote_addr,
                        output_report.type = BT_HID_TRANS_DATA |
                                        BT_HID_DATA_RTYPE_INPUT;
                        memcpy(output_report.rep_data, data, data_len);
-                       bytes = write(info->intr_fd, &output_report,
+                       bytes = write(info->ctrl_fd, &output_report,
                                                sizeof(output_report));
                        BT_DBG("Bytes Written %d", bytes);
                        break;
@@ -960,50 +968,40 @@ BT_EXPORT_API int bluetooth_hid_device_reply_to_report(const char *remote_addr,
        break;
 
        case HTYPE_TRANS_GET_PROTOCOL: {
-               BT_DBG("Replying to Get_PROTOCOL");
                output_report.type = BT_HID_TRANS_DATA | BT_HID_DATA_RTYPE_OUTPUT;
                output_report.rep_data[0] = data[0];
-               bytes = write(info->intr_fd, &output_report, 2);
-               BT_DBG("Bytes Written %d", bytes);
+               bytes = write(info->ctrl_fd, &output_report, 2);
                break;
        }
 
        case HTYPE_TRANS_SET_PROTOCOL: {
-               BT_DBG("Reply to Set_Protocol");
                output_report.type = BT_HID_TRANS_DATA | BT_HID_DATA_RTYPE_INPUT;
                memcpy(output_report.rep_data, data, data_len);
                bytes = write(info->ctrl_fd, &output_report,
                                sizeof(output_report));
-               BT_DBG("Bytes Written %d", bytes);
                break;
        }
 
        case HTYPE_TRANS_HANDSHAKE: {
-               BT_DBG("Replying Handshake");
                output_report.type = BT_HID_TRANS_HANDSHAKE | data[0];
                memset(output_report.rep_data, 0, sizeof(output_report.rep_data));
-               bytes = write(info->intr_fd,  &output_report.type,
+               bytes = write(info->ctrl_fd,  &output_report.type,
                                sizeof(output_report.type));
-               BT_DBG("Bytes Written %d", bytes);
                break;
        }
 
        case HTYPE_TRANS_GET_IDLE: {
-               BT_DBG("Replying to Get_IDLE");
                output_report.type = BT_HID_TRANS_DATA | BT_HID_DATA_RTYPE_OUTPUT;
                output_report.rep_data[0] = data[0];
-               bytes = write(info->intr_fd, &output_report, 2);
-               BT_DBG("Bytes Written %d", bytes);
+               bytes = write(info->ctrl_fd, &output_report, 2);
                break;
        }
 
        case HTYPE_TRANS_SET_IDLE: {
-               BT_DBG("Reply to Set_IDLE");
                output_report.type = BT_HID_TRANS_DATA | BT_HID_DATA_RTYPE_INPUT;
                memcpy(output_report.rep_data, data, data_len);
                bytes = write(info->ctrl_fd, &output_report,
                                sizeof(output_report));
-               BT_DBG("Bytes Written %d", bytes);
                break;
        }
 
@@ -1011,5 +1009,8 @@ BT_EXPORT_API int bluetooth_hid_device_reply_to_report(const char *remote_addr,
                break;
                }
        }
+
+       BT_DBG("Bytes Written %d", bytes);
+
        return bytes;
 }
index d13c6b7..e404adc 100644 (file)
@@ -2347,6 +2347,8 @@ static void __bt_telephony_adapter_filter(GDBusConnection *connection,
                        if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE)
                                BT_ERR("__bluetooth_telephony_register failed");
                }
+
+               g_variant_unref(optional_param);
        }
 
        FN_END;
old mode 100755 (executable)
new mode 100644 (file)
index ea988f7..e283430
@@ -407,7 +407,12 @@ void _bt_rfcomm_client_disconnect_all(void);
 gboolean _check_uuid_path(char *path, char *uuid);
 #endif
 
-void _bluetooth_hid_free_hid_info(void);
+int _bt_hid_device_get_fd(const char *address, int *ctrl, int *intr);
+
+int _bt_hid_new_connection(bluetooth_device_address_t *addr,
+                               int ctrl_fd, int intr_fd);
+
+void _bt_hid_free_hid_info(void);
 
 int _bt_get_error_value_from_message(const char *error_message);
 
old mode 100755 (executable)
new mode 100644 (file)
index 541c284..6050f9b
@@ -63,10 +63,6 @@ void _bt_unregister_name_owner_changed(void);
 
 int _bt_register_manager_subscribe_signal(gboolean subscribe);
 
-int _bt_hid_device_get_fd(const char *address, int *ctrl, int *intr);
-
-int new_hid_connection(const char *path, int fd, bluetooth_device_address_t *addr);
-
 #ifdef __cplusplus
 }
 #endif
index 30608a1..a901c7a 100644 (file)
@@ -88,7 +88,6 @@ typedef struct {
 #define BT_HAL_ADV_FILTER_POLICY_DEFAULT    0x00
 #define BT_HAL_ADV_TYPE_DEFAULT     0x00
 #define BT_HAL_ADV_FILTER_POLICY_ALLOW_SCAN_CONN_WL_ONLY    0x03
-#define BT_HAL_ADV_MULTI_MAX   16
 
 /* Multi Advertisement callback event */
 #define BT_HAL_MULTI_ADV_ENB_EVT           1
@@ -210,7 +209,7 @@ gboolean _bt_hal_update_le_feature_support(const char *item, const char *value)
                int slot_num;
 
                slot_num = atoi(value);
-               if (slot_num < 0 || slot_num > BT_HAL_ADV_MULTI_MAX) {
+               if (slot_num < 0) {
                        ERR("ERR:Advertising MAX instance [%d]", slot_num);
                        return FALSE;
                }
index 603fc78..db0f47d 100644 (file)
@@ -228,7 +228,7 @@ static void __bt_hal_adapter_property_changed_event(GVariant *msg)
                                        HAL_PROP_ADAPTER_ADDR, sizeof(bdaddr), bdaddr);
                        ev->num_props++;
                } else if (!g_strcmp0(key, "Alias")) {
-                       g_variant_get(value, "s", &name);
+                       g_variant_get(value, "&s", &name);
                        DBG("##Alias [%s] ", name);
                        size += __bt_insert_hal_properties(buf + size,
                                        HAL_PROP_ADAPTER_NAME, strlen(name) + 1, name);
@@ -269,7 +269,7 @@ static void __bt_hal_adapter_property_changed_event(GVariant *msg)
                                        HAL_PROP_ADAPTER_VERSION, strlen(version) + 1, version);
                        ev->num_props++;
                } else if (!g_strcmp0(key, "Name")) {
-                       g_variant_get(value, "s", &name);
+                       g_variant_get(value, "&s", &name);
                        DBG("##Name [%s]", name);
                        size += __bt_insert_hal_properties(buf + size,
                                        HAL_PROP_ADAPTER_NAME, strlen(name) + 1, name);
@@ -436,14 +436,16 @@ static void __bt_hal_adapter_property_changed_event(GVariant *msg)
                        g_variant_get(value, "as", &iter);
 
                        if (iter == NULL)
-                               return;
-                       while (g_variant_iter_loop(iter, "s", &name)) {
-                               DBG("name = %s", name);
+                               continue;
+
+                       while (g_variant_iter_next(iter, "&s", &name) &&
+                               g_variant_iter_next(iter, "&s", &value)) {
+                               DBG("name = %s, Value = %s", name, value);
                                g_variant_iter_loop(iter, "s", &val);
-                               DBG("Value = %s", val);
-                               if (FALSE == _bt_hal_update_le_feature_support(name, val))
-                                       INFO("Fail to update LE feature info");
+                               if (FALSE == _bt_hal_update_le_feature_support(name, value))
+                                       ERR("Failed to update LE feature (name = %s, value = %s)", name, value);
                        }
+
                        g_variant_iter_free(iter);
                } else if (!g_strcmp0(key, "IpspInitStateChanged")) {
                        g_variant_get(value, "b" ,&ipsp_initialized);
index 9827df5..b82c333 100644 (file)
@@ -423,7 +423,7 @@ static void __bt_visibility_alarm_create()
        }
 }
 
-static int __bt_set_visible_time(int timeout)
+int _bt_start_visibility_timer(int timeout)
 {
        int result;
 #ifdef TIZEN_FEATURE_BT_DPM
@@ -460,19 +460,41 @@ static int __bt_set_visible_time(int timeout)
        if (result != 0)
                return BLUETOOTH_ERROR_INTERNAL;
 
+       if (!TIZEN_PROFILE_WEARABLE) {
+               if (vconf_set_int(BT_FILE_VISIBLE_TIME, timeout) != 0)
+                       BT_ERR("Set vconf failed");
+       }
+
        /* Take start time */
        time(&(visible_timer.start_time));
        visible_timer.event_id = g_timeout_add_seconds(1,
                        __bt_timeout_handler, NULL);
 
+       visible_timer.timeout = timeout;
+
        __bt_visibility_alarm_create();
 
        return BLUETOOTH_ERROR_NONE;
 }
 
+int _bt_stop_visibility_timer(void)
+{
+       __bt_visibility_alarm_remove();
+
+       visible_timer.timeout = 0;
+
+       if (!TIZEN_PROFILE_WEARABLE) {
+               if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
+                       BT_ERR("Set vconf failed");
+       }
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
 int _bt_set_discoverable_mode(int discoverable_mode, int timeout)
 {
        int result;
+       int ret = BLUETOOTH_ERROR_NONE;;
 #ifdef TIZEN_FEATURE_BT_DPM
        int discoverable_state = DPM_BT_ERROR;
 #endif
@@ -489,7 +511,7 @@ int _bt_set_discoverable_mode(int discoverable_mode, int timeout)
                        headed_plugin_info->headed_plugin->bt_launch_dpmpopup("DPM_POLICY_DISABLE_BT_HANDSFREE");
                return BLUETOOTH_ERROR_ACCESS_DENIED;
        }
-       if (discoverable_mode != BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE &&
+       if (discoverable_mode == BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE &&
                discoverable_state == DPM_RESTRICTED) {
                if (headed_plugin_info->plugin_headed_enabled)
                        headed_plugin_info->headed_plugin->bt_launch_dpmpopup("DPM_POLICY_DISABLE_BT");
@@ -524,10 +546,18 @@ int _bt_set_discoverable_mode(int discoverable_mode, int timeout)
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       if (discoverable_mode == BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE)
-               timeout = -1;
+       if (discoverable_mode == BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE) {
+               ret = _bt_stop_visibility_timer();
+               if (!TIZEN_PROFILE_WEARABLE) {
+                       if (vconf_set_int(BT_FILE_VISIBLE_TIME, -1) != 0)
+                                BT_ERR("Set vconf failed");
+               }
+       } else if (discoverable_mode == BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE) {
+               ret = _bt_start_visibility_timer(timeout);
 
-       result = __bt_set_visible_time(timeout);
+       } else {
+               ret = _bt_stop_visibility_timer();
+       }
 
        BT_DBG("-");
        return result;
index af8371e..5832d03 100755 (executable)
@@ -1184,7 +1184,10 @@ static  void __bt_manager_event_filter(GDBusConnection *connection,
                                bt_cache_info_t *cache_info;
                                bt_remote_dev_info_t *dev_info;
 
-                               ret_if(_bt_is_discovering() == FALSE);
+                               if(_bt_is_discovering() == FALSE) {
+                                       g_variant_unref(value);
+                                       return;
+                               }
 
                                cache_info = g_malloc0(sizeof(bt_cache_info_t));
                                ret_if(cache_info == NULL);
index 2d23b9c..0e555dd 100644 (file)
@@ -1380,13 +1380,6 @@ typedef struct {
                                              /**< device address */
 } bluetooth_rfcomm_connection_request_t;
 
-typedef struct {
-       int socket_fd;
-               /**< the socket fd */
-       bluetooth_device_address_t device_addr;
-                                             /**< device address */
-} bluetooth_hid_request_t;
-
 /**
  * HDP QOS types
  */
index 8f42138..522b59a 100644 (file)
@@ -363,6 +363,10 @@ ln -s ../bluetooth-frwk.service %{buildroot}%{_unitdir}/starter.target.wants/blu
 
 %postun -p /sbin/ldconfig
 
+%post service
+/usr/bin/chsmack -a '_' %{_varlibdir}/bluetooth/auto-pair-blacklist
+/usr/bin/chown 5001:100 %{_varlibdir}/bluetooth/auto-pair-blacklist
+
 %files
 %manifest %{name}.manifest
 %license LICENSE
@@ -409,6 +413,7 @@ popd
 %{_bindir}/bluetooth-frwk-test
 %{_varlibdir}/bluetooth
 %{_prefix}/etc/bluetooth
+%attr(-,owner,users) %{_varlibdir}/bluetooth/auto-pair-blacklist
 
 %files httpproxy
 %manifest %{name}.manifest