diff --git a/app/src/main/java/org/mozilla/fenix/home/intent/DeepLinkIntentProcessor.kt b/app/src/main/java/org/mozilla/fenix/home/intent/DeepLinkIntentProcessor.kt index 64775d972..71d0c69a7 100644 --- a/app/src/main/java/org/mozilla/fenix/home/intent/DeepLinkIntentProcessor.kt +++ b/app/src/main/java/org/mozilla/fenix/home/intent/DeepLinkIntentProcessor.kt @@ -21,6 +21,8 @@ import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.browser.browsingmode.BrowsingMode import org.mozilla.fenix.components.SearchWidgetCreator import org.mozilla.fenix.ext.alreadyOnDestination +import org.mozilla.fenix.home.intent.DeepLinkIntentProcessor.DeepLinkVerifier +import org.mozilla.fenix.settings.SupportUtils /** * Deep links in the form of `fenix://host` open different parts of the app. @@ -93,6 +95,16 @@ class DeepLinkIntentProcessor( settingsIntent.putExtra(SETTINGS_SHOW_FRAGMENT_ARGS, bundleOf(SETTINGS_SELECT_OPTION_KEY to DEFAULT_BROWSER_APP_OPTION)) activity.startActivity(settingsIntent) + } else { + activity.openToBrowserAndLoad( + searchTermOrURL = SupportUtils.getSumoURLForTopic( + activity, + SupportUtils.SumoTopic.SET_AS_DEFAULT_BROWSER + ), + newTab = true, + from = BrowserDirection.FromGlobal, + flags = EngineSession.LoadUrlFlags.external() + ) } } "open" -> { diff --git a/app/src/test/java/org/mozilla/fenix/home/intent/DeepLinkIntentProcessorTest.kt b/app/src/test/java/org/mozilla/fenix/home/intent/DeepLinkIntentProcessorTest.kt index 959200d5e..88b022db7 100644 --- a/app/src/test/java/org/mozilla/fenix/home/intent/DeepLinkIntentProcessorTest.kt +++ b/app/src/test/java/org/mozilla/fenix/home/intent/DeepLinkIntentProcessorTest.kt @@ -6,6 +6,9 @@ package org.mozilla.fenix.home.intent import android.content.Intent import android.net.Uri +import android.os.Build.VERSION_CODES.M +import android.os.Build.VERSION_CODES.N +import android.os.Build.VERSION_CODES.P import androidx.core.net.toUri import androidx.navigation.NavController import io.mockk.Called @@ -27,6 +30,8 @@ import org.mozilla.fenix.NavGraphDirections import org.mozilla.fenix.browser.browsingmode.BrowsingMode import org.mozilla.fenix.components.SearchWidgetCreator import org.mozilla.fenix.helpers.FenixRobolectricTestRunner +import org.mozilla.fenix.settings.SupportUtils +import org.robolectric.annotation.Config @RunWith(FenixRobolectricTestRunner::class) class DeepLinkIntentProcessorTest { @@ -244,9 +249,31 @@ class DeepLinkIntentProcessorTest { } @Test - fun `process make_default_browser deep link`() { + @Config(minSdk = N, maxSdk = P) + fun `process make_default_browser deep link for above API 23`() { assertTrue(processor.process(testIntent("make_default_browser"), navController, out)) + verify { activity.startActivity(any()) } + verify { navController wasNot Called } + verify { out wasNot Called } + } + + @Test + @Config(maxSdk = M) + fun `process make_default_browser deep link for API 23 and below`() { + assertTrue(processor.process(testIntent("make_default_browser"), navController, out)) + + verify { + activity.openToBrowserAndLoad( + searchTermOrURL = SupportUtils.getSumoURLForTopic( + activity, + SupportUtils.SumoTopic.SET_AS_DEFAULT_BROWSER + ), + newTab = true, + from = BrowserDirection.FromGlobal, + flags = EngineSession.LoadUrlFlags.external() + ) + } verify { navController wasNot Called } verify { out wasNot Called } } diff --git a/docs/mma.md b/docs/mma.md index ab632d0f1..92e41d690 100644 --- a/docs/mma.md +++ b/docs/mma.md @@ -357,7 +357,7 @@ Here is the list of current deep links available, which can be found here in the `fenix://make_default_browser` - Opens to the Android default apps settings screen. **Only works on Android API >=24** + Opens to the Android default apps settings screen. If Android API <= 23 opens tab to support page defined in SupportUtils.SumoTopic.SET_AS_DEFAULT_BROWSER `fenix://settings_notifications`