From 6e4060212e537bdcb69b21c2ba814c23cd393d42 Mon Sep 17 00:00:00 2001 From: Kausik Sinnaswamy Date: Fri, 1 Jun 2012 16:08:04 +0530 Subject: [PATCH] Fixed a race condition during pairing with carkits wherein connect was issued even before ACTION.uuid changed was received. Change-Id: Iafc2c61b92537a219e46e08366fab1ad5f4e97bd --- .../settings/bluetooth/CachedBluetoothDevice.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java index e28e064fe52..5a4f9e8ccce 100755 --- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java @@ -208,12 +208,15 @@ final class CachedBluetoothDevice implements Comparable { 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