Diff between 7e518f2f9a7dfd195ec39825b41a58d8fcc4a849 and 811c5edc0078e7b358a4b5772d870898f428f6d2

Changed Files

File Additions Deletions Status
android/bluetooth.c +13 -1 modified

Full Patch

diff --git a/android/bluetooth.c b/android/bluetooth.c
index 984ecba..96f6101 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -889,8 +889,20 @@ static void update_device_state(struct device *dev, uint8_t addr_type,
 
 	new_bond = device_bond_state(dev);
 
-	if (old_bond != new_bond)
+	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);
+	}
 }
 
 static void send_device_property(struct device *dev, uint8_t type,