Merge "Add new internal API: enableOptionalCodecs()/disableOptionalCodecs()" am: 3c7fce3579

am: 25105f6561

Change-Id: I67601df54e55171e3d559b71258d99ad1e0a8c5d
This commit is contained in:
Pavlin Radoslavov
2017-03-29 22:51:41 +00:00
committed by android-build-merger
4 changed files with 74 additions and 1 deletions

View File

@@ -610,6 +610,51 @@ public final class BluetoothA2dp implements BluetoothProfile {
} }
} }
/**
* Enables the optional codecs.
*
* @hide
*/
public void enableOptionalCodecs() {
if (DBG) Log.d(TAG, "enableOptionalCodecs");
enableDisableOptionalCodecs(true);
}
/**
* Disables the optional codecs.
*
* @hide
*/
public void disableOptionalCodecs() {
if (DBG) Log.d(TAG, "disableOptionalCodecs");
enableDisableOptionalCodecs(false);
}
/**
* Enables or disables the optional codecs.
*
* @param enable if true, enable the optional codecs, other disable them
*/
private void enableDisableOptionalCodecs(boolean enable) {
try {
mServiceLock.readLock().lock();
if (mService != null && isEnabled()) {
if (enable) {
mService.enableOptionalCodecs();
} else {
mService.disableOptionalCodecs();
}
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
return;
} catch (RemoteException e) {
Log.e(TAG, "Error talking to BT service in enableDisableOptionalCodecs()", e);
return;
} finally {
mServiceLock.readLock().unlock();
}
}
/** /**
* Helper for converting a state to a string. * Helper for converting a state to a string.
* *

View File

@@ -63,7 +63,7 @@ public final class BluetoothCodecConfig implements Parcelable {
public static final int CHANNEL_MODE_STEREO = 0x1 << 1; public static final int CHANNEL_MODE_STEREO = 0x1 << 1;
private final int mCodecType; private final int mCodecType;
private final int mCodecPriority; private int mCodecPriority;
private final int mSampleRate; private final int mSampleRate;
private final int mBitsPerSample; private final int mBitsPerSample;
private final int mChannelMode; private final int mChannelMode;
@@ -279,6 +279,15 @@ public final class BluetoothCodecConfig implements Parcelable {
return mCodecType; 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. * Gets the codec selection priority.
* The codec selection priority is relative to other codecs: larger value * The codec selection priority is relative to other codecs: larger value
@@ -290,6 +299,17 @@ public final class BluetoothCodecConfig implements Parcelable {
return mCodecPriority; 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 * Gets the codec sample rate. The value can be a bitmask with all
* supported sample rates: * supported sample rates:

View File

@@ -40,4 +40,6 @@ interface IBluetoothA2dp {
boolean isA2dpPlaying(in BluetoothDevice device); boolean isA2dpPlaying(in BluetoothDevice device);
BluetoothCodecStatus getCodecStatus(); BluetoothCodecStatus getCodecStatus();
oneway void setCodecConfigPreference(in BluetoothCodecConfig codecConfig); oneway void setCodecConfigPreference(in BluetoothCodecConfig codecConfig);
oneway void enableOptionalCodecs();
oneway void disableOptionalCodecs();
} }

View File

@@ -124,6 +124,8 @@
<item>aptX</item> <item>aptX</item>
<item>aptX HD</item> <item>aptX HD</item>
<item>LDAC</item> <item>LDAC</item>
<item>Enable Optional Codecs</item>
<item>Disable Optional Codecs</item>
</string-array> </string-array>
<!-- Values for Bluetooth Audio Codec selection preference. --> <!-- Values for Bluetooth Audio Codec selection preference. -->
@@ -134,6 +136,8 @@
<item>2</item> <item>2</item>
<item>3</item> <item>3</item>
<item>4</item> <item>4</item>
<item>5</item>
<item>6</item>
</string-array> </string-array>
<!-- Summaries for Bluetooth Audio Codec selection preference. [CHAR LIMIT=50]--> <!-- Summaries for Bluetooth Audio Codec selection preference. [CHAR LIMIT=50]-->
@@ -144,6 +148,8 @@
<item>aptX</item> <item>aptX</item>
<item>aptX HD</item> <item>aptX HD</item>
<item>LDAC</item> <item>LDAC</item>
<item>Enable Optional Codecs</item>
<item>Disable Optional Codecs</item>
</string-array> </string-array>
<!-- Titles for Bluetooth Audio Codec Sample Rate selection preference. [CHAR LIMIT=50] --> <!-- Titles for Bluetooth Audio Codec Sample Rate selection preference. [CHAR LIMIT=50] -->