From 2b40bd6cf83ee257ae5d6dd9c2d7ca726014bc26 Mon Sep 17 00:00:00 2001 From: himanshu Date: Wed, 15 Apr 2020 14:06:42 +0530 Subject: [PATCH] Return ALREADY_CONNECT ERROR if device is already paired Change-Id: I1ff5ec86191059d740cba14b19f2eef0e42ff8a6 Signed-off-by: himanshu --- bt-oal/bluez_hal/src/bt-hal-device-dbus-handler.c | 9 +++------ bt-oal/common/oal-common.c | 2 ++ bt-oal/hardware/bluetooth.h | 3 ++- bt-oal/include/oal-manager.h | 3 ++- .../services/device/bt-service-core-device.c | 12 ++++++++++++ 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/bt-oal/bluez_hal/src/bt-hal-device-dbus-handler.c b/bt-oal/bluez_hal/src/bt-hal-device-dbus-handler.c index 8ed366f..1ffc035 100644 --- a/bt-oal/bluez_hal/src/bt-hal-device-dbus-handler.c +++ b/bt-oal/bluez_hal/src/bt-hal-device-dbus-handler.c @@ -737,8 +737,8 @@ static void __bt_hal_bond_device_cb(GDBusProxy *proxy, GAsyncResult *res, g_dbus_error_strip_remote_error(err); ERR("@@@Error occured in CreateBonding [%s]", err->message); if (g_strrstr(err->message, "Already Exists")) { - ERR("Still bond existing even after remove"); - result = BT_STATUS_AUTH_FAILURE; + ERR("Bond Already exists"); + result = BT_STATUS_ALREADY_CONNECT; } else if (g_strrstr(err->message, "Authentication Rejected")) { INFO("REJECTED"); result = BT_STATUS_AUTH_REJECTED; @@ -774,10 +774,7 @@ static void __bt_hal_bond_device_cb(GDBusProxy *proxy, GAsyncResult *res, } } - if (result == BT_STATUS_AUTH_FAILURE || - result == BT_STATUS_RMT_DEV_DOWN || - result == BT_STATUS_AUTH_REJECTED || - result == BT_STATUS_FAIL) { + if (result != BT_STATUS_SUCCESS) { DBG("Bonding Failed!!"); /* Prepare to send event to HAL bluetooth */ diff --git a/bt-oal/common/oal-common.c b/bt-oal/common/oal-common.c index a367159..068cf6f 100644 --- a/bt-oal/common/oal-common.c +++ b/bt-oal/common/oal-common.c @@ -187,6 +187,8 @@ oal_status_t convert_to_oal_status(bt_status_t status) break; case BT_STATUS_CONN_TOUT: ret = OAL_STATUS_LINK_LOSS; + case BT_STATUS_ALREADY_CONNECT: + ret = OAL_STATUS_ALREADY_CONNECT; break; #ifdef TIZEN_BT_HAL case BT_STATUS_CONN_TERM_LOCAL_HOST: diff --git a/bt-oal/hardware/bluetooth.h b/bt-oal/hardware/bluetooth.h index 7cda2ee..6a233bc 100644 --- a/bt-oal/hardware/bluetooth.h +++ b/bt-oal/hardware/bluetooth.h @@ -98,7 +98,8 @@ typedef enum { BT_STATUS_CONN_TOUT, /* disconnection due to supervision timeout */ BT_STATUS_AUTH_REJECTED, BT_STATUS_CONN_TERM_LOCAL_HOST, - BT_STATUS_CONN_TERM_RMT_HOST + BT_STATUS_CONN_TERM_RMT_HOST, + BT_STATUS_ALREADY_CONNECT, #endif } bt_status_t; diff --git a/bt-oal/include/oal-manager.h b/bt-oal/include/oal-manager.h index dc4fa39..8a1ab7d 100755 --- a/bt-oal/include/oal-manager.h +++ b/bt-oal/include/oal-manager.h @@ -82,7 +82,8 @@ typedef enum { #else OAL_STATUS_LINK_LOSS, OAL_STATUS_CONN_TERM_LOCAL_HOST, - OAL_STATUS_CONN_TERM_RMT_HOST + OAL_STATUS_CONN_TERM_RMT_HOST, + OAL_STATUS_ALREADY_CONNECT, #endif } oal_status_t; diff --git a/bt-service-adaptation/services/device/bt-service-core-device.c b/bt-service-adaptation/services/device/bt-service-core-device.c index 33867f8..c6e2ad5 100644 --- a/bt-service-adaptation/services/device/bt-service-core-device.c +++ b/bt-service-adaptation/services/device/bt-service-core-device.c @@ -924,6 +924,18 @@ static void __bt_device_handle_bond_failed_event(event_dev_bond_failed_t* bond_f __bt_free_pairing_info(&trigger_pairing_info); break; } + case OAL_STATUS_ALREADY_CONNECT: + { + int result = BLUETOOTH_ERROR_ALREADY_CONNECT; + BT_INFO("OAL_STATUS_ALREADY_CONNECT"); + + if (trigger_bond_info) { + __bt_device_handle_pending_requests(result, BT_BOND_DEVICE, + trigger_bond_info->addr, BT_ADDRESS_STRING_SIZE); + __bt_free_bond_info(BT_DEVICE_BOND_INFO); + } + break; + } case OAL_STATUS_INTERNAL_ERROR: { BT_INFO("OAL_STATUS_INTERNAL_ERROR"); -- 2.7.4