From 2a07e06b099a9c1bcbb0ca3678cf5782aa817d83 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Wed, 29 Jan 2014 17:08:05 +0100 Subject: [PATCH] android/bluetooth: Fix unbonding device on auth failure This was causing removal of device info from storage and resulting in loosing bond after bluetoothd restart. --- android/bluetooth.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/android/bluetooth.c b/android/bluetooth.c index b105ac8d2..d74d7927f 100644 --- a/android/bluetooth.c +++ b/android/bluetooth.c @@ -1279,6 +1279,7 @@ static void mgmt_auth_failed_event(uint16_t index, uint16_t length, const void *param, void *user_data) { const struct mgmt_ev_auth_failed *ev = param; + struct device *dev; if (length < sizeof(*ev)) { error("Too small auth failed mgmt event (%u bytes)", length); @@ -1287,8 +1288,12 @@ static void mgmt_auth_failed_event(uint16_t index, uint16_t length, DBG(""); - set_device_bond_state(&ev->addr.bdaddr, status_mgmt2hal(ev->status), - HAL_BOND_STATE_NONE); + dev = find_device(&ev->addr.bdaddr); + + if (dev && dev->bond_state == HAL_BOND_STATE_BONDING) + set_device_bond_state(&ev->addr.bdaddr, + status_mgmt2hal(ev->status), + HAL_BOND_STATE_NONE); } static void mgmt_device_unpaired_event(uint16_t index, uint16_t length, -- 2.47.3