diff options
| author | Jaikumar Ganesh <jaikumar@google.com> | 2010-10-18 16:41:53 -0700 |
|---|---|---|
| committer | Jaikumar Ganesh <jaikumar@google.com> | 2010-10-22 11:36:27 -0700 |
| commit | 03cd78cf5e51c3adb78d2e3d314838dcf3e36b26 (patch) | |
| tree | 898125c6e6cfc7f22a44ce986205557d7f571dff /core/java/android/bluetooth/BluetoothHeadset.java | |
| parent | e1627c9d0e472cf32bc52533570ce8768048db29 (diff) | |
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
Diffstat (limited to 'core/java/android/bluetooth/BluetoothHeadset.java')
| -rw-r--r-- | core/java/android/bluetooth/BluetoothHeadset.java | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/core/java/android/bluetooth/BluetoothHeadset.java b/core/java/android/bluetooth/BluetoothHeadset.java index 0496b1f27cef..c64fdbe396da 100644 --- a/core/java/android/bluetooth/BluetoothHeadset.java +++ b/core/java/android/bluetooth/BluetoothHeadset.java @@ -18,20 +18,16 @@ package android.bluetooth; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; -import android.bluetooth.BluetoothAdapter; -import android.bluetooth.BluetoothDevice; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; -import android.os.RemoteException; import android.os.IBinder; +import android.os.RemoteException; import android.util.Log; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; +import java.util.ArrayList; +import java.util.List; /** * Public API for controlling the Bluetooth Headset Service. This includes both @@ -218,35 +214,35 @@ public final class BluetoothHeadset implements BluetoothProfile { /** * {@inheritDoc} */ - public Set<BluetoothDevice> getConnectedDevices() { + public List<BluetoothDevice> getConnectedDevices() { if (DBG) log("getConnectedDevices()"); if (mService != null && isEnabled()) { try { - return toDeviceSet(mService.getConnectedDevices()); + return mService.getConnectedDevices(); } catch (RemoteException e) { Log.e(TAG, Log.getStackTraceString(new Throwable())); - return toDeviceSet(new BluetoothDevice[0]); + return new ArrayList<BluetoothDevice>(); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); - return toDeviceSet(new BluetoothDevice[0]); + return new ArrayList<BluetoothDevice>(); } /** * {@inheritDoc} */ - public Set<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { + public List<BluetoothDevice> 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, Log.getStackTraceString(new Throwable())); - return toDeviceSet(new BluetoothDevice[0]); + return new ArrayList<BluetoothDevice>(); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); - return toDeviceSet(new BluetoothDevice[0]); + return new ArrayList<BluetoothDevice>(); } /** @@ -569,11 +565,6 @@ public final class BluetoothHeadset implements BluetoothProfile { return false; } - private Set<BluetoothDevice> toDeviceSet(BluetoothDevice[] devices) { - return Collections.unmodifiableSet( - new HashSet<BluetoothDevice>(Arrays.asList(devices))); - } - private static void log(String msg) { Log.d(TAG, msg); } |
