From 6319d47c4fed4f35af17fb2e906e5d97c07b3bb6 Mon Sep 17 00:00:00 2001 From: Pavlin Radoslavov Date: Fri, 24 Feb 2017 10:19:14 -0800 Subject: Add new internal API: enableOptionalCodecs()/disableOptionalCodecs() This API can be used to enable the optional codecs, or disable them and use only the mandatory SBC. Internally, it is implemented by raising the SBC priority to highest (so SBC will be used/selected), or reducing the SBC priority to its default value (lowest). Test: A2DP streaming and enabling/disabling/selecting optional codecs Bug: 35873828 Change-Id: Ia82036ac33590a3a402b1f5a36102264d47a9029 --- .../android/bluetooth/BluetoothCodecConfig.java | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'framework/java/android/bluetooth/BluetoothCodecConfig.java') diff --git a/framework/java/android/bluetooth/BluetoothCodecConfig.java b/framework/java/android/bluetooth/BluetoothCodecConfig.java index 176e48fb6e..d5e1429810 100644 --- a/framework/java/android/bluetooth/BluetoothCodecConfig.java +++ b/framework/java/android/bluetooth/BluetoothCodecConfig.java @@ -63,7 +63,7 @@ public final class BluetoothCodecConfig implements Parcelable { public static final int CHANNEL_MODE_STEREO = 0x1 << 1; private final int mCodecType; - private final int mCodecPriority; + private int mCodecPriority; private final int mSampleRate; private final int mBitsPerSample; private final int mChannelMode; @@ -279,6 +279,15 @@ public final class BluetoothCodecConfig implements Parcelable { return mCodecType; } + /** + * Checks whether the codec is mandatory. + * + * @return true if the codec is mandatory, otherwise false. + */ + 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 @@ -290,6 +299,17 @@ public final class BluetoothCodecConfig implements Parcelable { 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. + * + * @param codecPriority the codec priority + */ + public void setCodecPriority(int codecPriority) { + mCodecPriority = codecPriority; + } + /** * Gets the codec sample rate. The value can be a bitmask with all * supported sample rates: -- cgit v1.2.3