Revert "Revert "Pass in active device to all BluetoothA2dp APIs ..."

Revert submission 10303287-revert-10253996-bt-a2dp-no-null-FQRXACWPIA

Reason for revert: Fixing breakage
Reverted Changes:
I4d9f2f819:Revert "Make sure calls to BluetoothA2dp APIs pass...
I771ca0d57:Revert "Need to now pass in active device instead ...
I76529c7a1:Revert "Pass in active device to all BluetoothA2dp...
I297bda68d:Revert "Require user pass in a non-null BluetoothD...
I525327959:Revert "Pass in active device to all BluetoothA2dp...
I1d8660b11:Revert "Pass in active device to all BluetoothA2dp...

Bug: 147287141
Test: robotests
Merged-In: I5aecfa4b5a8e371b914573ddd080acb98078bfca
Change-Id: I5aecfa4b5a8e371b914573ddd080acb98078bfca
This commit is contained in:
Rahul Sabnis
2020-02-25 22:28:00 +00:00
parent f7fe2b0dec
commit 3e0f661f11
11 changed files with 137 additions and 45 deletions

View File

@@ -80,7 +80,10 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
}
writeConfigurationValues(index);
final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig();
bluetoothA2dp.setCodecConfigPreference(null, codecConfig);
BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice();
if (activeDevice != null) {
bluetoothA2dp.setCodecConfigPreference(activeDevice, codecConfig);
}
mPreference.setSummary(((BaseBluetoothDialogPreference) mPreference).generateSummary(
index));
}
@@ -146,7 +149,13 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
if (bluetoothA2dp == null) {
return null;
}
final BluetoothCodecStatus codecStatus = bluetoothA2dp.getCodecStatus(null);
BluetoothDevice activeDevice = bluetoothA2dp.getActiveDevice();
if (activeDevice == null) {
Log.d(TAG, "Unable to get current codec config. No active device.");
return null;
}
final BluetoothCodecStatus codecStatus =
bluetoothA2dp.getCodecStatus(activeDevice);
if (codecStatus == null) {
Log.d(TAG, "Unable to get current codec config. Codec status is null");
return null;
@@ -164,7 +173,12 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
if (bluetoothA2dp == null) {
return null;
}
final BluetoothCodecStatus codecStatus = bluetoothA2dp.getCodecStatus(device);
BluetoothDevice bluetoothDevice =
(device != null) ? device : bluetoothA2dp.getActiveDevice();
if (bluetoothDevice == null) {
return null;
}
final BluetoothCodecStatus codecStatus = bluetoothA2dp.getCodecStatus(bluetoothDevice);
if (codecStatus != null) {
return codecStatus.getCodecsSelectableCapabilities();
}
@@ -177,7 +191,12 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
* @return {@link BluetoothCodecConfig}.
*/
protected BluetoothCodecConfig getSelectableByCodecType(int codecTypeValue) {
final BluetoothCodecConfig[] configs = getSelectableConfigs(null);
BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice();
if (activeDevice == null) {
Log.d(TAG, "Unable to get selectable config. No active device.");
return null;
}
final BluetoothCodecConfig[] configs = getSelectableConfigs(activeDevice);
if (configs == null) {
Log.d(TAG, "Unable to get selectable config. Selectable configs is empty.");
return null;