@@ -79,8 +79,6 @@
#include "advertising.h"
#include "eir.h"
-#define ADAPTER_INTERFACE "org.bluez.Adapter1"
-
#define MODE_OFF 0x00
#define MODE_CONNECTABLE 0x01
#define MODE_DISCOVERABLE 0x02
@@ -26,6 +26,8 @@
#include <dbus/dbus.h>
#include <glib.h>
+#define ADAPTER_INTERFACE "org.bluez.Adapter1"
+
#define MAX_NAME_LENGTH 248
/* Invalid SSP passkey value used to indicate negative replies */
@@ -3001,6 +3001,7 @@ void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type)
void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type)
{
struct bearer_state *state = get_state(device, bdaddr_type);
+ bool remove_device = false;
if (!state->connected)
return;
@@ -3018,6 +3019,10 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type)
while (device->disconnects) {
DBusMessage *msg = device->disconnects->data;
+ if (dbus_message_is_method_call(msg, ADAPTER_INTERFACE,
+ "RemoveDevice"))
+ remove_device = true;
+
g_dbus_send_reply(dbus_conn, msg, DBUS_TYPE_INVALID);
device->disconnects = g_slist_remove(device->disconnects, msg);
dbus_message_unref(msg);
@@ -3043,6 +3048,9 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type)
g_dbus_emit_property_changed(dbus_conn, device->path,
DEVICE_INTERFACE, "Connected");
+
+ if (remove_device)
+ btd_adapter_remove_device(device->adapter, device);
}
guint device_add_disconnect_watch(struct btd_device *device,
@@ -4457,6 +4465,9 @@ void device_remove(struct btd_device *device, gboolean remove_stored)
disconnect_all(device);
}
+ if (device->temporary_timer > 0)
+ g_source_remove(device->temporary_timer);
+
if (device->store_id > 0) {
g_source_remove(device->store_id);
device->store_id = 0;