From ffd4cdd9703d43345228b9efbd944ae3d0a5cebf Mon Sep 17 00:00:00 2001 From: Jonathan Almeida Date: Thu, 27 Feb 2020 10:43:43 -0500 Subject: [PATCH] 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://` --- app/build.gradle | 7 ++++++- app/src/main/AndroidManifest.xml | 18 +++++++++--------- .../home/intent/DeepLinkIntentProcessor.kt | 3 ++- .../home/intent/DeepLinkIntentProcessorTest.kt | 9 +++++++++ 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f6e6347e0..7bc63cc8f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -45,9 +45,12 @@ android { vectorDrawables.useSupportLibrary = true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunnerArguments clearPackageData: 'true' - manifestPlaceholders.isRaptorEnabled = "false" resValue "bool", "IS_DEBUG", "false" buildConfigField "boolean", "USE_RELEASE_VERSIONING", "false" + manifestPlaceholders = [ + "isRaptorEnabled": "false", + "deepLinkScheme": "fenix" + ] } def releaseTemplate = { @@ -74,10 +77,12 @@ android { fenixNightly releaseTemplate >> { applicationIdSuffix ".fenix.nightly" buildConfigField "boolean", "USE_RELEASE_VERSIONING", "true" + manifestPlaceholders = ["deepLinkScheme": "fenix-nightly"] } fenixBeta releaseTemplate >> { applicationIdSuffix ".fenix.beta" buildConfigField "boolean", "USE_RELEASE_VERSIONING", "true" + manifestPlaceholders = ["deepLinkScheme": "fenix-beta"] } fenixProduction releaseTemplate >> { applicationIdSuffix ".fenix" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 65efb553a..716716204 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -77,23 +77,23 @@ - - - - - - - - - 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 3e3c0f69c..cb1a1922e 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 @@ -24,7 +24,8 @@ class DeepLinkIntentProcessor( ) : HomeIntentProcessor { 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) } true } else { 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 8bd2173fb..1169d7a0b 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 @@ -58,6 +58,15 @@ class DeepLinkIntentProcessorTest { 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 fun `process home deep link`() { assertTrue(processor.process(testIntent("fenix://home"), navController, out))