Loading mobile/android/android-components/components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt +2 −0 Original line number Diff line number Diff line Loading @@ -1503,6 +1503,8 @@ class GeckoEngine( installedExtension.registerTabHandler(webExtensionTabHandler, defaultSettings) onSuccess(installedExtension) } fun getTorIntegrationController() = runtime.getTorIntegrationController() } internal fun ContentBlockingController.LogEntry.BlockingData.hasBlockedCookies(): Boolean { Loading mobile/android/fenix/app/build.gradle +11 −0 Original line number Diff line number Diff line Loading @@ -329,12 +329,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 Loading Loading @@ -775,6 +783,9 @@ dependencies { lintPublish project(":mozilla-lint-rules") lintChecks project(':tooling-lint') // Tor Expert Bundle implementation files('tor-expert-bundle.aar') } protobuf { Loading mobile/android/fenix/app/src/main/assets/common/torrc-defaults 0 → 100644 +9 −0 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 mobile/android/fenix/app/src/main/java/org/mozilla/fenix/FenixApplication.kt +20 −1 Original line number Diff line number Diff line Loading @@ -137,6 +137,8 @@ open class FenixApplication : LocaleAwareApplication(), Provider { isDeviceRamAboveThreshold() } var terminating = false open val components by lazy { Components(this) } var visibilityLifecycleCallback: VisibilityLifecycleCallback? = null Loading Loading @@ -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() { Loading Loading @@ -314,6 +331,8 @@ open class FenixApplication : LocaleAwareApplication(), Provider { components.analytics.metricsStorage.tryRegisterAsUsageRecorder(this) downloadWallpapers() components.torController.start() } @OptIn(DelicateCoroutinesApi::class) // GlobalScope usage Loading Loading @@ -917,7 +936,7 @@ open class FenixApplication : LocaleAwareApplication(), Provider { clipboardSuggestionsEnabled.set(settings.shouldShowClipboardSuggestions) searchShortcutsEnabled.set(settings.shouldShowSearchShortcuts) voiceSearchEnabled.set(settings.shouldShowVoiceSearch) openLinksInAppEnabled.set(settings.openLinksInExternalApp) //openLinksInAppEnabled.set(settings.openLinksInExternalApp) signedInSync.set(settings.signedInFxaAccount) val syncedItems = SyncEnginesStorage(applicationContext).getStatus().entries.filter { Loading mobile/android/fenix/app/src/main/java/org/mozilla/fenix/HomeActivity.kt +46 −8 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import androidx.annotation.VisibleForTesting import androidx.appcompat.app.ActionBar import androidx.appcompat.widget.Toolbar import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.core.content.ContentProviderCompat.requireContext import androidx.lifecycle.lifecycleScope import androidx.navigation.NavController import androidx.navigation.fragment.NavHostFragment Loading Loading @@ -143,6 +144,7 @@ import org.mozilla.fenix.tabhistory.TabHistoryDialogFragment import org.mozilla.fenix.tabstray.TabsTrayFragment import org.mozilla.fenix.theme.DefaultThemeManager import org.mozilla.fenix.theme.ThemeManager import org.mozilla.fenix.tor.TorEvents import org.mozilla.fenix.utils.Settings import java.lang.ref.WeakReference import java.util.Locale Loading @@ -166,6 +168,8 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { private var isToolbarInflated = false private var isBeingRecreated = false private val webExtensionPopupObserver by lazy { WebExtensionPopupObserver(components.core.store, ::openPopup) } Loading Loading @@ -314,6 +318,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { it.start() } /* if (settings().shouldShowOnboarding( hasUserBeenOnboarded = components.fenixOnboarding.userHasBeenOnboarded(), isLauncherIntent = intent.toSafeIntent().isLauncherIntent, Loading @@ -324,6 +329,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { navHost.navController.navigate(NavGraphDirections.actionGlobalOnboarding()) } } else { */ lifecycleScope.launch(IO) { // showFullscreenMessageIfNeeded(applicationContext) } Loading @@ -344,7 +350,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { navHost.navController.navigate(NavGraphDirections.actionGlobalHomeOnboardingDialog()) } */ } //} Performance.processIntentIfPerformanceTest(intent, this) Loading Loading @@ -627,6 +633,15 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { if (this !is ExternalAppBrowserActivity && !activityStartedWithLink) { stopMediaSession() } if (!isBeingRecreated && !(application as FenixApplication).isTerminating()) { // We assume the Activity is being destroyed because the user // swiped away the app on the Recent screen. When this happens, // we assume the user expects the entire Application is destroyed // and not only the top Activity/Task. Therefore we kill the // underlying Application, as well. (application as FenixApplication).terminate() } } final override fun onConfigurationChanged(newConfig: Configuration) { Loading @@ -646,6 +661,8 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { message = "recreate()", ) isBeingRecreated = true super.recreate() } Loading Loading @@ -673,6 +690,24 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { * Handles intents received when the activity is open. */ final override fun onNewIntent(intent: Intent?) { if (intent?.action == ACTION_MAIN || components.torController.isConnected) { onNewIntentInternal(intent) } else { // Wait until Tor is connected to handle intents from external apps for links, search, etc. components.torController.registerTorListener(object : TorEvents { override fun onTorConnected() { components.torController.unregisterTorListener(this) onNewIntentInternal(intent) } override fun onTorConnecting() { /* no-op */ } override fun onTorStopped() { /* no-op */ } override fun onTorStatusUpdate(entry: String?, status: String?, progress: Double?) { /* no-op */ } }) return } } private fun onNewIntentInternal(intent: Intent?) { super.onNewIntent(intent) intent?.let { handleNewIntent(it) Loading Loading @@ -1191,11 +1226,11 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { @VisibleForTesting internal fun navigateToHome(navController: NavController) { if (this is ExternalAppBrowserActivity) { return } //if (this is ExternalAppBrowserActivity) { // return //} navController.navigate(NavGraphDirections.actionStartupHome()) navHost.navController.navigate(NavGraphDirections.actionStartupTorbootstrap()) } final override fun attachBaseContext(base: Context) { Loading Loading @@ -1284,14 +1319,17 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { /** * Indicates if the user should be redirected to the [BrowserFragment] or to the [HomeFragment], * links from an external apps should always opened in the [BrowserFragment]. * links from an external apps should always opened in the [BrowserFragment], * unless Tor is not yet connected. */ @VisibleForTesting internal fun shouldStartOnHome(intent: Intent? = this.intent): Boolean { return components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) { // We only want to open on home when users tap the app, // we want to ignore other cases when the app gets open by users clicking on links. getSettings().shouldStartOnHome() && intent?.action == ACTION_MAIN // we want to ignore other cases when the app gets open by users clicking on links, // unless Tor is not yet connected. getSettings().shouldStartOnHome() && (intent?.action == ACTION_MAIN || !components.torController.isConnected) } } Loading Loading
mobile/android/android-components/components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt +2 −0 Original line number Diff line number Diff line Loading @@ -1503,6 +1503,8 @@ class GeckoEngine( installedExtension.registerTabHandler(webExtensionTabHandler, defaultSettings) onSuccess(installedExtension) } fun getTorIntegrationController() = runtime.getTorIntegrationController() } internal fun ContentBlockingController.LogEntry.BlockingData.hasBlockedCookies(): Boolean { Loading
mobile/android/fenix/app/build.gradle +11 −0 Original line number Diff line number Diff line Loading @@ -329,12 +329,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 Loading Loading @@ -775,6 +783,9 @@ dependencies { lintPublish project(":mozilla-lint-rules") lintChecks project(':tooling-lint') // Tor Expert Bundle implementation files('tor-expert-bundle.aar') } protobuf { Loading
mobile/android/fenix/app/src/main/assets/common/torrc-defaults 0 → 100644 +9 −0 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
mobile/android/fenix/app/src/main/java/org/mozilla/fenix/FenixApplication.kt +20 −1 Original line number Diff line number Diff line Loading @@ -137,6 +137,8 @@ open class FenixApplication : LocaleAwareApplication(), Provider { isDeviceRamAboveThreshold() } var terminating = false open val components by lazy { Components(this) } var visibilityLifecycleCallback: VisibilityLifecycleCallback? = null Loading Loading @@ -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() { Loading Loading @@ -314,6 +331,8 @@ open class FenixApplication : LocaleAwareApplication(), Provider { components.analytics.metricsStorage.tryRegisterAsUsageRecorder(this) downloadWallpapers() components.torController.start() } @OptIn(DelicateCoroutinesApi::class) // GlobalScope usage Loading Loading @@ -917,7 +936,7 @@ open class FenixApplication : LocaleAwareApplication(), Provider { clipboardSuggestionsEnabled.set(settings.shouldShowClipboardSuggestions) searchShortcutsEnabled.set(settings.shouldShowSearchShortcuts) voiceSearchEnabled.set(settings.shouldShowVoiceSearch) openLinksInAppEnabled.set(settings.openLinksInExternalApp) //openLinksInAppEnabled.set(settings.openLinksInExternalApp) signedInSync.set(settings.signedInFxaAccount) val syncedItems = SyncEnginesStorage(applicationContext).getStatus().entries.filter { Loading
mobile/android/fenix/app/src/main/java/org/mozilla/fenix/HomeActivity.kt +46 −8 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import androidx.annotation.VisibleForTesting import androidx.appcompat.app.ActionBar import androidx.appcompat.widget.Toolbar import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.core.content.ContentProviderCompat.requireContext import androidx.lifecycle.lifecycleScope import androidx.navigation.NavController import androidx.navigation.fragment.NavHostFragment Loading Loading @@ -143,6 +144,7 @@ import org.mozilla.fenix.tabhistory.TabHistoryDialogFragment import org.mozilla.fenix.tabstray.TabsTrayFragment import org.mozilla.fenix.theme.DefaultThemeManager import org.mozilla.fenix.theme.ThemeManager import org.mozilla.fenix.tor.TorEvents import org.mozilla.fenix.utils.Settings import java.lang.ref.WeakReference import java.util.Locale Loading @@ -166,6 +168,8 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { private var isToolbarInflated = false private var isBeingRecreated = false private val webExtensionPopupObserver by lazy { WebExtensionPopupObserver(components.core.store, ::openPopup) } Loading Loading @@ -314,6 +318,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { it.start() } /* if (settings().shouldShowOnboarding( hasUserBeenOnboarded = components.fenixOnboarding.userHasBeenOnboarded(), isLauncherIntent = intent.toSafeIntent().isLauncherIntent, Loading @@ -324,6 +329,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { navHost.navController.navigate(NavGraphDirections.actionGlobalOnboarding()) } } else { */ lifecycleScope.launch(IO) { // showFullscreenMessageIfNeeded(applicationContext) } Loading @@ -344,7 +350,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { navHost.navController.navigate(NavGraphDirections.actionGlobalHomeOnboardingDialog()) } */ } //} Performance.processIntentIfPerformanceTest(intent, this) Loading Loading @@ -627,6 +633,15 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { if (this !is ExternalAppBrowserActivity && !activityStartedWithLink) { stopMediaSession() } if (!isBeingRecreated && !(application as FenixApplication).isTerminating()) { // We assume the Activity is being destroyed because the user // swiped away the app on the Recent screen. When this happens, // we assume the user expects the entire Application is destroyed // and not only the top Activity/Task. Therefore we kill the // underlying Application, as well. (application as FenixApplication).terminate() } } final override fun onConfigurationChanged(newConfig: Configuration) { Loading @@ -646,6 +661,8 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { message = "recreate()", ) isBeingRecreated = true super.recreate() } Loading Loading @@ -673,6 +690,24 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { * Handles intents received when the activity is open. */ final override fun onNewIntent(intent: Intent?) { if (intent?.action == ACTION_MAIN || components.torController.isConnected) { onNewIntentInternal(intent) } else { // Wait until Tor is connected to handle intents from external apps for links, search, etc. components.torController.registerTorListener(object : TorEvents { override fun onTorConnected() { components.torController.unregisterTorListener(this) onNewIntentInternal(intent) } override fun onTorConnecting() { /* no-op */ } override fun onTorStopped() { /* no-op */ } override fun onTorStatusUpdate(entry: String?, status: String?, progress: Double?) { /* no-op */ } }) return } } private fun onNewIntentInternal(intent: Intent?) { super.onNewIntent(intent) intent?.let { handleNewIntent(it) Loading Loading @@ -1191,11 +1226,11 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { @VisibleForTesting internal fun navigateToHome(navController: NavController) { if (this is ExternalAppBrowserActivity) { return } //if (this is ExternalAppBrowserActivity) { // return //} navController.navigate(NavGraphDirections.actionStartupHome()) navHost.navController.navigate(NavGraphDirections.actionStartupTorbootstrap()) } final override fun attachBaseContext(base: Context) { Loading Loading @@ -1284,14 +1319,17 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { /** * Indicates if the user should be redirected to the [BrowserFragment] or to the [HomeFragment], * links from an external apps should always opened in the [BrowserFragment]. * links from an external apps should always opened in the [BrowserFragment], * unless Tor is not yet connected. */ @VisibleForTesting internal fun shouldStartOnHome(intent: Intent? = this.intent): Boolean { return components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) { // We only want to open on home when users tap the app, // we want to ignore other cases when the app gets open by users clicking on links. getSettings().shouldStartOnHome() && intent?.action == ACTION_MAIN // we want to ignore other cases when the app gets open by users clicking on links, // unless Tor is not yet connected. getSettings().shouldStartOnHome() && (intent?.action == ACTION_MAIN || !components.torController.isConnected) } } Loading