A2DP codec priority [2/3]
neobuddy89: Simplify and change sequence.
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Change-Id: I710505d8fa0bb4103996acd45693f16a17dda985
diff --git a/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java b/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java
index 260a08f..6fec26b 100644
--- a/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java
+++ b/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java
@@ -23,6 +23,7 @@
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
import android.os.SystemProperties;
+import android.provider.Settings;
import android.util.Log;
import com.android.bluetooth.R;
import com.android.bluetooth.btservice.AdapterService;
@@ -297,6 +298,37 @@
mA2dpSourceCodecPriorityAptxTwsp = BluetoothCodecConfig.CODEC_PRIORITY_DISABLED;
}
+ // Set highest codec priority in the end, so that it can override xml values
+ int codec_priority = Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.A2DP_SOURCE_CODEC_PRIORITY, 0);
+
+ switch (codec_priority) {
+ case 0:
+ default:
+ break;
+ case 1:
+ mA2dpSourceCodecPrioritySbc = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
+ break;
+ case 2:
+ mA2dpSourceCodecPriorityAac = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
+ break;
+ case 3:
+ mA2dpSourceCodecPriorityAptx = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
+ break;
+ case 4:
+ mA2dpSourceCodecPriorityAptxHd = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
+ break;
+ case 5:
+ mA2dpSourceCodecPriorityLdac = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
+ break;
+ case 6:
+ mA2dpSourceCodecPriorityAptxAdaptive = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
+ break;
+ case 7:
+ mA2dpSourceCodecPriorityAptxTwsp = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
+ break;
+ }
+
BluetoothCodecConfig codecConfig;
BluetoothCodecConfig[] codecConfigArray;
int codecCount = 0;
@@ -333,7 +365,8 @@
.CHANNEL_MODE_NONE, 0 /* codecSpecific1 */,
0 /* codecSpecific2 */, 0 /* codecSpecific3 */, 0 /* codecSpecific4 */);
codecConfigArray[codecCount++] = codecConfig;
- if (mAdapterService.isVendorIntfEnabled()) {
+ if (mAdapterService.isVendorIntfEnabled() ||
+ mA2dpSourceCodecPriorityAptxTwsp == BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST) {
codecConfig = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_TWSP,
mA2dpSourceCodecPriorityAptxTwsp, BluetoothCodecConfig.SAMPLE_RATE_NONE,
BluetoothCodecConfig.BITS_PER_SAMPLE_NONE, BluetoothCodecConfig