Commit 60e3d583 authored by Matthew Finkel's avatar Matthew Finkel Committed by morgan
Browse files

[android] Add Tor integration and UI

Bug 40001: Start Tor as part of the Fenix initialization

Bug 40028: Implement Tor Service controller

Bug 40028: Integrate Tor Controller into HomeFragment

Bug 40028: Implement Tor connect and logger screens

Bug 40028: Implement Tor Onboarding

Bug 40028: Implement new home screen

Bug 40028: Define bootstrapping events and Quick Start

Bug 40041: Implement Tor Network Settings

Bug 40041: Integrate Tor Network Settings

Bug 40179: Show Snowflake bridge option on Release

Bug 40176: Re-render Home fragment on resume

Bug 41394: Implement a setting to always prioritize Onion sites.
parent d98bd74a
Loading
Loading
Loading
Loading
+0 −8
Changes for mobile/android/android-components/components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt: 0 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -1347,13 +1347,6 @@ class GeckoEngine(
                    localeUpdater.updateValue()
                }
            }
        override var prioritizeOnions: Boolean
            get() = runtime.settings.prioritizeOnions
            set(value) {
                value.let {
                    runtime.settings.prioritizeOnions = it
                }
            }
    }.apply {
        defaultSettings?.let {
            this.javascriptEnabled = it.javascriptEnabled
@@ -1382,7 +1375,6 @@ class GeckoEngine(
            this.emailTrackerBlockingPrivateBrowsing = it.emailTrackerBlockingPrivateBrowsing
            this.torSecurityLevel = it.torSecurityLevel
            this.spoofEnglish = it.spoofEnglish
            this.prioritizeOnions = it.prioritizeOnions
        }
    }

+0 −1
Changes for mobile/android/android-components/components/concept/engine/src/main/java/mozilla/components/concept/engine/Settings.kt: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -259,7 +259,6 @@ abstract class Settings {

    open var spoofEnglish: Boolean by UnsupportedSetting()

    open var prioritizeOnions: Boolean by UnsupportedSetting()
}

/**
+16 −0
Changes for mobile/android/fenix/app/build.gradle: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -311,12 +311,20 @@ android.applicationVariants.configureEach { variant ->
    def isDebugOrDCD = isDebug || isDataCollectionDisabled
    def useReleaseVersioning = variant.buildType.buildConfigFields['USE_RELEASE_VERSIONING']?.value ?: false

    def disableTor = false
    if (project.hasProperty("disableTor")) {
        disableTor = project.getProperty("disableTor")
    }

    println("----------------------------------------------")
    println("Variant name:      " + variant.name)
    println("Application ID:    " + [variant.applicationId, variant.buildType.applicationIdSuffix].findAll().join())
    println("Build type:        " + variant.buildType.name)
    println("Flavor:            " + variant.flavorName)
    println("Telemetry enabled: " + !isDebugOrDCD)
    println("Tor is disabled:   " + disableTor)

    buildConfigField "boolean", "DISABLE_TOR", "$disableTor"

    if (useReleaseVersioning) {
        // The Google Play Store does not allow multiple APKs for the same app that all have the
@@ -764,6 +772,14 @@ dependencies {

    lintPublish project(":mozilla-lint-rules")
    lintChecks project(':tooling-lint')

    // Tor Android Services Dependencies
    implementation 'net.freehaven.tor.control:jtorctl:0.2'
    implementation 'org.slf4j:slf4j-api:1.7.25'
    implementation 'org.slf4j:slf4j-android:1.7.25'

    // Tor Expert Bundle
    implementation files('tor-expert-bundle.aar')
}

protobuf {
+9 −0
Changes for mobile/android/fenix/app/src/main/assets/common/torrc-defaults: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
## torrc-defaults for Tor Browser for Android
AvoidDiskWrites 1
# (stderr|stdout|syslog|file FILENAME).
Log notice stdout
CookieAuthentication 1
DormantCanceledByStartup 1
ClientTransportPlugin meek_lite,obfs2,obfs3,obfs4,scramblesuit,webtunnel exec ./libObfs4proxy.so
ClientTransportPlugin snowflake exec ./libSnowflake.so
ClientTransportPlugin conjure exec ./libConjure.so -registerURL https://registration.refraction.network/api
+19 −8
Changes for mobile/android/fenix/app/src/main/java/org/mozilla/fenix/FenixApplication.kt: 19 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -137,6 +137,8 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
        isDeviceRamAboveThreshold()
    }

    var terminating = false

    open val components by lazy { Components(this) }

    var visibilityLifecycleCallback: VisibilityLifecycleCallback? = null
@@ -186,6 +188,21 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
        }
    }

    fun isTerminating() = terminating

    fun terminate() {
        onTerminate()
        System.exit(0)
    }

    override fun onTerminate() {
        terminating = true

        super.onTerminate()
        components.torController.stop()
        components.torController.stopTor()
    }

    @OptIn(DelicateCoroutinesApi::class) // GlobalScope usage
    @VisibleForTesting
    protected open fun initializeGlean() {
@@ -241,14 +258,6 @@ open class FenixApplication : LocaleAwareApplication(), Provider {

    @VisibleForTesting
    protected open fun setupInMainProcessOnly() {
        // ⚠️ DO NOT ADD ANYTHING ABOVE THIS LINE.
        // Especially references to the engine/BrowserStore which can alter the app initialization.
        // See: https://github.com/mozilla-mobile/fenix/issues/26320
        //
        // We can initialize Nimbus before Glean because Glean will queue messages
        // before it's initialized.
        initializeNimbus()

        ProfilerMarkerFactProcessor.create { components.core.engine.profiler }.register()

        run {
@@ -314,6 +323,8 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
        components.analytics.metricsStorage.tryRegisterAsUsageRecorder(this)

        downloadWallpapers()

        components.torController.start()
    }

    @OptIn(DelicateCoroutinesApi::class) // GlobalScope usage
Loading