Replace deprecated APIs in audio switcher.

- Remove isWiredHeadsetOn() and isBluetoothA2dpOn()
in MediaOutputPreferenceController.

- Remove isWiredHeadsetOn() and isBluetoothScoOn()
in HandsFreeProfileOutputPreferenceController.

- Replace with AudioManager.getDevicesForStream().

- Update test cases.

Bug: 78141441
Test: make RunSettingsRoboTests ROBOTEST_FILTER="MediaOutputPreferenceControllerTest" -j40
Test: make RunSettingsRoboTests ROBOTEST_FILTER="HandsFreeProfileOutputPreferenceControllerTest" -j40
Test: make RunSettingsRoboTests ROBOTEST_FILTER="AudioOutputSwitchPreferenceControllerTest" -j40
Change-Id: Ic57c40badf0fd5633f1b7412d63a0b5417d0f47a
This commit is contained in:
ryanywlin
2018-04-17 16:48:30 +08:00
committed by caxtonchan
parent f99a4a3e06
commit dca308e56d
6 changed files with 54 additions and 9 deletions

View File

@@ -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;
@@ -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