device: Fix issue where the le connection was not completely released when le bond... 23/315523/1 accepted/tizen/7.0/unified/20241217.173206
authorWootak Jung <wootak.jung@samsung.com>
Fri, 29 Nov 2024 00:41:45 +0000 (09:41 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Fri, 29 Nov 2024 05:46:17 +0000 (14:46 +0900)
Change-Id: I5069dc4e7f005f019af4cb370698510aaf0ef4c0
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
src/device.c
src/device.h
src/gatt-database.c

index 769c6badc9d9c3e028aabfbf7369bc9cc1bb3ce9..4ee9e1d5f6f65cf83ef189e6e4f46dc6fed20f11 100644 (file)
@@ -111,6 +111,9 @@ struct bonding_req {
        guint retry_timer;
        struct timespec attempt_start_time;
        long last_attempt_duration_ms;
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       GIOChannel *io;
+#endif
 };
 
 typedef enum {
@@ -1848,6 +1851,13 @@ void device_set_accept_io(const struct btd_device *device, GIOChannel *io)
                conn_info->accept_io = io;
        }
 }
+
+void device_set_le_bonding_io(struct btd_device *device, GIOChannel *io)
+{
+       if (device->bonding) {
+               device->bonding->io = io;
+       }
+}
 #endif
 
 static void append_manufacturer_data(void *data, void *user_data)
@@ -3647,6 +3657,13 @@ static void bonding_request_free(struct bonding_req *bonding)
        if (!bonding)
                return;
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       if (bonding->io) {
+               g_io_channel_shutdown(bonding->io, FALSE, NULL);
+               g_io_channel_unref(bonding->io);
+       }
+#endif
+
        if (bonding->listener_id)
                g_dbus_remove_watch(dbus_conn, bonding->listener_id);
 
@@ -3792,10 +3809,7 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
         * this in the ATT connect callback)
         */
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-       if (((conn_type == DEV_CONN_LE && bdaddr_type != BDADDR_BREDR) ||
-               (connect_le)) && !device->le_state.connected)
-               err = device_connect_le(device);
-       else if (connect_le) /* Send bonding request if LE is already connected*/
+       if ((conn_type == DEV_CONN_LE && bdaddr_type != BDADDR_BREDR) || connect_le)
                err = adapter_create_bonding(adapter, &device->bdaddr,
                                                        bdaddr_type, io_cap);
        else
index 22b4e422319e4b3387b61474c9ff11db2e3b4de9..596ed62faa1204f7487d8f3e8cd48911c2c0c9b1 100644 (file)
@@ -245,6 +245,7 @@ void btd_device_set_legacy_pairing(struct btd_device *dev, bool legacy_pairing);
 void btd_device_set_svc_changed_indication(struct btd_device *dev, bool value);
 bool btd_device_get_svc_changed_indication(struct btd_device *dev);
 void device_set_accept_io(const struct btd_device *device, GIOChannel *io);
+void device_set_le_bonding_io(struct btd_device *device, GIOChannel *io);
 #ifdef TIZEN_FEATURE_BLUEZ_BATTERY_WATCH
 void device_change_pkt_type(gpointer data, gpointer user_data);
 #endif /* TIZEN_FEATURE_BLUEZ_BATTERY_WATCH */
index 8a75831c42a46c39430fe69c22cdf4ae71a26785..ed7011060a82e4131f0386d81a21577e907f4272 100644 (file)
@@ -733,6 +733,7 @@ static void connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
 
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        device_set_accept_io(device, io);
+       device_set_le_bonding_io(device, io);
 
        if (btd_device_get_svc_changed_indication(device)) {
                send_service_changed_indication_on_reconnect(device,