Loading src/com/android/settings/sound/AudioSwitchPreferenceController.java +5 −1 Original line number Diff line number Diff line Loading @@ -193,8 +193,12 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont public void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState) { } protected boolean isStreamFromOutputDevice(int streamType, int device) { return mAudioManager.getDevicesForStream(streamType) == device; } protected boolean isOngoingCallStatus() { int audioMode = mAudioManager.getMode(); final int audioMode = mAudioManager.getMode(); return audioMode == AudioManager.MODE_RINGTONE || audioMode == AudioManager.MODE_IN_CALL || audioMode == AudioManager.MODE_IN_COMMUNICATION; Loading src/com/android/settings/sound/HandsFreeProfileOutputPreferenceController.java +4 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.settings.sound; import static android.media.AudioManager.STREAM_VOICE_CALL; import static android.media.AudioSystem.DEVICE_OUT_USB_HEADSET; import android.bluetooth.BluetoothDevice; import android.content.Context; import android.support.v7.preference.Preference; Loading Loading @@ -76,7 +79,7 @@ public class HandsFreeProfileOutputPreferenceController extends // Setup devices entries, select active connected device setupPreferenceEntries(mediaOutputs, mediaValues, activeDevice); if (mAudioManager.isWiredHeadsetOn() && !mAudioManager.isBluetoothScoOn()) { if (isStreamFromOutputDevice(STREAM_VOICE_CALL, DEVICE_OUT_USB_HEADSET)) { // If wired headset is plugged in and active, select to default device. mSelectedIndex = getDefaultDeviceIndex(); } Loading src/com/android/settings/sound/MediaOutputPreferenceController.java +3 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.settings.sound; import static android.media.AudioManager.STREAM_VOICE_CALL; import static android.media.AudioSystem.DEVICE_OUT_USB_HEADSET; import static android.media.MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY; import android.bluetooth.BluetoothDevice; Loading Loading @@ -91,7 +93,7 @@ public class MediaOutputPreferenceController extends AudioSwitchPreferenceContro // Setup devices entries, select active connected device setupPreferenceEntries(mediaOutputs, mediaValues, activeDevice); if (mAudioManager.isWiredHeadsetOn() && !mAudioManager.isBluetoothA2dpOn()) { if (isStreamFromOutputDevice(STREAM_VOICE_CALL, DEVICE_OUT_USB_HEADSET)) { // If wired headset is plugged in and active, select to default device. mSelectedIndex = getDefaultDeviceIndex(); } Loading tests/robotests/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceControllerTest.java +5 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.settings.sound; import static android.media.AudioSystem.DEVICE_OUT_USB_HEADSET; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.mock; Loading Loading @@ -205,10 +207,9 @@ public class HandsFreeProfileOutputPreferenceControllerTest { * Preference summary should be "This device" */ @Test public void hapBtDevicesAreAvailableButWiredHeadsetIsActivated_shouldSetDefaultSummary() { public void updateState_withAvailableDevicesWiredHeadsetActivated_shouldSetDefaultSummary() { mShadowAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION); mShadowAudioManager.setWiredHeadsetOn(true); mShadowAudioManager.setBluetoothScoOn(false); mShadowAudioManager.setStream(DEVICE_OUT_USB_HEADSET); when(mHeadsetProfile.getConnectedDevices()).thenReturn(mConnectedDevices); when(mHeadsetProfile.getActiveDevice()).thenReturn( mBluetoothDevice); // BT device is still activated in this case Loading @@ -226,7 +227,7 @@ public class HandsFreeProfileOutputPreferenceControllerTest { * Preference summary should be "This device" */ @Test public void noAvailableHeadsetBtDevices_preferenceEnableIsFalse_shouldSetDefaultSummary() { public void updateState_noAvailableHeadsetBtDevices_shouldSetDefaultSummary() { mShadowAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION); List<BluetoothDevice> emptyDeviceList = new ArrayList<>(); when(mHeadsetProfile.getConnectedDevices()).thenReturn(emptyDeviceList); Loading tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java +3 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.settings.sound; import static android.media.AudioSystem.DEVICE_OUT_USB_HEADSET; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.mock; Loading Loading @@ -256,8 +258,7 @@ public class MediaOutputPreferenceControllerTest { @Test public void updateState_a2dpDevicesAvailableWiredHeadsetIsActivated_shouldSetDefaultSummary() { mShadowAudioManager.setMode(AudioManager.MODE_NORMAL); mShadowAudioManager.setWiredHeadsetOn(true); mShadowAudioManager.setBluetoothA2dpOn(false); mShadowAudioManager.setStream(DEVICE_OUT_USB_HEADSET); when(mA2dpProfile.getConnectedDevices()).thenReturn(mConnectedDevices); when(mA2dpProfile.getActiveDevice()).thenReturn( mBluetoothDevice); // BT device is still activated in this case Loading Loading
src/com/android/settings/sound/AudioSwitchPreferenceController.java +5 −1 Original line number Diff line number Diff line Loading @@ -193,8 +193,12 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont public void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState) { } protected boolean isStreamFromOutputDevice(int streamType, int device) { return mAudioManager.getDevicesForStream(streamType) == device; } protected boolean isOngoingCallStatus() { int audioMode = mAudioManager.getMode(); final int audioMode = mAudioManager.getMode(); return audioMode == AudioManager.MODE_RINGTONE || audioMode == AudioManager.MODE_IN_CALL || audioMode == AudioManager.MODE_IN_COMMUNICATION; Loading
src/com/android/settings/sound/HandsFreeProfileOutputPreferenceController.java +4 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.settings.sound; import static android.media.AudioManager.STREAM_VOICE_CALL; import static android.media.AudioSystem.DEVICE_OUT_USB_HEADSET; import android.bluetooth.BluetoothDevice; import android.content.Context; import android.support.v7.preference.Preference; Loading Loading @@ -76,7 +79,7 @@ public class HandsFreeProfileOutputPreferenceController extends // Setup devices entries, select active connected device setupPreferenceEntries(mediaOutputs, mediaValues, activeDevice); if (mAudioManager.isWiredHeadsetOn() && !mAudioManager.isBluetoothScoOn()) { if (isStreamFromOutputDevice(STREAM_VOICE_CALL, DEVICE_OUT_USB_HEADSET)) { // If wired headset is plugged in and active, select to default device. mSelectedIndex = getDefaultDeviceIndex(); } Loading
src/com/android/settings/sound/MediaOutputPreferenceController.java +3 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.settings.sound; import static android.media.AudioManager.STREAM_VOICE_CALL; import static android.media.AudioSystem.DEVICE_OUT_USB_HEADSET; import static android.media.MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY; import android.bluetooth.BluetoothDevice; Loading Loading @@ -91,7 +93,7 @@ public class MediaOutputPreferenceController extends AudioSwitchPreferenceContro // Setup devices entries, select active connected device setupPreferenceEntries(mediaOutputs, mediaValues, activeDevice); if (mAudioManager.isWiredHeadsetOn() && !mAudioManager.isBluetoothA2dpOn()) { if (isStreamFromOutputDevice(STREAM_VOICE_CALL, DEVICE_OUT_USB_HEADSET)) { // If wired headset is plugged in and active, select to default device. mSelectedIndex = getDefaultDeviceIndex(); } Loading
tests/robotests/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceControllerTest.java +5 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.settings.sound; import static android.media.AudioSystem.DEVICE_OUT_USB_HEADSET; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.mock; Loading Loading @@ -205,10 +207,9 @@ public class HandsFreeProfileOutputPreferenceControllerTest { * Preference summary should be "This device" */ @Test public void hapBtDevicesAreAvailableButWiredHeadsetIsActivated_shouldSetDefaultSummary() { public void updateState_withAvailableDevicesWiredHeadsetActivated_shouldSetDefaultSummary() { mShadowAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION); mShadowAudioManager.setWiredHeadsetOn(true); mShadowAudioManager.setBluetoothScoOn(false); mShadowAudioManager.setStream(DEVICE_OUT_USB_HEADSET); when(mHeadsetProfile.getConnectedDevices()).thenReturn(mConnectedDevices); when(mHeadsetProfile.getActiveDevice()).thenReturn( mBluetoothDevice); // BT device is still activated in this case Loading @@ -226,7 +227,7 @@ public class HandsFreeProfileOutputPreferenceControllerTest { * Preference summary should be "This device" */ @Test public void noAvailableHeadsetBtDevices_preferenceEnableIsFalse_shouldSetDefaultSummary() { public void updateState_noAvailableHeadsetBtDevices_shouldSetDefaultSummary() { mShadowAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION); List<BluetoothDevice> emptyDeviceList = new ArrayList<>(); when(mHeadsetProfile.getConnectedDevices()).thenReturn(emptyDeviceList); Loading
tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java +3 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.settings.sound; import static android.media.AudioSystem.DEVICE_OUT_USB_HEADSET; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.mock; Loading Loading @@ -256,8 +258,7 @@ public class MediaOutputPreferenceControllerTest { @Test public void updateState_a2dpDevicesAvailableWiredHeadsetIsActivated_shouldSetDefaultSummary() { mShadowAudioManager.setMode(AudioManager.MODE_NORMAL); mShadowAudioManager.setWiredHeadsetOn(true); mShadowAudioManager.setBluetoothA2dpOn(false); mShadowAudioManager.setStream(DEVICE_OUT_USB_HEADSET); when(mA2dpProfile.getConnectedDevices()).thenReturn(mConnectedDevices); when(mA2dpProfile.getActiveDevice()).thenReturn( mBluetoothDevice); // BT device is still activated in this case Loading