summaryrefslogtreecommitdiff
path: root/android/bluetooth.c
diff options
context:
space:
mode:
authorLukasz Rymanowski <lukasz.rymanowski@tieto.com>2014-09-02 15:54:59 +0200
committerSzymon Janc <szymon.janc@tieto.com>2014-09-02 17:59:38 +0200
commit8029744da20f39d799f3be790db18066f8cb68d7 (patch)
treea232745a7623d4680608978b3b1ba81d7e9c113a /android/bluetooth.c
parent5d3bff7a9370182e27e154a30280722aa7d7657f (diff)
downloadbluez-8029744da20f39d799f3be790db18066f8cb68d7.tar.gz
android/bluetooth: Extract function sending bond state
Diffstat (limited to 'android/bluetooth.c')
-rw-r--r--android/bluetooth.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 211e0600b..e71f8084c 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -879,6 +879,27 @@ static uint8_t device_bond_state(struct device *dev)
return HAL_BOND_STATE_NONE;
}
+static void update_bond_state(struct device *dev, uint8_t status,
+ uint8_t old_bond, uint8_t new_bond)
+{
+ if (old_bond == new_bond)
+ return;
+
+ /*
+ * For incoming just works bonding we will switch here from
+ * non bonded to bonded directly. This is something Android
+ * will not handle in their bond state machine. To make Android
+ * handle it corretly we need to send BONDING state before BOND
+ */
+ if (old_bond == HAL_BOND_STATE_NONE &&
+ new_bond == HAL_BOND_STATE_BONDED)
+ send_bond_state_change(dev, status,
+ HAL_BOND_STATE_BONDING);
+
+ send_bond_state_change(dev, status, new_bond);
+
+}
+
static void update_device_state(struct device *dev, uint8_t addr_type,
uint8_t status, bool pairing, bool paired,
bool bonded)
@@ -894,20 +915,7 @@ static void update_device_state(struct device *dev, uint8_t addr_type,
new_bond = device_bond_state(dev);
- if (old_bond != new_bond) {
- /*
- * For incoming just works bonding we will switch here from
- * non bonded to bonded directly. This is something Android
- * will not handle in their bond state machine. To make Android
- * handle it corretly we need to send BONDING state before BOND
- */
- if (old_bond == HAL_BOND_STATE_NONE &&
- new_bond == HAL_BOND_STATE_BONDED)
- send_bond_state_change(dev, status,
- HAL_BOND_STATE_BONDING);
-
- send_bond_state_change(dev, status, new_bond);
- }
+ update_bond_state(dev, status, old_bond, new_bond);
}
static void send_device_property(struct device *dev, uint8_t type,