Merge "Unable to set Bluetooth configuration at the first time"

This commit is contained in:
tim peng
2020-01-17 02:48:54 +00:00
committed by Android (Google) Code Review
5 changed files with 46 additions and 9 deletions

View File

@@ -54,7 +54,7 @@ public class BluetoothA2dpConfigStore {
mChannelMode = channelMode;
}
public void setCodecSpecific1Value(int codecSpecific1Value) {
public void setCodecSpecific1Value(long codecSpecific1Value) {
mCodecSpecific1Value = codecSpecific1Value;
}

View File

@@ -53,9 +53,12 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
protected static final int[] CHANNEL_MODES = {BluetoothCodecConfig.CHANNEL_MODE_STEREO,
BluetoothCodecConfig.CHANNEL_MODE_MONO};
protected final BluetoothA2dpConfigStore mBluetoothA2dpConfigStore;
public AbstractBluetoothDialogPreferenceController(Context context, Lifecycle lifecycle,
BluetoothA2dpConfigStore store) {
super(context, lifecycle, store);
mBluetoothA2dpConfigStore = store;
}
@Override
@@ -92,6 +95,25 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
return getCurrentIndexByConfig(codecConfig);
}
@Override
public void onBluetoothServiceConnected(BluetoothA2dp bluetoothA2dp) {
super.onBluetoothServiceConnected(bluetoothA2dp);
initConfigStore();
}
private void initConfigStore() {
final BluetoothCodecConfig config = getCurrentCodecConfig();
if (config == null) {
return;
}
mBluetoothA2dpConfigStore.setCodecType(config.getCodecType());
mBluetoothA2dpConfigStore.setSampleRate(config.getSampleRate());
mBluetoothA2dpConfigStore.setBitsPerSample(config.getBitsPerSample());
mBluetoothA2dpConfigStore.setChannelMode(config.getChannelMode());
mBluetoothA2dpConfigStore.setCodecPriority(config.getCodecPriority());
mBluetoothA2dpConfigStore.setCodecSpecific1Value(config.getCodecSpecific1());
}
/**
* Updates the new value to the {@link BluetoothA2dpConfigStore}.
*
@@ -174,7 +196,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
*
* @param enabled Is {@code true} when the setting is enabled.
*/
public void onHDAudioEnabled(boolean enabled) {};
public void onHDAudioEnabled(boolean enabled) {}
static int getHighestCodec(BluetoothCodecConfig[] configs) {
if (configs == null) {

View File

@@ -33,13 +33,11 @@ public abstract class AbstractBluetoothPreferenceController extends
DeveloperOptionsPreferenceController implements BluetoothServiceConnectionListener,
LifecycleObserver, OnDestroy {
protected final BluetoothA2dpConfigStore mBluetoothA2dpConfigStore;
protected volatile BluetoothA2dp mBluetoothA2dp;
public AbstractBluetoothPreferenceController(Context context, Lifecycle lifecycle,
BluetoothA2dpConfigStore store) {
super(context);
mBluetoothA2dpConfigStore = store;
if (lifecycle != null) {
lifecycle.addObserver(this);
}

View File

@@ -57,7 +57,7 @@ public class BluetoothQualityDialogPreferenceController extends
@Override
protected void writeConfigurationValues(final int index) {
int codecSpecific1Value = 0; // default
long codecSpecific1Value = 0; // default
switch (index) {
case 0:
case 1: