diff options
| author | Jaikumar Ganesh <jaikumar@google.com> | 2009-10-30 09:37:25 -0700 |
|---|---|---|
| committer | Jaikumar Ganesh <jaikumar@google.com> | 2009-10-30 09:37:25 -0700 |
| commit | 4b3db907f04d85cd20e0a0e35056ba44a10e8867 (patch) | |
| tree | 9567dd6ff4ada816edad712453f98ec36db332a5 /core/java/android/bluetooth | |
| parent | 678cdbe55e0de71436f8aad5f139eafc2ab6f937 (diff) | |
| download | frameworks_base-4b3db907f04d85cd20e0a0e35056ba44a10e8867.zip frameworks_base-4b3db907f04d85cd20e0a0e35056ba44a10e8867.tar.gz frameworks_base-4b3db907f04d85cd20e0a0e35056ba44a10e8867.tar.bz2 | |
Revert the channge where channels were not selected randomly.
The Bluez SDP bug has been fixed.
Reverting parts of the commit: 16fb88a673c41b93c5d57ccb28c2697e7d87701a
Bug: 2173752
Dr No: Eastham
Diffstat (limited to 'core/java/android/bluetooth')
| -rw-r--r-- | core/java/android/bluetooth/BluetoothAdapter.java | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index ff48583..3fc676b 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -597,14 +597,6 @@ public final class BluetoothAdapter { /** * Picks RFCOMM channels until none are left. * Avoids reserved channels. - * Ideally we would pick random channels, but in the current implementation - * we start with the channel that is the hash of the UUID, and try every - * available channel from there. This means that in most cases a given - * uuid will use the same channel. This is a workaround for a Bluez SDP - * bug where we are not updating the cache when the channel changes for a - * uuid. - * TODO: Fix the Bluez SDP caching bug, and go back to random channel - * selection */ private static class RfcommChannelPicker { private static final int[] RESERVED_RFCOMM_CHANNELS = new int[] { @@ -637,19 +629,12 @@ public final class BluetoothAdapter { } mUuid = uuid; } - /* Returns next channel, or -1 if we're out */ + /* Returns next random channel, or -1 if we're out */ public int nextChannel() { - int channel = mUuid.hashCode(); // always pick the same channel to try first - Integer channelInt; - while (mChannels.size() > 0) { - channelInt = new Integer(channel); - if (mChannels.remove(channelInt)) { - return channel; - } - channel = (channel % BluetoothSocket.MAX_RFCOMM_CHANNEL) + 1; + if (mChannels.size() == 0) { + return -1; } - - return -1; + return mChannels.remove(sRandom.nextInt(mChannels.size())); } } |
