For #7661: Add variant-specific schemas for deep links

In order to target specific variants of Fenix, we're adding schemas that
are specific that app in order to avoid collisions with the other
variants and with other forks of fenix that may have the same schemas.

The current schema for variants:
 - Fenix Nightly: `fenix-nightly://`
 - Fenix Beta: `fenix-beta://`
 - Everything else: `fenix://`
fennec/beta
Jonathan Almeida 4 years ago committed by Jonathan Almeida
parent ca05863138
commit ffd4cdd970

@ -45,9 +45,12 @@ android {
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: 'true' testInstrumentationRunnerArguments clearPackageData: 'true'
manifestPlaceholders.isRaptorEnabled = "false"
resValue "bool", "IS_DEBUG", "false" resValue "bool", "IS_DEBUG", "false"
buildConfigField "boolean", "USE_RELEASE_VERSIONING", "false" buildConfigField "boolean", "USE_RELEASE_VERSIONING", "false"
manifestPlaceholders = [
"isRaptorEnabled": "false",
"deepLinkScheme": "fenix"
]
} }
def releaseTemplate = { def releaseTemplate = {
@ -74,10 +77,12 @@ android {
fenixNightly releaseTemplate >> { fenixNightly releaseTemplate >> {
applicationIdSuffix ".fenix.nightly" applicationIdSuffix ".fenix.nightly"
buildConfigField "boolean", "USE_RELEASE_VERSIONING", "true" buildConfigField "boolean", "USE_RELEASE_VERSIONING", "true"
manifestPlaceholders = ["deepLinkScheme": "fenix-nightly"]
} }
fenixBeta releaseTemplate >> { fenixBeta releaseTemplate >> {
applicationIdSuffix ".fenix.beta" applicationIdSuffix ".fenix.beta"
buildConfigField "boolean", "USE_RELEASE_VERSIONING", "true" buildConfigField "boolean", "USE_RELEASE_VERSIONING", "true"
manifestPlaceholders = ["deepLinkScheme": "fenix-beta"]
} }
fenixProduction releaseTemplate >> { fenixProduction releaseTemplate >> {
applicationIdSuffix ".fenix" applicationIdSuffix ".fenix"

@ -77,23 +77,23 @@
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<data android:scheme="fenix" <data android:scheme="${deepLinkScheme}"
android:host="home"/> android:host="home"/>
<data android:scheme="fenix" <data android:scheme="${deepLinkScheme}"
android:host="settings"/> android:host="settings"/>
<data android:scheme="fenix" <data android:scheme="${deepLinkScheme}"
android:host="turn_on_sync"/> android:host="turn_on_sync"/>
<data android:scheme="fenix" <data android:scheme="${deepLinkScheme}"
android:host="settings_search_engine"/> android:host="settings_search_engine"/>
<data android:scheme="fenix" <data android:scheme="${deepLinkScheme}"
android:host="settings_accessibility"/> android:host="settings_accessibility"/>
<data android:scheme="fenix" <data android:scheme="${deepLinkScheme}"
android:host="settings_delete_browsing_data"/> android:host="settings_delete_browsing_data"/>
<data android:scheme="fenix" <data android:scheme="${deepLinkScheme}"
android:host="enable_private_browsing"/> android:host="enable_private_browsing"/>
<data android:scheme="fenix" <data android:scheme="${deepLinkScheme}"
android:host="open"/> android:host="open"/>
<data android:scheme="fenix" <data android:scheme="${deepLinkScheme}"
android:host="make_default_browser"/> android:host="make_default_browser"/>
</intent-filter> </intent-filter>
</activity> </activity>

@ -24,7 +24,8 @@ class DeepLinkIntentProcessor(
) : HomeIntentProcessor { ) : HomeIntentProcessor {
override fun process(intent: Intent, navController: NavController, out: Intent): Boolean { override fun process(intent: Intent, navController: NavController, out: Intent): Boolean {
return if (intent.scheme == "fenix") { val scheme = intent.scheme?.contains("fenix") ?: return false
return if (scheme) {
intent.data?.let { handleDeepLink(it, navController) } intent.data?.let { handleDeepLink(it, navController) }
true true
} else { } else {

@ -58,6 +58,15 @@ class DeepLinkIntentProcessorTest {
verify { out wasNot Called } verify { out wasNot Called }
} }
@Test
fun `return true if scheme is a fenix variant`() {
assertTrue(processor.process(testIntent("fenix-beta://test"), navController, out))
verify { activity wasNot Called }
verify { navController wasNot Called }
verify { out wasNot Called }
}
@Test @Test
fun `process home deep link`() { fun `process home deep link`() {
assertTrue(processor.process(testIntent("fenix://home"), navController, out)) assertTrue(processor.process(testIntent("fenix://home"), navController, out))

Loading…
Cancel
Save