Merge "A2DP profile multiple source support" into tizen
authorPyun DoHyun <dh79.pyun@samsung.com>
Wed, 30 Jan 2019 01:05:46 +0000 (01:05 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Wed, 30 Jan 2019 01:05:46 +0000 (01:05 +0000)
bt-api/bt-event-handler.c
bt-api/bt-gatt-service.c
bt-api/include/bt-gatt-server.h
bt-oal/bluez_hal/bluetooth-frwk-gap-agent.conf
bt-service-adaptation/services/gatt/bt-service-gatt.c

index 6a3ce72..105d1cc 100644 (file)
@@ -3852,7 +3852,7 @@ static void __bt_gatt_server_event_filter(GDBusConnection *connection,
 
        } else if (strcasecmp(signal_name, BT_GATT_SERVER_ACQUIRE_NOTIFICATION) == 0) {
 
-               bluetooth_gatt_server_send_acquire_notify_response(parameters);
+               bluetooth_gatt_server_send_acquire_notify_response(parameters, event_info);
 
        }  else if (strcasecmp(signal_name, BT_GATT_SERVER_NOTIFICATION_COMPLETED) == 0) {
                const char *address = NULL;
@@ -3898,6 +3898,9 @@ static void __bt_gatt_server_event_filter(GDBusConnection *connection,
                BT_INFO("GATT Server: Notification Enabled?? Handle: [%d] address [%s] Is Enabled [%d] result [%d]",
                                info.handle, address, info.notification, result);
 
+               if (info.notification == FALSE)
+                       cleanup_gatt_acquire_fd(info.handle);
+
                _bt_gatt_server_event_cb(BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED,
                                result, &info,
                                event_info->cb, event_info->user_data);
index 49e2f46..91149a8 100644 (file)
@@ -391,10 +391,14 @@ static void bluetooth_characteristic_info_free(bluetooth_gatt_acquire_notify_inf
 static gboolean bluetooth_gatt_write_channel_watch_cb(GIOChannel *gio,
                                        GIOCondition cond, gpointer data)
 {
+       BT_INFO("+");
+
        bluetooth_gatt_acquire_notify_info_t *chr_info = (bluetooth_gatt_acquire_notify_info_t *)data;
 
-       if (!chr_info)
+       if (!chr_info) {
+               BT_INFO("chr_info is NULL");
                return FALSE;
+       }
 
        if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) {
                BT_ERR("Error : GIOCondition %d, []", cond);;
@@ -3207,7 +3211,7 @@ void  bluetooth_gatt_server_send_acquire_write_response(GVariant * parameters)
 
 
 
-void  bluetooth_gatt_server_send_acquire_notify_response(GVariant * parameters)
+void  bluetooth_gatt_server_send_acquire_notify_response(GVariant * parameters, bt_event_info_t *event_info)
 {
                        int con_id  =  -1;
                        int tran_id  =  -1;
@@ -3220,18 +3224,21 @@ void  bluetooth_gatt_server_send_acquire_notify_response(GVariant * parameters)
                        int result =  -1;
                        int fd = -1;
                        bluetooth_gatt_acquire_notify_info_t *chr_info;
+                       const char *address = NULL;
 
-                       g_variant_get(parameters, "(iiiiii)",
+                       g_variant_get(parameters, "(iiiiiis)",
                                                        &result,
                                                        &con_id,
                                                        &tran_id,
                                                        &att_han,
                                                        &mtu,
-                                                       &offset);
+                                                       &offset,
+                                                       &address);
 
                                BT_DBG("GATT ServerAcquire  Conn ID:   [%d]", con_id);
                                BT_DBG("GATT Server Acquire notify  att handle:[%d]", att_han);
                                BT_DBG("GATT Server Acquire Notify Offset:    [%d]", offset);
+                               BT_DBG("GATT Server Acquire Notify address:    [%s]", address);
 
 
                        if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipefd) < 0) {
@@ -3265,6 +3272,7 @@ void  bluetooth_gatt_server_send_acquire_notify_response(GVariant * parameters)
                                        chr_info->write_fd = fd;
 
 
+                               BT_INFO("setting up g_io channel");
                                channel = g_io_channel_unix_new(fd);
                                g_io_channel_set_encoding(channel, NULL, NULL);
                                g_io_channel_set_buffered(channel, FALSE);
@@ -3292,4 +3300,43 @@ void  bluetooth_gatt_server_send_acquire_notify_response(GVariant * parameters)
 
                                BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
+
+                               //send
+                               if (result == BLUETOOTH_ERROR_NONE) {
+
+                                       BT_INFO("sending gatt server notification state changed event");
+                                       bluetooth_gatt_server_notification_changed_t info;
+                                       bluetooth_device_address_t dev_address = { {0} };
+                                       memset(&info, 0x00, sizeof(bluetooth_gatt_server_notification_changed_t));
+
+                                       _bt_convert_addr_string_to_type(dev_address.addr, address);
+                                       memcpy(info.device_address.addr,
+                                                       dev_address.addr,
+                                                       BLUETOOTH_ADDRESS_LENGTH);
+                                       info.handle = att_han;
+                                       info.notification = TRUE;
+
+                                       _bt_gatt_server_event_cb(BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED,
+                                                       result, &info,
+                                                       event_info->cb, event_info->user_data);
+
+                               }
+}
+
+void cleanup_gatt_acquire_fd(int handle)
+{
+       bluetooth_gatt_acquire_notify_info_t *chr_info = NULL;
+
+       BT_INFO("+");
+
+       chr_info = bluetooth_get_characteristic_info_from_path(handle);
+
+       if (chr_info != NULL) {
+               BT_INFO("GATT Server: acquire notification char info found");
+
+               if (chr_info->write_fd >= 0) {
+                       BT_INFO("closing fd");
+                       close(chr_info->write_fd);
+               }
+       }
 }
index bcc5dfe..89c9b86 100644 (file)
@@ -9,7 +9,10 @@ extern "C" {
 
 void  bluetooth_gatt_server_send_acquire_write_response(GVariant * parameter);
 
-void  bluetooth_gatt_server_send_acquire_notify_response(GVariant * parameter);
+void  bluetooth_gatt_server_send_acquire_notify_response(GVariant * parameter, bt_event_info_t *event_info);
+
+void cleanup_gatt_acquire_fd(int handle);
+
 
 #ifdef __cplusplus
 }
index afe7243..0e3f5dd 100644 (file)
     </policy>
     <policy context="default">
         <deny own_prefix="org.bt.frwk"/>
-        <deny send_destination_prefix="org.bt.frwk"/>
+        <allow own_prefix="org.bt.frwk"/>
+        <deny send_destination_prefix="org.bt.frwk" send_interface="org.bluez.Profile1"/>
         <deny own_prefix="org.frwk.gatt_service"/>
-        <deny send_destination_prefix="org.frwk.gatt_service"/>
+        <allow own_prefix="org.frwk.gatt_service"/>
+        <deny send_destination_prefix="org.frwk.gatt_service" send_interface="org.bluez.GattDescriptor1"/>
+        <deny send_destination_prefix="org.frwk.gatt_service" send_interface="org.bluez.GattCharacteristic1"/>
     </policy>
 </busconfig>
index 0395d7c..4ba0750 100644 (file)
@@ -1705,10 +1705,18 @@ static void __bt_handle_gatt_server_acquire_notify_requested(event_gatts_srvc_ac
        GVariant *param = NULL;
        int result = BLUETOOTH_ERROR_NONE;
        struct gatt_server_req_info *req_info = NULL;
+       bluetooth_device_address_t dev_addr;
+       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
 
        BT_INFO("GATT Server ACQUIRE  Notify Req Connection ID: [%d]", event->attr_trans.conn_id);
        BT_INFO("GATT Server ACQUIRE Notify  Req Transaction ID:[%d]", event->attr_trans.trans_id);
        BT_INFO("GATT Server ACQUIRE Notify Req Attribute Handle: [%d]", event->attr_trans.attr_handle);
+       BT_INFO("GATT Server ACQUIRE notify Req address : [%s]", address);
+
+       memcpy(dev_addr.addr, event->address.addr, 6);
+       _bt_convert_addr_type_to_string(address,
+                       (unsigned char *)dev_addr.addr);
+       BT_INFO("GATT Server ACQUIRE notify Req remote address : [%s]", address);
 
        req_info = g_new0(struct gatt_server_req_info, 1);
        req_info->request_id = event->attr_trans.trans_id;
@@ -1717,11 +1725,12 @@ static void __bt_handle_gatt_server_acquire_notify_requested(event_gatts_srvc_ac
        req_info->request_type = BLUETOOTH_GATT_REQUEST_TYPE_ACQUIRE_NOTIFY;
        gatt_server_requests = g_slist_append(gatt_server_requests, req_info);
 
-       param = g_variant_new("(iiiiii)", result,
+       param = g_variant_new("(iiiiiis)", result,
                        event->attr_trans.conn_id,
                        event->attr_trans.trans_id,
                        event->attr_trans.attr_handle,
-                       event->mtu, event->attr_trans.offset);
+                       event->mtu, event->attr_trans.offset,
+                       address);
 
        BT_INFO("GATT Server ACQUIRE Notify  Req Attribute : ");