diff options
| author | Pavlin Radoslavov <pavlin@google.com> | 2018-04-19 17:59:36 -0700 |
|---|---|---|
| committer | android-build-merger <android-build-merger@google.com> | 2018-04-19 17:59:36 -0700 |
| commit | 493dbf789fa8ca3a5b5ab5c79dfb31265dd18a14 (patch) | |
| tree | 32cf51a7f22117125614b5d6ed3e05079b9580b6 /core/java/android | |
| parent | 0036df97ca0f3550f847ba825fae869600c109fe (diff) | |
| parent | 3a1ca762c9349067fe4f644d483de7d1cf24b5ad (diff) | |
Merge "Fix the implementation of BluetoothCodecStatus.equals()"
am: 3a1ca762c9
Change-Id: I159c2128068021b5ca5e0a7bf3eae218de0bdf1b
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/bluetooth/BluetoothCodecStatus.java | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/core/java/android/bluetooth/BluetoothCodecStatus.java b/core/java/android/bluetooth/BluetoothCodecStatus.java index 7ae4cb706233..3a05e7093d40 100644 --- a/core/java/android/bluetooth/BluetoothCodecStatus.java +++ b/core/java/android/bluetooth/BluetoothCodecStatus.java @@ -57,13 +57,35 @@ public final class BluetoothCodecStatus implements Parcelable { if (o instanceof BluetoothCodecStatus) { BluetoothCodecStatus other = (BluetoothCodecStatus) o; return (Objects.equals(other.mCodecConfig, mCodecConfig) - && Objects.equals(other.mCodecsLocalCapabilities, mCodecsLocalCapabilities) - && Objects.equals(other.mCodecsSelectableCapabilities, + && sameCapabilities(other.mCodecsLocalCapabilities, mCodecsLocalCapabilities) + && sameCapabilities(other.mCodecsSelectableCapabilities, mCodecsSelectableCapabilities)); } return false; } + /** + * Checks whether two arrays of capabilities contain same capabilities. + * The order of the capabilities in each array is ignored. + * + * @param c1 the first array of capabilities to compare + * @param c2 the second array of capabilities to compare + * @return true if both arrays contain same capabilities + */ + private static boolean sameCapabilities(BluetoothCodecConfig[] c1, + BluetoothCodecConfig[] c2) { + if (c1 == null) { + return (c2 == null); + } + if (c2 == null) { + return false; + } + if (c1.length != c2.length) { + return false; + } + return Arrays.asList(c1).containsAll(Arrays.asList(c2)); + } + @Override public int hashCode() { return Objects.hash(mCodecConfig, mCodecsLocalCapabilities, |
