Bug 1852224 - Prevent background media from being stopped when existing application from an external link.

fenix/124.1.0
t-p-white 4 months ago committed by mergify[bot]
parent 6ac615710b
commit 667e5fb209

@ -612,7 +612,8 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
privateNotificationObserver?.stop() privateNotificationObserver?.stop()
components.notificationsDelegate.unBindActivity(this) components.notificationsDelegate.unBindActivity(this)
if (this !is ExternalAppBrowserActivity) { val activityStartedWithLink = startupPathProvider.startupPathForActivity == StartupPathProvider.StartupPath.VIEW
if (this !is ExternalAppBrowserActivity && !activityStartedWithLink) {
stopMediaSession() stopMediaSession()
} }
} }

@ -100,7 +100,6 @@ class StartupPathProvider {
override fun onStop(owner: LifecycleOwner) { override fun onStop(owner: LifecycleOwner) {
// Clear existing state. // Clear existing state.
startupPathForActivity = StartupPath.NOT_SET
wasResumedSinceStartedState = false wasResumedSinceStartedState = false
} }
} }

@ -108,12 +108,12 @@ class StartupPathProviderTest {
} }
@Test @Test
fun `GIVEN the app is launched to the homescreen and stopped WHEN getting the start up path THEN it is not set`() { fun `GIVEN the app is launched to the homescreen with MAIN and stopped WHEN getting the start up path THEN it set to MAIN`() {
every { intent.action } returns Intent.ACTION_MAIN every { intent.action } returns Intent.ACTION_MAIN
launchApp(intent) launchApp(intent)
stopLaunchedApp() stopLaunchedApp()
assertEquals(StartupPath.NOT_SET, provider.startupPathForActivity) assertEquals(StartupPath.MAIN, provider.startupPathForActivity)
} }
@Test @Test
@ -129,13 +129,13 @@ class StartupPathProviderTest {
} }
@Test @Test
fun `GIVEN the app is launched to the homescreen, stopped, and relaunched warm from the app switcher WHEN getting the start up path THEN it is not set`() { fun `GIVEN the app is launched to the homescreen with MAIN, stopped, and relaunched warm from the app switcher WHEN getting the start up path THEN it set to MAIN'`() {
every { intent.action } returns Intent.ACTION_MAIN every { intent.action } returns Intent.ACTION_MAIN
launchApp(intent) launchApp(intent)
stopLaunchedApp() stopLaunchedApp()
startStoppedAppFromAppSwitcher() startStoppedAppFromAppSwitcher()
assertEquals(StartupPath.NOT_SET, provider.startupPathForActivity) assertEquals(StartupPath.MAIN, provider.startupPathForActivity)
} }
@Test @Test
@ -159,7 +159,7 @@ class StartupPathProviderTest {
} }
@Test @Test
fun `GIVEN the app is launched, stopped, started from the app switcher and receives an intent in the foreground WHEN getting the start up path THEN it returns not set`() { fun `GIVEN the app is launched with MAIN, stopped, started from the app switcher and receives an intent in the foreground WHEN getting the start up path THEN it returns MAIN`() {
every { intent.action } returns Intent.ACTION_MAIN every { intent.action } returns Intent.ACTION_MAIN
launchApp(intent) launchApp(intent)
stopLaunchedApp() stopLaunchedApp()
@ -167,7 +167,7 @@ class StartupPathProviderTest {
every { intent.action } returns Intent.ACTION_VIEW every { intent.action } returns Intent.ACTION_VIEW
receiveIntentInForeground(intent) receiveIntentInForeground(intent)
assertEquals(StartupPath.NOT_SET, provider.startupPathForActivity) assertEquals(StartupPath.MAIN, provider.startupPathForActivity)
} }
private fun launchApp(intent: Intent) { private fun launchApp(intent: Intent) {

Loading…
Cancel
Save