From 659b39abf8580a49bd77f194c9ac30359f610709 Mon Sep 17 00:00:00 2001 From: Jaikumar Ganesh Date: Mon, 18 Oct 2010 17:14:56 -0700 Subject: [PATCH] Update BT APIs for change in return type. Change-Id: Ic85b47da50876fd6bdc6e223af4248a8586d82bc --- .../bluetooth/CachedBluetoothDevice.java | 2 +- .../bluetooth/LocalBluetoothManager.java | 5 ++- .../LocalBluetoothProfileManager.java | 33 ++++++++----------- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java index 7805e14a73c..c0fa105d82d 100644 --- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java @@ -300,7 +300,7 @@ public class CachedBluetoothDevice implements Comparable LocalBluetoothProfileManager profileManager = LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile); CachedBluetoothDeviceManager cachedDeviceManager = mLocalManager.getCachedDeviceManager(); - Set devices = profileManager.getConnectedDevices(); + List devices = profileManager.getConnectedDevices(); if (devices == null) return; for (BluetoothDevice btDevice : devices) { CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(btDevice); diff --git a/src/com/android/settings/bluetooth/LocalBluetoothManager.java b/src/com/android/settings/bluetooth/LocalBluetoothManager.java index d50332555e4..613ee258676 100644 --- a/src/com/android/settings/bluetooth/LocalBluetoothManager.java +++ b/src/com/android/settings/bluetooth/LocalBluetoothManager.java @@ -196,10 +196,9 @@ public class LocalBluetoothManager { // If we are playing music, don't scan unless forced. if (mBluetoothA2dp != null) { - Set sinks = mBluetoothA2dp.getConnectedDevices(); + List sinks = mBluetoothA2dp.getConnectedDevices(); if (sinks.size() > 0) { - BluetoothDevice sink = sinks.toArray(new BluetoothDevice[sinks.size()])[0]; - if (mBluetoothA2dp.isA2dpPlaying(sink)) return; + if (mBluetoothA2dp.isA2dpPlaying(sinks.get(0))) return; } } } diff --git a/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java b/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java index 7e11887a9b6..1480b163e4f 100644 --- a/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java +++ b/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java @@ -197,7 +197,7 @@ public abstract class LocalBluetoothProfileManager { mLocalManager = localManager; } - public abstract Set getConnectedDevices(); + public abstract List getConnectedDevices(); public abstract boolean connect(BluetoothDevice device); @@ -261,7 +261,7 @@ public abstract class LocalBluetoothProfileManager { } @Override - public Set getConnectedDevices() { + public List getConnectedDevices() { return mService.getDevicesMatchingConnectionStates( new int[] {BluetoothProfile.STATE_CONNECTED, BluetoothProfile.STATE_CONNECTING, @@ -270,7 +270,7 @@ public abstract class LocalBluetoothProfileManager { @Override public boolean connect(BluetoothDevice device) { - Set sinks = getConnectedDevices(); + List sinks = getConnectedDevices(); if (sinks != null) { for (BluetoothDevice sink : sinks) { mService.disconnect(sink); @@ -378,14 +378,11 @@ public abstract class LocalBluetoothProfileManager { * We just bound to the service, so refresh the UI of the * headset device. */ - Set deviceSet = mService.getConnectedDevices(); - if (deviceSet.size() == 0) return; - - BluetoothDevice[] devices = - deviceSet.toArray(new BluetoothDevice[deviceSet.size()]); + List deviceList = mService.getConnectedDevices(); + if (deviceList.size() == 0) return; mLocalManager.getCachedDeviceManager() - .onProfileStateChanged(devices[0], Profile.HEADSET, + .onProfileStateChanged(deviceList.get(0), Profile.HEADSET, BluetoothProfile.STATE_CONNECTED); } }); @@ -415,7 +412,7 @@ public abstract class LocalBluetoothProfileManager { } @Override - public Set getConnectedDevices() { + public List getConnectedDevices() { return mService.getConnectedDevices(); } @@ -426,9 +423,8 @@ public abstract class LocalBluetoothProfileManager { @Override public boolean disconnect(BluetoothDevice device) { - Set deviceSet = getConnectedDevices(); - BluetoothDevice[] devices = deviceSet.toArray(new BluetoothDevice[deviceSet.size()]); - if (devices.length != 0 && devices[0].equals(device)) { + List deviceList = getConnectedDevices(); + if (deviceList.size() != 0 && deviceList.get(0).equals(device)) { // Downgrade prority as user is disconnecting the headset. if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) { mService.setPriority(device, BluetoothProfile.PRIORITY_ON); @@ -441,10 +437,9 @@ public abstract class LocalBluetoothProfileManager { @Override public int getConnectionStatus(BluetoothDevice device) { - Set deviceSet = getConnectedDevices(); - BluetoothDevice[] devices = deviceSet.toArray(new BluetoothDevice[deviceSet.size()]); + List deviceList = getConnectedDevices(); - return devices.length > 0 && devices[0].equals(device) + return deviceList.size() > 0 && deviceList.get(0).equals(device) ? convertState(mService.getConnectionState(device)) : SettingsBtStatus.CONNECTION_STATUS_DISCONNECTED; } @@ -506,7 +501,7 @@ public abstract class LocalBluetoothProfileManager { } @Override - public Set getConnectedDevices() { + public List getConnectedDevices() { return null; } @@ -605,7 +600,7 @@ public abstract class LocalBluetoothProfileManager { } @Override - public Set getConnectedDevices() { + public List getConnectedDevices() { return mService.getConnectedInputDevices(); } @@ -703,7 +698,7 @@ public abstract class LocalBluetoothProfileManager { } @Override - public Set getConnectedDevices() { + public List getConnectedDevices() { return mService.getConnectedDevices(); }