tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit b534b9bfcbdf821b0faea865db5ab04e71aebe11
parent e5dec8ed6814a494b6e358527a131c1b9f445b61
Author: t-p-white <towhite@mozilla.com>
Date:   Thu,  6 Nov 2025 15:15:24 +0000

Bug 1998389 - Part 1: Updated regions, some minor refactoring and renaming. r=android-reviewers,joberhauser

Differential Revision: https://phabricator.services.mozilla.com/D271412

Diffstat:
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/experiments/RecordedNimbusContext.kt | 5+++++
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/termsofuse/experimentation/TermsOfUseAdvancedTargetingHelper.kt | 11+++++------
Amobile/android/fenix/app/src/main/java/org/mozilla/fenix/termsofuse/experimentation/utils/Locales.kt | 123+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dmobile/android/fenix/app/src/main/java/org/mozilla/fenix/termsofuse/experimentation/utils/Regions.kt | 105-------------------------------------------------------------------------------
Mmobile/android/fenix/app/src/test/java/org/mozilla/fenix/termsofuse/experimentation/SponsoredContentPointsTest.kt | 12++++++------
Mmobile/android/fenix/app/src/test/java/org/mozilla/fenix/termsofuse/experimentation/TermsOfUseAdvancedTargetingHelperTest.kt | 4++--
Amobile/android/fenix/app/src/test/java/org/mozilla/fenix/termsofuse/experimentation/utils/Locales.kt | 123+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dmobile/android/fenix/app/src/test/java/org/mozilla/fenix/termsofuse/experimentation/utils/Regions.kt | 105-------------------------------------------------------------------------------
8 files changed, 264 insertions(+), 224 deletions(-)

diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/experiments/RecordedNimbusContext.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/experiments/RecordedNimbusContext.kt @@ -7,6 +7,8 @@ package org.mozilla.fenix.experiments import android.content.Context import android.os.Build import androidx.annotation.VisibleForTesting +import mozilla.components.support.locale.LocaleManager +import mozilla.components.support.locale.LocaleManager.getSystemDefault import mozilla.components.support.utils.ext.getPackageInfoCompat import org.json.JSONArray import org.json.JSONObject @@ -177,8 +179,11 @@ class RecordedNimbusContext( isFirstRun: Boolean, ): RecordedNimbusContext { val settings = context.settings() + val langTag = LocaleManager.getCurrentLocale(context) + ?.toLanguageTag() ?: getSystemDefault().toLanguageTag() val termsOfUseAdvancedTargetingHelper = TermsOfUseAdvancedTargetingHelper( DefaultTermsOfUseDataProvider(settings), + langTag, ) val packageInfo = context.packageManager.getPackageInfoCompat(context.packageName, 0) diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/termsofuse/experimentation/TermsOfUseAdvancedTargetingHelper.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/termsofuse/experimentation/TermsOfUseAdvancedTargetingHelper.kt @@ -5,10 +5,9 @@ package org.mozilla.fenix.termsofuse.experimentation import androidx.annotation.VisibleForTesting -import mozilla.components.support.locale.LocaleManager.getSystemDefault import org.mozilla.fenix.termsofuse.experimentation.utils.TermsOfUseDataProvider -import org.mozilla.fenix.termsofuse.experimentation.utils.supportedSponsoredShortcutsRegions -import org.mozilla.fenix.termsofuse.experimentation.utils.supportedSponsoredStoriesRegions +import org.mozilla.fenix.termsofuse.experimentation.utils.supportedSponsoredShortcutsLocales +import org.mozilla.fenix.termsofuse.experimentation.utils.supportedSponsoredStoriesLocales /** * Helper class for Terms of Use advanced targeting options. @@ -18,7 +17,7 @@ import org.mozilla.fenix.termsofuse.experimentation.utils.supportedSponsoredStor */ class TermsOfUseAdvancedTargetingHelper( private val termsOfUseDataProvider: TermsOfUseDataProvider, - private val systemLanguageTag: String = getSystemDefault().toLanguageTag(), + private val systemLanguageTag: String, ) { /** * Gets the users 'points' for Advanced Targeting. @@ -65,9 +64,9 @@ class TermsOfUseAdvancedTargetingHelper( @VisibleForTesting internal fun regionSupportsSponsoredShortcuts() = - supportedSponsoredShortcutsRegions.contains(systemLanguageTag) + supportedSponsoredShortcutsLocales.contains(systemLanguageTag) @VisibleForTesting internal fun regionSupportsSponsoredStories() = - supportedSponsoredStoriesRegions.contains(systemLanguageTag) + supportedSponsoredStoriesLocales.contains(systemLanguageTag) } diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/termsofuse/experimentation/utils/Locales.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/termsofuse/experimentation/utils/Locales.kt @@ -0,0 +1,123 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.fenix.termsofuse.experimentation.utils + +/** + * List of supported locales (language/region) for sponsored shortcuts/tiles (Top Sites). + */ +internal val supportedSponsoredShortcutsLocales = listOf( + // Austria + "de-AT", + + // Belgium + "de-BE", + "fr-BE", + + // Bulgaria + "bg-BG", + + // Canada + "en-CA", + + // Croatia + "hr-HR", + + // Cyprus + "el-CY", + "tr-CY", + + // Czechia + "cs-CZ", + + // Denmark + "da-DK", + + // Estonia + "et-EE", + + // Finland + "fi-FI", + "sv-FI", + + // France + "fr-FR", + + // Germany + "de-DE", + + // Greece + "el-GR", + + // Hungary + "hu-HU", + + // Iceland + "is-IS", + + // Ireland + "en-IE", + + // Latvia + "lv-LV", + + // Lithuania + "lt-LT", + + // Japan + "ja-JP", + + // Malta + "mt-MT", + + // Netherlands + "nl-NL", + + // New Zealand + "en-NZ", + + // Norway + "nb-NO", + + // Poland + "pl-PL", + + // Portugal + "pt-PT", + + // Romania + "ro-RO", + + // Singapore + "en-SG", + + // Slovakia + "sk-SK", + + // Spain + "es-ES", + + // Sweden + "sv-SE", + + // Switzerland + "de-CH", + + // UK + "en-GB", + + // US + "en-US", +) + +/** + * List of supported locales (language/region) for sponsored stories. + */ +internal val supportedSponsoredStoriesLocales = listOf( + // US + "en-US", + + // Canada + "en-CA", +) diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/termsofuse/experimentation/utils/Regions.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/termsofuse/experimentation/utils/Regions.kt @@ -1,105 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.fenix.termsofuse.experimentation.utils - -/** - * List of supported regions for sponsored shortcuts (Top Sites). - */ -internal val supportedSponsoredShortcutsRegions = listOf( - // Australia - "en-AU", - - // Austria - "de-AT", - "fr-AT", - "it-AT", - "rm-AT", - - // Belgium - "de-BE", - "fr-BE", - "it-BE", - "rm-BE", - - // Brazil - "pt-BR", - - // Canada - "en-CA", - - // Czechia - "cs-CZ", - - // Denmark - "da-DK", - - // Finland - "fi-FI", - - // France - "fr", - "fr-FR", - - // Germany - "de", - "de-DE", - - // Hungary - "hu-HU", - - // India - "en-IN", - - // Ireland - "en-IE", - - // Japan - "ja-JP", - - // Netherlands - "nl-NL", - - // New Zealand - "en-NZ", - - // Norway - "nb-NO", - - // Poland - "pl-PL", - - // Portugal - "pt-PT", - - // Singapore - "en-SG", - - // Slovakia - "sk-SK", - - // Spain - "es", - "es-ES", - - // Sweden - "sv-SE", - - // UK - "en-GB", - - // US - "en-US", -) - -/** - * List of supported regions for sponsored stories. - */ -internal val supportedSponsoredStoriesRegions = listOf( - // US - "en-US", - - // Canada - "en-CA", -) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/termsofuse/experimentation/SponsoredContentPointsTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/termsofuse/experimentation/SponsoredContentPointsTest.kt @@ -9,16 +9,16 @@ import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test import org.mozilla.fenix.termsofuse.experimentation.utils.FakeTermsOfUseDataProvider -import org.mozilla.fenix.termsofuse.experimentation.utils.supportedSponsoredShortcutsRegions -import org.mozilla.fenix.termsofuse.experimentation.utils.supportedSponsoredStoriesRegions +import org.mozilla.fenix.termsofuse.experimentation.utils.supportedSponsoredShortcutsLocales +import org.mozilla.fenix.termsofuse.experimentation.utils.supportedSponsoredStoriesLocales /** * Test for the [TermsOfUseAdvancedTargetingHelper.sponsoredContentPoints] function and dependencies. */ class SponsoredContentPointsTest { - private val shortcutsLocale = supportedSponsoredShortcutsRegions.first() - private val storiesLocale = supportedSponsoredStoriesRegions.first() + private val shortcutsLocale = supportedSponsoredShortcutsLocales.first() + private val storiesLocale = supportedSponsoredStoriesLocales.first() @Test fun `WHEN eligible user opted out of shortcuts THEN sponsoredContentPoints returns 1`() { @@ -185,7 +185,7 @@ class SponsoredContentPointsTest { @Test fun `WHEN region is supported THEN regionSupportsSponsoredShortcuts returns true`() { - supportedSponsoredShortcutsRegions.forEach { + supportedSponsoredShortcutsLocales.forEach { val helper = TermsOfUseAdvancedTargetingHelper(FakeTermsOfUseDataProvider(), it) assertTrue(helper.regionSupportsSponsoredShortcuts()) @@ -194,7 +194,7 @@ class SponsoredContentPointsTest { @Test fun `WHEN region is supported THEN regionSupportsSponsoredStories returns true`() { - supportedSponsoredStoriesRegions.forEach { + supportedSponsoredStoriesLocales.forEach { val helper = TermsOfUseAdvancedTargetingHelper(FakeTermsOfUseDataProvider(), it) assertTrue(helper.regionSupportsSponsoredStories()) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/termsofuse/experimentation/TermsOfUseAdvancedTargetingHelperTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/termsofuse/experimentation/TermsOfUseAdvancedTargetingHelperTest.kt @@ -7,11 +7,11 @@ package org.mozilla.fenix.termsofuse.experimentation import org.junit.Assert.assertEquals import org.junit.Test import org.mozilla.fenix.termsofuse.experimentation.utils.FakeTermsOfUseDataProvider -import org.mozilla.fenix.termsofuse.experimentation.utils.supportedSponsoredShortcutsRegions +import org.mozilla.fenix.termsofuse.experimentation.utils.supportedSponsoredShortcutsLocales class TermsOfUseAdvancedTargetingHelperTest { - private val shortcutsLocale = supportedSponsoredShortcutsRegions.first() + private val shortcutsLocale = supportedSponsoredShortcutsLocales.first() @Test fun `WHEN privacySettingsPoints and sponsoredContentPoints each return 1 THEN getTouPoints returns 2`() { diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/termsofuse/experimentation/utils/Locales.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/termsofuse/experimentation/utils/Locales.kt @@ -0,0 +1,123 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.fenix.termsofuse.experimentation.utils + +/** + * Test duplicate of [supportedSponsoredShortcutsLocales], these should be the same locales. + */ +internal val supportedSponsoredShortcutsLocales = listOf( + // Austria + "de-AT", + + // Belgium + "de-BE", + "fr-BE", + + // Bulgaria + "bg-BG", + + // Canada + "en-CA", + + // Croatia + "hr-HR", + + // Cyprus + "el-CY", + "tr-CY", + + // Czechia + "cs-CZ", + + // Denmark + "da-DK", + + // Estonia + "et-EE", + + // Finland + "fi-FI", + "sv-FI", + + // France + "fr-FR", + + // Germany + "de-DE", + + // Greece + "el-GR", + + // Hungary + "hu-HU", + + // Iceland + "is-IS", + + // Ireland + "en-IE", + + // Latvia + "lv-LV", + + // Lithuania + "lt-LT", + + // Japan + "ja-JP", + + // Malta + "mt-MT", + + // Netherlands + "nl-NL", + + // New Zealand + "en-NZ", + + // Norway + "nb-NO", + + // Poland + "pl-PL", + + // Portugal + "pt-PT", + + // Romania + "ro-RO", + + // Singapore + "en-SG", + + // Slovakia + "sk-SK", + + // Spain + "es-ES", + + // Sweden + "sv-SE", + + // Switzerland + "de-CH", + + // UK + "en-GB", + + // US + "en-US", +) + +/** + * Test duplicate of [supportedSponsoredStoriesLocales], these should be the same locales. + */ +internal val supportedSponsoredStoriesLocales = listOf( + // US + "en-US", + + // Canada + "en-CA", +) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/termsofuse/experimentation/utils/Regions.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/termsofuse/experimentation/utils/Regions.kt @@ -1,105 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.fenix.termsofuse.experimentation.utils - -/** - * Test duplicate of [supportedSponsoredShortcutsRegions], these should be the same regions. - */ -internal val supportedSponsoredShortcutsRegions = listOf( - // Australia - "en-AU", - - // Austria - "de-AT", - "fr-AT", - "it-AT", - "rm-AT", - - // Belgium - "de-BE", - "fr-BE", - "it-BE", - "rm-BE", - - // Brazil - "pt-BR", - - // Canada - "en-CA", - - // Czechia - "cs-CZ", - - // Denmark - "da-DK", - - // Finland - "fi-FI", - - // France - "fr", - "fr-FR", - - // Germany - "de", - "de-DE", - - // Hungary - "hu-HU", - - // India - "en-IN", - - // Ireland - "en-IE", - - // Japan - "ja-JP", - - // Netherlands - "nl-NL", - - // New Zealand - "en-NZ", - - // Norway - "nb-NO", - - // Poland - "pl-PL", - - // Portugal - "pt-PT", - - // Singapore - "en-SG", - - // Slovakia - "sk-SK", - - // Spain - "es", - "es-ES", - - // Sweden - "sv-SE", - - // UK - "en-GB", - - // US - "en-US", -) - -/** - * Test duplicate of [supportedSponsoredStoriesRegions], these should be the same regions. - */ -internal val supportedSponsoredStoriesRegions = listOf( - // US - "en-US", - - // Canada - "en-CA", -)