device: Fix issue where the le connection was not completely released when le bond... 90/316790/1
authorWootak Jung <wootak.jung@samsung.com>
Fri, 29 Nov 2024 00:41:45 +0000 (09:41 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Tue, 17 Dec 2024 02:09:54 +0000 (11:09 +0900)
Change-Id: I5069dc4e7f005f019af4cb370698510aaf0ef4c0
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
src/device.c
src/device.h
src/gatt-database.c

index 87be2942a4d97137d7f5788dac1e050a7e0489f4..97015fa5efbe0f823eb67de9f9a8c0086213f28c 100644 (file)
@@ -108,6 +108,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 {
@@ -1917,6 +1920,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)
@@ -3691,6 +3701,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);
 
@@ -3836,10 +3853,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 8346d6c60dd606a3477ec2270c597004eaa5be83..248020c9b4825499ff29a280ce126e3d0f4d4762 100644 (file)
@@ -257,6 +257,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 468655c98d489bec1768bc14fc95cb3ce1853ca5..180851de70c3d2feb49e233c6431fa70ad4e93bb 100644 (file)
@@ -747,6 +747,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,