Loading src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java +3 −4 Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig(); synchronized (mBluetoothA2dpConfigStore) { if (mBluetoothA2dp != null) { setCodecConfigPreference(mBluetoothA2dp.getActiveDevice(), codecConfig); setCodecConfigPreference(null, codecConfig); // Use current active device } } // Because the setting is not persisted into permanent storage, we cannot call update state Loading @@ -102,14 +102,13 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends @Override public void updateState(Preference preference) { BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice(); if (getCodecConfig(activeDevice) == null || mPreference == null) { if (getCodecConfig(null) == null || mPreference == null) { // Use current active device return; } BluetoothCodecConfig codecConfig; synchronized (mBluetoothA2dpConfigStore) { codecConfig = getCodecConfig(activeDevice); codecConfig = getCodecConfig(null); // Use current active device } final int index = getCurrentA2dpSettingIndex(codecConfig); Loading src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java +3 −5 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends } writeConfigurationValues(index); final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig(); bluetoothA2dp.setCodecConfigPreference(bluetoothA2dp.getActiveDevice(), codecConfig); bluetoothA2dp.setCodecConfigPreference(null, codecConfig); mPreference.setSummary(((BaseBluetoothDialogPreference) mPreference).generateSummary( index)); } Loading Loading @@ -146,8 +146,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends if (bluetoothA2dp == null) { return null; } final BluetoothCodecStatus codecStatus = bluetoothA2dp.getCodecStatus(bluetoothA2dp.getActiveDevice()); final BluetoothCodecStatus codecStatus = bluetoothA2dp.getCodecStatus(null); if (codecStatus == null) { Log.d(TAG, "Unable to get current codec config. Codec status is null"); return null; Loading Loading @@ -178,8 +177,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends * @return {@link BluetoothCodecConfig}. */ protected BluetoothCodecConfig getSelectableByCodecType(int codecTypeValue) { final BluetoothCodecConfig[] configs = getSelectableConfigs( mBluetoothA2dp.getActiveDevice()); final BluetoothCodecConfig[] configs = getSelectableConfigs(null); if (configs == null) { Log.d(TAG, "Unable to get selectable config. Selectable configs is empty."); return null; Loading src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java +3 −4 Original line number Diff line number Diff line Loading @@ -83,9 +83,9 @@ public class BluetoothCodecDialogPreferenceController extends return index; } // Check HD audio is enabled, display the available list. if (bluetoothA2dp.isOptionalCodecsEnabled(activeDevice) if (bluetoothA2dp.getOptionalCodecsEnabled(activeDevice) == BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED) { BluetoothCodecConfig[] configs = getSelectableConfigs(bluetoothA2dp.getActiveDevice()); BluetoothCodecConfig[] configs = getSelectableConfigs(null); if (configs != null) { return getIndexFromConfig(configs); } Loading @@ -101,8 +101,7 @@ public class BluetoothCodecDialogPreferenceController extends int codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT; switch (index) { case 0: codecTypeValue = getHighestCodec(getSelectableConfigs( mBluetoothA2dp.getActiveDevice())); codecTypeValue = getHighestCodec(getSelectableConfigs(null)); codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; break; case 1: Loading src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceController.java +2 −2 Original line number Diff line number Diff line Loading @@ -58,11 +58,11 @@ public class BluetoothHDAudioPreferenceController extends AbstractBluetoothPrefe mPreference.setEnabled(false); return; } final boolean supported = (bluetoothA2dp.isOptionalCodecsSupported(activeDevice) final boolean supported = (bluetoothA2dp.supportsOptionalCodecs(activeDevice) == BluetoothA2dp.OPTIONAL_CODECS_SUPPORTED); mPreference.setEnabled(supported); if (supported) { final boolean isEnabled = bluetoothA2dp.isOptionalCodecsEnabled(activeDevice) final boolean isEnabled = bluetoothA2dp.getOptionalCodecsEnabled(activeDevice) == BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED; ((SwitchPreference) mPreference).setChecked(isEnabled); } Loading tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java +8 −15 Original line number Diff line number Diff line Loading @@ -103,15 +103,13 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void onIndexUpdated_checkFlow() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, null); when(mBluetoothA2dp.getCodecStatus( mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); when(mBluetoothA2dpConfigStore.createCodecConfig()).thenReturn(mCodecConfigAAC); mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onIndexUpdated(mCurrentConfig); verify(mController).writeConfigurationValues(mCurrentConfig); verify(mBluetoothA2dp).setCodecConfigPreference( mBluetoothA2dp.getActiveDevice(), mCodecConfigAAC); verify(mBluetoothA2dp).setCodecConfigPreference(null, mCodecConfigAAC); assertThat(mPreference.getSummary()).isEqualTo(SUMMARY); } Loading @@ -136,15 +134,14 @@ public class AbstractBluetoothDialogPreferenceControllerTest { assertThat(mController.getCurrentCodecConfig()).isNull(); mController.onBluetoothServiceConnected(mBluetoothA2dp); when(mBluetoothA2dp.getCodecStatus(mBluetoothA2dp.getActiveDevice())).thenReturn(null); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(null); assertThat(mController.getCurrentCodecConfig()).isNull(); } @Test public void getCurrentCodecConfig_verifyConfig() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, null); when(mBluetoothA2dp.getCodecStatus( mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getCurrentCodecConfig()).isEqualTo(mCodecConfigAAC); Loading @@ -153,8 +150,7 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void getSelectableConfigs_verifyConfig() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); when(mBluetoothA2dp.getCodecStatus( mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getSelectableConfigs(null)).isEqualTo(mCodecConfigs); Loading @@ -163,8 +159,7 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void getSelectableByCodecType_verifyConfig() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); when(mBluetoothA2dp.getCodecStatus( mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getSelectableByCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)) Loading @@ -174,8 +169,7 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void getSelectableByCodecType_unavailable() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); when(mBluetoothA2dp.getCodecStatus( mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getSelectableByCodecType( Loading @@ -185,8 +179,7 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); when(mBluetoothA2dp.getCodecStatus( mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); verify(mBluetoothA2dpConfigStore).setCodecType(mCodecConfigAAC.getCodecType()); Loading Loading
src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java +3 −4 Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig(); synchronized (mBluetoothA2dpConfigStore) { if (mBluetoothA2dp != null) { setCodecConfigPreference(mBluetoothA2dp.getActiveDevice(), codecConfig); setCodecConfigPreference(null, codecConfig); // Use current active device } } // Because the setting is not persisted into permanent storage, we cannot call update state Loading @@ -102,14 +102,13 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends @Override public void updateState(Preference preference) { BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice(); if (getCodecConfig(activeDevice) == null || mPreference == null) { if (getCodecConfig(null) == null || mPreference == null) { // Use current active device return; } BluetoothCodecConfig codecConfig; synchronized (mBluetoothA2dpConfigStore) { codecConfig = getCodecConfig(activeDevice); codecConfig = getCodecConfig(null); // Use current active device } final int index = getCurrentA2dpSettingIndex(codecConfig); Loading
src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java +3 −5 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends } writeConfigurationValues(index); final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig(); bluetoothA2dp.setCodecConfigPreference(bluetoothA2dp.getActiveDevice(), codecConfig); bluetoothA2dp.setCodecConfigPreference(null, codecConfig); mPreference.setSummary(((BaseBluetoothDialogPreference) mPreference).generateSummary( index)); } Loading Loading @@ -146,8 +146,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends if (bluetoothA2dp == null) { return null; } final BluetoothCodecStatus codecStatus = bluetoothA2dp.getCodecStatus(bluetoothA2dp.getActiveDevice()); final BluetoothCodecStatus codecStatus = bluetoothA2dp.getCodecStatus(null); if (codecStatus == null) { Log.d(TAG, "Unable to get current codec config. Codec status is null"); return null; Loading Loading @@ -178,8 +177,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends * @return {@link BluetoothCodecConfig}. */ protected BluetoothCodecConfig getSelectableByCodecType(int codecTypeValue) { final BluetoothCodecConfig[] configs = getSelectableConfigs( mBluetoothA2dp.getActiveDevice()); final BluetoothCodecConfig[] configs = getSelectableConfigs(null); if (configs == null) { Log.d(TAG, "Unable to get selectable config. Selectable configs is empty."); return null; Loading
src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java +3 −4 Original line number Diff line number Diff line Loading @@ -83,9 +83,9 @@ public class BluetoothCodecDialogPreferenceController extends return index; } // Check HD audio is enabled, display the available list. if (bluetoothA2dp.isOptionalCodecsEnabled(activeDevice) if (bluetoothA2dp.getOptionalCodecsEnabled(activeDevice) == BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED) { BluetoothCodecConfig[] configs = getSelectableConfigs(bluetoothA2dp.getActiveDevice()); BluetoothCodecConfig[] configs = getSelectableConfigs(null); if (configs != null) { return getIndexFromConfig(configs); } Loading @@ -101,8 +101,7 @@ public class BluetoothCodecDialogPreferenceController extends int codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT; switch (index) { case 0: codecTypeValue = getHighestCodec(getSelectableConfigs( mBluetoothA2dp.getActiveDevice())); codecTypeValue = getHighestCodec(getSelectableConfigs(null)); codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; break; case 1: Loading
src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceController.java +2 −2 Original line number Diff line number Diff line Loading @@ -58,11 +58,11 @@ public class BluetoothHDAudioPreferenceController extends AbstractBluetoothPrefe mPreference.setEnabled(false); return; } final boolean supported = (bluetoothA2dp.isOptionalCodecsSupported(activeDevice) final boolean supported = (bluetoothA2dp.supportsOptionalCodecs(activeDevice) == BluetoothA2dp.OPTIONAL_CODECS_SUPPORTED); mPreference.setEnabled(supported); if (supported) { final boolean isEnabled = bluetoothA2dp.isOptionalCodecsEnabled(activeDevice) final boolean isEnabled = bluetoothA2dp.getOptionalCodecsEnabled(activeDevice) == BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED; ((SwitchPreference) mPreference).setChecked(isEnabled); } Loading
tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java +8 −15 Original line number Diff line number Diff line Loading @@ -103,15 +103,13 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void onIndexUpdated_checkFlow() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, null); when(mBluetoothA2dp.getCodecStatus( mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); when(mBluetoothA2dpConfigStore.createCodecConfig()).thenReturn(mCodecConfigAAC); mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onIndexUpdated(mCurrentConfig); verify(mController).writeConfigurationValues(mCurrentConfig); verify(mBluetoothA2dp).setCodecConfigPreference( mBluetoothA2dp.getActiveDevice(), mCodecConfigAAC); verify(mBluetoothA2dp).setCodecConfigPreference(null, mCodecConfigAAC); assertThat(mPreference.getSummary()).isEqualTo(SUMMARY); } Loading @@ -136,15 +134,14 @@ public class AbstractBluetoothDialogPreferenceControllerTest { assertThat(mController.getCurrentCodecConfig()).isNull(); mController.onBluetoothServiceConnected(mBluetoothA2dp); when(mBluetoothA2dp.getCodecStatus(mBluetoothA2dp.getActiveDevice())).thenReturn(null); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(null); assertThat(mController.getCurrentCodecConfig()).isNull(); } @Test public void getCurrentCodecConfig_verifyConfig() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, null); when(mBluetoothA2dp.getCodecStatus( mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getCurrentCodecConfig()).isEqualTo(mCodecConfigAAC); Loading @@ -153,8 +150,7 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void getSelectableConfigs_verifyConfig() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); when(mBluetoothA2dp.getCodecStatus( mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getSelectableConfigs(null)).isEqualTo(mCodecConfigs); Loading @@ -163,8 +159,7 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void getSelectableByCodecType_verifyConfig() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); when(mBluetoothA2dp.getCodecStatus( mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getSelectableByCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)) Loading @@ -174,8 +169,7 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void getSelectableByCodecType_unavailable() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); when(mBluetoothA2dp.getCodecStatus( mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getSelectableByCodecType( Loading @@ -185,8 +179,7 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); when(mBluetoothA2dp.getCodecStatus( mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); verify(mBluetoothA2dpConfigStore).setCodecType(mCodecConfigAAC.getCodecType()); Loading