Fix : LE Connect d-bus method is not returned 56/136656/1
authorSeungyoun Ju <sy39.ju@samsung.com>
Wed, 21 Jun 2017 06:25:59 +0000 (15:25 +0900)
committerSeungyoun Ju <sy39.ju@samsung.com>
Fri, 30 Jun 2017 14:41:41 +0000 (23:41 +0900)
[Problem] While advertising is going on, if le connection is initiated
 to the device which doesn't have proxy (it means that the device neither
 be discovered once nor be paired), d-bus timeout happens in caller side.
[Cause & Measure] When le connection API is called in timer callback,
 there is no logic to reply to previous d-bus method call. This patch
 adds the logic to return the result in such a case.
[Checking Method] Try to connect to unknown LE device during advertising

Change-Id: Icbeba665eb749b84bc6bb35deeff09747c4a007a

bt-service/bt-service-device.c

index 96c8a78..6b17704 100644 (file)
@@ -1990,14 +1990,41 @@ fail:
 
 static gboolean __bt_connect_le_timer_cb(gpointer user_data)
 {
+       int ret;
+
        BT_INFO("Try to initiate pending LE connection");
 
        pending_le_conn_timer_id = 0;
 
-       __bt_connect_le_device_internal(pending_le_conn_info->req_id,
-               &pending_le_conn_info->bd_addr,
-               pending_le_conn_info->auto_connect);
+       ret = __bt_connect_le_device_internal(pending_le_conn_info->req_id,
+                       &pending_le_conn_info->bd_addr,
+                       pending_le_conn_info->auto_connect);
+       if (ret != BLUETOOTH_ERROR_NONE) {
+               request_info_t *req_info = NULL;
+               GVariant *out_param1;
+
+               req_info = _bt_get_request_info(pending_le_conn_info->req_id);
+               if (req_info == NULL) {
+                       BT_ERR("req_info is NULL");
+                       goto done;
+               }
+
+               if (req_info->context == NULL) {
+                       BT_ERR("req_info->context is NULL");
+                       _bt_delete_request_list(req_info->req_id);
+                       goto done;
+               }
+
+               out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+                               &pending_le_conn_info->bd_addr,
+                               sizeof(bluetooth_device_address_t), TRUE,
+                               NULL, NULL);
 
+               g_dbus_method_invocation_return_value(req_info->context,
+                               g_variant_new("(iv)", ret, out_param1));
+       }
+
+done:
        g_free(pending_le_conn_info);
        pending_le_conn_info = NULL;