Skip to content

Commit

Permalink
For mozilla-mobile#18453 - Show SUMO for default browser deeplink on …
Browse files Browse the repository at this point in the history
…Android <N

Lower Android versions don't offer the possibility of opening system settings
at a specific preference. In this cases we already shown a sumo article
detailing the manual steps each user is expected to perform to change the
system set default browser.
  • Loading branch information
kershan authored and pkirakosyan committed Aug 5, 2021
1 parent d6d65b7 commit e2eccc5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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" -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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 }
}
Expand Down
2 changes: 1 addition & 1 deletion docs/mma.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ Here is the list of current deep links available, which can be found here in the
</tr>
<tr>
<td>`fenix://make_default_browser`</td>
<td>Opens to the Android default apps settings screen. **Only works on Android API >=24**</td>
<td>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</td>
</tr>
<tr>
<td>`fenix://settings_notifications`</td>
Expand Down

0 comments on commit e2eccc5

Please sign in to comment.