aboutsummaryrefslogtreecommitdiff
path: root/framework/java
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2018-04-19 23:55:31 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-04-19 23:55:31 +0000
commit16ec9cbb96939a15e84cea08ebbbfa9dd0ca311d (patch)
tree946a0571275e1176e1a5c3021c692d7066390d1f /framework/java
parent90e13c0b0d94bc5bef0c2be24bd51422075a83e8 (diff)
parent93e6d423f62546155b9316a399ab786f8d057dc5 (diff)
Merge "Fix the implementation of BluetoothCodecStatus.equals()"
Diffstat (limited to 'framework/java')
-rw-r--r--framework/java/android/bluetooth/BluetoothCodecStatus.java26
1 files changed, 24 insertions, 2 deletions
diff --git a/framework/java/android/bluetooth/BluetoothCodecStatus.java b/framework/java/android/bluetooth/BluetoothCodecStatus.java
index 7ae4cb7062..3a05e7093d 100644
--- a/framework/java/android/bluetooth/BluetoothCodecStatus.java
+++ b/framework/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,