diff options
author | 2025-03-18 17:06:26 -0500 | |
---|---|---|
committer | 2025-03-24 09:40:15 -0500 | |
commit | fc57496f392cd038cf29ded6bbee82882e8d9d66 (patch) | |
tree | 92ebf50564e221ad28073d2ddb83d0d45a5d78a9 | |
parent | acd55a7ade685c31e9c947337895b2dda5a65240 (diff) |
Clean up MEDIA_REMOTE_RESUME flag
Flag: EXEMPT unreleased legacy flag
Fixes: 270437894
Test: atest LegacyMediaDataManagerImplTest
Test: atest MediaDataProcessorTest
Test: atest MediaResumeListenerTest
Change-Id: I8203850ca3f330a238681ac38711d4a59a28b6ca
9 files changed, 11 insertions, 168 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt index 9a37439e7486..6aacdde57c53 100644 --- a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt +++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt @@ -200,9 +200,6 @@ object Flags { // TODO(b/266157412): Tracking Bug val MEDIA_RETAIN_SESSIONS = unreleasedFlag("media_retain_sessions") - // TODO(b/270437894): Tracking Bug - val MEDIA_REMOTE_RESUME = unreleasedFlag("media_remote_resume") - // 1000 - dock val SIMULATE_DOCK_THROUGH_CHARGING = releasedFlag("simulate_dock_through_charging") diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImpl.kt b/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImpl.kt index ab4467e87a3e..4c83c588d8a2 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImpl.kt @@ -1296,10 +1296,7 @@ class LegacyMediaDataManagerImpl( } private fun isAbleToResume(data: MediaData): Boolean { - val isEligibleForResume = - data.isLocalSession() || - (mediaFlags.isRemoteResumeAllowed() && - data.playbackLocation != MediaData.PLAYBACK_CAST_REMOTE) + val isEligibleForResume = data.isLocalSession() return useMediaResumption && data.resumeAction != null && isEligibleForResume } diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaDataProcessor.kt b/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaDataProcessor.kt index 7dfa69efc155..4bfb7a18a346 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaDataProcessor.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaDataProcessor.kt @@ -1233,10 +1233,7 @@ class MediaDataProcessor( } private fun isAbleToResume(data: MediaData): Boolean { - val isEligibleForResume = - data.isLocalSession() || - (mediaFlags.isRemoteResumeAllowed() && - data.playbackLocation != MediaData.PLAYBACK_CAST_REMOTE) + val isEligibleForResume = data.isLocalSession() return useMediaResumption && data.resumeAction != null && isEligibleForResume } diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/domain/resume/MediaResumeListener.kt b/packages/SystemUI/src/com/android/systemui/media/controls/domain/resume/MediaResumeListener.kt index 0a70e78bf039..89d66e82bcab 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/domain/resume/MediaResumeListener.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/domain/resume/MediaResumeListener.kt @@ -38,7 +38,6 @@ import com.android.systemui.dump.DumpManager import com.android.systemui.media.controls.domain.pipeline.MediaDataManager import com.android.systemui.media.controls.domain.pipeline.RESUME_MEDIA_TIMEOUT import com.android.systemui.media.controls.shared.model.MediaData -import com.android.systemui.media.controls.util.MediaFlags import com.android.systemui.settings.UserTracker import com.android.systemui.tuner.TunerService import com.android.systemui.util.Utils @@ -67,7 +66,6 @@ constructor( private val mediaBrowserFactory: ResumeMediaBrowserFactory, dumpManager: DumpManager, private val systemClock: SystemClock, - private val mediaFlags: MediaFlags, ) : MediaDataManager.Listener, Dumpable { private var useMediaResumption: Boolean = Utils.useMediaResumption(context) @@ -251,10 +249,7 @@ constructor( mediaBrowser = null } // If we don't have a resume action, check if we haven't already - val isEligibleForResume = - data.isLocalSession() || - (mediaFlags.isRemoteResumeAllowed() && - data.playbackLocation != MediaData.PLAYBACK_CAST_REMOTE) + val isEligibleForResume = data.isLocalSession() if (data.resumeAction == null && !data.hasCheckedForResume && isEligibleForResume) { // TODO also check for a media button receiver intended for restarting (b/154127084) // Set null action to prevent additional attempts to connect diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/util/MediaFlags.kt b/packages/SystemUI/src/com/android/systemui/media/controls/util/MediaFlags.kt index 8ad10ba2a240..1db821c89324 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/util/MediaFlags.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/util/MediaFlags.kt @@ -45,7 +45,4 @@ class MediaFlags @Inject constructor(private val featureFlags: FeatureFlagsClass * whether the underlying notification was dismissed */ fun isRetainingPlayersEnabled() = featureFlags.isEnabled(FlagsClassic.MEDIA_RETAIN_SESSIONS) - - /** Check whether we allow remote media to generate resume controls */ - fun isRemoteResumeAllowed() = featureFlags.isEnabled(FlagsClassic.MEDIA_REMOTE_RESUME) } diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImplTest.kt index 5084f318b05d..dfd72bdd2516 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImplTest.kt @@ -51,7 +51,6 @@ import com.android.systemui.InstanceIdSequenceFake import com.android.systemui.SysuiTestCase import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.dump.DumpManager -import com.android.systemui.flags.Flags.MEDIA_REMOTE_RESUME import com.android.systemui.flags.Flags.MEDIA_RETAIN_SESSIONS import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.kosmos.testDispatcher @@ -287,7 +286,6 @@ class LegacyMediaDataManagerImplTest(flags: FlagsParameterization) : SysuiTestCa whenever(mediaSmartspaceTarget.creationTimeMillis).thenReturn(SMARTSPACE_CREATION_TIME) whenever(mediaSmartspaceTarget.expiryTimeMillis).thenReturn(SMARTSPACE_EXPIRY_TIME) fakeFeatureFlags.set(MEDIA_RETAIN_SESSIONS, false) - fakeFeatureFlags.set(MEDIA_REMOTE_RESUME, false) whenever(logger.getNewInstanceId()).thenReturn(instanceIdSequence.newInstanceId()) whenever(keyguardUpdateMonitor.isUserInLockdown(any())).thenReturn(false) } @@ -814,56 +812,6 @@ class LegacyMediaDataManagerImplTest(flags: FlagsParameterization) : SysuiTestCa } @Test - fun testOnNotificationRemoved_withResumption_isRemoteAndRemoteAllowed() { - // With the flag enabled to allow remote media to resume - fakeFeatureFlags.set(MEDIA_REMOTE_RESUME, true) - - // GIVEN that the manager has a notification with a resume action, but is not local - whenever(controller.metadata).thenReturn(metadataBuilder.build()) - whenever(playbackInfo.playbackType) - .thenReturn(MediaController.PlaybackInfo.PLAYBACK_TYPE_REMOTE) - addNotificationAndLoad() - val data = mediaDataCaptor.value - val dataRemoteWithResume = - data.copy(resumeAction = Runnable {}, playbackLocation = MediaData.PLAYBACK_CAST_LOCAL) - mediaDataManager.onMediaDataLoaded(KEY, null, dataRemoteWithResume) - - // WHEN the notification is removed - mediaDataManager.onNotificationRemoved(KEY) - - // THEN the media data is converted to a resume state - verify(listener) - .onMediaDataLoaded( - eq(PACKAGE_NAME), - eq(KEY), - capture(mediaDataCaptor), - eq(true), - eq(0), - eq(false), - ) - assertThat(mediaDataCaptor.value.resumption).isTrue() - } - - @Test - fun testOnNotificationRemoved_withResumption_isRcnAndRemoteAllowed() { - // With the flag enabled to allow remote media to resume - fakeFeatureFlags.set(MEDIA_REMOTE_RESUME, true) - - // GIVEN that the manager has a remote cast notification - addNotificationAndLoad(remoteCastNotification) - val data = mediaDataCaptor.value - assertThat(data.playbackLocation).isEqualTo(MediaData.PLAYBACK_CAST_REMOTE) - val dataRemoteWithResume = data.copy(resumeAction = Runnable {}) - mediaDataManager.onMediaDataLoaded(KEY, null, dataRemoteWithResume) - - // WHEN the RCN is removed - mediaDataManager.onNotificationRemoved(KEY) - - // THEN the media data is removed - verify(listener).onMediaDataRemoved(eq(KEY), eq(false)) - } - - @Test fun testOnNotificationRemoved_withResumption_tooManyPlayers() { // Given the maximum number of resume controls already val desc = diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDataProcessorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDataProcessorTest.kt index 5ea669d74cc1..8064317891d4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDataProcessorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDataProcessorTest.kt @@ -55,7 +55,6 @@ import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.coroutines.collectLastValue import com.android.systemui.dump.DumpManager import com.android.systemui.flags.EnableSceneContainer -import com.android.systemui.flags.Flags.MEDIA_REMOTE_RESUME import com.android.systemui.flags.Flags.MEDIA_RETAIN_SESSIONS import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.kosmos.testDispatcher @@ -311,7 +310,6 @@ class MediaDataProcessorTest(flags: FlagsParameterization) : SysuiTestCase() { whenever(mediaSmartspaceTarget.creationTimeMillis).thenReturn(SMARTSPACE_CREATION_TIME) whenever(mediaSmartspaceTarget.expiryTimeMillis).thenReturn(SMARTSPACE_EXPIRY_TIME) fakeFeatureFlags.set(MEDIA_RETAIN_SESSIONS, false) - fakeFeatureFlags.set(MEDIA_REMOTE_RESUME, false) whenever(logger.getNewInstanceId()).thenReturn(instanceIdSequence.newInstanceId()) whenever(keyguardUpdateMonitor.isUserInLockdown(any())).thenReturn(false) } @@ -834,56 +832,6 @@ class MediaDataProcessorTest(flags: FlagsParameterization) : SysuiTestCase() { } @Test - fun testOnNotificationRemoved_withResumption_isRemoteAndRemoteAllowed() { - // With the flag enabled to allow remote media to resume - fakeFeatureFlags.set(MEDIA_REMOTE_RESUME, true) - - // GIVEN that the manager has a notification with a resume action, but is not local - whenever(controller.metadata).thenReturn(metadataBuilder.build()) - whenever(playbackInfo.playbackType) - .thenReturn(MediaController.PlaybackInfo.PLAYBACK_TYPE_REMOTE) - addNotificationAndLoad() - val data = mediaDataCaptor.value - val dataRemoteWithResume = - data.copy(resumeAction = Runnable {}, playbackLocation = MediaData.PLAYBACK_CAST_LOCAL) - mediaDataProcessor.onMediaDataLoaded(KEY, null, dataRemoteWithResume) - - // WHEN the notification is removed - mediaDataProcessor.onNotificationRemoved(KEY) - - // THEN the media data is converted to a resume state - verify(listener) - .onMediaDataLoaded( - eq(PACKAGE_NAME), - eq(KEY), - capture(mediaDataCaptor), - eq(true), - eq(0), - eq(false), - ) - assertThat(mediaDataCaptor.value.resumption).isTrue() - } - - @Test - fun testOnNotificationRemoved_withResumption_isRcnAndRemoteAllowed() { - // With the flag enabled to allow remote media to resume - fakeFeatureFlags.set(MEDIA_REMOTE_RESUME, true) - - // GIVEN that the manager has a remote cast notification - addNotificationAndLoad(remoteCastNotification) - val data = mediaDataCaptor.value - assertThat(data.playbackLocation).isEqualTo(MediaData.PLAYBACK_CAST_REMOTE) - val dataRemoteWithResume = data.copy(resumeAction = Runnable {}) - mediaDataProcessor.onMediaDataLoaded(KEY, null, dataRemoteWithResume) - - // WHEN the RCN is removed - mediaDataProcessor.onNotificationRemoved(KEY) - - // THEN the media data is removed - verify(listener).onMediaDataRemoved(eq(KEY), eq(false)) - } - - @Test fun testOnNotificationRemoved_withResumption_tooManyPlayers() { // Given the maximum number of resume controls already val desc = diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/resume/MediaResumeListenerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/resume/MediaResumeListenerTest.kt index bc29d2a8ba0d..366b6457e0d8 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/resume/MediaResumeListenerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/resume/MediaResumeListenerTest.kt @@ -38,7 +38,6 @@ import com.android.systemui.media.controls.domain.pipeline.MediaDataManager import com.android.systemui.media.controls.domain.pipeline.RESUME_MEDIA_TIMEOUT import com.android.systemui.media.controls.shared.model.MediaData import com.android.systemui.media.controls.shared.model.MediaDeviceData -import com.android.systemui.media.controls.util.MediaFlags import com.android.systemui.settings.UserTracker import com.android.systemui.tuner.TunerService import com.android.systemui.util.concurrency.FakeExecutor @@ -93,7 +92,6 @@ class MediaResumeListenerTest : SysuiTestCase() { @Mock private lateinit var mockContext: Context @Mock private lateinit var pendingIntent: PendingIntent @Mock private lateinit var dumpManager: DumpManager - @Mock private lateinit var mediaFlags: MediaFlags @Captor lateinit var callbackCaptor: ArgumentCaptor<ResumeMediaBrowser.Callback> @Captor lateinit var actionCaptor: ArgumentCaptor<Runnable> @@ -110,7 +108,7 @@ class MediaResumeListenerTest : SysuiTestCase() { Settings.Global.getInt( context.contentResolver, Settings.Global.SHOW_MEDIA_ON_QUICK_SETTINGS, - 1 + 1, ) private var originalResumeSetting = Settings.Secure.getInt(context.contentResolver, Settings.Secure.MEDIA_CONTROLS_RESUME, 0) @@ -122,7 +120,7 @@ class MediaResumeListenerTest : SysuiTestCase() { Settings.Global.putInt( context.contentResolver, Settings.Global.SHOW_MEDIA_ON_QUICK_SETTINGS, - 1 + 1, ) Settings.Secure.putInt(context.contentResolver, Settings.Secure.MEDIA_CONTROLS_RESUME, 1) @@ -139,7 +137,6 @@ class MediaResumeListenerTest : SysuiTestCase() { whenever(mockContext.contentResolver).thenReturn(context.contentResolver) whenever(mockContext.userId).thenReturn(context.userId) whenever(mockContext.resources).thenReturn(context.resources) - whenever(mediaFlags.isRemoteResumeAllowed()).thenReturn(false) executor = FakeExecutor(clock) resumeListener = @@ -153,7 +150,6 @@ class MediaResumeListenerTest : SysuiTestCase() { resumeBrowserFactory, dumpManager, clock, - mediaFlags, ) resumeListener.setManager(mediaDataManager) mediaDataManager.addListener(resumeListener) @@ -162,7 +158,7 @@ class MediaResumeListenerTest : SysuiTestCase() { MediaTestUtils.emptyMediaData.copy( song = TITLE, packageName = PACKAGE_NAME, - token = token + token = token, ) } @@ -171,12 +167,12 @@ class MediaResumeListenerTest : SysuiTestCase() { Settings.Global.putInt( context.contentResolver, Settings.Global.SHOW_MEDIA_ON_QUICK_SETTINGS, - originalQsSetting + originalQsSetting, ) Settings.Secure.putInt( context.contentResolver, Settings.Secure.MEDIA_CONTROLS_RESUME, - originalResumeSetting + originalResumeSetting, ) } @@ -196,7 +192,6 @@ class MediaResumeListenerTest : SysuiTestCase() { resumeBrowserFactory, dumpManager, clock, - mediaFlags, ) listener.setManager(mediaDataManager) verify(broadcastDispatcher, never()) @@ -251,32 +246,6 @@ class MediaResumeListenerTest : SysuiTestCase() { } @Test - fun testOnLoad_localCast_remoteResumeAllowed_doesCheck() { - // If local cast media is allowed to resume - whenever(mediaFlags.isRemoteResumeAllowed()).thenReturn(true) - - // When media data is loaded that has not been checked yet, and is a local cast - val dataCast = data.copy(playbackLocation = MediaData.PLAYBACK_CAST_LOCAL) - onMediaDataLoaded(KEY, null, dataCast) - - // Then we report back to the manager - verify(mediaDataManager).setResumeAction(KEY, null) - } - - @Test - fun testOnLoad_remoteCast_remoteResumeAllowed_doesCheck() { - // If local cast media is allowed to resume - whenever(mediaFlags.isRemoteResumeAllowed()).thenReturn(true) - - // When media data is loaded that has not been checked yet, and is a remote cast - val dataRcn = data.copy(playbackLocation = MediaData.PLAYBACK_CAST_REMOTE) - onMediaDataLoaded(KEY, null, dataRcn, false) - - // Then we do not take action - verify(mediaDataManager, never()).setResumeAction(any(), any()) - } - - @Test fun testOnLoad_checksForResume_hasService() { setUpMbsWithValidResolveInfo() @@ -351,7 +320,7 @@ class MediaResumeListenerTest : SysuiTestCase() { any(), any(), anyInt(), - any() + any(), ) // When we get an unlock event @@ -441,7 +410,6 @@ class MediaResumeListenerTest : SysuiTestCase() { resumeBrowserFactory, dumpManager, clock, - mediaFlags, ) resumeListener.setManager(mediaDataManager) mediaDataManager.addListener(resumeListener) @@ -475,7 +443,6 @@ class MediaResumeListenerTest : SysuiTestCase() { resumeBrowserFactory, dumpManager, clock, - mediaFlags, ) resumeListener.setManager(mediaDataManager) mediaDataManager.addListener(resumeListener) @@ -518,7 +485,6 @@ class MediaResumeListenerTest : SysuiTestCase() { resumeBrowserFactory, dumpManager, clock, - mediaFlags, ) resumeListener.setManager(mediaDataManager) mediaDataManager.addListener(resumeListener) @@ -645,7 +611,7 @@ class MediaResumeListenerTest : SysuiTestCase() { eq(token), eq(PACKAGE_NAME), eq(pendingIntent), - eq(PACKAGE_NAME) + eq(PACKAGE_NAME), ) } @@ -688,7 +654,7 @@ class MediaResumeListenerTest : SysuiTestCase() { key: String, oldKey: String?, data: MediaData, - resume: Boolean = true + resume: Boolean = true, ) { resumeListener.onMediaDataLoaded(key, oldKey, data) if (resume) { diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/media/controls/domain/pipeline/MediaResumeListenerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/media/controls/domain/pipeline/MediaResumeListenerKosmos.kt index 2a3e84b74369..76fb52c84a1b 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/media/controls/domain/pipeline/MediaResumeListenerKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/media/controls/domain/pipeline/MediaResumeListenerKosmos.kt @@ -23,7 +23,6 @@ import com.android.systemui.dump.dumpManager import com.android.systemui.kosmos.Kosmos import com.android.systemui.media.controls.domain.resume.MediaResumeListener import com.android.systemui.media.controls.domain.resume.resumeMediaBrowserFactory -import com.android.systemui.media.controls.util.mediaFlags import com.android.systemui.settings.userTracker import com.android.systemui.tuner.TunerService import com.android.systemui.util.mockito.mock @@ -41,6 +40,5 @@ val Kosmos.mediaResumeListener by mediaBrowserFactory = resumeMediaBrowserFactory, dumpManager = dumpManager, systemClock = systemClock, - mediaFlags = mediaFlags, ) } |