Return errors without retry if bond info. already exists or it's in progress 94/198194/1 accepted/tizen/unified/20190128.061620 submit/tizen/20190123.050251
authorDeokhyun Kim <dukan.kim@samsung.com>
Tue, 22 Jan 2019 07:38:49 +0000 (16:38 +0900)
committerDeokhyun Kim <dukan.kim@samsung.com>
Tue, 22 Jan 2019 07:38:49 +0000 (16:38 +0900)
  If create_bond is called in case GATT is connected and it's already bonded,
  then bond info. is removed and GATT is disconnected unexpectedly.

Change-Id: I078da398322f68522e427c7b7f18a8fd8e229f91
Signed-off-by: Deokhyun Kim <dukan.kim@samsung.com>
bt-service/bt-service-device.c

index 3b33125..e7002e9 100644 (file)
@@ -122,9 +122,6 @@ static guint pending_le_conn_timer_id = 0;
 static void __bt_bond_device_cb(GDBusProxy *proxy, GAsyncResult *res,
                                        gpointer user_data);
 
-static int __bt_retry_bond(void);
-
-
 /*static void __bt_decline_pair_request()
 {
        GVariant *out_param1;
@@ -691,81 +688,6 @@ static int __bt_cancel_bonding(void)
        return BLUETOOTH_ERROR_NONE;
 }
 
-static int __bt_retry_bond(void)
-{
-       BT_CHECK_PARAMETER(bonding_info, return);
-       BT_CHECK_PARAMETER(bonding_info->addr, return);
-
-       g_dbus_proxy_call(bonding_info->device_proxy, "Pair",
-                               g_variant_new("(y)", bonding_info->conn_type),
-                               G_DBUS_CALL_FLAGS_NONE,
-                               BT_MAX_DBUS_TIMEOUT,
-                               NULL,
-                               (GAsyncReadyCallback)__bt_bond_device_cb,
-                               NULL);
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-
-static int __bt_remove_and_bond(void)
-{
-       GDBusProxy *adapter_proxy;
-       GVariant *result = NULL;
-       GError *err = NULL;
-       char *device_path = NULL;
-
-       BT_CHECK_PARAMETER(bonding_info, return);
-       BT_CHECK_PARAMETER(bonding_info->addr, return);
-
-       adapter_proxy = _bt_get_adapter_proxy();
-       retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       result = g_dbus_proxy_call_sync(adapter_proxy, "FindDevice",
-                               g_variant_new("(s)", bonding_info->addr),
-                               G_DBUS_CALL_FLAGS_NONE,
-                               -1,
-                               NULL,
-                               NULL);
-       if (result == NULL)
-               return BLUETOOTH_ERROR_INTERNAL;
-
-       g_variant_get(result , "(o)", &device_path);
-       g_variant_unref(result);
-
-       retv_if(device_path == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       result = g_dbus_proxy_call_sync(adapter_proxy, "UnpairDevice",
-                               g_variant_new("(o)", device_path),
-                               G_DBUS_CALL_FLAGS_NONE,
-                               -1,
-                               NULL,
-                               &err);
-       g_free(device_path);
-       if (result == NULL) {
-               if (err != NULL) {
-                       BT_ERR("UnpairDevice Fail: %s", err->message);
-                       g_error_free(err);
-               }
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       return __bt_retry_bond();
-}
-
-static int __bt_cancel_and_bond(void)
-{
-       int ret = BLUETOOTH_ERROR_NONE;
-
-       ret = _bt_agent_reply_cancellation();
-       if (ret != BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Fail to call reply cancellation");
-               return ret;
-       }
-       return __bt_retry_bond();
-}
-
-
 static void __bt_bond_device_cb(GDBusProxy *proxy, GAsyncResult *res,
                                        gpointer user_data)
 {
@@ -807,10 +729,8 @@ static void __bt_bond_device_cb(GDBusProxy *proxy, GAsyncResult *res,
                BT_ERR("Error occured in CreateBonding [%s]", err->message);
 
                if (g_strrstr(err->message, "Already Exists")) {
-                       BT_INFO("Existing Bond, remove and retry");
-                       ret_if(__bt_remove_and_bond() == BLUETOOTH_ERROR_NONE);
-
-                       result = BLUETOOTH_ERROR_PARING_FAILED;
+                       BT_INFO("Existing Bond");
+                       result = BLUETOOTH_ERROR_ALREADY_CONNECT;
                } else if (_bt_agent_is_canceled() ||
                        g_strrstr(err->message, "Authentication Canceled")) {
                        BT_INFO("Cancelled by USER");
@@ -819,10 +739,8 @@ static void __bt_bond_device_cb(GDBusProxy *proxy, GAsyncResult *res,
                        BT_INFO("REJECTED");
                        result = BLUETOOTH_ERROR_ACCESS_DENIED;
                } else if (g_strrstr(err->message, "In Progress")) {
-                       BT_INFO("Bond in progress, cancel and retry");
-                       ret_if(__bt_cancel_and_bond() == BLUETOOTH_ERROR_NONE);
-
-                       result = BLUETOOTH_ERROR_PARING_FAILED;
+                       BT_INFO("Bond in progress");
+                       result = BLUETOOTH_ERROR_IN_PROGRESS;
                } else if (g_strrstr(err->message, "Authentication Failed")) {
                        BT_INFO("Authentication Failed");
                        if (bonding_info->is_autopair == TRUE) {