Loading packages/SettingsLib/aconfig/settingslib_media_flag_declarations.aconfig +0 −11 Original line number Original line Diff line number Diff line Loading @@ -31,14 +31,3 @@ flag { purpose: PURPOSE_BUGFIX purpose: PURPOSE_BUGFIX } } } } flag { name: "use_playback_info_for_routing_controls" namespace: "media_solutions" description: "Use app-provided playback info when providing media routing information." bug: "333564788" metadata { purpose: PURPOSE_BUGFIX } } packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -250,7 +250,7 @@ public abstract class InfoMediaManager { @Nullable MediaSession.Token token) { @Nullable MediaSession.Token token) { MediaController mediaController = null; MediaController mediaController = null; if (Flags.usePlaybackInfoForRoutingControls() && token != null) { if (token != null) { mediaController = new MediaController(context, token); mediaController = new MediaController(context, token); } } Loading Loading @@ -490,7 +490,7 @@ public abstract class InfoMediaManager { RoutingSessionInfo activeSession = sessions.get(sessions.size() - 1); RoutingSessionInfo activeSession = sessions.get(sessions.size() - 1); // Logic from MediaRouter2Manager#getRoutingSessionForMediaController // Logic from MediaRouter2Manager#getRoutingSessionForMediaController if (!Flags.usePlaybackInfoForRoutingControls() || mMediaController == null) { if (mMediaController == null) { return activeSession; return activeSession; } } Loading packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManager.kt +1 −30 Original line number Original line Diff line number Diff line Loading @@ -395,7 +395,7 @@ constructor( private fun updateCurrent() { private fun updateCurrent() { if (isLeAudioBroadcastEnabled()) { if (isLeAudioBroadcastEnabled()) { current = getLeAudioBroadcastDeviceData() current = getLeAudioBroadcastDeviceData() } else if (Flags.usePlaybackInfoForRoutingControls()) { } else { val activeDevice: MediaDeviceData? val activeDevice: MediaDeviceData? // LocalMediaManager provides the connected device based on PlaybackInfo. // LocalMediaManager provides the connected device based on PlaybackInfo. Loading Loading @@ -442,35 +442,6 @@ constructor( current = activeDevice ?: EMPTY_AND_DISABLED_MEDIA_DEVICE_DATA current = activeDevice ?: EMPTY_AND_DISABLED_MEDIA_DEVICE_DATA logger.logNewDeviceName(current?.name?.toString()) logger.logNewDeviceName(current?.name?.toString()) } else { val aboutToConnect = aboutToConnectDeviceOverride if ( aboutToConnect != null && aboutToConnect.fullMediaDevice == null && aboutToConnect.backupMediaDeviceData != null ) { // Only use [backupMediaDeviceData] when we don't have [fullMediaDevice]. current = aboutToConnect.backupMediaDeviceData return } val device = aboutToConnect?.fullMediaDevice ?: localMediaManager.currentConnectedDevice val routingSession = controller?.let { mr2manager.get().getRoutingSessionForMediaController(it) } // If we have a controller but get a null route, then don't trust the device val enabled = device != null && (controller == null || routingSession != null) val name = getDeviceName(device, routingSession) logger.logNewDeviceName(name) current = MediaDeviceData( enabled, device?.iconWithoutBackground, name, id = device?.id, showBroadcastButton = false, ) } } } } Loading packages/SystemUI/src/com/android/systemui/media/dialog/MediaSwitchingController.java +1 −2 Original line number Original line Diff line number Diff line Loading @@ -310,8 +310,7 @@ public class MediaSwitchingController } } private MediaController getMediaController() { private MediaController getMediaController() { if (mToken != null if (mToken != null) { && com.android.settingslib.media.flags.Flags.usePlaybackInfoForRoutingControls()) { return new MediaController(mContext, mToken); return new MediaController(mContext, mToken); } else { } else { for (NotificationEntry entry : mNotifCollection.getAllNotifs()) { for (NotificationEntry entry : mNotifCollection.getAllNotifs()) { Loading packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManagerTest.kt +0 −95 Original line number Original line Diff line number Diff line Loading @@ -31,7 +31,6 @@ import android.media.session.MediaController.PlaybackInfo import android.media.session.MediaSession import android.media.session.MediaSession import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.annotations.RequiresFlagsDisabled import android.platform.test.annotations.RequiresFlagsEnabled import android.platform.test.annotations.RequiresFlagsEnabled import android.platform.test.flag.junit.DeviceFlagsValueProvider import android.platform.test.flag.junit.DeviceFlagsValueProvider import android.platform.test.flag.junit.FlagsParameterization import android.platform.test.flag.junit.FlagsParameterization Loading @@ -44,8 +43,6 @@ import com.android.settingslib.flags.Flags import com.android.settingslib.media.InfoMediaManager.SuggestedDeviceState import com.android.settingslib.media.InfoMediaManager.SuggestedDeviceState import com.android.settingslib.media.LocalMediaManager import com.android.settingslib.media.LocalMediaManager import com.android.settingslib.media.MediaDevice import com.android.settingslib.media.MediaDevice import com.android.settingslib.media.PhoneMediaDevice import com.android.settingslib.media.flags.Flags.FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS import com.android.systemui.Flags.FLAG_ENABLE_SUGGESTED_DEVICE_UI import com.android.systemui.Flags.FLAG_ENABLE_SUGGESTED_DEVICE_UI import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase import com.android.systemui.media.controls.MediaTestUtils import com.android.systemui.media.controls.MediaTestUtils Loading Loading @@ -487,20 +484,6 @@ public class MediaDeviceManagerTest(flags: FlagsParameterization) : SysuiTestCas assertThat(secondData.icon).isEqualTo(firstData.icon) assertThat(secondData.icon).isEqualTo(firstData.icon) } } @RequiresFlagsDisabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) @Test fun onMediaDataLoaded_withRemotePlaybackInfo_noMatchingRoutingSession_setsDisabledDevice() { // GIVEN that MR2Manager returns null for routing session whenever(playbackInfo.playbackType).thenReturn(PlaybackInfo.PLAYBACK_TYPE_REMOTE) whenever(mr2.getRoutingSessionForMediaController(any())).thenReturn(null) // WHEN a notification is added // THEN the device is disabled and name is set to null val data = loadMediaAndCaptureDeviceData() assertThat(data.enabled).isFalse() assertThat(data.name).isNull() } @RequiresFlagsEnabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) @Test @Test fun onMediaDataLoaded_withRemotePlaybackInfo_noMatchingRoutingSession_returnsOtherDevice() { fun onMediaDataLoaded_withRemotePlaybackInfo_noMatchingRoutingSession_returnsOtherDevice() { // GIVEN that MR2Manager returns null for routing session // GIVEN that MR2Manager returns null for routing session Loading @@ -515,7 +498,6 @@ public class MediaDeviceManagerTest(flags: FlagsParameterization) : SysuiTestCas } } @Test @Test @RequiresFlagsEnabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) fun onMediaDataLoaded_withRemotePlaybackInfo_noMatchingRoutingSession() { fun onMediaDataLoaded_withRemotePlaybackInfo_noMatchingRoutingSession() { whenever(playbackInfo.playbackType).thenReturn(PlaybackInfo.PLAYBACK_TYPE_REMOTE) whenever(playbackInfo.playbackType).thenReturn(PlaybackInfo.PLAYBACK_TYPE_REMOTE) whenever(mr2.getRoutingSessionForMediaController(any())).thenReturn(null) whenever(mr2.getRoutingSessionForMediaController(any())).thenReturn(null) Loading @@ -528,27 +510,6 @@ public class MediaDeviceManagerTest(flags: FlagsParameterization) : SysuiTestCas assertThat(secondData.icon).isEqualTo(firstData.icon) assertThat(secondData.icon).isEqualTo(firstData.icon) } } @RequiresFlagsDisabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) @Test fun onSelectedDeviceStateChanged_withRemotePlaybackInfo_noMatchingRoutingSession_setsDisabledDevice() { // GIVEN a notif is added loadMediaAndCaptureDeviceData() reset(listener) // AND MR2Manager returns null for routing session whenever(playbackInfo.playbackType).thenReturn(PlaybackInfo.PLAYBACK_TYPE_REMOTE) whenever(mr2.getRoutingSessionForMediaController(any())).thenReturn(null) // WHEN the selected device changes state val deviceCallback = captureCallback() deviceCallback.onSelectedDeviceStateChanged(device, 1) fakeBgExecutor.runAllReady() fakeFgExecutor.runAllReady() // THEN the device is disabled and name is set to null val data = captureDeviceData(KEY) assertThat(data.enabled).isFalse() assertThat(data.name).isNull() } @RequiresFlagsEnabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) @Test @Test fun onSelectedDeviceStateChanged_withRemotePlaybackInfo_noMatchingRoutingSession_returnOtherDevice() { fun onSelectedDeviceStateChanged_withRemotePlaybackInfo_noMatchingRoutingSession_returnOtherDevice() { // GIVEN a notif is added // GIVEN a notif is added Loading @@ -569,27 +530,6 @@ public class MediaDeviceManagerTest(flags: FlagsParameterization) : SysuiTestCas assertThat(data.icon).isEqualTo(OTHER_DEVICE_ICON_STUB) assertThat(data.icon).isEqualTo(OTHER_DEVICE_ICON_STUB) } } @RequiresFlagsDisabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) @Test fun onDeviceListUpdate_withRemotePlaybackInfo_noMatchingRoutingSession_setsDisabledDevice() { // GIVEN a notif is added loadMediaAndCaptureDeviceData() reset(listener) // GIVEN that MR2Manager returns null for routing session whenever(playbackInfo.playbackType).thenReturn(PlaybackInfo.PLAYBACK_TYPE_REMOTE) whenever(mr2.getRoutingSessionForMediaController(any())).thenReturn(null) // WHEN the selected device changes state val deviceCallback = captureCallback() deviceCallback.onDeviceListUpdate(mutableListOf(device)) fakeBgExecutor.runAllReady() fakeFgExecutor.runAllReady() // THEN the device is disabled and name is set to null val data = captureDeviceData(KEY) assertThat(data.enabled).isFalse() assertThat(data.name).isNull() } @RequiresFlagsEnabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) @Test @Test fun onDeviceListUpdate_withRemotePlaybackInfo_noMatchingRoutingSession_returnsOtherDevice() { fun onDeviceListUpdate_withRemotePlaybackInfo_noMatchingRoutingSession_returnsOtherDevice() { // GIVEN a notif is added // GIVEN a notif is added Loading @@ -610,41 +550,6 @@ public class MediaDeviceManagerTest(flags: FlagsParameterization) : SysuiTestCas assertThat(data.icon).isEqualTo(OTHER_DEVICE_ICON_STUB) assertThat(data.icon).isEqualTo(OTHER_DEVICE_ICON_STUB) } } // With the flag enabled, MediaDeviceManager no longer gathers device name information directly. @RequiresFlagsDisabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) @Test fun mr2ReturnsSystemRouteWithNullName_isPhone_usePhoneName() { // When the routing session name is null, and is a system session for a PhoneMediaDevice val phoneDevice = mock(PhoneMediaDevice::class.java) whenever(phoneDevice.iconWithoutBackground).thenReturn(icon) whenever(lmm.currentConnectedDevice).thenReturn(phoneDevice) whenever(routingSession.isSystemSession).thenReturn(true) whenever(routingSession.name).thenReturn(null) whenever(mr2.getSelectedRoutes(any())).thenReturn(listOf(selectedRoute)) whenever(selectedRoute.name).thenReturn(REMOTE_DEVICE_NAME) whenever(selectedRoute.type).thenReturn(MediaRoute2Info.TYPE_BUILTIN_SPEAKER) // Then the device name is the PhoneMediaDevice string val data = loadMediaAndCaptureDeviceData() assertThat(data.name).isEqualTo(PhoneMediaDevice.getMediaTransferThisDeviceName(context)) } // With the flag enabled, MediaDeviceManager no longer gathers device name information directly. @RequiresFlagsDisabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) @Test fun mr2ReturnsSystemRouteWithNullName_useSelectedRouteName() { // When the routing session does not have a name, and is a system session whenever(routingSession.name).thenReturn(null) whenever(mr2.getSelectedRoutes(any())).thenReturn(listOf(selectedRoute)) whenever(selectedRoute.name).thenReturn(REMOTE_DEVICE_NAME) whenever(routingSession.isSystemSession).thenReturn(true) // Then the device name is the selected route name val data = loadMediaAndCaptureDeviceData() assertThat(data.name).isEqualTo(REMOTE_DEVICE_NAME) } @Test @Test fun mr2ReturnsNonSystemRouteWithNullName_useLocalDeviceName() { fun mr2ReturnsNonSystemRouteWithNullName_useLocalDeviceName() { // GIVEN that MR2Manager returns a routing session that does not have a name // GIVEN that MR2Manager returns a routing session that does not have a name Loading Loading
packages/SettingsLib/aconfig/settingslib_media_flag_declarations.aconfig +0 −11 Original line number Original line Diff line number Diff line Loading @@ -31,14 +31,3 @@ flag { purpose: PURPOSE_BUGFIX purpose: PURPOSE_BUGFIX } } } } flag { name: "use_playback_info_for_routing_controls" namespace: "media_solutions" description: "Use app-provided playback info when providing media routing information." bug: "333564788" metadata { purpose: PURPOSE_BUGFIX } }
packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -250,7 +250,7 @@ public abstract class InfoMediaManager { @Nullable MediaSession.Token token) { @Nullable MediaSession.Token token) { MediaController mediaController = null; MediaController mediaController = null; if (Flags.usePlaybackInfoForRoutingControls() && token != null) { if (token != null) { mediaController = new MediaController(context, token); mediaController = new MediaController(context, token); } } Loading Loading @@ -490,7 +490,7 @@ public abstract class InfoMediaManager { RoutingSessionInfo activeSession = sessions.get(sessions.size() - 1); RoutingSessionInfo activeSession = sessions.get(sessions.size() - 1); // Logic from MediaRouter2Manager#getRoutingSessionForMediaController // Logic from MediaRouter2Manager#getRoutingSessionForMediaController if (!Flags.usePlaybackInfoForRoutingControls() || mMediaController == null) { if (mMediaController == null) { return activeSession; return activeSession; } } Loading
packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManager.kt +1 −30 Original line number Original line Diff line number Diff line Loading @@ -395,7 +395,7 @@ constructor( private fun updateCurrent() { private fun updateCurrent() { if (isLeAudioBroadcastEnabled()) { if (isLeAudioBroadcastEnabled()) { current = getLeAudioBroadcastDeviceData() current = getLeAudioBroadcastDeviceData() } else if (Flags.usePlaybackInfoForRoutingControls()) { } else { val activeDevice: MediaDeviceData? val activeDevice: MediaDeviceData? // LocalMediaManager provides the connected device based on PlaybackInfo. // LocalMediaManager provides the connected device based on PlaybackInfo. Loading Loading @@ -442,35 +442,6 @@ constructor( current = activeDevice ?: EMPTY_AND_DISABLED_MEDIA_DEVICE_DATA current = activeDevice ?: EMPTY_AND_DISABLED_MEDIA_DEVICE_DATA logger.logNewDeviceName(current?.name?.toString()) logger.logNewDeviceName(current?.name?.toString()) } else { val aboutToConnect = aboutToConnectDeviceOverride if ( aboutToConnect != null && aboutToConnect.fullMediaDevice == null && aboutToConnect.backupMediaDeviceData != null ) { // Only use [backupMediaDeviceData] when we don't have [fullMediaDevice]. current = aboutToConnect.backupMediaDeviceData return } val device = aboutToConnect?.fullMediaDevice ?: localMediaManager.currentConnectedDevice val routingSession = controller?.let { mr2manager.get().getRoutingSessionForMediaController(it) } // If we have a controller but get a null route, then don't trust the device val enabled = device != null && (controller == null || routingSession != null) val name = getDeviceName(device, routingSession) logger.logNewDeviceName(name) current = MediaDeviceData( enabled, device?.iconWithoutBackground, name, id = device?.id, showBroadcastButton = false, ) } } } } Loading
packages/SystemUI/src/com/android/systemui/media/dialog/MediaSwitchingController.java +1 −2 Original line number Original line Diff line number Diff line Loading @@ -310,8 +310,7 @@ public class MediaSwitchingController } } private MediaController getMediaController() { private MediaController getMediaController() { if (mToken != null if (mToken != null) { && com.android.settingslib.media.flags.Flags.usePlaybackInfoForRoutingControls()) { return new MediaController(mContext, mToken); return new MediaController(mContext, mToken); } else { } else { for (NotificationEntry entry : mNotifCollection.getAllNotifs()) { for (NotificationEntry entry : mNotifCollection.getAllNotifs()) { Loading
packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManagerTest.kt +0 −95 Original line number Original line Diff line number Diff line Loading @@ -31,7 +31,6 @@ import android.media.session.MediaController.PlaybackInfo import android.media.session.MediaSession import android.media.session.MediaSession import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.annotations.RequiresFlagsDisabled import android.platform.test.annotations.RequiresFlagsEnabled import android.platform.test.annotations.RequiresFlagsEnabled import android.platform.test.flag.junit.DeviceFlagsValueProvider import android.platform.test.flag.junit.DeviceFlagsValueProvider import android.platform.test.flag.junit.FlagsParameterization import android.platform.test.flag.junit.FlagsParameterization Loading @@ -44,8 +43,6 @@ import com.android.settingslib.flags.Flags import com.android.settingslib.media.InfoMediaManager.SuggestedDeviceState import com.android.settingslib.media.InfoMediaManager.SuggestedDeviceState import com.android.settingslib.media.LocalMediaManager import com.android.settingslib.media.LocalMediaManager import com.android.settingslib.media.MediaDevice import com.android.settingslib.media.MediaDevice import com.android.settingslib.media.PhoneMediaDevice import com.android.settingslib.media.flags.Flags.FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS import com.android.systemui.Flags.FLAG_ENABLE_SUGGESTED_DEVICE_UI import com.android.systemui.Flags.FLAG_ENABLE_SUGGESTED_DEVICE_UI import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase import com.android.systemui.media.controls.MediaTestUtils import com.android.systemui.media.controls.MediaTestUtils Loading Loading @@ -487,20 +484,6 @@ public class MediaDeviceManagerTest(flags: FlagsParameterization) : SysuiTestCas assertThat(secondData.icon).isEqualTo(firstData.icon) assertThat(secondData.icon).isEqualTo(firstData.icon) } } @RequiresFlagsDisabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) @Test fun onMediaDataLoaded_withRemotePlaybackInfo_noMatchingRoutingSession_setsDisabledDevice() { // GIVEN that MR2Manager returns null for routing session whenever(playbackInfo.playbackType).thenReturn(PlaybackInfo.PLAYBACK_TYPE_REMOTE) whenever(mr2.getRoutingSessionForMediaController(any())).thenReturn(null) // WHEN a notification is added // THEN the device is disabled and name is set to null val data = loadMediaAndCaptureDeviceData() assertThat(data.enabled).isFalse() assertThat(data.name).isNull() } @RequiresFlagsEnabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) @Test @Test fun onMediaDataLoaded_withRemotePlaybackInfo_noMatchingRoutingSession_returnsOtherDevice() { fun onMediaDataLoaded_withRemotePlaybackInfo_noMatchingRoutingSession_returnsOtherDevice() { // GIVEN that MR2Manager returns null for routing session // GIVEN that MR2Manager returns null for routing session Loading @@ -515,7 +498,6 @@ public class MediaDeviceManagerTest(flags: FlagsParameterization) : SysuiTestCas } } @Test @Test @RequiresFlagsEnabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) fun onMediaDataLoaded_withRemotePlaybackInfo_noMatchingRoutingSession() { fun onMediaDataLoaded_withRemotePlaybackInfo_noMatchingRoutingSession() { whenever(playbackInfo.playbackType).thenReturn(PlaybackInfo.PLAYBACK_TYPE_REMOTE) whenever(playbackInfo.playbackType).thenReturn(PlaybackInfo.PLAYBACK_TYPE_REMOTE) whenever(mr2.getRoutingSessionForMediaController(any())).thenReturn(null) whenever(mr2.getRoutingSessionForMediaController(any())).thenReturn(null) Loading @@ -528,27 +510,6 @@ public class MediaDeviceManagerTest(flags: FlagsParameterization) : SysuiTestCas assertThat(secondData.icon).isEqualTo(firstData.icon) assertThat(secondData.icon).isEqualTo(firstData.icon) } } @RequiresFlagsDisabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) @Test fun onSelectedDeviceStateChanged_withRemotePlaybackInfo_noMatchingRoutingSession_setsDisabledDevice() { // GIVEN a notif is added loadMediaAndCaptureDeviceData() reset(listener) // AND MR2Manager returns null for routing session whenever(playbackInfo.playbackType).thenReturn(PlaybackInfo.PLAYBACK_TYPE_REMOTE) whenever(mr2.getRoutingSessionForMediaController(any())).thenReturn(null) // WHEN the selected device changes state val deviceCallback = captureCallback() deviceCallback.onSelectedDeviceStateChanged(device, 1) fakeBgExecutor.runAllReady() fakeFgExecutor.runAllReady() // THEN the device is disabled and name is set to null val data = captureDeviceData(KEY) assertThat(data.enabled).isFalse() assertThat(data.name).isNull() } @RequiresFlagsEnabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) @Test @Test fun onSelectedDeviceStateChanged_withRemotePlaybackInfo_noMatchingRoutingSession_returnOtherDevice() { fun onSelectedDeviceStateChanged_withRemotePlaybackInfo_noMatchingRoutingSession_returnOtherDevice() { // GIVEN a notif is added // GIVEN a notif is added Loading @@ -569,27 +530,6 @@ public class MediaDeviceManagerTest(flags: FlagsParameterization) : SysuiTestCas assertThat(data.icon).isEqualTo(OTHER_DEVICE_ICON_STUB) assertThat(data.icon).isEqualTo(OTHER_DEVICE_ICON_STUB) } } @RequiresFlagsDisabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) @Test fun onDeviceListUpdate_withRemotePlaybackInfo_noMatchingRoutingSession_setsDisabledDevice() { // GIVEN a notif is added loadMediaAndCaptureDeviceData() reset(listener) // GIVEN that MR2Manager returns null for routing session whenever(playbackInfo.playbackType).thenReturn(PlaybackInfo.PLAYBACK_TYPE_REMOTE) whenever(mr2.getRoutingSessionForMediaController(any())).thenReturn(null) // WHEN the selected device changes state val deviceCallback = captureCallback() deviceCallback.onDeviceListUpdate(mutableListOf(device)) fakeBgExecutor.runAllReady() fakeFgExecutor.runAllReady() // THEN the device is disabled and name is set to null val data = captureDeviceData(KEY) assertThat(data.enabled).isFalse() assertThat(data.name).isNull() } @RequiresFlagsEnabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) @Test @Test fun onDeviceListUpdate_withRemotePlaybackInfo_noMatchingRoutingSession_returnsOtherDevice() { fun onDeviceListUpdate_withRemotePlaybackInfo_noMatchingRoutingSession_returnsOtherDevice() { // GIVEN a notif is added // GIVEN a notif is added Loading @@ -610,41 +550,6 @@ public class MediaDeviceManagerTest(flags: FlagsParameterization) : SysuiTestCas assertThat(data.icon).isEqualTo(OTHER_DEVICE_ICON_STUB) assertThat(data.icon).isEqualTo(OTHER_DEVICE_ICON_STUB) } } // With the flag enabled, MediaDeviceManager no longer gathers device name information directly. @RequiresFlagsDisabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) @Test fun mr2ReturnsSystemRouteWithNullName_isPhone_usePhoneName() { // When the routing session name is null, and is a system session for a PhoneMediaDevice val phoneDevice = mock(PhoneMediaDevice::class.java) whenever(phoneDevice.iconWithoutBackground).thenReturn(icon) whenever(lmm.currentConnectedDevice).thenReturn(phoneDevice) whenever(routingSession.isSystemSession).thenReturn(true) whenever(routingSession.name).thenReturn(null) whenever(mr2.getSelectedRoutes(any())).thenReturn(listOf(selectedRoute)) whenever(selectedRoute.name).thenReturn(REMOTE_DEVICE_NAME) whenever(selectedRoute.type).thenReturn(MediaRoute2Info.TYPE_BUILTIN_SPEAKER) // Then the device name is the PhoneMediaDevice string val data = loadMediaAndCaptureDeviceData() assertThat(data.name).isEqualTo(PhoneMediaDevice.getMediaTransferThisDeviceName(context)) } // With the flag enabled, MediaDeviceManager no longer gathers device name information directly. @RequiresFlagsDisabled(FLAG_USE_PLAYBACK_INFO_FOR_ROUTING_CONTROLS) @Test fun mr2ReturnsSystemRouteWithNullName_useSelectedRouteName() { // When the routing session does not have a name, and is a system session whenever(routingSession.name).thenReturn(null) whenever(mr2.getSelectedRoutes(any())).thenReturn(listOf(selectedRoute)) whenever(selectedRoute.name).thenReturn(REMOTE_DEVICE_NAME) whenever(routingSession.isSystemSession).thenReturn(true) // Then the device name is the selected route name val data = loadMediaAndCaptureDeviceData() assertThat(data.name).isEqualTo(REMOTE_DEVICE_NAME) } @Test @Test fun mr2ReturnsNonSystemRouteWithNullName_useLocalDeviceName() { fun mr2ReturnsNonSystemRouteWithNullName_useLocalDeviceName() { // GIVEN that MR2Manager returns a routing session that does not have a name // GIVEN that MR2Manager returns a routing session that does not have a name Loading