Fixed a race condition during pairing with carkits wherein connect was

issued even before ACTION.uuid changed was received.

Change-Id: Iafc2c61b92537a219e46e08366fab1ad5f4e97bd
This commit is contained in:
Kausik Sinnaswamy
2012-06-01 16:08:04 +05:30
committed by Matthew Xie
parent 2582e6ca94
commit 6e4060212e

View File

@@ -208,13 +208,16 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
private void connectWithoutResettingTimer(boolean connectAllProfiles) {
// Try to initialize the profiles if they were not.
if (mProfiles.isEmpty()) {
if (!updateProfiles()) {
// if mProfiles is empty, then do not invoke updateProfiles. This causes a race
// condition with carkits during pairing, wherein RemoteDevice.UUIDs have been updated
// from bluetooth stack but ACTION.uuid is not sent yet.
// Eventually ACTION.uuid will be received which shall trigger the connection of the
// various profiles
// If UUIDs are not available yet, connect will be happen
// upon arrival of the ACTION_UUID intent.
if (DEBUG) Log.d(TAG, "No profiles. Maybe we will connect later");
Log.d(TAG, "No profiles. Maybe we will connect later");
return;
}
}
// Reset the only-show-one-error-dialog tracking variable
mIsConnectingErrorPossible = true;