Commit ffd4cdd9 authored by Jonathan Almeida's avatar Jonathan Almeida Committed by Jonathan Almeida
Browse files

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://`
parent ca058631
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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"
+9 −9
Original line number Diff line number Diff line
@@ -77,23 +77,23 @@
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="fenix"
                <data android:scheme="${deepLinkScheme}"
                    android:host="home"/>
                <data android:scheme="fenix"
                <data android:scheme="${deepLinkScheme}"
                      android:host="settings"/>
                <data android:scheme="fenix"
                <data android:scheme="${deepLinkScheme}"
                    android:host="turn_on_sync"/>
                <data android:scheme="fenix"
                <data android:scheme="${deepLinkScheme}"
                    android:host="settings_search_engine"/>
                <data android:scheme="fenix"
                <data android:scheme="${deepLinkScheme}"
                    android:host="settings_accessibility"/>
                <data android:scheme="fenix"
                <data android:scheme="${deepLinkScheme}"
                    android:host="settings_delete_browsing_data"/>
                <data android:scheme="fenix"
                <data android:scheme="${deepLinkScheme}"
                    android:host="enable_private_browsing"/>
                <data android:scheme="fenix"
                <data android:scheme="${deepLinkScheme}"
                    android:host="open"/>
                <data android:scheme="fenix"
                <data android:scheme="${deepLinkScheme}"
                    android:host="make_default_browser"/>
            </intent-filter>
        </activity>
+2 −1
Original line number Diff line number Diff line
@@ -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 {
+9 −0
Original line number Diff line number Diff line
@@ -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))