Loading packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManager.kt +12 −3 Original line number Diff line number Diff line Loading @@ -136,7 +136,15 @@ constructor( localMediaManagerFactory.create(data.packageName, controller?.sessionToken) val muteAwaitConnectionManager = muteAwaitConnectionManagerFactory.create(localMediaManager) entry = Entry(key, oldKey, controller, localMediaManager, muteAwaitConnectionManager) entry = Entry( key, oldKey, controller, localMediaManager, muteAwaitConnectionManager, data.resumption, ) entries[key] = entry entry.start() } Loading Loading @@ -195,6 +203,7 @@ constructor( val controller: MediaController?, val localMediaManager: LocalMediaManager, val muteAwaitConnectionManager: MediaMuteAwaitConnectionManager, val isResumption: Boolean, ) : LocalMediaManager.DeviceCallback, MediaController.Callback() { val token Loading Loading @@ -233,7 +242,7 @@ constructor( playbackType = controller?.playbackInfo?.playbackType ?: PLAYBACK_TYPE_UNKNOWN playbackVolumeControlId = controller?.playbackInfo?.volumeControlId controller?.registerCallback(this) if (enableSuggestedDeviceUi()) { if (enableSuggestedDeviceUi() && !isResumption) { updateCurrent(notifyListeners = false) updateSuggestion( localMediaManager.getSuggestedDevice(), Loading Loading @@ -309,7 +318,7 @@ constructor( } override fun onSuggestedDeviceUpdated(state: SuggestedDeviceState?) { if (!enableSuggestedDeviceUi()) { if (!enableSuggestedDeviceUi() || isResumption) { return } bgExecutor.execute { updateSuggestion(state) } Loading packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt +5 −1 Original line number Diff line number Diff line Loading @@ -1241,7 +1241,11 @@ constructor( } fun onCarouselVisibleToUser() { if (!enableSuggestedDeviceUi() || !mediaCarouselScrollHandler.visibleToUser) { if ( !enableSuggestedDeviceUi() || !mediaCarouselScrollHandler.visibleToUser || MediaPlayerData.mediaData().all { it.second.resumption } ) { return } val visibleMediaIndex = mediaCarouselScrollHandler.visibleMediaIndex Loading packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaControlPanel.java +3 −1 Original line number Diff line number Diff line Loading @@ -629,7 +629,9 @@ public class MediaControlPanel { @Nullable SuggestedMediaDeviceData suggestionDeviceData = suggestionData.getSuggestedMediaDeviceData(); if (suggestionDeviceData != null && isValidSuggestion(suggestionDeviceData)) { if (suggestionDeviceData != null && isValidSuggestion(suggestionDeviceData) && !data.getResumption()) { // Don't show the OSw device text if we have a suggestion: just show the icon deviceText.setVisibility(View.GONE); setSuggestionClickListener(suggestionDeviceData); Loading packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManagerTest.kt +33 −0 Original line number Diff line number Diff line Loading @@ -363,6 +363,22 @@ public class MediaDeviceManagerTest(flags: FlagsParameterization) : SysuiTestCas assertThat(suggestionData.icon).isEqualTo(icon) } @Test @EnableFlags(FLAG_ENABLE_SUGGESTED_DEVICE_UI) fun onMediaDataLoaded_resumption_doesNotLoadSuggestionData() { val resumptionMediaData = mediaData.copy(resumption = true) manager.onMediaDataLoaded(KEY, null, resumptionMediaData) fakeBgExecutor.runAllReady() fakeFgExecutor.runAllReady() verify(listener, never()) .onMediaDeviceAndSuggestionDataChanged(eq(KEY), any(), any(), any()) val data = captureDeviceData(KEY) assertThat(data.enabled).isTrue() assertThat(data.name).isEqualTo(DEVICE_NAME) } @Test @EnableFlags(FLAG_ENABLE_SUGGESTED_DEVICE_UI) fun suggestedDeviceUpdate() { Loading Loading @@ -403,6 +419,23 @@ public class MediaDeviceManagerTest(flags: FlagsParameterization) : SysuiTestCas assertThat(fakeFgExecutor.runAllReady()).isEqualTo(0) } @Test @EnableFlags(FLAG_ENABLE_SUGGESTED_DEVICE_UI) fun suggestedDeviceUpdate_resumption_doesNotNotifyListener() { val resumptionMediaData = mediaData.copy(resumption = true) manager.onMediaDataLoaded(KEY, null, resumptionMediaData) fakeBgExecutor.runAllReady() fakeFgExecutor.runAllReady() clearInvocations(listener) val deviceCallback = captureCallback() deviceCallback.onSuggestedDeviceUpdated(suggestedDeviceState2) fakeBgExecutor.runAllReady() fakeFgExecutor.runAllReady() verifyNoMoreInteractions(listener) } @Test fun selectedDeviceStateChanged() { whenever(lmm.getCurrentConnectedDevice()).thenReturn(null) Loading packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaControlPanelTest.kt +18 −0 Original line number Diff line number Diff line Loading @@ -1284,6 +1284,24 @@ public class MediaControlPanelTest : SysuiTestCase() { assertThat(deviceSuggestionButton.visibility).isEqualTo(View.GONE) } @Test @RequiresFlagsEnabled(Flags.FLAG_ENABLE_SUGGESTED_DEVICE_UI) fun bindDeviceResumptionPlayerWithSuggestedDeviceData() { player.attachPlayer(viewHolder) player.bindPlayer( mediaData.copy( suggestionData = createSuggestionData(DEVICE_NAME, MediaDeviceState.STATE_DISCONNECTED), resumption = true, ), PACKAGE, ) assertThat(seamlessText.visibility).isEqualTo(View.VISIBLE) assertThat(deviceSuggestionButton.visibility).isEqualTo(View.GONE) } /* ***** Guts tests for the player ***** */ @Test Loading Loading
packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManager.kt +12 −3 Original line number Diff line number Diff line Loading @@ -136,7 +136,15 @@ constructor( localMediaManagerFactory.create(data.packageName, controller?.sessionToken) val muteAwaitConnectionManager = muteAwaitConnectionManagerFactory.create(localMediaManager) entry = Entry(key, oldKey, controller, localMediaManager, muteAwaitConnectionManager) entry = Entry( key, oldKey, controller, localMediaManager, muteAwaitConnectionManager, data.resumption, ) entries[key] = entry entry.start() } Loading Loading @@ -195,6 +203,7 @@ constructor( val controller: MediaController?, val localMediaManager: LocalMediaManager, val muteAwaitConnectionManager: MediaMuteAwaitConnectionManager, val isResumption: Boolean, ) : LocalMediaManager.DeviceCallback, MediaController.Callback() { val token Loading Loading @@ -233,7 +242,7 @@ constructor( playbackType = controller?.playbackInfo?.playbackType ?: PLAYBACK_TYPE_UNKNOWN playbackVolumeControlId = controller?.playbackInfo?.volumeControlId controller?.registerCallback(this) if (enableSuggestedDeviceUi()) { if (enableSuggestedDeviceUi() && !isResumption) { updateCurrent(notifyListeners = false) updateSuggestion( localMediaManager.getSuggestedDevice(), Loading Loading @@ -309,7 +318,7 @@ constructor( } override fun onSuggestedDeviceUpdated(state: SuggestedDeviceState?) { if (!enableSuggestedDeviceUi()) { if (!enableSuggestedDeviceUi() || isResumption) { return } bgExecutor.execute { updateSuggestion(state) } Loading
packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt +5 −1 Original line number Diff line number Diff line Loading @@ -1241,7 +1241,11 @@ constructor( } fun onCarouselVisibleToUser() { if (!enableSuggestedDeviceUi() || !mediaCarouselScrollHandler.visibleToUser) { if ( !enableSuggestedDeviceUi() || !mediaCarouselScrollHandler.visibleToUser || MediaPlayerData.mediaData().all { it.second.resumption } ) { return } val visibleMediaIndex = mediaCarouselScrollHandler.visibleMediaIndex Loading
packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaControlPanel.java +3 −1 Original line number Diff line number Diff line Loading @@ -629,7 +629,9 @@ public class MediaControlPanel { @Nullable SuggestedMediaDeviceData suggestionDeviceData = suggestionData.getSuggestedMediaDeviceData(); if (suggestionDeviceData != null && isValidSuggestion(suggestionDeviceData)) { if (suggestionDeviceData != null && isValidSuggestion(suggestionDeviceData) && !data.getResumption()) { // Don't show the OSw device text if we have a suggestion: just show the icon deviceText.setVisibility(View.GONE); setSuggestionClickListener(suggestionDeviceData); Loading
packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManagerTest.kt +33 −0 Original line number Diff line number Diff line Loading @@ -363,6 +363,22 @@ public class MediaDeviceManagerTest(flags: FlagsParameterization) : SysuiTestCas assertThat(suggestionData.icon).isEqualTo(icon) } @Test @EnableFlags(FLAG_ENABLE_SUGGESTED_DEVICE_UI) fun onMediaDataLoaded_resumption_doesNotLoadSuggestionData() { val resumptionMediaData = mediaData.copy(resumption = true) manager.onMediaDataLoaded(KEY, null, resumptionMediaData) fakeBgExecutor.runAllReady() fakeFgExecutor.runAllReady() verify(listener, never()) .onMediaDeviceAndSuggestionDataChanged(eq(KEY), any(), any(), any()) val data = captureDeviceData(KEY) assertThat(data.enabled).isTrue() assertThat(data.name).isEqualTo(DEVICE_NAME) } @Test @EnableFlags(FLAG_ENABLE_SUGGESTED_DEVICE_UI) fun suggestedDeviceUpdate() { Loading Loading @@ -403,6 +419,23 @@ public class MediaDeviceManagerTest(flags: FlagsParameterization) : SysuiTestCas assertThat(fakeFgExecutor.runAllReady()).isEqualTo(0) } @Test @EnableFlags(FLAG_ENABLE_SUGGESTED_DEVICE_UI) fun suggestedDeviceUpdate_resumption_doesNotNotifyListener() { val resumptionMediaData = mediaData.copy(resumption = true) manager.onMediaDataLoaded(KEY, null, resumptionMediaData) fakeBgExecutor.runAllReady() fakeFgExecutor.runAllReady() clearInvocations(listener) val deviceCallback = captureCallback() deviceCallback.onSuggestedDeviceUpdated(suggestedDeviceState2) fakeBgExecutor.runAllReady() fakeFgExecutor.runAllReady() verifyNoMoreInteractions(listener) } @Test fun selectedDeviceStateChanged() { whenever(lmm.getCurrentConnectedDevice()).thenReturn(null) Loading
packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaControlPanelTest.kt +18 −0 Original line number Diff line number Diff line Loading @@ -1284,6 +1284,24 @@ public class MediaControlPanelTest : SysuiTestCase() { assertThat(deviceSuggestionButton.visibility).isEqualTo(View.GONE) } @Test @RequiresFlagsEnabled(Flags.FLAG_ENABLE_SUGGESTED_DEVICE_UI) fun bindDeviceResumptionPlayerWithSuggestedDeviceData() { player.attachPlayer(viewHolder) player.bindPlayer( mediaData.copy( suggestionData = createSuggestionData(DEVICE_NAME, MediaDeviceState.STATE_DISCONNECTED), resumption = true, ), PACKAGE, ) assertThat(seamlessText.visibility).isEqualTo(View.VISIBLE) assertThat(deviceSuggestionButton.visibility).isEqualTo(View.GONE) } /* ***** Guts tests for the player ***** */ @Test Loading