Fixed a race condition during pairing with carkits wherein connect was
issued even before ACTION.uuid changed was received.

Change-Id: Iafc2c61b92537a219e46e08366fab1ad5f4e97bd
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
index e28e064..5a4f9e8 100755
--- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
@@ -208,12 +208,15 @@
     private void connectWithoutResettingTimer(boolean connectAllProfiles) {
         // Try to initialize the profiles if they were not.
         if (mProfiles.isEmpty()) {
-            if (!updateProfiles()) {
-                // 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");
-                return;
-            }
+            // 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.
+            Log.d(TAG, "No profiles. Maybe we will connect later");
+            return;
         }
 
         // Reset the only-show-one-error-dialog tracking variable