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
This commit is contained in:
committed by
Andre Eisenbach
parent
44b9f13f9c
commit
d35167adca
@@ -645,6 +645,9 @@ public final class BluetoothGatt implements BluetoothProfile {
|
||||
}
|
||||
mConnState = CONN_STATE_CONNECTING;
|
||||
}
|
||||
|
||||
mAutoConnect = autoConnect;
|
||||
|
||||
if (!registerApp(callback)) {
|
||||
synchronized(mStateLock) {
|
||||
mConnState = CONN_STATE_IDLE;
|
||||
@@ -653,8 +656,7 @@ public final class BluetoothGatt implements BluetoothProfile {
|
||||
return false;
|
||||
}
|
||||
|
||||
// the connection will continue after successful callback registration
|
||||
mAutoConnect = autoConnect;
|
||||
// The connection will continue in the onClientRegistered callback
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user