From 5aa4bd22ff59c9a3910fc60e6f4876b8bbad571d Mon Sep 17 00:00:00 2001 From: Patty Date: Tue, 25 Jan 2022 19:58:37 +0800 Subject: Add API to set the codec preference for specific device Add the APIs that would use in developer optin for setting the codec config preference and getiting the codec status. Expose the APIs first, some of the implementations will be done later. Add equals function to BluetoothLeAudioCodecConfig for comparison usage Tag: #feature Bug: 216276721 Bug: 150670922 Test: atest BluetoothInstrumentationTests Change-Id: Iaa9b7b1278f06228b7a22a1c61668b879b6f3dc9 Merged-In: Iaa9b7b1278f06228b7a22a1c61668b879b6f3dc9 (cherry picked from commit 7cf686a443eb2a1d036ba89c874a328fa24bb425) --- .../bluetooth/BluetoothLeAudioCodecConfig.java | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'framework/java/android/bluetooth/BluetoothLeAudioCodecConfig.java') diff --git a/framework/java/android/bluetooth/BluetoothLeAudioCodecConfig.java b/framework/java/android/bluetooth/BluetoothLeAudioCodecConfig.java index 8456259581..e3f691a66a 100644 --- a/framework/java/android/bluetooth/BluetoothLeAudioCodecConfig.java +++ b/framework/java/android/bluetooth/BluetoothLeAudioCodecConfig.java @@ -23,6 +23,7 @@ import android.os.Parcelable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.Objects; /** * Represents the codec configuration for a Bluetooth LE Audio source device. @@ -346,6 +347,31 @@ public final class BluetoothLeAudioCodecConfig implements Parcelable { return mOctetsPerFrame; } + @Override + public boolean equals(@NonNull Object o) { + if (o instanceof BluetoothLeAudioCodecConfig) { + BluetoothLeAudioCodecConfig other = (BluetoothLeAudioCodecConfig) o; + return (other.getCodecType() == mCodecType + && other.getCodecPriority() == mCodecPriority + && other.getSampleRate() == mSampleRate + && other.getBitsPerSample() == mBitsPerSample + && other.getChannelMode() == mChannelMode + && other.getFrameDuration() == mFrameDuration + && other.getOctetsPerFrame() == mOctetsPerFrame); + } + return false; + } + + /** + * Returns a hash representation of this BluetoothLeAudioCodecConfig + * based on all the config values. + */ + @Override + public int hashCode() { + return Objects.hash(mCodecType, mCodecPriority, mSampleRate, + mBitsPerSample, mChannelMode, mFrameDuration, mOctetsPerFrame); + } + /** * Builder for {@link BluetoothLeAudioCodecConfig}. *

By default, the codec type will be set to -- cgit v1.2.3