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