Apply LE OOB pairing related patchsets: 03/234703/2
authorWootak Jung <wootak.jung@samsung.com>
Thu, 28 May 2020 06:00:38 +0000 (15:00 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Thu, 28 May 2020 06:07:43 +0000 (15:07 +0900)
1. Fix: LE OOB pairing failed
2. Keep LE oob data to reduce NFC OOB pairing failure
3. Move the poistion to set OOB data with random address
4. Fix: LE OOB pairing fail after Flight mode

Change-Id: I096a25e267dd675bb72e9f0f3436868894d4638f
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
bt-api/bt-common.c
bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c
bt-service-adaptation/services/bt-request-handler.c
bt-service-adaptation/services/include/bt-service-core-adapter-le.h
bt-service-adaptation/services/obex/bt-service-oob.c
bt-service-adaptation/services/obex/include/bt-service-oob.h

index 1e6341c..867e43f 100644 (file)
@@ -1605,7 +1605,7 @@ int _bt_discover_service_uuids(char *address, char *remote_uuid)
        GVariant *value = NULL;
        GVariant *ret = NULL;
        int result = BLUETOOTH_ERROR_INTERNAL;
-       BT_INFO("+");
+
        retv_if(remote_uuid == NULL, BLUETOOTH_ERROR_INTERNAL);
        gconn = _bt_get_system_private_conn();
        retv_if(gconn == NULL, BLUETOOTH_ERROR_INTERNAL);
index 5f146f3..ab6d4b8 100644 (file)
@@ -33,6 +33,7 @@
 #include "bt-service-gatt.h"
 #include "bt-service-util.h"
 #include "bt-service-core-device.h"
+#include "bt-service-oob.h"
 #include "bt-service-battery-monitor.h"
 
 #include <oal-hardware.h>
@@ -81,6 +82,8 @@ static GSList *adv_data_pending_list = NULL;
 static bt_le_status_t adapter_le_state = BT_LE_DEACTIVATED;
 static bt_le_discovery_state_t adapter_le_discovery_state = LE_DISCOVERY_STOPPED;
 
+static bool is_static_random_address = false;
+
 /******************************************* LE Scan *********************************************/
 #define BT_LE_SCAN_INTERVAL_MIN 2.5
 #define BT_LE_SCAN_INTERVAL_MAX 10240
@@ -193,6 +196,8 @@ static gboolean __bt_le_post_set_disabled(gpointer user_data)
        BT_INFO("_bt_adapter_post_set_disabled>>");
 
        /* Add LE disabled post processing codes */
+       _bt_le_oob_reset_local_cache_data();
+       is_static_random_address = false;
 
        return FALSE;
 }
@@ -2299,7 +2304,13 @@ int _bt_set_le_static_random_address(gboolean is_enable)
        } else {
                BT_INFO("SetLeStaticRandomAddress as %d", is_enable);
                result = BLUETOOTH_ERROR_NONE;
+               is_static_random_address = is_enable;
        }
 
        return result;
 }
+
+bool _bt_is_le_static_random_address_enabled(void)
+{
+       return is_static_random_address;
+}
index 15cb4d2..a879275 100644 (file)
@@ -2128,9 +2128,23 @@ int __bt_bluez_request(int function_name,
        }
        case BT_LE_OOB_READ_LOCAL_DATA: {
                bt_oob_data_t local_oob_data;
+               bt_oob_data_t *local_oob_cache_data;
+
+               local_oob_cache_data = _bt_le_oob_get_local_cache_data();
+               if (local_oob_cache_data && local_oob_cache_data->eir_len) {
+                       g_array_append_vals(*out_param1, local_oob_cache_data,
+                               sizeof(bt_oob_data_t));
+                       return BLUETOOTH_ERROR_NONE;
+               }
+
+               /* We should modify this logic in later */
+               if (_bt_is_le_static_random_address_enabled() == false) {
+                       /* Seperate BT & LE address */
+                       _bt_set_le_static_random_address(TRUE);
+               }
 
-               memset(&local_oob_data, 0x00, sizeof(bt_oob_data_t));
                result = _bt_le_oob_read_local_data(&local_oob_data);
+               _bt_le_oob_set_local_cache_data(&local_oob_data);
 
                g_array_append_vals(*out_param1, &local_oob_data,
                                sizeof(bt_oob_data_t));
index 0e41726..fb37f5d 100644 (file)
@@ -110,6 +110,8 @@ gboolean _bt_is_scan_filter_supported(void);
 
 int _bt_set_le_static_random_address(gboolean is_enable);
 
+bool _bt_is_le_static_random_address_enabled(void);
+
 int _bt_set_le_privacy(gboolean set_privacy);
 
 int _bt_set_white_list(bluetooth_device_address_t *device_address, int address_type, bool is_add);
index ca09467..b791809 100644 (file)
@@ -31,6 +31,8 @@
 #include "bt-service-oob.h"
 #include "bt-service-event.h"
 
+static bt_oob_data_t local_le_oob_cache_data = {0, };
+
 static int __get_oob_data_from_variant(GVariant *variant,
                unsigned char *buf, int size)
 {
@@ -342,6 +344,7 @@ int _bt_le_oob_read_local_data(bt_oob_data_t *local_oob_data)
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
+       BT_INFO("Get LE OOB data");
        reply = g_dbus_proxy_call_sync(proxy, "LEReadLocalData",
                        NULL,
                        G_DBUS_CALL_FLAGS_NONE, -1,
@@ -371,3 +374,21 @@ int _bt_le_oob_read_local_data(bt_oob_data_t *local_oob_data)
        return BLUETOOTH_ERROR_NONE;
 }
 
+void _bt_le_oob_reset_local_cache_data(void)
+{
+       memset(&local_le_oob_cache_data, 0x00, sizeof(bt_oob_data_t));
+}
+
+bt_oob_data_t *_bt_le_oob_get_local_cache_data(void)
+{
+       if (local_le_oob_cache_data.eir_len)
+               return &local_le_oob_cache_data;
+       else
+               return NULL;
+}
+
+void _bt_le_oob_set_local_cache_data(bt_oob_data_t *data)
+{
+       memcpy(&local_le_oob_cache_data, data, sizeof(bt_oob_data_t));
+}
+
index 18c9c01..45fccb7 100644 (file)
@@ -39,6 +39,13 @@ int _bt_oob_remove_remote_data(
 
 int _bt_le_oob_read_local_data(bt_oob_data_t *local_oob_data);
 
+void _bt_le_oob_reset_local_cache_data(void);
+
+bt_oob_data_t *_bt_le_oob_get_local_cache_data(void);
+
+void _bt_le_oob_set_local_cache_data(bt_oob_data_t *data);
+
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */