Modify the logic of bonding with LE type
[platform/core/connectivity/bluetooth-frwk.git] / bt-service-adaptation / services / device / bt-service-core-device.c
index 38adcd1..01c0461 100644 (file)
@@ -1832,6 +1832,7 @@ int _bt_bond_device(bluetooth_device_address_t *device_address,
        int result = BLUETOOTH_ERROR_NONE;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        bluetooth_device_info_t dev_info;
+       const char *stack_name = NULL;
        BT_DBG("+");
 
        retv_if(device_address == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
@@ -1855,19 +1856,21 @@ int _bt_bond_device(bluetooth_device_address_t *device_address,
 
        /* Ready to initiate bonding */
 
-       /* In Tizen, we will first remove bond and then attempt to create bond to keep
-          consistency with bluedroid. Even if remove bond fails due to device not already
-          bonded, then straight away create bond is triggered. This is because, remove bond
-          is handled differently in bluedroid and bluez. In Bluez, if device is
-          already removed, remove bond call fails.
-          However in bluedroid, remove bond on already removed device returns success. So we will
-          handle the cases transparently*/
-       if (conn_type == BLUETOOTH_DEV_CONN_BREDR) {
-               bt_device_bond_state = BT_DEVICE_BOND_STATE_REMOVE_BONDING;
-       } else if (conn_type == BLUETOOTH_DEV_CONN_LE) {
-               /* No need to remove if LE conn */
+       stack_name = oal_get_stack_name();
+       if (stack_name && !g_strcmp0(stack_name, "bluez")) {
+               BT_DBG("[bluez] Create bond by type %d", conn_type);
                bt_device_bond_state = BT_DEVICE_BOND_STATE_REMOVED_BONDING;
+       } else {
+               /* In Tizen, we will first remove bond and then attempt to create bond to keep
+                  consistency with bluedroid. Even if remove bond fails due to device not already
+                  bonded, then straight away create bond is triggered. This is because, remove bond
+                  is handled differently in bluedroid and bluez. In Bluez, if device is
+                  already removed, remove bond call fails.
+                  However in bluedroid, remove bond on already removed device returns success. So we will
+                  handle the cases transparently */
+               bt_device_bond_state = BT_DEVICE_BOND_STATE_REMOVE_BONDING;
        }
+
        bond_retry_count = 0;
        result = __bt_device_handle_bond_state();