commit 93a889885e1fec771d73fdff5b20cd6a6d3f11a2 parent e9090d7ea57c8640e8da3bd9c675453d82b8a41e Author: Roger Yang <royang@mozilla.com> Date: Wed, 12 Nov 2025 16:50:55 +0000 Bug 1837538 - Remove MR2022 Nimbus sections and feature flags. r=android-reviewers,petru Differential Revision: https://phabricator.services.mozilla.com/D272046 Diffstat:
12 files changed, 34 insertions(+), 208 deletions(-)
diff --git a/mobile/android/fenix/app/nimbus.fml.yaml b/mobile/android/fenix/app/nimbus.fml.yaml @@ -97,25 +97,6 @@ features: - channel: developer value: enabled: true - mr2022: - description: Features for MR 2022. - variables: - sections-enabled: - description: "This property provides a lookup table of whether or not the given section should be enabled." - type: Map<MR2022Section, Boolean> - default: - { - "wallpapers-selection-tool": true, - "tcp-cfr": true, - "tcp-feature": true, - } - defaults: - - channel: developer - value: { - "sections-enabled": { - "wallpapers-selection-tool": true, - } - } query-parameter-stripping: description: Features for query parameter stripping. variables: @@ -1070,15 +1051,6 @@ types: collections: description: The collections section of the homepage. - MR2022Section: - description: The identifiers for the sections of the MR 2022. - variants: - wallpapers-selection-tool: - description: Wallpapers selection dialog tool for the home screen. - tcp-cfr: - description: CFR for the first time you use the browse with Total Cookie Protection on the browser screen. - tcp-feature: - description: Controls the Total Cookie Protection feature. CookieBannersSection: description: The identifiers for the sections of the MR 2022. variants: diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/TrackingProtectionPolicyFactory.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/TrackingProtectionPolicyFactory.kt @@ -44,9 +44,9 @@ class TrackingProtectionPolicyFactory( } return when { - normalMode && privateMode -> trackingProtectionPolicy.applyTCPIfNeeded(settings) - normalMode && !privateMode -> trackingProtectionPolicy.applyTCPIfNeeded(settings).forRegularSessionsOnly() - !normalMode && privateMode -> trackingProtectionPolicy.applyTCPIfNeeded(settings).forPrivateSessionsOnly() + normalMode && privateMode -> trackingProtectionPolicy.applyTCPIfNeeded() + normalMode && !privateMode -> trackingProtectionPolicy.applyTCPIfNeeded().forRegularSessionsOnly() + !normalMode && privateMode -> trackingProtectionPolicy.applyTCPIfNeeded().forPrivateSessionsOnly() else -> TrackingProtectionPolicy.none() } } @@ -128,18 +128,10 @@ class TrackingProtectionPolicyFactory( } @VisibleForTesting -internal fun TrackingProtectionPolicyForSessionTypes.applyTCPIfNeeded( - settings: Settings, -): TrackingProtectionPolicyForSessionTypes { - val updatedCookiePolicy = if (settings.enabledTotalCookieProtection) { - CookiePolicy.ACCEPT_FIRST_PARTY_AND_ISOLATE_OTHERS - } else { - cookiePolicy - } - +internal fun TrackingProtectionPolicyForSessionTypes.applyTCPIfNeeded(): TrackingProtectionPolicyForSessionTypes { return TrackingProtectionPolicy.select( trackingCategories = trackingCategories, - cookiePolicy = updatedCookiePolicy, + cookiePolicy = CookiePolicy.ACCEPT_FIRST_PARTY_AND_ISOLATE_OTHERS, strictSocialTrackingProtection = strictSocialTrackingProtection, cookiePurging = cookiePurging, bounceTrackingProtectionMode = bounceTrackingProtectionMode, diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/CustomEtpCookiesOptionsDropDownListPreference.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/CustomEtpCookiesOptionsDropDownListPreference.kt @@ -7,7 +7,6 @@ package org.mozilla.fenix.settings import android.content.Context import android.util.AttributeSet import org.mozilla.fenix.R -import org.mozilla.fenix.ext.settings /** * Custom [DropDownListPreference] that automatically builds the list of available options for the @@ -18,30 +17,23 @@ class CustomEtpCookiesOptionsDropDownListPreference @JvmOverloads constructor( attrs: AttributeSet? = null, ) : DropDownListPreference(context, attrs) { init { - with(context) { - entries = arrayOf( - getString(R.string.preference_enhanced_tracking_protection_custom_cookies_1), - getString(R.string.preference_enhanced_tracking_protection_custom_cookies_2), - getString(R.string.preference_enhanced_tracking_protection_custom_cookies_3), - getString(R.string.preference_enhanced_tracking_protection_custom_cookies_4), - ) + entries = arrayOf( + context.getString(R.string.preference_enhanced_tracking_protection_custom_cookies_5), + context.getString(R.string.preference_enhanced_tracking_protection_custom_cookies_1), + context.getString(R.string.preference_enhanced_tracking_protection_custom_cookies_2), + context.getString(R.string.preference_enhanced_tracking_protection_custom_cookies_3), + context.getString(R.string.preference_enhanced_tracking_protection_custom_cookies_4), + ) - entryValues = arrayOf( - getString(R.string.social), - getString(R.string.unvisited), - getString(R.string.third_party), - getString(R.string.all), - ) - - @Suppress("UNCHECKED_CAST") - if (context.settings().enabledTotalCookieProtection) { - // If the new "Total cookie protection" should be shown it must be first item. - entries = arrayOf(getString(R.string.preference_enhanced_tracking_protection_custom_cookies_5)) + - entries as Array<String> - entryValues = arrayOf(getString(R.string.total_protection)) + entryValues as Array<String> - } - } + entryValues = arrayOf( + context.getString(R.string.total_protection), + context.getString(R.string.social), + context.getString(R.string.unvisited), + context.getString(R.string.third_party), + context.getString(R.string.all), + ) + // Default to first (Total Cookie Protection) setDefaultValue(entryValues.first()) } } diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/trustpanel/TrustPanelFragment.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/trustpanel/TrustPanelFragment.kt @@ -306,7 +306,6 @@ class TrustPanelFragment : BottomSheetDialogFragment() { Route.TrackerCategoryDetailsPanel -> { TrackerCategoryDetailsPanel( title = args.title, - isTotalCookieProtectionEnabled = components.settings.enabledTotalCookieProtection, detailedTrackerCategory = detailedTrackerCategory, bucketedTrackers = bucketedTrackers, onBackButtonClick = { diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/trustpanel/ui/TrackerCategoryDetailsPanel.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/trustpanel/ui/TrackerCategoryDetailsPanel.kt @@ -28,7 +28,6 @@ import org.mozilla.fenix.trackingprotection.TrackingProtectionCategory @Composable internal fun TrackerCategoryDetailsPanel( title: String, - isTotalCookieProtectionEnabled: Boolean, detailedTrackerCategory: TrackingProtectionCategory?, bucketedTrackers: TrackerBuckets, onBackButtonClick: () -> Unit, @@ -49,9 +48,7 @@ internal fun TrackerCategoryDetailsPanel( val trackerCategoryTitle: String val trackerCategoryDescription: String - if (detailedTrackerCategory == TrackingProtectionCategory.CROSS_SITE_TRACKING_COOKIES && - isTotalCookieProtectionEnabled - ) { + if (detailedTrackerCategory == TrackingProtectionCategory.CROSS_SITE_TRACKING_COOKIES) { trackerCategoryTitle = stringResource(id = R.string.etp_cookies_title_2) trackerCategoryDescription = stringResource(id = R.string.etp_cookies_description_2) } else if (detailedTrackerCategory != null) { @@ -109,7 +106,6 @@ private fun TrackersBlockedPanelPreview() { ) { TrackerCategoryDetailsPanel( title = "Mozilla", - isTotalCookieProtectionEnabled = true, detailedTrackerCategory = TrackingProtectionCategory.CROSS_SITE_TRACKING_COOKIES, bucketedTrackers = TrackerBuckets(), onBackButtonClick = {}, diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/trackingprotection/TrackingProtectionBlockingFragment.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/trackingprotection/TrackingProtectionBlockingFragment.kt @@ -40,7 +40,7 @@ class TrackingProtectionBlockingFragment : Fragment(R.layout.fragment_tracking_p binding = FragmentTrackingProtectionBlockingBinding.bind(view) - setTotalCookieProtectionText(settings.enabledTotalCookieProtection) + setTotalCookieProtectionText() updateCategoryVisibility(args.protectionMode, settings) } @@ -48,18 +48,12 @@ class TrackingProtectionBlockingFragment : Fragment(R.layout.fragment_tracking_p /** * Sets the title and description for the "Cookies" category based on whether the * "Total Cookie Protection" feature is enabled. - * - * @param totalCookieProtectionEnabled A flag indicating if the - * `enabledTotalCookieProtection` feature flag is active. */ @VisibleForTesting - internal fun setTotalCookieProtectionText(totalCookieProtectionEnabled: Boolean) { - // Text for the updated "Total cookie protection" option should be updated as part of a staged rollout - if (totalCookieProtectionEnabled) { - binding.categoryCookies.apply { - trackingProtectionCategoryTitle.text = getText(R.string.etp_cookies_title_2) - trackingProtectionCategoryItemDescription.text = getText(R.string.etp_cookies_description_2) - } + internal fun setTotalCookieProtectionText() { + binding.categoryCookies.apply { + trackingProtectionCategoryTitle.text = getText(R.string.etp_cookies_title_2) + trackingProtectionCategoryItemDescription.text = getText(R.string.etp_cookies_description_2) } } diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/trackingprotection/TrackingProtectionPanelView.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/trackingprotection/TrackingProtectionPanelView.kt @@ -134,10 +134,8 @@ class TrackingProtectionPanelView( binding.notBlockingHeader.isGone = bucketedTrackers.loadedIsEmpty() binding.blockingHeader.isGone = bucketedTrackers.blockedIsEmpty() - if (settings.enabledTotalCookieProtection) { - binding.crossSiteTracking.text = containerView.context.getString(R.string.etp_cookies_title_2) - binding.crossSiteTrackingLoaded.text = containerView.context.getString(R.string.etp_cookies_title_2) - } + binding.crossSiteTracking.text = containerView.context.getString(R.string.etp_cookies_title_2) + binding.crossSiteTrackingLoaded.text = containerView.context.getString(R.string.etp_cookies_title_2) updateCategoryVisibility() focusAccessibilityLastUsedCategory(state.lastAccessedCategory) @@ -151,9 +149,7 @@ class TrackingProtectionPanelView( binding.normalMode.visibility = View.GONE binding.detailsMode.visibility = View.VISIBLE - if (category == CROSS_SITE_TRACKING_COOKIES && - settings.enabledTotalCookieProtection - ) { + if (category == CROSS_SITE_TRACKING_COOKIES) { binding.categoryTitle.setText(R.string.etp_cookies_title_2) binding.categoryDescription.setText(R.string.etp_cookies_description_2) } else { diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -60,7 +60,6 @@ import org.mozilla.fenix.nimbus.CookieBannersSection import org.mozilla.fenix.nimbus.DefaultBrowserPrompt import org.mozilla.fenix.nimbus.FxNimbus import org.mozilla.fenix.nimbus.HomeScreenSection -import org.mozilla.fenix.nimbus.Mr2022Section import org.mozilla.fenix.nimbus.QueryParameterStrippingSection import org.mozilla.fenix.nimbus.QueryParameterStrippingSection.QUERY_PARAMETER_STRIPPING import org.mozilla.fenix.nimbus.QueryParameterStrippingSection.QUERY_PARAMETER_STRIPPING_ALLOW_LIST @@ -461,10 +460,9 @@ class Settings(private val appContext: Context) : PreferencesHolder { /** * Indicates if the wallpaper onboarding dialog should be shown. */ - var showWallpaperOnboarding by lazyFeatureFlagPreference( + var showWallpaperOnboarding by booleanPreference( key = appContext.getPreferenceKey(R.string.pref_key_wallpapers_onboarding), - featureFlag = true, - default = { mr2022Sections[Mr2022Section.WALLPAPERS_SELECTION_TOOL] == true }, + default = true, ) var openLinksInAPrivateTab by booleanPreference( @@ -1187,9 +1185,6 @@ class Settings(private val appContext: Context) : PreferencesHolder { default = true, ) - val enabledTotalCookieProtection: Boolean - get() = mr2022Sections[Mr2022Section.TCP_FEATURE] == true - /** * Indicates if the cookie banners CRF should be shown. */ @@ -1211,11 +1206,7 @@ class Settings(private val appContext: Context) : PreferencesHolder { val blockCookiesSelectionInCustomTrackingProtection by stringPreference( key = appContext.getPreferenceKey(R.string.pref_key_tracking_protection_custom_cookies_select), - default = if (enabledTotalCookieProtection) { - appContext.getString(R.string.total_protection) - } else { - appContext.getString(R.string.social) - }, + default = appContext.getString(R.string.total_protection), ) val blockTrackingContentInCustomTrackingProtection by booleanPreference( @@ -1968,10 +1959,6 @@ class Settings(private val appContext: Context) : PreferencesHolder { return featureGate.isAddressFeatureEnabled() } - private val mr2022Sections: Map<Mr2022Section, Boolean> - get() = - FxNimbus.features.mr2022.value().sectionsEnabled - private val cookieBannersSection: Map<CookieBannersSection, Int> get() = FxNimbus.features.cookieBanners.value().sectionsEnabled diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/TrackingProtectionPolicyFactoryTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/TrackingProtectionPolicyFactoryTest.kt @@ -136,9 +136,6 @@ class TrackingProtectionPolicyFactoryTest { @Test fun `GIVEN TCP is enabled by nimbus WHEN applyTCPIfNeeded THEN cookie policy should be TCP`() { - val settings: Settings = mockk(relaxed = true) - every { settings.enabledTotalCookieProtection } returns true - val policies = arrayOf( TrackingProtectionPolicy.strict(), TrackingProtectionPolicy.recommended(), @@ -146,7 +143,7 @@ class TrackingProtectionPolicyFactoryTest { ) for (policy in policies) { - val adaptedPolicy = policy.applyTCPIfNeeded(settings) + val adaptedPolicy = policy.applyTCPIfNeeded() assertEquals( CookiePolicy.ACCEPT_FIRST_PARTY_AND_ISOLATE_OTHERS, adaptedPolicy.cookiePolicy, @@ -154,26 +151,6 @@ class TrackingProtectionPolicyFactoryTest { } } - fun `GIVEN TCP is NOT enabled by nimbus WHEN applyTCPIfNeeded THEN reuse cookie policy`() { - val settings: Settings = mockk(relaxed = true) - - every { settings.enabledTotalCookieProtection } returns false - - val policies = arrayOf( - TrackingProtectionPolicy.strict(), - TrackingProtectionPolicy.recommended(), - TrackingProtectionPolicy.select(), - ) - - for (policy in policies) { - val adaptedPolicy = policy.applyTCPIfNeeded(settings) - assertEquals( - policy.cookiePolicy, - adaptedPolicy.cookiePolicy, - ) - } - } - @Test fun `GIVEN custom policy WHEN cookie policy social THEN tracking policy should have cookie policy allow non-trackers`() { val expected = TrackingProtectionPolicy.select( @@ -670,7 +647,6 @@ class TrackingProtectionPolicyFactoryTest { customConvenience: Boolean = false, ): Settings = mockk { every { useStandardTrackingProtection } returns useStandard - every { enabledTotalCookieProtection } returns false every { useStrictTrackingProtection } returns useStrict every { useCustomTrackingProtection } returns useCustom every { shouldUseTrackingProtection } returns useTrackingProtection diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/CustomEtpCookiesOptionsDropDownListPreferenceTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/CustomEtpCookiesOptionsDropDownListPreferenceTest.kt @@ -5,15 +5,12 @@ package org.mozilla.fenix.settings import androidx.preference.Preference -import io.mockk.every -import io.mockk.mockk import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertArrayEquals import org.junit.Assert.assertEquals import org.junit.Test import org.junit.runner.RunWith import org.mozilla.fenix.R -import org.mozilla.fenix.ext.components import org.robolectric.RobolectricTestRunner @RunWith(RobolectricTestRunner::class) @@ -24,11 +21,6 @@ class CustomEtpCookiesOptionsDropDownListPreferenceTest { testContext.getString(R.string.preference_enhanced_tracking_protection_custom_cookies_5), ) + defaultEntries val expectedValues = arrayOf(testContext.getString(R.string.total_protection)) + defaultValues - - every { testContext.components.settings } returns mockk { - every { enabledTotalCookieProtection } returns true - } - val preference = CustomEtpCookiesOptionsDropDownListPreference(testContext) assertArrayEquals(expectedEntries, preference.entries) @@ -36,19 +28,6 @@ class CustomEtpCookiesOptionsDropDownListPreferenceTest { assertEquals(expectedValues[0], preference.getDefaultValue()) } - @Test - fun `GIVEN total cookie protection is disabled WHEN using this preference THEN don't show the total cookie protection option`() { - every { testContext.components.settings } returns mockk { - every { enabledTotalCookieProtection } returns false - } - - val preference = CustomEtpCookiesOptionsDropDownListPreference(testContext) - - assertArrayEquals(defaultEntries, preference.entries) - assertArrayEquals(defaultValues, preference.entryValues) - assertEquals(defaultValues[0], preference.getDefaultValue()) - } - /** * Use reflection to get the private member holding the default value set for this preference. */ diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/trackingprotection/TrackingProtectionBlockingFragmentTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/trackingprotection/TrackingProtectionBlockingFragmentTest.kt @@ -29,27 +29,7 @@ class TrackingProtectionBlockingFragmentTest { fun `GIVEN total cookie protection is enabled WHEN showing details THEN show the updated cookie protection text`() { val expectedTitle = testContext.getString(R.string.etp_cookies_title_2) val expectedDescription = testContext.getString(R.string.etp_cookies_description_2) - - val mockSettings = mockk<Settings>(relaxed = true) { - every { enabledTotalCookieProtection } returns true - } - - val fragment = createFragment(mockSettings) - - val cookiesCategory = fragment.binding.categoryCookies - assertEquals(expectedTitle, cookiesCategory.trackingProtectionCategoryTitle.text.toString()) - assertEquals(expectedDescription, cookiesCategory.trackingProtectionCategoryItemDescription.text.toString()) - } - - @Test - fun `GIVEN total cookie protection is disabled WHEN showing details THEN show the default cookie protection text`() { - val expectedTitle = testContext.getString(R.string.etp_cookies_title) - val expectedDescription = testContext.getString(R.string.etp_cookies_description) - - val mockSettings = mockk<Settings>(relaxed = true) { - every { enabledTotalCookieProtection } returns false - } - + val mockSettings = mockk<Settings>(relaxed = true) val fragment = createFragment(mockSettings) val cookiesCategory = fragment.binding.categoryCookies @@ -90,7 +70,6 @@ class TrackingProtectionBlockingFragmentTest { @Test fun `GIVEN custom mode WHEN all blocking settings are true THEN all categories are visible`() { val mockSettings = mockk<Settings> { - every { enabledTotalCookieProtection } returns false every { blockFingerprintersInCustomTrackingProtection } returns true every { blockCryptominersInCustomTrackingProtection } returns true every { blockCookiesInCustomTrackingProtection } returns true @@ -113,7 +92,6 @@ class TrackingProtectionBlockingFragmentTest { @Test fun `GIVEN custom mode WHEN all blocking settings are false THEN all categories are hidden`() { val mockSettings = mockk<Settings> { - every { enabledTotalCookieProtection } returns false every { blockFingerprintersInCustomTrackingProtection } returns false every { blockCryptominersInCustomTrackingProtection } returns false every { blockCookiesInCustomTrackingProtection } returns false diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/trackingprotection/TrackingProtectionPanelViewTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/trackingprotection/TrackingProtectionPanelViewTest.kt @@ -69,8 +69,6 @@ class TrackingProtectionPanelViewTest { @Test fun testNormalModeUiCookiesWithTotalCookieProtectionEnabled() { - every { settings.enabledTotalCookieProtection } returns true - val expectedTitle = testContext.getString(R.string.etp_cookies_title_2) view.update(baseState.copy(mode = ProtectionsState.Mode.Normal)) @@ -80,18 +78,6 @@ class TrackingProtectionPanelViewTest { } @Test - fun testNormalModeUiCookiesWithTotalCookieProtectionDisabled() { - every { settings.enabledTotalCookieProtection } returns false - - val expectedTitle = testContext.getString(R.string.etp_cookies_title) - - view.update(baseState.copy(mode = ProtectionsState.Mode.Normal)) - - assertEquals(expectedTitle, view.binding.crossSiteTracking.text) - assertEquals(expectedTitle, view.binding.crossSiteTrackingLoaded.text) - } - - @Test fun testPrivateModeUi() { view.update( baseState.copy( @@ -119,7 +105,6 @@ class TrackingProtectionPanelViewTest { @Test fun testPrivateModeUiCookiesWithTotalCookieProtectionEnabled() { - every { settings.enabledTotalCookieProtection } returns true val expectedTitle = testContext.getString(R.string.etp_cookies_title_2) val expectedDescription = testContext.getString(R.string.etp_cookies_description_2) @@ -137,26 +122,6 @@ class TrackingProtectionPanelViewTest { } @Test - fun testPrivateModeUiCookiesWithTotalCookieProtectionDisabled() { - every { settings.enabledTotalCookieProtection } returns false - - val expectedTitle = testContext.getString(R.string.etp_cookies_title) - val expectedDescription = testContext.getString(R.string.etp_cookies_description) - - view.update( - baseState.copy( - mode = ProtectionsState.Mode.Details( - selectedCategory = CROSS_SITE_TRACKING_COOKIES, - categoryBlocked = false, - ), - ), - ) - - assertEquals(expectedTitle, view.binding.categoryTitle.text) - assertEquals(expectedDescription, view.binding.categoryDescription.text) - } - - @Test fun testProtectionSettings() { view.binding.protectionSettings.performClick() verify { interactor.selectTrackingProtectionSettings() }