diff --git a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt index eaa4d725a0..8ea4a4d8ef 100644 --- a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt +++ b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt @@ -612,7 +612,8 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { privateNotificationObserver?.stop() components.notificationsDelegate.unBindActivity(this) - if (this !is ExternalAppBrowserActivity) { + val activityStartedWithLink = startupPathProvider.startupPathForActivity == StartupPathProvider.StartupPath.VIEW + if (this !is ExternalAppBrowserActivity && !activityStartedWithLink) { stopMediaSession() } } diff --git a/app/src/main/java/org/mozilla/fenix/perf/StartupPathProvider.kt b/app/src/main/java/org/mozilla/fenix/perf/StartupPathProvider.kt index 1cd6263067..d6b0abe1ca 100644 --- a/app/src/main/java/org/mozilla/fenix/perf/StartupPathProvider.kt +++ b/app/src/main/java/org/mozilla/fenix/perf/StartupPathProvider.kt @@ -100,7 +100,6 @@ class StartupPathProvider { override fun onStop(owner: LifecycleOwner) { // Clear existing state. - startupPathForActivity = StartupPath.NOT_SET wasResumedSinceStartedState = false } } diff --git a/app/src/test/java/org/mozilla/fenix/perf/StartupPathProviderTest.kt b/app/src/test/java/org/mozilla/fenix/perf/StartupPathProviderTest.kt index 8d22d86d3e..ad14ebc0c1 100644 --- a/app/src/test/java/org/mozilla/fenix/perf/StartupPathProviderTest.kt +++ b/app/src/test/java/org/mozilla/fenix/perf/StartupPathProviderTest.kt @@ -108,12 +108,12 @@ class StartupPathProviderTest { } @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 launchApp(intent) stopLaunchedApp() - assertEquals(StartupPath.NOT_SET, provider.startupPathForActivity) + assertEquals(StartupPath.MAIN, provider.startupPathForActivity) } @Test @@ -129,13 +129,13 @@ class StartupPathProviderTest { } @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 launchApp(intent) stopLaunchedApp() startStoppedAppFromAppSwitcher() - assertEquals(StartupPath.NOT_SET, provider.startupPathForActivity) + assertEquals(StartupPath.MAIN, provider.startupPathForActivity) } @Test @@ -159,7 +159,7 @@ class StartupPathProviderTest { } @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 launchApp(intent) stopLaunchedApp() @@ -167,7 +167,7 @@ class StartupPathProviderTest { every { intent.action } returns Intent.ACTION_VIEW receiveIntentInForeground(intent) - assertEquals(StartupPath.NOT_SET, provider.startupPathForActivity) + assertEquals(StartupPath.MAIN, provider.startupPathForActivity) } private fun launchApp(intent: Intent) {