summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2018-04-20 02:12:09 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-04-20 02:12:09 +0000
commit1c75189a0adcf4f3a3739f622580dc3983c137fb (patch)
tree121d67dfaf9d49351f43f6da2fc82c1c6b3f488f /core/java/android
parent1c0d00fac4a03b2fb4a5c5ea47e1c080baab65cb (diff)
parenta291ce625a4a36d22c764abf31c88ea32f2de688 (diff)
Merge "Fix the implementation of BluetoothCodecStatus.equals()" into pi-dev
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/bluetooth/BluetoothCodecStatus.java26
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,