summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEtienne Ruffieux <eruffieux@google.com>2022-02-01 22:27:41 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-02-01 22:27:41 +0000
commit524990d8b92663c70f6855c062cb5b34e91f22f9 (patch)
tree5b6a932a9119e350cbea69310e7550c151e9206b
parent84e2eee3a9bcd02420a5da379aa198b7ff7c291f (diff)
parent3271d6d1b4c2cff965d033d3381cffaaf1d8d0ba (diff)
downloadconnectivity-524990d8b92663c70f6855c062cb5b34e91f22f9.tar.gz
Replacing getActiveDevice by btAdapter.getActiveDevices() am: fb43b1d232 am: 3271d6d1b4
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Test/connectivity/+/1967501 Change-Id: Ibbb680811b3f477570172c1cd447c089d9d730ef
-rw-r--r--PMC/src/com/android/pmc/A2dpReceiver.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/PMC/src/com/android/pmc/A2dpReceiver.java b/PMC/src/com/android/pmc/A2dpReceiver.java
index 4728830..f610788 100644
--- a/PMC/src/com/android/pmc/A2dpReceiver.java
+++ b/PMC/src/com/android/pmc/A2dpReceiver.java
@@ -404,7 +404,7 @@ public class A2dpReceiver extends BroadcastReceiver {
List<BluetoothCodecConfig> codecsSelectableCapabilities = new ArrayList<>();
if (mBluetoothA2dp != null) {
- BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice();
+ BluetoothDevice activeDevice = getA2dpActiveDevice();
if (activeDevice == null) {
Log.e(TAG, "getCodecValue: Active device is null");
return null;
@@ -478,13 +478,13 @@ public class A2dpReceiver extends BroadcastReceiver {
}
if (mBluetoothA2dp != null) {
- BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice();
+ BluetoothDevice activeDevice = getA2dpActiveDevice();
if (activeDevice == null) {
Log.e(TAG, "setCodecValue: Active device is null. Codec is not set.");
return false;
}
Log.d(TAG, "setCodecConfigPreference()");
- mBluetoothA2dp.setCodecConfigPreference(mBluetoothA2dp.getActiveDevice(), codecConfig);
+ mBluetoothA2dp.setCodecConfigPreference(getA2dpActiveDevice(), codecConfig);
} else {
Log.e(TAG, "mBluetoothA2dp is null. Codec is not set");
return false;
@@ -509,6 +509,15 @@ public class A2dpReceiver extends BroadcastReceiver {
return true;
}
+ private BluetoothDevice getA2dpActiveDevice() {
+ if (mBluetoothAdapter == null) {
+ return null;
+ }
+ List<BluetoothDevice> activeDevices =
+ mBluetoothAdapter.getActiveDevices(BluetoothProfile.A2DP);
+ return (activeDevices.size() > 0) ? activeDevices.get(0) : null;
+ }
+
/**
* Method to verify if the codec config values are changed
*