diff --git a/android/hidhost.c b/android/hidhost.c
index b4e5c52..e0e3ecf 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
if (dev->hog) {
bt_hid_notify_state(dev,
HAL_HIDHOST_STATE_DISCONNECTED);
- bt_hog_detach(dev->hog);
+ bt_hog_detach(dev->hog, true);
return;
}
goto fail;
diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c
index 2d8d0f3..964acc7 100644
--- a/profiles/input/hog-lib.c
+++ b/profiles/input/hog-lib.c
{
struct bt_hog *hog = data;
- bt_hog_detach(hog);
+ bt_hog_detach(hog, true);
uhid_destroy(hog);
queue_destroy(hog->bas, (void *) bt_bas_unref);
return true;
}
-void bt_hog_detach(struct bt_hog *hog)
+void bt_hog_detach(struct bt_hog *hog, bool force)
{
GSList *l;
for (l = hog->instances; l; l = l->next) {
struct bt_hog *instance = l->data;
- bt_hog_detach(instance);
+ bt_hog_detach(instance, force);
}
for (l = hog->reports; l; l = l->next) {
queue_remove_all(hog->gatt_op, cancel_gatt_req, hog, destroy_gatt_req);
g_attrib_unref(hog->attrib);
hog->attrib = NULL;
+
+ if (force)
+ uhid_destroy(hog);
}
int bt_hog_set_control_point(struct bt_hog *hog, bool suspend)
diff --git a/profiles/input/hog-lib.h b/profiles/input/hog-lib.h
index a796489..abca829 100644
--- a/profiles/input/hog-lib.h
+++ b/profiles/input/hog-lib.h
void bt_hog_unref(struct bt_hog *hog);
bool bt_hog_attach(struct bt_hog *hog, void *gatt);
-void bt_hog_detach(struct bt_hog *hog);
+void bt_hog_detach(struct bt_hog *hog, bool force);
int bt_hog_set_control_point(struct bt_hog *hog, bool suspend);
int bt_hog_send_report(struct bt_hog *hog, void *data, size_t size, int type);
diff --git a/profiles/input/hog.c b/profiles/input/hog.c
index d50b823..2db52d1 100644
--- a/profiles/input/hog.c
+++ b/profiles/input/hog.c
{
struct hog_device *dev = btd_service_get_user_data(service);
- bt_hog_detach(dev->hog);
+ bt_hog_detach(dev->hog, false);
btd_service_disconnecting_complete(service, 0);