b/2318290 connect should be called instead of connect(profile) if device is unpaired.

Change-Id: I5d665d1c3149ffc77387f96c3822e80b84c78de1
diff --git a/src/com/android/settings/bluetooth/DockService.java b/src/com/android/settings/bluetooth/DockService.java
index 5bf0214..1ad2987 100644
--- a/src/com/android/settings/bluetooth/DockService.java
+++ b/src/com/android/settings/bluetooth/DockService.java
@@ -459,19 +459,19 @@
 
         mPendingDevice = null;
 
+        boolean callConnect = false;
+        CachedBluetoothDevice cachedDevice = getCachedBluetoothDevice(mContext, mBtManager,
+                device);
         for (int i = 0; i < mProfiles.length; i++) {
             LocalBluetoothProfileManager profileManager = LocalBluetoothProfileManager
                     .getProfileManager(mBtManager, mProfiles[i]);
             boolean isConnected = profileManager.isConnected(device);
-            CachedBluetoothDevice cachedDevice = getCachedBluetoothDevice(mContext, mBtManager,
-                    device);
 
             if (DEBUG) Log.d(TAG, mProfiles[i].toString() + " = " + mCheckedItems[i]);
 
             if (mCheckedItems[i] && !isConnected) {
                 // Checked but not connected
-                if (DEBUG) Log.d(TAG, "applyBtSettings - Connecting");
-                cachedDevice.connect(mProfiles[i]);
+                callConnect = true;
             } else if (!mCheckedItems[i] && isConnected) {
                 // Unchecked but connected
                 if (DEBUG) Log.d(TAG, "applyBtSettings - Disconnecting");
@@ -484,6 +484,11 @@
                 }
             }
         }
+
+        if (callConnect) {
+            if (DEBUG) Log.d(TAG, "applyBtSettings - Connecting");
+            cachedDevice.connect();
+        }
     }
 
     void handleUndocked(Context context, LocalBluetoothManager localManager,