Disable media output switcher in Settings when audio sharing
Bug: 327080094 Test: atest MediaOutputPreferenceControllerTest Change-Id: I1e81d507c5c92c2b6f21494551931b359d5043cb
This commit is contained in:
@@ -22,6 +22,7 @@ import static android.media.AudioSystem.DEVICE_OUT_EARPIECE;
|
||||
import static android.media.AudioSystem.DEVICE_OUT_HEARING_AID;
|
||||
|
||||
import static com.android.settingslib.media.flags.Flags.FLAG_ENABLE_OUTPUT_SWITCHER_FOR_SYSTEM_ROUTING;
|
||||
import static com.android.settingslib.flags.Flags.FLAG_ENABLE_LE_AUDIO_SHARING;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -35,6 +36,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothLeBroadcast;
|
||||
import android.bluetooth.BluetoothManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -63,6 +65,7 @@ import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
||||
import com.android.settingslib.bluetooth.HearingAidProfile;
|
||||
import com.android.settingslib.bluetooth.LeAudioProfile;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||
import com.android.settingslib.media.MediaOutputConstants;
|
||||
@@ -123,6 +126,8 @@ public class MediaOutputPreferenceControllerTest {
|
||||
@Mock
|
||||
private LeAudioProfile mLeAudioProfile;
|
||||
@Mock
|
||||
private LocalBluetoothLeBroadcast mLocalBluetoothLeBroadcast;
|
||||
@Mock
|
||||
private AudioSwitchPreferenceController.AudioSwitchCallback mAudioSwitchPreferenceCallback;
|
||||
@Mock
|
||||
private MediaSessionManager mMediaSessionManager;
|
||||
@@ -194,6 +199,8 @@ public class MediaOutputPreferenceControllerTest {
|
||||
when(mLocalBluetoothProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile);
|
||||
when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
|
||||
when(mLocalBluetoothProfileManager.getLeAudioProfile()).thenReturn(mLeAudioProfile);
|
||||
when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile())
|
||||
.thenReturn(mLocalBluetoothLeBroadcast);
|
||||
|
||||
mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
|
||||
mBluetoothAdapter = mBluetoothManager.getAdapter();
|
||||
@@ -243,6 +250,25 @@ public class MediaOutputPreferenceControllerTest {
|
||||
ShadowBluetoothUtils.reset();
|
||||
}
|
||||
|
||||
/** Device start broadcasting so Preference summary should become "Audio Sharing" */
|
||||
@Test
|
||||
public void audioSharingStart_changeSummary() {
|
||||
mSetFlagsRule.enableFlags(FLAG_ENABLE_LE_AUDIO_SHARING);
|
||||
mController.onStart();
|
||||
ArgumentCaptor<BluetoothLeBroadcast.Callback> broadcastCallbackCaptor =
|
||||
ArgumentCaptor.forClass(BluetoothLeBroadcast.Callback.class);
|
||||
mShadowAudioManager.setOutputDevice(DEVICE_OUT_BLUETOOTH_A2DP);
|
||||
mAudioManager.setMode(AudioManager.MODE_NORMAL);
|
||||
when(mLocalBluetoothLeBroadcast.isEnabled(null)).thenReturn(true);
|
||||
verify(mLocalBluetoothLeBroadcast)
|
||||
.registerServiceCallBack(any(), broadcastCallbackCaptor.capture());
|
||||
BluetoothLeBroadcast.Callback callback = broadcastCallbackCaptor.getValue();
|
||||
|
||||
callback.onBroadcastStarted(0, 0);
|
||||
assertThat(mPreference.getSummary().toString())
|
||||
.isEqualTo(mContext.getText(R.string.media_output_audio_sharing).toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* A2DP Bluetooth device(s) are connected, but no device is set as activated
|
||||
* Preference summary should be "This device"
|
||||
|
Reference in New Issue
Block a user