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:
@@ -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;
|
||||
|
@@ -83,9 +83,9 @@ public class BluetoothCodecDialogPreferenceController extends
|
||||
return index;
|
||||
}
|
||||
// Check HD audio is enabled, display the available list.
|
||||
if (bluetoothA2dp.getOptionalCodecsEnabled(activeDevice)
|
||||
if (bluetoothA2dp.isOptionalCodecsEnabled(activeDevice)
|
||||
== BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED) {
|
||||
BluetoothCodecConfig[] configs = getSelectableConfigs(null);
|
||||
BluetoothCodecConfig[] configs = getSelectableConfigs(activeDevice);
|
||||
if (configs != null) {
|
||||
return getIndexFromConfig(configs);
|
||||
}
|
||||
@@ -101,7 +101,8 @@ public class BluetoothCodecDialogPreferenceController extends
|
||||
int codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT;
|
||||
switch (index) {
|
||||
case 0:
|
||||
codecTypeValue = getHighestCodec(getSelectableConfigs(null));
|
||||
codecTypeValue = getHighestCodec(getSelectableConfigs(
|
||||
mBluetoothA2dp.getActiveDevice()));
|
||||
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
||||
break;
|
||||
case 1:
|
||||
|
@@ -58,11 +58,11 @@ public class BluetoothHDAudioPreferenceController extends AbstractBluetoothPrefe
|
||||
mPreference.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
final boolean supported = (bluetoothA2dp.supportsOptionalCodecs(activeDevice)
|
||||
final boolean supported = (bluetoothA2dp.isOptionalCodecsSupported(activeDevice)
|
||||
== BluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
|
||||
mPreference.setEnabled(supported);
|
||||
if (supported) {
|
||||
final boolean isEnabled = bluetoothA2dp.getOptionalCodecsEnabled(activeDevice)
|
||||
final boolean isEnabled = bluetoothA2dp.isOptionalCodecsEnabled(activeDevice)
|
||||
== BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED;
|
||||
((SwitchPreference) mPreference).setChecked(isEnabled);
|
||||
}
|
||||
@@ -84,11 +84,16 @@ public class BluetoothHDAudioPreferenceController extends AbstractBluetoothPrefe
|
||||
final int prefValue = enabled
|
||||
? BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED
|
||||
: BluetoothA2dp.OPTIONAL_CODECS_PREF_DISABLED;
|
||||
bluetoothA2dp.setOptionalCodecsEnabled(bluetoothA2dp.getActiveDevice(), prefValue);
|
||||
BluetoothDevice activeDevice = bluetoothA2dp.getActiveDevice();
|
||||
if (activeDevice == null) {
|
||||
mPreference.setEnabled(false);
|
||||
return true;
|
||||
}
|
||||
bluetoothA2dp.setOptionalCodecsEnabled(activeDevice, prefValue);
|
||||
if (enabled) {
|
||||
bluetoothA2dp.enableOptionalCodecs(null); // Use current active device
|
||||
bluetoothA2dp.enableOptionalCodecs(activeDevice);
|
||||
} else {
|
||||
bluetoothA2dp.disableOptionalCodecs(null); // Use current active device
|
||||
bluetoothA2dp.disableOptionalCodecs(activeDevice);
|
||||
}
|
||||
mCallback.onBluetoothHDAudioEnabled(enabled);
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user