commit | d35167adcaa40cb54df8e392379dfdfe98bcdba2 | [log] [tgz] |
---|---|---|
author | Sungki Kim <skkim7@gmail.com> | Thu May 19 10:18:07 2016 -0700 |
committer | Andre Eisenbach <eisenbach@google.com> | Thu May 19 18:25:25 2016 +0000 |
tree | 140bff52a19e40f469567735d5b9369ad61b3ebc | |
parent | 44b9f13f9cfaf2e1136a1f2baab54b229d221fe4 [diff] |
Fix GATT autoConnect race condition As pointed out here: https://code.google.com/p/android/issues/detail?id=69834 registerApp() causes onClientRegistered() to happen before autoConnect is set. This patch fixes that. Bug: 28861330 Change-Id: Ie1174c0f224f5084178439420b383164d22d542c
diff --git a/core/java/android/bluetooth/BluetoothGatt.java b/core/java/android/bluetooth/BluetoothGatt.java index b8a40dc..800dd43 100644 --- a/core/java/android/bluetooth/BluetoothGatt.java +++ b/core/java/android/bluetooth/BluetoothGatt.java
@@ -645,6 +645,9 @@ } mConnState = CONN_STATE_CONNECTING; } + + mAutoConnect = autoConnect; + if (!registerApp(callback)) { synchronized(mStateLock) { mConnState = CONN_STATE_IDLE; @@ -653,8 +656,7 @@ return false; } - // the connection will continue after successful callback registration - mAutoConnect = autoConnect; + // The connection will continue in the onClientRegistered callback return true; }