diff options
author | William Escande <wescande@google.com> | 2022-04-21 14:52:56 -0700 |
---|---|---|
committer | William Escande <wescande@google.com> | 2022-04-22 09:10:34 -0700 |
commit | 1fcb1f8552b0d023ecb8709c60ba367810effe20 (patch) | |
tree | 12c218710248d43a3f0c97a551f401c416ffcfcf /framework/java/android/bluetooth/BluetoothLeAudioCodecConfigMetadata.java | |
parent | 12a99ac50a97cef61811461b18c00ef245c63567 (diff) |
Implement Equals and Hash for BluetoothLeAudioCodecConfigMetadata
Test: atest 'CtsBluetoothTestCases:android.bluetooth.cts.BluetoothLeAudioCodecConfigMetadataTest#testCreateCodecConfigMetadataFromCopy'
Fix: 230012767
Ignore-AOSP-First: Tm-dev is cut-off, cherry-picking from aosp
Merged-In: I569ab7afca938b4e4f5d38bc134b14d4760f094c
Change-Id: I569ab7afca938b4e4f5d38bc134b14d4760f094c
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothLeAudioCodecConfigMetadata.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothLeAudioCodecConfigMetadata.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothLeAudioCodecConfigMetadata.java b/framework/java/android/bluetooth/BluetoothLeAudioCodecConfigMetadata.java index 9881ec2067..4e6fd7f350 100644 --- a/framework/java/android/bluetooth/BluetoothLeAudioCodecConfigMetadata.java +++ b/framework/java/android/bluetooth/BluetoothLeAudioCodecConfigMetadata.java @@ -17,6 +17,7 @@ package android.bluetooth; import android.annotation.NonNull; +import android.annotation.Nullable; import android.annotation.SystemApi; import android.bluetooth.BluetoothUtils.TypeValueEntry; import android.os.Parcel; @@ -24,7 +25,9 @@ import android.os.Parcelable; import java.nio.ByteBuffer; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Objects; /** * A class representing the codec specific config metadata information defined in the Basic Audio @@ -44,6 +47,21 @@ public final class BluetoothLeAudioCodecConfigMetadata implements Parcelable { mRawMetadata = rawMetadata; } + @Override + public boolean equals(@Nullable Object o) { + if (o != null && o instanceof BluetoothLeAudioCodecConfigMetadata) { + final BluetoothLeAudioCodecConfigMetadata oth = (BluetoothLeAudioCodecConfigMetadata) o; + return mAudioLocation == oth.getAudioLocation() + && Arrays.equals(mRawMetadata, oth.getRawMetadata()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash(mAudioLocation, mRawMetadata); + } + /** * Get the audio location information as defined in the Generic Audio section of Bluetooth * Assigned numbers. |