Merge "Make BluetoothCodecConfig and BluetoothCodecStatus public."
This commit is contained in:
@@ -9024,6 +9024,72 @@ package android.bluetooth {
|
||||
field public static final int TELEPHONY = 4194304; // 0x400000
|
||||
}
|
||||
|
||||
public final class BluetoothCodecConfig implements android.os.Parcelable {
|
||||
ctor public BluetoothCodecConfig(int);
|
||||
method public int describeContents();
|
||||
method public int getBitsPerSample();
|
||||
method public int getChannelMode();
|
||||
method public int getCodecPriority();
|
||||
method public long getCodecSpecific1();
|
||||
method public long getCodecSpecific2();
|
||||
method public long getCodecSpecific3();
|
||||
method public long getCodecSpecific4();
|
||||
method public int getCodecType();
|
||||
method public static int getMaxCodecType();
|
||||
method public int getSampleRate();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final int BITS_PER_SAMPLE_16 = 1; // 0x1
|
||||
field public static final int BITS_PER_SAMPLE_24 = 2; // 0x2
|
||||
field public static final int BITS_PER_SAMPLE_32 = 4; // 0x4
|
||||
field public static final int BITS_PER_SAMPLE_NONE = 0; // 0x0
|
||||
field public static final int CHANNEL_MODE_MONO = 1; // 0x1
|
||||
field public static final int CHANNEL_MODE_NONE = 0; // 0x0
|
||||
field public static final int CHANNEL_MODE_STEREO = 2; // 0x2
|
||||
field public static final int CODEC_PRIORITY_DEFAULT = 0; // 0x0
|
||||
field public static final int CODEC_PRIORITY_DISABLED = -1; // 0xffffffff
|
||||
field public static final int CODEC_PRIORITY_HIGHEST = 1000000; // 0xf4240
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.bluetooth.BluetoothCodecConfig> CREATOR;
|
||||
field public static final int SAMPLE_RATE_176400 = 16; // 0x10
|
||||
field public static final int SAMPLE_RATE_192000 = 32; // 0x20
|
||||
field public static final int SAMPLE_RATE_44100 = 1; // 0x1
|
||||
field public static final int SAMPLE_RATE_48000 = 2; // 0x2
|
||||
field public static final int SAMPLE_RATE_88200 = 4; // 0x4
|
||||
field public static final int SAMPLE_RATE_96000 = 8; // 0x8
|
||||
field public static final int SAMPLE_RATE_NONE = 0; // 0x0
|
||||
field public static final int SOURCE_CODEC_TYPE_AAC = 1; // 0x1
|
||||
field public static final int SOURCE_CODEC_TYPE_APTX = 2; // 0x2
|
||||
field public static final int SOURCE_CODEC_TYPE_APTX_HD = 3; // 0x3
|
||||
field public static final int SOURCE_CODEC_TYPE_INVALID = 1000000; // 0xf4240
|
||||
field public static final int SOURCE_CODEC_TYPE_LDAC = 4; // 0x4
|
||||
field public static final int SOURCE_CODEC_TYPE_SBC = 0; // 0x0
|
||||
}
|
||||
|
||||
public static final class BluetoothCodecConfig.Builder {
|
||||
ctor public BluetoothCodecConfig.Builder();
|
||||
method @NonNull public android.bluetooth.BluetoothCodecConfig build();
|
||||
method @NonNull public android.bluetooth.BluetoothCodecConfig.Builder setBitsPerSample(int);
|
||||
method @NonNull public android.bluetooth.BluetoothCodecConfig.Builder setChannelMode(int);
|
||||
method @NonNull public android.bluetooth.BluetoothCodecConfig.Builder setCodecPriority(int);
|
||||
method @NonNull public android.bluetooth.BluetoothCodecConfig.Builder setCodecSpecific1(long);
|
||||
method @NonNull public android.bluetooth.BluetoothCodecConfig.Builder setCodecSpecific2(long);
|
||||
method @NonNull public android.bluetooth.BluetoothCodecConfig.Builder setCodecSpecific3(long);
|
||||
method @NonNull public android.bluetooth.BluetoothCodecConfig.Builder setCodecSpecific4(long);
|
||||
method @NonNull public android.bluetooth.BluetoothCodecConfig.Builder setCodecType(int);
|
||||
method @NonNull public android.bluetooth.BluetoothCodecConfig.Builder setSampleRate(int);
|
||||
}
|
||||
|
||||
public final class BluetoothCodecStatus implements android.os.Parcelable {
|
||||
ctor public BluetoothCodecStatus(@Nullable android.bluetooth.BluetoothCodecConfig, @Nullable java.util.List<android.bluetooth.BluetoothCodecConfig>, @Nullable java.util.List<android.bluetooth.BluetoothCodecConfig>);
|
||||
method public int describeContents();
|
||||
method @Nullable public android.bluetooth.BluetoothCodecConfig getCodecConfig();
|
||||
method @NonNull public java.util.List<android.bluetooth.BluetoothCodecConfig> getCodecsLocalCapabilities();
|
||||
method @NonNull public java.util.List<android.bluetooth.BluetoothCodecConfig> getCodecsSelectableCapabilities();
|
||||
method public boolean isCodecConfigSelectable(@Nullable android.bluetooth.BluetoothCodecConfig);
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.bluetooth.BluetoothCodecStatus> CREATOR;
|
||||
field public static final String EXTRA_CODEC_STATUS = "android.bluetooth.extra.CODEC_STATUS";
|
||||
}
|
||||
|
||||
public final class BluetoothCsipSetCoordinator implements java.lang.AutoCloseable android.bluetooth.BluetoothProfile {
|
||||
method public void close();
|
||||
method protected void finalize();
|
||||
|
||||
@@ -29,16 +29,14 @@ import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Represents the codec configuration for a Bluetooth A2DP source device.
|
||||
* <p>Contains the source codec type, the codec priority, the codec sample
|
||||
* rate, the codec bits per sample, and the codec channel mode.
|
||||
* <p>The source codec type values are the same as those supported by the
|
||||
* device hardware.
|
||||
*
|
||||
* {@see BluetoothA2dp}
|
||||
*
|
||||
* {@hide}
|
||||
*/
|
||||
public final class BluetoothCodecConfig implements Parcelable {
|
||||
// Add an entry for each source codec here.
|
||||
// NOTE: The values should be same as those listed in the following file:
|
||||
// hardware/libhardware/include/hardware/bt_av.h
|
||||
|
||||
/** @hide */
|
||||
@IntDef(prefix = "SOURCE_CODEC_TYPE_", value = {
|
||||
SOURCE_CODEC_TYPE_SBC,
|
||||
@@ -46,33 +44,49 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
SOURCE_CODEC_TYPE_APTX,
|
||||
SOURCE_CODEC_TYPE_APTX_HD,
|
||||
SOURCE_CODEC_TYPE_LDAC,
|
||||
SOURCE_CODEC_TYPE_MAX,
|
||||
SOURCE_CODEC_TYPE_INVALID
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface SourceCodecType {}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Source codec type SBC. This is the mandatory source codec
|
||||
* type.
|
||||
*/
|
||||
public static final int SOURCE_CODEC_TYPE_SBC = 0;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Source codec type AAC.
|
||||
*/
|
||||
public static final int SOURCE_CODEC_TYPE_AAC = 1;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Source codec type APTX.
|
||||
*/
|
||||
public static final int SOURCE_CODEC_TYPE_APTX = 2;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Source codec type APTX HD.
|
||||
*/
|
||||
public static final int SOURCE_CODEC_TYPE_APTX_HD = 3;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Source codec type LDAC.
|
||||
*/
|
||||
public static final int SOURCE_CODEC_TYPE_LDAC = 4;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
public static final int SOURCE_CODEC_TYPE_MAX = 5;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Source codec type invalid. This is the default value used for codec
|
||||
* type.
|
||||
*/
|
||||
public static final int SOURCE_CODEC_TYPE_INVALID = 1000 * 1000;
|
||||
|
||||
/**
|
||||
* Represents the count of valid source codec types. Can be accessed via
|
||||
* {@link #getMaxCodecType}.
|
||||
*/
|
||||
private static final int SOURCE_CODEC_TYPE_MAX = 5;
|
||||
|
||||
/** @hide */
|
||||
@IntDef(prefix = "CODEC_PRIORITY_", value = {
|
||||
CODEC_PRIORITY_DISABLED,
|
||||
@@ -82,16 +96,24 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface CodecPriority {}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Codec priority disabled.
|
||||
* Used to indicate that this codec is disabled and should not be used.
|
||||
*/
|
||||
public static final int CODEC_PRIORITY_DISABLED = -1;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Codec priority default.
|
||||
* Default value used for codec priority.
|
||||
*/
|
||||
public static final int CODEC_PRIORITY_DEFAULT = 0;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Codec priority highest.
|
||||
* Used to indicate the highest priority a codec can have.
|
||||
*/
|
||||
public static final int CODEC_PRIORITY_HIGHEST = 1000 * 1000;
|
||||
|
||||
|
||||
/** @hide */
|
||||
@IntDef(prefix = "SAMPLE_RATE_", value = {
|
||||
SAMPLE_RATE_NONE,
|
||||
@@ -105,28 +127,42 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface SampleRate {}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Codec sample rate 0 Hz. Default value used for
|
||||
* codec sample rate.
|
||||
*/
|
||||
public static final int SAMPLE_RATE_NONE = 0;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Codec sample rate 44100 Hz.
|
||||
*/
|
||||
public static final int SAMPLE_RATE_44100 = 0x1 << 0;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Codec sample rate 48000 Hz.
|
||||
*/
|
||||
public static final int SAMPLE_RATE_48000 = 0x1 << 1;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Codec sample rate 88200 Hz.
|
||||
*/
|
||||
public static final int SAMPLE_RATE_88200 = 0x1 << 2;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Codec sample rate 96000 Hz.
|
||||
*/
|
||||
public static final int SAMPLE_RATE_96000 = 0x1 << 3;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Codec sample rate 176400 Hz.
|
||||
*/
|
||||
public static final int SAMPLE_RATE_176400 = 0x1 << 4;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Codec sample rate 192000 Hz.
|
||||
*/
|
||||
public static final int SAMPLE_RATE_192000 = 0x1 << 5;
|
||||
|
||||
|
||||
/** @hide */
|
||||
@IntDef(prefix = "BITS_PER_SAMPLE_", value = {
|
||||
BITS_PER_SAMPLE_NONE,
|
||||
@@ -137,19 +173,27 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface BitsPerSample {}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Codec bits per sample 0. Default value of the codec
|
||||
* bits per sample.
|
||||
*/
|
||||
public static final int BITS_PER_SAMPLE_NONE = 0;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Codec bits per sample 16.
|
||||
*/
|
||||
public static final int BITS_PER_SAMPLE_16 = 0x1 << 0;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Codec bits per sample 24.
|
||||
*/
|
||||
public static final int BITS_PER_SAMPLE_24 = 0x1 << 1;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Codec bits per sample 32.
|
||||
*/
|
||||
public static final int BITS_PER_SAMPLE_32 = 0x1 << 2;
|
||||
|
||||
|
||||
/** @hide */
|
||||
@IntDef(prefix = "CHANNEL_MODE_", value = {
|
||||
CHANNEL_MODE_NONE,
|
||||
@@ -159,13 +203,20 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface ChannelMode {}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Codec channel mode NONE. Default value of the
|
||||
* codec channel mode.
|
||||
*/
|
||||
public static final int CHANNEL_MODE_NONE = 0;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Codec channel mode MONO.
|
||||
*/
|
||||
public static final int CHANNEL_MODE_MONO = 0x1 << 0;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Codec channel mode STEREO.
|
||||
*/
|
||||
public static final int CHANNEL_MODE_STEREO = 0x1 << 1;
|
||||
|
||||
private final @SourceCodecType int mCodecType;
|
||||
@@ -178,6 +229,21 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
private final long mCodecSpecific3;
|
||||
private final long mCodecSpecific4;
|
||||
|
||||
/**
|
||||
* Creates a new BluetoothCodecConfig.
|
||||
*
|
||||
* @param codecType the source codec type
|
||||
* @param codecPriority the priority of this codec
|
||||
* @param sampleRate the codec sample rate
|
||||
* @param bitsPerSample the bits per sample of this codec
|
||||
* @param channelMode the channel mode of this codec
|
||||
* @param codecSpecific1 the specific value 1
|
||||
* @param codecSpecific2 the specific value 2
|
||||
* @param codecSpecific3 the specific value 3
|
||||
* @param codecSpecific4 the specific value 4
|
||||
* values to 0.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public BluetoothCodecConfig(@SourceCodecType int codecType, @CodecPriority int codecPriority,
|
||||
@SampleRate int sampleRate, @BitsPerSample int bitsPerSample,
|
||||
@@ -195,17 +261,34 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
mCodecSpecific4 = codecSpecific4;
|
||||
}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
/**
|
||||
* Creates a new BluetoothCodecConfig.
|
||||
* <p> By default, the codec priority will be set
|
||||
* to {@link BluetoothCodecConfig#CODEC_PRIORITY_DEFAULT}, the sample rate to
|
||||
* {@link BluetoothCodecConfig#SAMPLE_RATE_NONE}, the bits per sample to
|
||||
* {@link BluetoothCodecConfig#BITS_PER_SAMPLE_NONE}, the channel mode to
|
||||
* {@link BluetoothCodecConfig#CHANNEL_MODE_NONE}, and all the codec specific
|
||||
* values to 0.
|
||||
*
|
||||
* @param codecType the source codec type
|
||||
*/
|
||||
public BluetoothCodecConfig(@SourceCodecType int codecType) {
|
||||
mCodecType = codecType;
|
||||
mCodecPriority = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT;
|
||||
mSampleRate = BluetoothCodecConfig.SAMPLE_RATE_NONE;
|
||||
mBitsPerSample = BluetoothCodecConfig.BITS_PER_SAMPLE_NONE;
|
||||
mChannelMode = BluetoothCodecConfig.CHANNEL_MODE_NONE;
|
||||
mCodecSpecific1 = 0;
|
||||
mCodecSpecific2 = 0;
|
||||
mCodecSpecific3 = 0;
|
||||
mCodecSpecific4 = 0;
|
||||
this(codecType, BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_NONE,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
|
||||
BluetoothCodecConfig.CHANNEL_MODE_NONE, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
private BluetoothCodecConfig(Parcel in) {
|
||||
mCodecType = in.readInt();
|
||||
mCodecPriority = in.readInt();
|
||||
mSampleRate = in.readInt();
|
||||
mBitsPerSample = in.readInt();
|
||||
mChannelMode = in.readInt();
|
||||
mCodecSpecific1 = in.readLong();
|
||||
mCodecSpecific2 = in.readLong();
|
||||
mCodecSpecific3 = in.readLong();
|
||||
mCodecSpecific4 = in.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -226,10 +309,8 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash based on the config values
|
||||
*
|
||||
* @return a hash based on the config values
|
||||
* @hide
|
||||
* Returns a hash representation of this BluetoothCodecConfig
|
||||
* based on all the config values.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
@@ -238,33 +319,25 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
mCodecSpecific2, mCodecSpecific3, mCodecSpecific4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the object contains valid codec configuration.
|
||||
*
|
||||
* @return true if the object contains valid codec configuration, otherwise false.
|
||||
* @hide
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return (mSampleRate != SAMPLE_RATE_NONE)
|
||||
&& (mBitsPerSample != BITS_PER_SAMPLE_NONE)
|
||||
&& (mChannelMode != CHANNEL_MODE_NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds capability string to an existing string.
|
||||
*
|
||||
* @param prevStr the previous string with the capabilities. Can be a null pointer.
|
||||
* @param capStr the capability string to append to prevStr argument.
|
||||
* @return the result string in the form "prevStr|capStr".
|
||||
* @param prevStr the previous string with the capabilities. Can be a {@code null} pointer
|
||||
* @param capStr the capability string to append to prevStr argument
|
||||
* @return the result string in the form "prevStr|capStr"
|
||||
*/
|
||||
private static String appendCapabilityToString(String prevStr,
|
||||
String capStr) {
|
||||
private static String appendCapabilityToString(@Nullable String prevStr,
|
||||
@NonNull String capStr) {
|
||||
if (prevStr == null) {
|
||||
return capStr;
|
||||
}
|
||||
return prevStr + "|" + capStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link String} that describes each BluetoothCodecConfig parameter
|
||||
* current value.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String sampleRateStr = null;
|
||||
@@ -331,8 +404,6 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Always returns 0
|
||||
*
|
||||
* @return 0
|
||||
* @hide
|
||||
*/
|
||||
@@ -344,20 +415,7 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
public static final @android.annotation.NonNull Parcelable.Creator<BluetoothCodecConfig> CREATOR =
|
||||
new Parcelable.Creator<BluetoothCodecConfig>() {
|
||||
public BluetoothCodecConfig createFromParcel(Parcel in) {
|
||||
final int codecType = in.readInt();
|
||||
final int codecPriority = in.readInt();
|
||||
final int sampleRate = in.readInt();
|
||||
final int bitsPerSample = in.readInt();
|
||||
final int channelMode = in.readInt();
|
||||
final long codecSpecific1 = in.readLong();
|
||||
final long codecSpecific2 = in.readLong();
|
||||
final long codecSpecific3 = in.readLong();
|
||||
final long codecSpecific4 = in.readLong();
|
||||
return new BluetoothCodecConfig(codecType, codecPriority,
|
||||
sampleRate, bitsPerSample,
|
||||
channelMode, codecSpecific1,
|
||||
codecSpecific2, codecSpecific3,
|
||||
codecSpecific4);
|
||||
return new BluetoothCodecConfig(in);
|
||||
}
|
||||
|
||||
public BluetoothCodecConfig[] newArray(int size) {
|
||||
@@ -368,8 +426,8 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
/**
|
||||
* Flattens the object to a parcel
|
||||
*
|
||||
* @param out The Parcel in which the object should be written.
|
||||
* @param flags Additional flags about how the object should be written.
|
||||
* @param out The Parcel in which the object should be written
|
||||
* @param flags Additional flags about how the object should be written
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@@ -387,9 +445,8 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the codec name.
|
||||
*
|
||||
* @return the codec name
|
||||
* Returns the codec name converted to {@link String}.
|
||||
* @hide
|
||||
*/
|
||||
public @NonNull String getCodecName() {
|
||||
switch (mCodecType) {
|
||||
@@ -412,137 +469,100 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the codec type.
|
||||
* See {@link android.bluetooth.BluetoothCodecConfig#SOURCE_CODEC_TYPE_SBC}.
|
||||
*
|
||||
* @return the codec type
|
||||
* Returns the source codec type of this config.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public @SourceCodecType int getCodecType() {
|
||||
return mCodecType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the valid codec types count.
|
||||
*/
|
||||
public static int getMaxCodecType() {
|
||||
return SOURCE_CODEC_TYPE_MAX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the codec is mandatory.
|
||||
* <p> The actual mandatory codec type for Android Bluetooth audio is SBC.
|
||||
* See {@link #SOURCE_CODEC_TYPE_SBC}.
|
||||
*
|
||||
* @return true if the codec is mandatory, otherwise false.
|
||||
* @return {@code true} if the codec is mandatory, {@code false} otherwise
|
||||
* @hide
|
||||
*/
|
||||
public boolean isMandatoryCodec() {
|
||||
return mCodecType == SOURCE_CODEC_TYPE_SBC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the codec selection priority.
|
||||
* The codec selection priority is relative to other codecs: larger value
|
||||
* means higher priority. If 0, reset to default.
|
||||
*
|
||||
* @return the codec priority
|
||||
* Returns the codec selection priority.
|
||||
* <p>The codec selection priority is relative to other codecs: larger value
|
||||
* means higher priority.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public @CodecPriority int getCodecPriority() {
|
||||
return mCodecPriority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the codec selection priority.
|
||||
* The codec selection priority is relative to other codecs: larger value
|
||||
* means higher priority. If 0, reset to default.
|
||||
* <p>The codec selection priority is relative to other codecs: larger value
|
||||
* means higher priority.
|
||||
*
|
||||
* @param codecPriority the codec priority
|
||||
* @param codecPriority the priority this codec should have
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public void setCodecPriority(@CodecPriority int codecPriority) {
|
||||
mCodecPriority = codecPriority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the codec sample rate. The value can be a bitmask with all
|
||||
* supported sample rates:
|
||||
* {@link android.bluetooth.BluetoothCodecConfig#SAMPLE_RATE_NONE} or
|
||||
* {@link android.bluetooth.BluetoothCodecConfig#SAMPLE_RATE_44100} or
|
||||
* {@link android.bluetooth.BluetoothCodecConfig#SAMPLE_RATE_48000} or
|
||||
* {@link android.bluetooth.BluetoothCodecConfig#SAMPLE_RATE_88200} or
|
||||
* {@link android.bluetooth.BluetoothCodecConfig#SAMPLE_RATE_96000} or
|
||||
* {@link android.bluetooth.BluetoothCodecConfig#SAMPLE_RATE_176400} or
|
||||
* {@link android.bluetooth.BluetoothCodecConfig#SAMPLE_RATE_192000}
|
||||
*
|
||||
* @return the codec sample rate
|
||||
* Returns the codec sample rate. The value can be a bitmask with all
|
||||
* supported sample rates.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public @SampleRate int getSampleRate() {
|
||||
return mSampleRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the codec bits per sample. The value can be a bitmask with all
|
||||
* bits per sample supported:
|
||||
* {@link android.bluetooth.BluetoothCodecConfig#BITS_PER_SAMPLE_NONE} or
|
||||
* {@link android.bluetooth.BluetoothCodecConfig#BITS_PER_SAMPLE_16} or
|
||||
* {@link android.bluetooth.BluetoothCodecConfig#BITS_PER_SAMPLE_24} or
|
||||
* {@link android.bluetooth.BluetoothCodecConfig#BITS_PER_SAMPLE_32}
|
||||
*
|
||||
* @return the codec bits per sample
|
||||
* Returns the codec bits per sample. The value can be a bitmask with all
|
||||
* bits per sample supported.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public @BitsPerSample int getBitsPerSample() {
|
||||
return mBitsPerSample;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the codec channel mode. The value can be a bitmask with all
|
||||
* supported channel modes:
|
||||
* {@link android.bluetooth.BluetoothCodecConfig#CHANNEL_MODE_NONE} or
|
||||
* {@link android.bluetooth.BluetoothCodecConfig#CHANNEL_MODE_MONO} or
|
||||
* {@link android.bluetooth.BluetoothCodecConfig#CHANNEL_MODE_STEREO}
|
||||
*
|
||||
* @return the codec channel mode
|
||||
* @hide
|
||||
* Returns the codec channel mode. The value can be a bitmask with all
|
||||
* supported channel modes.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public @ChannelMode int getChannelMode() {
|
||||
return mChannelMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a codec specific value1.
|
||||
*
|
||||
* @return a codec specific value1.
|
||||
* Returns the codec specific value1.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public long getCodecSpecific1() {
|
||||
return mCodecSpecific1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a codec specific value2.
|
||||
*
|
||||
* @return a codec specific value2
|
||||
* @hide
|
||||
* Returns the codec specific value2.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public long getCodecSpecific2() {
|
||||
return mCodecSpecific2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a codec specific value3.
|
||||
*
|
||||
* @return a codec specific value3
|
||||
* @hide
|
||||
* Returns the codec specific value3.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public long getCodecSpecific3() {
|
||||
return mCodecSpecific3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a codec specific value4.
|
||||
*
|
||||
* @return a codec specific value4
|
||||
* @hide
|
||||
* Returns the codec specific value4.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public long getCodecSpecific4() {
|
||||
return mCodecSpecific4;
|
||||
}
|
||||
@@ -551,7 +571,7 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
* Checks whether a value set presented by a bitmask has zero or single bit
|
||||
*
|
||||
* @param valueSet the value set presented by a bitmask
|
||||
* @return true if the valueSet contains zero or single bit, otherwise false.
|
||||
* @return {@code true} if the valueSet contains zero or single bit, {@code false} otherwise
|
||||
* @hide
|
||||
*/
|
||||
private static boolean hasSingleBit(int valueSet) {
|
||||
@@ -559,9 +579,7 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the object contains none or single sample rate.
|
||||
*
|
||||
* @return true if the object contains none or single sample rate, otherwise false.
|
||||
* Returns whether the object contains none or single sample rate.
|
||||
* @hide
|
||||
*/
|
||||
public boolean hasSingleSampleRate() {
|
||||
@@ -569,9 +587,7 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the object contains none or single bits per sample.
|
||||
*
|
||||
* @return true if the object contains none or single bits per sample, otherwise false.
|
||||
* Returns whether the object contains none or single bits per sample.
|
||||
* @hide
|
||||
*/
|
||||
public boolean hasSingleBitsPerSample() {
|
||||
@@ -579,9 +595,7 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the object contains none or single channel mode.
|
||||
*
|
||||
* @return true if the object contains none or single channel mode, otherwise false.
|
||||
* Returns whether the object contains none or single channel mode.
|
||||
* @hide
|
||||
*/
|
||||
public boolean hasSingleChannelMode() {
|
||||
@@ -589,10 +603,10 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the audio feeding parameters are same.
|
||||
* Checks whether the audio feeding parameters are the same.
|
||||
*
|
||||
* @param other the codec config to compare against
|
||||
* @return true if the audio feeding parameters are same, otherwise false
|
||||
* @return {@code true} if the audio feeding parameters are same, {@code false} otherwise
|
||||
* @hide
|
||||
*/
|
||||
public boolean sameAudioFeedingParameters(BluetoothCodecConfig other) {
|
||||
@@ -606,7 +620,7 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
* Any parameters with NONE value will be considered to be a wildcard matching.
|
||||
*
|
||||
* @param other the codec config to compare against
|
||||
* @return true if the audio feeding parameters are similar, otherwise false.
|
||||
* @return {@code true} if the audio feeding parameters are similar, {@code false} otherwise
|
||||
* @hide
|
||||
*/
|
||||
public boolean similarCodecFeedingParameters(BluetoothCodecConfig other) {
|
||||
@@ -614,18 +628,18 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
return false;
|
||||
}
|
||||
int sampleRate = other.mSampleRate;
|
||||
if (mSampleRate == BluetoothCodecConfig.SAMPLE_RATE_NONE
|
||||
|| sampleRate == BluetoothCodecConfig.SAMPLE_RATE_NONE) {
|
||||
if (mSampleRate == SAMPLE_RATE_NONE
|
||||
|| sampleRate == SAMPLE_RATE_NONE) {
|
||||
sampleRate = mSampleRate;
|
||||
}
|
||||
int bitsPerSample = other.mBitsPerSample;
|
||||
if (mBitsPerSample == BluetoothCodecConfig.BITS_PER_SAMPLE_NONE
|
||||
|| bitsPerSample == BluetoothCodecConfig.BITS_PER_SAMPLE_NONE) {
|
||||
if (mBitsPerSample == BITS_PER_SAMPLE_NONE
|
||||
|| bitsPerSample == BITS_PER_SAMPLE_NONE) {
|
||||
bitsPerSample = mBitsPerSample;
|
||||
}
|
||||
int channelMode = other.mChannelMode;
|
||||
if (mChannelMode == BluetoothCodecConfig.CHANNEL_MODE_NONE
|
||||
|| channelMode == BluetoothCodecConfig.CHANNEL_MODE_NONE) {
|
||||
if (mChannelMode == CHANNEL_MODE_NONE
|
||||
|| channelMode == CHANNEL_MODE_NONE) {
|
||||
channelMode = mChannelMode;
|
||||
}
|
||||
return sameAudioFeedingParameters(new BluetoothCodecConfig(
|
||||
@@ -636,25 +650,158 @@ public final class BluetoothCodecConfig implements Parcelable {
|
||||
|
||||
/**
|
||||
* Checks whether the codec specific parameters are the same.
|
||||
* <p> Currently, only AAC VBR and LDAC Playback Quality on CodecSpecific1
|
||||
* are compared.
|
||||
*
|
||||
* @param other the codec config to compare against
|
||||
* @return true if the codec specific parameters are the same, otherwise false.
|
||||
* @return {@code true} if the codec specific parameters are the same, {@code false} otherwise
|
||||
* @hide
|
||||
*/
|
||||
public boolean sameCodecSpecificParameters(BluetoothCodecConfig other) {
|
||||
if (other == null && mCodecType != other.mCodecType) {
|
||||
return false;
|
||||
}
|
||||
// Currently we only care about the AAC VBR and LDAC Playback Quality at CodecSpecific1
|
||||
switch (mCodecType) {
|
||||
case SOURCE_CODEC_TYPE_AAC:
|
||||
case SOURCE_CODEC_TYPE_LDAC:
|
||||
if (mCodecSpecific1 != other.mCodecSpecific1) {
|
||||
return false;
|
||||
}
|
||||
// fall through
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder for {@link BluetoothCodecConfig}.
|
||||
* <p> By default, the codec type will be set to
|
||||
* {@link BluetoothCodecConfig#SOURCE_CODEC_TYPE_INVALID}, the codec priority
|
||||
* to {@link BluetoothCodecConfig#CODEC_PRIORITY_DEFAULT}, the sample rate to
|
||||
* {@link BluetoothCodecConfig#SAMPLE_RATE_NONE}, the bits per sample to
|
||||
* {@link BluetoothCodecConfig#BITS_PER_SAMPLE_NONE}, the channel mode to
|
||||
* {@link BluetoothCodecConfig#CHANNEL_MODE_NONE}, and all the codec specific
|
||||
* values to 0.
|
||||
*/
|
||||
public static final class Builder {
|
||||
private int mCodecType = BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID;
|
||||
private int mCodecPriority = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT;
|
||||
private int mSampleRate = BluetoothCodecConfig.SAMPLE_RATE_NONE;
|
||||
private int mBitsPerSample = BluetoothCodecConfig.BITS_PER_SAMPLE_NONE;
|
||||
private int mChannelMode = BluetoothCodecConfig.CHANNEL_MODE_NONE;
|
||||
private long mCodecSpecific1 = 0;
|
||||
private long mCodecSpecific2 = 0;
|
||||
private long mCodecSpecific3 = 0;
|
||||
private long mCodecSpecific4 = 0;
|
||||
|
||||
/**
|
||||
* Set codec type for Bluetooth codec config.
|
||||
*
|
||||
* @param codecType of this codec
|
||||
* @return the same Builder instance
|
||||
*/
|
||||
public @NonNull Builder setCodecType(@SourceCodecType int codecType) {
|
||||
mCodecType = codecType;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set codec priority for Bluetooth codec config.
|
||||
*
|
||||
* @param codecPriority of this codec
|
||||
* @return the same Builder instance
|
||||
*/
|
||||
public @NonNull Builder setCodecPriority(@CodecPriority int codecPriority) {
|
||||
mCodecPriority = codecPriority;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sample rate for Bluetooth codec config.
|
||||
*
|
||||
* @param sampleRate of this codec
|
||||
* @return the same Builder instance
|
||||
*/
|
||||
public @NonNull Builder setSampleRate(@SampleRate int sampleRate) {
|
||||
mSampleRate = sampleRate;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bits per sample for Bluetooth codec config.
|
||||
*
|
||||
* @param bitsPerSample of this codec
|
||||
* @return the same Builder instance
|
||||
*/
|
||||
public @NonNull Builder setBitsPerSample(@BitsPerSample int bitsPerSample) {
|
||||
mBitsPerSample = bitsPerSample;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the channel mode for Bluetooth codec config.
|
||||
*
|
||||
* @param channelMode of this codec
|
||||
* @return the same Builder instance
|
||||
*/
|
||||
public @NonNull Builder setChannelMode(@ChannelMode int channelMode) {
|
||||
mChannelMode = channelMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the first codec specific values for Bluetooth codec config.
|
||||
*
|
||||
* @param codecSpecific1 codec specific value or 0 if default
|
||||
* @return the same Builder instance
|
||||
*/
|
||||
public @NonNull Builder setCodecSpecific1(long codecSpecific1) {
|
||||
mCodecSpecific1 = codecSpecific1;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the second codec specific values for Bluetooth codec config.
|
||||
*
|
||||
* @param codecSpecific2 codec specific value or 0 if default
|
||||
* @return the same Builder instance
|
||||
*/
|
||||
public @NonNull Builder setCodecSpecific2(long codecSpecific2) {
|
||||
mCodecSpecific2 = codecSpecific2;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the third codec specific values for Bluetooth codec config.
|
||||
*
|
||||
* @param codecSpecific3 codec specific value or 0 if default
|
||||
* @return the same Builder instance
|
||||
*/
|
||||
public @NonNull Builder setCodecSpecific3(long codecSpecific3) {
|
||||
mCodecSpecific3 = codecSpecific3;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fourth codec specific values for Bluetooth codec config.
|
||||
*
|
||||
* @param codecSpecific4 codec specific value or 0 if default
|
||||
* @return the same Builder instance
|
||||
*/
|
||||
public @NonNull Builder setCodecSpecific4(long codecSpecific4) {
|
||||
mCodecSpecific4 = codecSpecific4;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build {@link BluetoothCodecConfig}.
|
||||
* @return new BluetoothCodecConfig built
|
||||
*/
|
||||
public @NonNull BluetoothCodecConfig build() {
|
||||
return new BluetoothCodecConfig(mCodecType, mCodecPriority,
|
||||
mSampleRate, mBitsPerSample,
|
||||
mChannelMode, mCodecSpecific1,
|
||||
mCodecSpecific2, mCodecSpecific3,
|
||||
mCodecSpecific4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,13 @@
|
||||
|
||||
package android.bluetooth;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -29,8 +30,6 @@ import java.util.Objects;
|
||||
* A2DP source device.
|
||||
*
|
||||
* {@see BluetoothA2dp}
|
||||
*
|
||||
* {@hide}
|
||||
*/
|
||||
public final class BluetoothCodecStatus implements Parcelable {
|
||||
/**
|
||||
@@ -39,22 +38,27 @@ public final class BluetoothCodecStatus implements Parcelable {
|
||||
* This extra represents the current codec status of the A2DP
|
||||
* profile.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public static final String EXTRA_CODEC_STATUS =
|
||||
"android.bluetooth.extra.CODEC_STATUS";
|
||||
|
||||
private final @Nullable BluetoothCodecConfig mCodecConfig;
|
||||
private final BluetoothCodecConfig[] mCodecsLocalCapabilities;
|
||||
private final BluetoothCodecConfig[] mCodecsSelectableCapabilities;
|
||||
private final @Nullable List<BluetoothCodecConfig> mCodecsLocalCapabilities;
|
||||
private final @Nullable List<BluetoothCodecConfig> mCodecsSelectableCapabilities;
|
||||
|
||||
public BluetoothCodecStatus(@Nullable BluetoothCodecConfig codecConfig,
|
||||
@Nullable BluetoothCodecConfig[] codecsLocalCapabilities,
|
||||
@Nullable BluetoothCodecConfig[] codecsSelectableCapabilities) {
|
||||
@Nullable List<BluetoothCodecConfig> codecsLocalCapabilities,
|
||||
@Nullable List<BluetoothCodecConfig> codecsSelectableCapabilities) {
|
||||
mCodecConfig = codecConfig;
|
||||
mCodecsLocalCapabilities = codecsLocalCapabilities;
|
||||
mCodecsSelectableCapabilities = codecsSelectableCapabilities;
|
||||
}
|
||||
|
||||
private BluetoothCodecStatus(Parcel in) {
|
||||
mCodecConfig = in.readTypedObject(BluetoothCodecConfig.CREATOR);
|
||||
mCodecsLocalCapabilities = in.createTypedArrayList(BluetoothCodecConfig.CREATOR);
|
||||
mCodecsSelectableCapabilities = in.createTypedArrayList(BluetoothCodecConfig.CREATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object o) {
|
||||
if (o instanceof BluetoothCodecStatus) {
|
||||
@@ -68,26 +72,25 @@ public final class BluetoothCodecStatus implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether two arrays of capabilities contain same capabilities.
|
||||
* The order of the capabilities in each array is ignored.
|
||||
* Checks whether two lists of capabilities contain same capabilities.
|
||||
* The order of the capabilities in each list 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
|
||||
* @hide
|
||||
* @param c1 the first list of capabilities to compare
|
||||
* @param c2 the second list of capabilities to compare
|
||||
* @return {@code true} if both lists contain same capabilities
|
||||
*/
|
||||
public static boolean sameCapabilities(BluetoothCodecConfig[] c1,
|
||||
BluetoothCodecConfig[] c2) {
|
||||
private static boolean sameCapabilities(@Nullable List<BluetoothCodecConfig> c1,
|
||||
@Nullable List<BluetoothCodecConfig> c2) {
|
||||
if (c1 == null) {
|
||||
return (c2 == null);
|
||||
}
|
||||
if (c2 == null) {
|
||||
return false;
|
||||
}
|
||||
if (c1.length != c2.length) {
|
||||
if (c1.size() != c2.size()) {
|
||||
return false;
|
||||
}
|
||||
return Arrays.asList(c1).containsAll(Arrays.asList(c2));
|
||||
return c1.containsAll(c2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,10 +98,9 @@ public final class BluetoothCodecStatus implements Parcelable {
|
||||
* Any parameters of the codec config with NONE value will be considered a wildcard matching.
|
||||
*
|
||||
* @param codecConfig the codec config to compare against
|
||||
* @return true if the codec config matches, otherwise false
|
||||
* @hide
|
||||
* @return {@code true} if the codec config matches, {@code false} otherwise
|
||||
*/
|
||||
public boolean isCodecConfigSelectable(BluetoothCodecConfig codecConfig) {
|
||||
public boolean isCodecConfigSelectable(@Nullable BluetoothCodecConfig codecConfig) {
|
||||
if (codecConfig == null || !codecConfig.hasSingleSampleRate()
|
||||
|| !codecConfig.hasSingleBitsPerSample() || !codecConfig.hasSingleChannelMode()) {
|
||||
return false;
|
||||
@@ -128,10 +130,7 @@ public final class BluetoothCodecStatus implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash based on the codec config and local capabilities
|
||||
*
|
||||
* @return a hash based on the config values
|
||||
* @hide
|
||||
* Returns a hash based on the codec config and local capabilities.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
@@ -139,17 +138,19 @@ public final class BluetoothCodecStatus implements Parcelable {
|
||||
mCodecsLocalCapabilities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link String} that describes each BluetoothCodecStatus parameter
|
||||
* current value.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{mCodecConfig:" + mCodecConfig
|
||||
+ ",mCodecsLocalCapabilities:" + Arrays.toString(mCodecsLocalCapabilities)
|
||||
+ ",mCodecsSelectableCapabilities:" + Arrays.toString(mCodecsSelectableCapabilities)
|
||||
+ ",mCodecsLocalCapabilities:" + mCodecsLocalCapabilities
|
||||
+ ",mCodecsSelectableCapabilities:" + mCodecsSelectableCapabilities
|
||||
+ "}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Always returns 0
|
||||
*
|
||||
* @return 0
|
||||
* @hide
|
||||
*/
|
||||
@@ -161,16 +162,7 @@ public final class BluetoothCodecStatus implements Parcelable {
|
||||
public static final @android.annotation.NonNull Parcelable.Creator<BluetoothCodecStatus> CREATOR =
|
||||
new Parcelable.Creator<BluetoothCodecStatus>() {
|
||||
public BluetoothCodecStatus createFromParcel(Parcel in) {
|
||||
final BluetoothCodecConfig codecConfig = in.readTypedObject(
|
||||
BluetoothCodecConfig.CREATOR);
|
||||
final BluetoothCodecConfig[] codecsLocalCapabilities = in.createTypedArray(
|
||||
BluetoothCodecConfig.CREATOR);
|
||||
final BluetoothCodecConfig[] codecsSelectableCapabilities = in.createTypedArray(
|
||||
BluetoothCodecConfig.CREATOR);
|
||||
|
||||
return new BluetoothCodecStatus(codecConfig,
|
||||
codecsLocalCapabilities,
|
||||
codecsSelectableCapabilities);
|
||||
return new BluetoothCodecStatus(in);
|
||||
}
|
||||
|
||||
public BluetoothCodecStatus[] newArray(int size) {
|
||||
@@ -179,47 +171,38 @@ public final class BluetoothCodecStatus implements Parcelable {
|
||||
};
|
||||
|
||||
/**
|
||||
* Flattens the object to a parcel
|
||||
* Flattens the object to a parcel.
|
||||
*
|
||||
* @param out The Parcel in which the object should be written.
|
||||
* @param flags Additional flags about how the object should be written.
|
||||
*
|
||||
* @hide
|
||||
* @param out The Parcel in which the object should be written
|
||||
* @param flags Additional flags about how the object should be written
|
||||
*/
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
public void writeToParcel(@NonNull Parcel out, int flags) {
|
||||
out.writeTypedObject(mCodecConfig, 0);
|
||||
out.writeTypedArray(mCodecsLocalCapabilities, 0);
|
||||
out.writeTypedArray(mCodecsSelectableCapabilities, 0);
|
||||
out.writeTypedList(mCodecsLocalCapabilities);
|
||||
out.writeTypedList(mCodecsSelectableCapabilities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current codec configuration.
|
||||
*
|
||||
* @return the current codec configuration
|
||||
* Returns the current codec configuration.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public @Nullable BluetoothCodecConfig getCodecConfig() {
|
||||
return mCodecConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the codecs local capabilities.
|
||||
*
|
||||
* @return an array with the codecs local capabilities
|
||||
* Returns the codecs local capabilities.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public @Nullable BluetoothCodecConfig[] getCodecsLocalCapabilities() {
|
||||
return mCodecsLocalCapabilities;
|
||||
public @NonNull List<BluetoothCodecConfig> getCodecsLocalCapabilities() {
|
||||
return (mCodecsLocalCapabilities == null)
|
||||
? Collections.emptyList() : mCodecsLocalCapabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the codecs selectable capabilities.
|
||||
*
|
||||
* @return an array with the codecs selectable capabilities
|
||||
* Returns the codecs selectable capabilities.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public @Nullable BluetoothCodecConfig[] getCodecsSelectableCapabilities() {
|
||||
return mCodecsSelectableCapabilities;
|
||||
public @NonNull List<BluetoothCodecConfig> getCodecsSelectableCapabilities() {
|
||||
return (mCodecsSelectableCapabilities == null)
|
||||
? Collections.emptyList() : mCodecsSelectableCapabilities;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package android.bluetooth;
|
||||
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import android.util.Log;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -34,7 +33,6 @@ public class BluetoothCodecConfigTest extends TestCase {
|
||||
BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
|
||||
BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
|
||||
BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
||||
BluetoothCodecConfig.SOURCE_CODEC_TYPE_MAX,
|
||||
BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID,
|
||||
};
|
||||
private static final int[] kCodecPriorityArray = new int[] {
|
||||
@@ -168,20 +166,11 @@ public class BluetoothCodecConfigTest extends TestCase {
|
||||
long codec_specific3 = selectCodecSpecific3(config_id);
|
||||
long codec_specific4 = selectCodecSpecific4(config_id);
|
||||
|
||||
BluetoothCodecConfig bcc = new BluetoothCodecConfig(codec_type, codec_priority,
|
||||
BluetoothCodecConfig bcc = buildBluetoothCodecConfig(codec_type, codec_priority,
|
||||
sample_rate, bits_per_sample,
|
||||
channel_mode, codec_specific1,
|
||||
codec_specific2, codec_specific3,
|
||||
codec_specific4);
|
||||
if (sample_rate == BluetoothCodecConfig.SAMPLE_RATE_NONE) {
|
||||
assertFalse(bcc.isValid());
|
||||
} else if (bits_per_sample == BluetoothCodecConfig.BITS_PER_SAMPLE_NONE) {
|
||||
assertFalse(bcc.isValid());
|
||||
} else if (channel_mode == BluetoothCodecConfig.CHANNEL_MODE_NONE) {
|
||||
assertFalse(bcc.isValid());
|
||||
} else {
|
||||
assertTrue(bcc.isValid());
|
||||
}
|
||||
|
||||
if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC) {
|
||||
assertTrue(bcc.isMandatoryCodec());
|
||||
@@ -204,10 +193,6 @@ public class BluetoothCodecConfigTest extends TestCase {
|
||||
if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC) {
|
||||
assertEquals("LDAC", bcc.getCodecName());
|
||||
}
|
||||
if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_MAX) {
|
||||
assertEquals("UNKNOWN CODEC(" + BluetoothCodecConfig.SOURCE_CODEC_TYPE_MAX + ")",
|
||||
bcc.getCodecName());
|
||||
}
|
||||
if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID) {
|
||||
assertEquals("INVALID CODEC", bcc.getCodecName());
|
||||
}
|
||||
@@ -227,7 +212,7 @@ public class BluetoothCodecConfigTest extends TestCase {
|
||||
@SmallTest
|
||||
public void testBluetoothCodecConfig_equals() {
|
||||
BluetoothCodecConfig bcc1 =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -235,7 +220,7 @@ public class BluetoothCodecConfigTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
BluetoothCodecConfig bcc2_same =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -244,7 +229,7 @@ public class BluetoothCodecConfigTest extends TestCase {
|
||||
assertTrue(bcc1.equals(bcc2_same));
|
||||
|
||||
BluetoothCodecConfig bcc3_codec_type =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -253,7 +238,7 @@ public class BluetoothCodecConfigTest extends TestCase {
|
||||
assertFalse(bcc1.equals(bcc3_codec_type));
|
||||
|
||||
BluetoothCodecConfig bcc4_codec_priority =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -262,7 +247,7 @@ public class BluetoothCodecConfigTest extends TestCase {
|
||||
assertFalse(bcc1.equals(bcc4_codec_priority));
|
||||
|
||||
BluetoothCodecConfig bcc5_sample_rate =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -271,7 +256,7 @@ public class BluetoothCodecConfigTest extends TestCase {
|
||||
assertFalse(bcc1.equals(bcc5_sample_rate));
|
||||
|
||||
BluetoothCodecConfig bcc6_bits_per_sample =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_24,
|
||||
@@ -280,7 +265,7 @@ public class BluetoothCodecConfigTest extends TestCase {
|
||||
assertFalse(bcc1.equals(bcc6_bits_per_sample));
|
||||
|
||||
BluetoothCodecConfig bcc7_channel_mode =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -289,7 +274,7 @@ public class BluetoothCodecConfigTest extends TestCase {
|
||||
assertFalse(bcc1.equals(bcc7_channel_mode));
|
||||
|
||||
BluetoothCodecConfig bcc8_codec_specific1 =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -298,7 +283,7 @@ public class BluetoothCodecConfigTest extends TestCase {
|
||||
assertFalse(bcc1.equals(bcc8_codec_specific1));
|
||||
|
||||
BluetoothCodecConfig bcc9_codec_specific2 =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -307,7 +292,7 @@ public class BluetoothCodecConfigTest extends TestCase {
|
||||
assertFalse(bcc1.equals(bcc9_codec_specific2));
|
||||
|
||||
BluetoothCodecConfig bcc10_codec_specific3 =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -316,7 +301,7 @@ public class BluetoothCodecConfigTest extends TestCase {
|
||||
assertFalse(bcc1.equals(bcc10_codec_specific3));
|
||||
|
||||
BluetoothCodecConfig bcc11_codec_specific4 =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -324,4 +309,21 @@ public class BluetoothCodecConfigTest extends TestCase {
|
||||
1000, 2000, 3000, 4004);
|
||||
assertFalse(bcc1.equals(bcc11_codec_specific4));
|
||||
}
|
||||
|
||||
private BluetoothCodecConfig buildBluetoothCodecConfig(int sourceCodecType,
|
||||
int codecPriority, int sampleRate, int bitsPerSample, int channelMode,
|
||||
long codecSpecific1, long codecSpecific2, long codecSpecific3, long codecSpecific4) {
|
||||
return new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(sourceCodecType)
|
||||
.setCodecPriority(codecPriority)
|
||||
.setSampleRate(sampleRate)
|
||||
.setBitsPerSample(bitsPerSample)
|
||||
.setChannelMode(channelMode)
|
||||
.setCodecSpecific1(codecSpecific1)
|
||||
.setCodecSpecific2(codecSpecific2)
|
||||
.setCodecSpecific3(codecSpecific3)
|
||||
.setCodecSpecific4(codecSpecific4)
|
||||
.build();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
package android.bluetooth;
|
||||
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Unit test cases for {@link BluetoothCodecStatus}.
|
||||
* <p>
|
||||
@@ -34,7 +34,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
|
||||
// Codec configs: A and B are same; C is different
|
||||
private static final BluetoothCodecConfig config_A =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -42,7 +42,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig config_B =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -50,7 +50,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig config_C =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -59,7 +59,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
|
||||
// Local capabilities: A and B are same; C is different
|
||||
private static final BluetoothCodecConfig local_capability1_A =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000,
|
||||
@@ -69,7 +69,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig local_capability1_B =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000,
|
||||
@@ -79,7 +79,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig local_capability1_C =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000,
|
||||
@@ -89,7 +89,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
|
||||
|
||||
private static final BluetoothCodecConfig local_capability2_A =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000,
|
||||
@@ -99,7 +99,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig local_capability2_B =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000,
|
||||
@@ -109,7 +109,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig local_capability2_C =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000,
|
||||
@@ -118,7 +118,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig local_capability3_A =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000,
|
||||
@@ -128,7 +128,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig local_capability3_B =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000,
|
||||
@@ -138,7 +138,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig local_capability3_C =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000,
|
||||
@@ -147,7 +147,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig local_capability4_A =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000,
|
||||
@@ -157,7 +157,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig local_capability4_B =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000,
|
||||
@@ -167,7 +167,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig local_capability4_C =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000,
|
||||
@@ -176,7 +176,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig local_capability5_A =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000 |
|
||||
@@ -190,7 +190,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig local_capability5_B =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000 |
|
||||
@@ -204,7 +204,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig local_capability5_C =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000 |
|
||||
@@ -219,7 +219,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
|
||||
// Selectable capabilities: A and B are same; C is different
|
||||
private static final BluetoothCodecConfig selectable_capability1_A =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -228,7 +228,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig selectable_capability1_B =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -237,7 +237,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig selectable_capability1_C =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -245,7 +245,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig selectable_capability2_A =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -254,7 +254,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig selectable_capability2_B =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -263,7 +263,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig selectable_capability2_C =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -271,7 +271,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig selectable_capability3_A =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -280,7 +280,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig selectable_capability3_B =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -289,7 +289,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig selectable_capability3_C =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
|
||||
@@ -297,7 +297,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig selectable_capability4_A =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_24,
|
||||
@@ -306,7 +306,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig selectable_capability4_B =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_24,
|
||||
@@ -315,7 +315,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig selectable_capability4_C =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_24,
|
||||
@@ -323,7 +323,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig selectable_capability5_A =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000 |
|
||||
@@ -337,7 +337,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig selectable_capability5_B =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000 |
|
||||
@@ -351,7 +351,7 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig selectable_capability5_C =
|
||||
new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
||||
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_44100 |
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000 |
|
||||
@@ -363,79 +363,87 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
|
||||
1000, 2000, 3000, 4000);
|
||||
|
||||
private static final BluetoothCodecConfig[] local_capability_A = {
|
||||
local_capability1_A,
|
||||
local_capability2_A,
|
||||
local_capability3_A,
|
||||
local_capability4_A,
|
||||
local_capability5_A,
|
||||
};
|
||||
private static final List<BluetoothCodecConfig> LOCAL_CAPABILITY_A =
|
||||
new ArrayList() {{
|
||||
add(local_capability1_A);
|
||||
add(local_capability2_A);
|
||||
add(local_capability3_A);
|
||||
add(local_capability4_A);
|
||||
add(local_capability5_A);
|
||||
}};
|
||||
|
||||
private static final BluetoothCodecConfig[] local_capability_B = {
|
||||
local_capability1_B,
|
||||
local_capability2_B,
|
||||
local_capability3_B,
|
||||
local_capability4_B,
|
||||
local_capability5_B,
|
||||
};
|
||||
private static final List<BluetoothCodecConfig> LOCAL_CAPABILITY_B =
|
||||
new ArrayList() {{
|
||||
add(local_capability1_B);
|
||||
add(local_capability2_B);
|
||||
add(local_capability3_B);
|
||||
add(local_capability4_B);
|
||||
add(local_capability5_B);
|
||||
}};
|
||||
|
||||
private static final BluetoothCodecConfig[] local_capability_B_reordered = {
|
||||
local_capability5_B,
|
||||
local_capability4_B,
|
||||
local_capability2_B,
|
||||
local_capability3_B,
|
||||
local_capability1_B,
|
||||
};
|
||||
private static final List<BluetoothCodecConfig> LOCAL_CAPABILITY_B_REORDERED =
|
||||
new ArrayList() {{
|
||||
add(local_capability5_B);
|
||||
add(local_capability4_B);
|
||||
add(local_capability2_B);
|
||||
add(local_capability3_B);
|
||||
add(local_capability1_B);
|
||||
}};
|
||||
|
||||
private static final BluetoothCodecConfig[] local_capability_C = {
|
||||
local_capability1_C,
|
||||
local_capability2_C,
|
||||
local_capability3_C,
|
||||
local_capability4_C,
|
||||
local_capability5_C,
|
||||
};
|
||||
private static final List<BluetoothCodecConfig> LOCAL_CAPABILITY_C =
|
||||
new ArrayList() {{
|
||||
add(local_capability1_C);
|
||||
add(local_capability2_C);
|
||||
add(local_capability3_C);
|
||||
add(local_capability4_C);
|
||||
add(local_capability5_C);
|
||||
}};
|
||||
|
||||
private static final BluetoothCodecConfig[] selectable_capability_A = {
|
||||
selectable_capability1_A,
|
||||
selectable_capability2_A,
|
||||
selectable_capability3_A,
|
||||
selectable_capability4_A,
|
||||
selectable_capability5_A,
|
||||
};
|
||||
private static final List<BluetoothCodecConfig> SELECTABLE_CAPABILITY_A =
|
||||
new ArrayList() {{
|
||||
add(selectable_capability1_A);
|
||||
add(selectable_capability2_A);
|
||||
add(selectable_capability3_A);
|
||||
add(selectable_capability4_A);
|
||||
add(selectable_capability5_A);
|
||||
}};
|
||||
|
||||
private static final BluetoothCodecConfig[] selectable_capability_B = {
|
||||
selectable_capability1_B,
|
||||
selectable_capability2_B,
|
||||
selectable_capability3_B,
|
||||
selectable_capability4_B,
|
||||
selectable_capability5_B,
|
||||
};
|
||||
private static final List<BluetoothCodecConfig> SELECTABLE_CAPABILITY_B =
|
||||
new ArrayList() {{
|
||||
add(selectable_capability1_B);
|
||||
add(selectable_capability2_B);
|
||||
add(selectable_capability3_B);
|
||||
add(selectable_capability4_B);
|
||||
add(selectable_capability5_B);
|
||||
}};
|
||||
|
||||
private static final BluetoothCodecConfig[] selectable_capability_B_reordered = {
|
||||
selectable_capability5_B,
|
||||
selectable_capability4_B,
|
||||
selectable_capability2_B,
|
||||
selectable_capability3_B,
|
||||
selectable_capability1_B,
|
||||
};
|
||||
private static final List<BluetoothCodecConfig> SELECTABLE_CAPABILITY_B_REORDERED =
|
||||
new ArrayList() {{
|
||||
add(selectable_capability5_B);
|
||||
add(selectable_capability4_B);
|
||||
add(selectable_capability2_B);
|
||||
add(selectable_capability3_B);
|
||||
add(selectable_capability1_B);
|
||||
}};
|
||||
|
||||
private static final BluetoothCodecConfig[] selectable_capability_C = {
|
||||
selectable_capability1_C,
|
||||
selectable_capability2_C,
|
||||
selectable_capability3_C,
|
||||
selectable_capability4_C,
|
||||
selectable_capability5_C,
|
||||
};
|
||||
private static final List<BluetoothCodecConfig> SELECTABLE_CAPABILITY_C =
|
||||
new ArrayList() {{
|
||||
add(selectable_capability1_C);
|
||||
add(selectable_capability2_C);
|
||||
add(selectable_capability3_C);
|
||||
add(selectable_capability4_C);
|
||||
add(selectable_capability5_C);
|
||||
}};
|
||||
|
||||
private static final BluetoothCodecStatus bcs_A =
|
||||
new BluetoothCodecStatus(config_A, local_capability_A, selectable_capability_A);
|
||||
new BluetoothCodecStatus(config_A, LOCAL_CAPABILITY_A, SELECTABLE_CAPABILITY_A);
|
||||
private static final BluetoothCodecStatus bcs_B =
|
||||
new BluetoothCodecStatus(config_B, local_capability_B, selectable_capability_B);
|
||||
new BluetoothCodecStatus(config_B, LOCAL_CAPABILITY_B, SELECTABLE_CAPABILITY_B);
|
||||
private static final BluetoothCodecStatus bcs_B_reordered =
|
||||
new BluetoothCodecStatus(config_B, local_capability_B_reordered,
|
||||
selectable_capability_B_reordered);
|
||||
new BluetoothCodecStatus(config_B, LOCAL_CAPABILITY_B_REORDERED,
|
||||
SELECTABLE_CAPABILITY_B_REORDERED);
|
||||
private static final BluetoothCodecStatus bcs_C =
|
||||
new BluetoothCodecStatus(config_C, local_capability_C, selectable_capability_C);
|
||||
new BluetoothCodecStatus(config_C, LOCAL_CAPABILITY_C, SELECTABLE_CAPABILITY_C);
|
||||
|
||||
@SmallTest
|
||||
public void testBluetoothCodecStatus_get_methods() {
|
||||
@@ -444,16 +452,16 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
assertTrue(Objects.equals(bcs_A.getCodecConfig(), config_B));
|
||||
assertFalse(Objects.equals(bcs_A.getCodecConfig(), config_C));
|
||||
|
||||
assertTrue(Arrays.equals(bcs_A.getCodecsLocalCapabilities(), local_capability_A));
|
||||
assertTrue(Arrays.equals(bcs_A.getCodecsLocalCapabilities(), local_capability_B));
|
||||
assertFalse(Arrays.equals(bcs_A.getCodecsLocalCapabilities(), local_capability_C));
|
||||
assertTrue(bcs_A.getCodecsLocalCapabilities().equals(LOCAL_CAPABILITY_A));
|
||||
assertTrue(bcs_A.getCodecsLocalCapabilities().equals(LOCAL_CAPABILITY_B));
|
||||
assertFalse(bcs_A.getCodecsLocalCapabilities().equals(LOCAL_CAPABILITY_C));
|
||||
|
||||
assertTrue(Arrays.equals(bcs_A.getCodecsSelectableCapabilities(),
|
||||
selectable_capability_A));
|
||||
assertTrue(Arrays.equals(bcs_A.getCodecsSelectableCapabilities(),
|
||||
selectable_capability_B));
|
||||
assertFalse(Arrays.equals(bcs_A.getCodecsSelectableCapabilities(),
|
||||
selectable_capability_C));
|
||||
assertTrue(bcs_A.getCodecsSelectableCapabilities()
|
||||
.equals(SELECTABLE_CAPABILITY_A));
|
||||
assertTrue(bcs_A.getCodecsSelectableCapabilities()
|
||||
.equals(SELECTABLE_CAPABILITY_B));
|
||||
assertFalse(bcs_A.getCodecsSelectableCapabilities()
|
||||
.equals(SELECTABLE_CAPABILITY_C));
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
@@ -465,4 +473,21 @@ public class BluetoothCodecStatusTest extends TestCase {
|
||||
assertFalse(bcs_A.equals(bcs_C));
|
||||
assertFalse(bcs_C.equals(bcs_A));
|
||||
}
|
||||
|
||||
private static BluetoothCodecConfig buildBluetoothCodecConfig(int sourceCodecType,
|
||||
int codecPriority, int sampleRate, int bitsPerSample, int channelMode,
|
||||
long codecSpecific1, long codecSpecific2, long codecSpecific3, long codecSpecific4) {
|
||||
return new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(sourceCodecType)
|
||||
.setCodecPriority(codecPriority)
|
||||
.setSampleRate(sampleRate)
|
||||
.setBitsPerSample(bitsPerSample)
|
||||
.setChannelMode(channelMode)
|
||||
.setCodecSpecific1(codecSpecific1)
|
||||
.setCodecSpecific2(codecSpecific2)
|
||||
.setCodecSpecific3(codecSpecific3)
|
||||
.setCodecSpecific4(codecSpecific4)
|
||||
.build();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,13 +28,16 @@ import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.bluetooth.BluetoothUuid;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.ParcelUuid;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.android.settingslib.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class A2dpProfile implements LocalBluetoothProfile {
|
||||
@@ -226,6 +229,10 @@ public class A2dpProfile implements LocalBluetoothProfile {
|
||||
return support == BluetoothA2dp.OPTIONAL_CODECS_SUPPORTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether high quality audio is enabled or not
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
|
||||
public boolean isHighQualityAudioEnabled(BluetoothDevice device) {
|
||||
BluetoothDevice bluetoothDevice = (device != null) ? device : mService.getActiveDevice();
|
||||
if (bluetoothDevice == null) {
|
||||
@@ -271,6 +278,13 @@ public class A2dpProfile implements LocalBluetoothProfile {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the label associated with the codec of a Bluetooth device.
|
||||
*
|
||||
* @param device to get codec label from
|
||||
* @return the label associated with the device codec
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
|
||||
public String getHighQualityAudioOptionLabel(BluetoothDevice device) {
|
||||
BluetoothDevice bluetoothDevice = (device != null) ? device : mService.getActiveDevice();
|
||||
int unknownCodecId = R.string.bluetooth_profile_a2dp_high_quality_unknown_codec;
|
||||
@@ -280,18 +294,18 @@ public class A2dpProfile implements LocalBluetoothProfile {
|
||||
}
|
||||
// We want to get the highest priority codec, since that's the one that will be used with
|
||||
// this device, and see if it is high-quality (ie non-mandatory).
|
||||
BluetoothCodecConfig[] selectable = null;
|
||||
List<BluetoothCodecConfig> selectable = null;
|
||||
if (mService.getCodecStatus(device) != null) {
|
||||
selectable = mService.getCodecStatus(device).getCodecsSelectableCapabilities();
|
||||
// To get the highest priority, we sort in reverse.
|
||||
Arrays.sort(selectable,
|
||||
Collections.sort(selectable,
|
||||
(a, b) -> {
|
||||
return b.getCodecPriority() - a.getCodecPriority();
|
||||
});
|
||||
}
|
||||
|
||||
final BluetoothCodecConfig codecConfig = (selectable == null || selectable.length < 1)
|
||||
? null : selectable[0];
|
||||
final BluetoothCodecConfig codecConfig = (selectable == null || selectable.size() < 1)
|
||||
? null : selectable.get(0);
|
||||
final int codecType = (codecConfig == null || codecConfig.isMandatoryCodec())
|
||||
? BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID : codecConfig.getCodecType();
|
||||
|
||||
|
||||
@@ -43,6 +43,9 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadow.api.Shadow;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {ShadowBluetoothAdapter.class})
|
||||
public class A2dpProfileTest {
|
||||
@@ -179,7 +182,7 @@ public class A2dpProfileTest {
|
||||
BluetoothProfile.STATE_CONNECTED);
|
||||
BluetoothCodecStatus status = mock(BluetoothCodecStatus.class);
|
||||
BluetoothCodecConfig config = mock(BluetoothCodecConfig.class);
|
||||
BluetoothCodecConfig[] configs = {config};
|
||||
List<BluetoothCodecConfig> configs = Arrays.asList(config);
|
||||
when(mBluetoothA2dp.getCodecStatus(mDevice)).thenReturn(status);
|
||||
when(status.getCodecsSelectableCapabilities()).thenReturn(configs);
|
||||
|
||||
@@ -194,7 +197,7 @@ public class A2dpProfileTest {
|
||||
BluetoothProfile.STATE_CONNECTED);
|
||||
BluetoothCodecStatus status = mock(BluetoothCodecStatus.class);
|
||||
BluetoothCodecConfig config = mock(BluetoothCodecConfig.class);
|
||||
BluetoothCodecConfig[] configs = {config};
|
||||
List<BluetoothCodecConfig> configs = Arrays.asList(config);
|
||||
when(mBluetoothA2dp.getCodecStatus(mDevice)).thenReturn(status);
|
||||
when(status.getCodecsSelectableCapabilities()).thenReturn(configs);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user