Loading src/com/android/settings/development/BluetoothA2dpConfigStore.java +1 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ public class BluetoothA2dpConfigStore { mChannelMode = channelMode; } public void setCodecSpecific1Value(int codecSpecific1Value) { public void setCodecSpecific1Value(long codecSpecific1Value) { mCodecSpecific1Value = codecSpecific1Value; } Loading src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java +23 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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}. * Loading Loading @@ -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) { Loading src/com/android/settings/development/bluetooth/AbstractBluetoothPreferenceController.java +0 −2 Original line number Diff line number Diff line Loading @@ -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); } Loading src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -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: Loading tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java +21 −4 Original line number Diff line number Diff line Loading @@ -102,6 +102,8 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void onIndexUpdated_checkFlow() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, null); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); when(mBluetoothA2dpConfigStore.createCodecConfig()).thenReturn(mCodecConfigAAC); mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onIndexUpdated(mCurrentConfig); Loading Loading @@ -138,27 +140,27 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void getCurrentCodecConfig_verifyConfig() { mController.onBluetoothServiceConnected(mBluetoothA2dp); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, null); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getCurrentCodecConfig()).isEqualTo(mCodecConfigAAC); } @Test public void getSelectableConfigs_verifyConfig() { mController.onBluetoothServiceConnected(mBluetoothA2dp); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getSelectableConfigs(null)).isEqualTo(mCodecConfigs); } @Test public void getSelectableByCodecType_verifyConfig() { mController.onBluetoothServiceConnected(mBluetoothA2dp); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getSelectableByCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)) .isEqualTo(mCodecConfigAAC); Loading @@ -166,14 +168,29 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void getSelectableByCodecType_unavailable() { mController.onBluetoothServiceConnected(mBluetoothA2dp); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getSelectableByCodecType( BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX)).isNull(); } @Test public void onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); verify(mBluetoothA2dpConfigStore).setCodecType(mCodecConfigAAC.getCodecType()); verify(mBluetoothA2dpConfigStore).setSampleRate(mCodecConfigAAC.getSampleRate()); verify(mBluetoothA2dpConfigStore).setBitsPerSample(mCodecConfigAAC.getBitsPerSample()); verify(mBluetoothA2dpConfigStore).setChannelMode(mCodecConfigAAC.getChannelMode()); verify(mBluetoothA2dpConfigStore).setCodecPriority(mCodecConfigAAC.getCodecPriority()); verify(mBluetoothA2dpConfigStore).setCodecSpecific1Value( mCodecConfigAAC.getCodecSpecific1()); } private static class AbstractBluetoothDialogPreferenceControllerImpl extends AbstractBluetoothDialogPreferenceController { Loading Loading
src/com/android/settings/development/BluetoothA2dpConfigStore.java +1 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ public class BluetoothA2dpConfigStore { mChannelMode = channelMode; } public void setCodecSpecific1Value(int codecSpecific1Value) { public void setCodecSpecific1Value(long codecSpecific1Value) { mCodecSpecific1Value = codecSpecific1Value; } Loading
src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java +23 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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}. * Loading Loading @@ -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) { Loading
src/com/android/settings/development/bluetooth/AbstractBluetoothPreferenceController.java +0 −2 Original line number Diff line number Diff line Loading @@ -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); } Loading
src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -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: Loading
tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java +21 −4 Original line number Diff line number Diff line Loading @@ -102,6 +102,8 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void onIndexUpdated_checkFlow() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, null); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); when(mBluetoothA2dpConfigStore.createCodecConfig()).thenReturn(mCodecConfigAAC); mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onIndexUpdated(mCurrentConfig); Loading Loading @@ -138,27 +140,27 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void getCurrentCodecConfig_verifyConfig() { mController.onBluetoothServiceConnected(mBluetoothA2dp); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, null); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getCurrentCodecConfig()).isEqualTo(mCodecConfigAAC); } @Test public void getSelectableConfigs_verifyConfig() { mController.onBluetoothServiceConnected(mBluetoothA2dp); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getSelectableConfigs(null)).isEqualTo(mCodecConfigs); } @Test public void getSelectableByCodecType_verifyConfig() { mController.onBluetoothServiceConnected(mBluetoothA2dp); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getSelectableByCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)) .isEqualTo(mCodecConfigAAC); Loading @@ -166,14 +168,29 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void getSelectableByCodecType_unavailable() { mController.onBluetoothServiceConnected(mBluetoothA2dp); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getSelectableByCodecType( BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX)).isNull(); } @Test public void onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); verify(mBluetoothA2dpConfigStore).setCodecType(mCodecConfigAAC.getCodecType()); verify(mBluetoothA2dpConfigStore).setSampleRate(mCodecConfigAAC.getSampleRate()); verify(mBluetoothA2dpConfigStore).setBitsPerSample(mCodecConfigAAC.getBitsPerSample()); verify(mBluetoothA2dpConfigStore).setChannelMode(mCodecConfigAAC.getChannelMode()); verify(mBluetoothA2dpConfigStore).setCodecPriority(mCodecConfigAAC.getCodecPriority()); verify(mBluetoothA2dpConfigStore).setCodecSpecific1Value( mCodecConfigAAC.getCodecSpecific1()); } private static class AbstractBluetoothDialogPreferenceControllerImpl extends AbstractBluetoothDialogPreferenceController { Loading