summaryrefslogtreecommitdiff
path: root/android/bluetooth.c
diff options
context:
space:
mode:
authorLukasz Rymanowski <lukasz.rymanowski@tieto.com>2014-09-02 15:55:02 +0200
committerSzymon Janc <szymon.janc@tieto.com>2014-09-02 18:00:06 +0200
commita4083d62eaf4d20864f146cef3639e64f1076a09 (patch)
tree4d0e100d484265f0fbfef625568f3e8b1302dd17 /android/bluetooth.c
parent14453fcd0e4169e3c0959ffb2e751d5f3cffb2e7 (diff)
downloadbluez-a4083d62eaf4d20864f146cef3639e64f1076a09.tar.gz
android/bluetooth: Fix bond state for non-bonded devices
When device is paired but no-bonded, Android GUI keep incorrect bonds state after ACL disconnect. This patch fixes that This patch also moved device_is_paired() up in the file
Diffstat (limited to 'android/bluetooth.c')
-rw-r--r--android/bluetooth.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 5526924ff..8b4701503 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -2051,6 +2051,19 @@ static void mgmt_device_connected_event(uint16_t index, uint16_t length,
HAL_EV_ACL_STATE_CHANGED, sizeof(hal_ev), &hal_ev);
}
+static bool device_is_paired(struct device *dev, uint8_t addr_type)
+{
+ if (addr_type == BDADDR_BREDR)
+ return dev->bredr_paired;
+
+ return dev->le_paired;
+}
+
+static bool device_is_bonded(struct device *dev)
+{
+ return dev->bredr_bonded || dev->le_bonded;
+}
+
static void mgmt_device_disconnected_event(uint16_t index, uint16_t length,
const void *param,
void *user_data)
@@ -2058,6 +2071,7 @@ static void mgmt_device_disconnected_event(uint16_t index, uint16_t length,
const struct mgmt_ev_device_disconnected *ev = param;
struct hal_ev_acl_state_changed hal_ev;
struct device *dev;
+ uint8_t type = ev->addr.type;
if (length < sizeof(*ev)) {
error("Too short device disconnected event (%u bytes)", length);
@@ -2074,6 +2088,11 @@ static void mgmt_device_disconnected_event(uint16_t index, uint16_t length,
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_BLUETOOTH,
HAL_EV_ACL_STATE_CHANGED, sizeof(hal_ev), &hal_ev);
+
+ if (device_is_paired(dev, type) && !device_is_bonded(dev))
+ update_device_state(dev, type, HAL_STATUS_SUCCESS, false,
+ false, false);
+
}
static uint8_t status_mgmt2hal(uint8_t mgmt)
@@ -4302,14 +4321,6 @@ uint8_t bt_device_last_seen_bearer(const bdaddr_t *bdaddr)
return select_device_bearer(dev);
}
-static bool device_is_paired(struct device *dev, uint8_t addr_type)
-{
- if (addr_type == BDADDR_BREDR)
- return dev->bredr_paired;
-
- return dev->le_paired;
-}
-
static void handle_create_bond_cmd(const void *buf, uint16_t len)
{
const struct hal_cmd_create_bond *cmd = buf;