diff options
author | Rahul Sabnis <rahulsabnis@google.com> | 2020-02-25 22:28:00 +0000 |
---|---|---|
committer | Rahul Sabnis <rahulsabnis@google.com> | 2020-03-03 16:21:49 -0800 |
commit | 3e0f661f1176a24802caa797502a3e8e786541f5 (patch) | |
tree | 299763dc5693f0aba554933d368a7f750eb79e19 /src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java | |
parent | f7fe2b0dec23f8a9dbe6c6d8d6be1188bfba4c2a (diff) |
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
Diffstat (limited to 'src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java')
-rw-r--r-- | src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java b/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java index 71907b6f9f..6bc9175ba8 100644 --- a/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java +++ b/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java @@ -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; |