am 213d579f: Merge "Don\'t disconnect the same device before connecting." into gingerbread

Merge commit '213d579f98a83145989f11cfdbd47631b64de000' into gingerbread-plus-aosp

* commit '213d579f98a83145989f11cfdbd47631b64de000':
  Don't disconnect the same device before connecting.
This commit is contained in:
Jaikumar Ganesh
2010-09-16 22:15:50 -07:00
committed by Android Git Automerger

View File

@@ -88,10 +88,10 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
// See mConnectAttempted // See mConnectAttempted
private static final long MAX_UUID_DELAY_FOR_AUTO_CONNECT = 5000; private static final long MAX_UUID_DELAY_FOR_AUTO_CONNECT = 5000;
/** /**
* Describes the current device and profile for logging. * Describes the current device and profile for logging.
* *
* @param profile Profile to describe * @param profile Profile to describe
* @return Description of the device and profile * @return Description of the device and profile
*/ */
@@ -104,7 +104,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
return sb.toString(); return sb.toString();
} }
private String describe(Profile profile) { private String describe(Profile profile) {
return describe(this, profile); return describe(this, profile);
} }
@@ -261,7 +261,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
.getProfileManager(mLocalManager, profile); .getProfileManager(mLocalManager, profile);
if (profileManager.isPreferred(mDevice)) { if (profileManager.isPreferred(mDevice)) {
++preferredProfiles; ++preferredProfiles;
disconnectConnected(profile); disconnectConnected(this, profile);
connectInt(this, profile); connectInt(this, profile);
} }
} }
@@ -284,7 +284,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
LocalBluetoothProfileManager profileManager = LocalBluetoothProfileManager LocalBluetoothProfileManager profileManager = LocalBluetoothProfileManager
.getProfileManager(mLocalManager, profile); .getProfileManager(mLocalManager, profile);
profileManager.setPreferred(mDevice, false); profileManager.setPreferred(mDevice, false);
disconnectConnected(profile); disconnectConnected(this, profile);
connectInt(this, profile); connectInt(this, profile);
} }
} }
@@ -294,19 +294,20 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
mConnectAttempted = SystemClock.elapsedRealtime(); mConnectAttempted = SystemClock.elapsedRealtime();
// Reset the only-show-one-error-dialog tracking variable // Reset the only-show-one-error-dialog tracking variable
mIsConnectingErrorPossible = true; mIsConnectingErrorPossible = true;
disconnectConnected(profile); disconnectConnected(this, profile);
connectInt(this, profile); connectInt(this, profile);
} }
private void disconnectConnected(Profile profile) { private void disconnectConnected(CachedBluetoothDevice device, Profile profile) {
LocalBluetoothProfileManager profileManager = LocalBluetoothProfileManager profileManager =
LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile); LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile);
CachedBluetoothDeviceManager cachedDeviceManager = mLocalManager.getCachedDeviceManager(); CachedBluetoothDeviceManager cachedDeviceManager = mLocalManager.getCachedDeviceManager();
Set<BluetoothDevice> devices = profileManager.getConnectedDevices(); Set<BluetoothDevice> devices = profileManager.getConnectedDevices();
if (devices == null) return; if (devices == null) return;
for (BluetoothDevice device : devices) { for (BluetoothDevice btDevice : devices) {
CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(device); CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(btDevice);
if (cachedDevice != null) {
if (cachedDevice != null && !cachedDevice.equals(device)) {
disconnectInt(cachedDevice, profile); disconnectInt(cachedDevice, profile);
} }
} }