Modify the logic of bonding with LE type 34/223234/1
authorWootak Jung <wootak.jung@samsung.com>
Wed, 15 Jan 2020 04:34:27 +0000 (13:34 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Tue, 28 Jan 2020 00:48:05 +0000 (09:48 +0900)
No need to unbond before bond with bluez stack
Add new oal function to get stack name

Change-Id: I29ade86c73bba5a26306a091b5da58a99f7666a8

bt-oal/bluez_hal/src/bt-hal-bluetooth.c
bt-oal/include/oal-manager.h
bt-oal/oal-manager.c
bt-service-adaptation/services/device/bt-service-core-device.c

index d914d3e..7c7dd44 100644 (file)
@@ -541,7 +541,7 @@ struct hw_module_t HAL_MODULE_INFO_SYM = {
        .version_major = 1,
        .version_minor = 0,
        .id = BT_HARDWARE_MODULE_ID,
-       .name = "Bluetooth stack",
+       .name = "bluez",
        .author = "Intel Corporation",
        .methods = &bluetooth_module_methods
 };
index ac05875..2b02fee 100755 (executable)
@@ -251,6 +251,15 @@ gboolean oal_get_debug_mode(void);
 void server_event_catch_register(oal_event_callback dbg_cb);
 #endif
 
+/**
+ * @brief Get stack name
+ *
+ * @return stack name
+ *
+ * @pre OAL API must be initialized with oal_bt_init().
+ */
+const char *oal_get_stack_name(void);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 56b821f..0d28d52 100644 (file)
@@ -263,3 +263,8 @@ gboolean oal_get_debug_mode(void)
        /*TODO Unsupported */
        return FALSE;
 }
+
+const char *oal_get_stack_name(void)
+{
+       return module ? module->name : NULL;
+}
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();