Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/5] android/bluetooth: Extract function sending bond state
@ 2014-09-02 13:54 Lukasz Rymanowski
  2014-09-02 13:55 ` [PATCH 2/5] android/bluetooth: Fix status in "fake" bonding notification Lukasz Rymanowski
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Lukasz Rymanowski @ 2014-09-02 13:54 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lukasz Rymanowski

---
 android/bluetooth.c | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index bd1e747..7c3c198 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -877,6 +877,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)
@@ -892,20 +913,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,
-- 
1.8.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-09-02 16:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-02 13:54 [PATCH 1/5] android/bluetooth: Extract function sending bond state Lukasz Rymanowski
2014-09-02 13:55 ` [PATCH 2/5] android/bluetooth: Fix status in "fake" bonding notification Lukasz Rymanowski
2014-09-02 13:55 ` [PATCH 3/5] android/bluetooth: Improve sending bond state notification Lukasz Rymanowski
2014-09-02 13:55 ` [PATCH 4/5] android/bluetooth: Fix bond state for non-bonded devices Lukasz Rymanowski
2014-09-02 13:55 ` [PATCH 5/5] android/tester: Add test verifying correct bond state notification Lukasz Rymanowski
2014-09-02 16:04 ` [PATCH 1/5] android/bluetooth: Extract function sending bond state Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox