Fix output switcher will show 2 media session in some use cases
Before this CL, we didn't check whether the remote session existed in the list before. If priority of remote session is higher than local session, it causes us to return the local session even if the list has a remote session. This CL uses a list to cache package names of remote sessions. If the local session has the same package name of the remote session then don't return the local session. Bug: 169052790 Test: make -j42 RunSettingsRoboTests Change-Id: I2726a3deb397f646e4c74a8c445dde6fafb694a8
This commit is contained in:
@@ -115,6 +115,33 @@ public class MediaOutputUtilsTest {
|
||||
|
||||
@Test
|
||||
public void getActiveLocalMediaController_bothHaveRemoteMediaAndLocalMedia_returnNull() {
|
||||
mMediaControllers.clear();
|
||||
final MediaController.PlaybackInfo playbackInfo = new MediaController.PlaybackInfo(
|
||||
MediaController.PlaybackInfo.PLAYBACK_TYPE_REMOTE,
|
||||
VolumeProvider.VOLUME_CONTROL_ABSOLUTE,
|
||||
100,
|
||||
10,
|
||||
new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_MEDIA).build(),
|
||||
null);
|
||||
final PlaybackState playbackState = new PlaybackState.Builder()
|
||||
.setState(PlaybackState.STATE_PLAYING, 0, 1)
|
||||
.build();
|
||||
final MediaController remoteMediaController = mock(MediaController.class);
|
||||
|
||||
mMediaControllers.add(remoteMediaController);
|
||||
mMediaControllers.add(mMediaController);
|
||||
initPlayback();
|
||||
|
||||
when(mMediaController.getPlaybackInfo()).thenReturn(mPlaybackInfo);
|
||||
when(mMediaController.getPlaybackState()).thenReturn(mPlaybackState);
|
||||
when(remoteMediaController.getPlaybackInfo()).thenReturn(playbackInfo);
|
||||
when(remoteMediaController.getPlaybackState()).thenReturn(playbackState);
|
||||
|
||||
assertThat(MediaOutputUtils.getActiveLocalMediaController(mMediaSessionManager)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getActiveLocalMediaController_bothHaveLocalMediaAndRemoteMedia_returnNull() {
|
||||
final MediaController.PlaybackInfo playbackInfo = new MediaController.PlaybackInfo(
|
||||
MediaController.PlaybackInfo.PLAYBACK_TYPE_REMOTE,
|
||||
VolumeProvider.VOLUME_CONTROL_ABSOLUTE,
|
||||
|
Reference in New Issue
Block a user