From 03cd78cf5e51c3adb78d2e3d314838dcf3e36b26 Mon Sep 17 00:00:00 2001 From: Jaikumar Ganesh Date: Mon, 18 Oct 2010 16:41:53 -0700 Subject: Convert return type of APIs from Set to List. Most of the time it will either be empty or have 1 device. Using list makes it much a better API and since its supported by the AIDL format, the code becomes much nicer. Change-Id: I5a2508b33ba754fc8cc738409d658e1235aaf2cf --- core/java/android/bluetooth/BluetoothA2dp.java | 28 +++++++++----------------- 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'core/java/android/bluetooth/BluetoothA2dp.java') diff --git a/core/java/android/bluetooth/BluetoothA2dp.java b/core/java/android/bluetooth/BluetoothA2dp.java index 920ef89..61b4303 100644 --- a/core/java/android/bluetooth/BluetoothA2dp.java +++ b/core/java/android/bluetooth/BluetoothA2dp.java @@ -26,11 +26,8 @@ import android.os.ServiceManager; import android.server.BluetoothA2dpService; import android.util.Log; -import java.util.Collections; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; +import java.util.ArrayList; +import java.util.List; /** @@ -167,35 +164,35 @@ public final class BluetoothA2dp implements BluetoothProfile { /** * {@inheritDoc} */ - public Set getConnectedDevices() { + public List getConnectedDevices() { if (DBG) log("getConnectedDevices()"); if (mService != null && isEnabled()) { try { - return toDeviceSet(mService.getConnectedDevices()); + return mService.getConnectedDevices(); } catch (RemoteException e) { Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); - return toDeviceSet(new BluetoothDevice[0]); + return new ArrayList(); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); - return toDeviceSet(new BluetoothDevice[0]); + return new ArrayList(); } /** * {@inheritDoc} */ - public Set getDevicesMatchingConnectionStates(int[] states) { + public List getDevicesMatchingConnectionStates(int[] states) { if (DBG) log("getDevicesMatchingStates()"); if (mService != null && isEnabled()) { try { - return toDeviceSet(mService.getDevicesMatchingConnectionStates(states)); + return mService.getDevicesMatchingConnectionStates(states); } catch (RemoteException e) { Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); - return toDeviceSet(new BluetoothDevice[0]); + return new ArrayList(); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); - return toDeviceSet(new BluetoothDevice[0]); + return new ArrayList(); } /** @@ -396,11 +393,6 @@ public final class BluetoothA2dp implements BluetoothProfile { return false; } - private Set toDeviceSet(BluetoothDevice[] devices) { - return Collections.unmodifiableSet( - new HashSet(Arrays.asList(devices))); - } - private static void log(String msg) { Log.d(TAG, msg); } -- cgit v1.1