summaryrefslogtreecommitdiffstats
path: root/core/java/android/bluetooth/BluetoothAdapter.java
diff options
context:
space:
mode:
authorJaikumar Ganesh <jaikumar@google.com>2009-10-30 10:31:25 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2009-10-30 10:31:25 -0700
commitbf2efbc0642d07acee1a83c17987abb380e5243a (patch)
treef30adb6a9a2f79b62d070fdf84236dc800fedbe9 /core/java/android/bluetooth/BluetoothAdapter.java
parent5546e9e6721a5b05678ea6ceb3be433219f53fe6 (diff)
parent3cf254d2ba303da3354ed65fd7f3136e87a56b9f (diff)
downloadframeworks_base-bf2efbc0642d07acee1a83c17987abb380e5243a.zip
frameworks_base-bf2efbc0642d07acee1a83c17987abb380e5243a.tar.gz
frameworks_base-bf2efbc0642d07acee1a83c17987abb380e5243a.tar.bz2
am 3cf254d2: Merge change I4b3db907 into eclair
Merge commit '3cf254d2ba303da3354ed65fd7f3136e87a56b9f' into eclair-mr2 * commit '3cf254d2ba303da3354ed65fd7f3136e87a56b9f': Revert the channge where channels were not selected randomly.
Diffstat (limited to 'core/java/android/bluetooth/BluetoothAdapter.java')
-rw-r--r--core/java/android/bluetooth/BluetoothAdapter.java23
1 files changed, 4 insertions, 19 deletions
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index 5b34ef9..53bffc1 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()));
}
}