Bug 1847266 - Implement status message for add-ons not signed correctly in the manager

fenix/120.0
William Durand 1 year ago committed by mergify[bot]
parent b542302d9e
commit c623101f19

@ -40,6 +40,7 @@ import org.mozilla.fenix.ext.runIfFragmentIsAttached
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.showToolbar
import org.mozilla.fenix.extension.WebExtensionPromptFeature
import org.mozilla.fenix.settings.SupportUtils
import org.mozilla.fenix.theme.ThemeManager
/**
@ -270,6 +271,8 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
val url = when (link) {
AddonsManagerAdapterDelegate.LearnMoreLinks.BLOCKLISTED_ADDON ->
"${BuildConfig.AMO_BASE_URL}/android/blocked-addon/${addon.id}/"
AddonsManagerAdapterDelegate.LearnMoreLinks.ADDON_NOT_CORRECTLY_SIGNED ->
SupportUtils.getSumoURLForTopic(requireContext(), SupportUtils.SumoTopic.UNSIGNED_ADDONS)
}
openLinkInNewTab(url)
}

@ -130,9 +130,9 @@ class InstalledAddonDetailsFragment : Fragment() {
val switch = provideEnableSwitch()
val privateBrowsingSwitch = providePrivateBrowsingSwitch()
switch.setState(addon.isEnabled())
// When the ad-on is blocklisted, we do not want to enable the toggle switch
// because users shouldn't be able to re-enable a blocklisted add-on.
if (addon.isDisabledAsBlocklisted()) {
// When the ad-on is blocklisted or not correctly signed, we do not want to enable the toggle switch
// because users shouldn't be able to re-enable an add-on in this state.
if (addon.isDisabledAsBlocklisted() || addon.isDisabledAsNotCorrectlySigned()) {
switch.isEnabled = false
return
}

@ -56,6 +56,7 @@ object SupportUtils {
SPONSOR_PRIVACY("sponsor-privacy"),
HTTPS_ONLY_MODE("https-only-mode-firefox-android"),
COOKIE_BANNER("cookie-banner-reduction-firefox-android"),
UNSIGNED_ADDONS("unsigned-addons"),
}
enum class MozillaPage(internal val path: String) {

@ -165,4 +165,7 @@
<!-- Tab Counter colors -->
<color name="mozac_ui_tabcounter_default_tint" tools:ignore="UnusedResources">@color/fx_mobile_icon_color_primary</color>
<color name="mozac_ui_tabcounter_default_text" tools:ignore="UnusedResources">@color/fx_mobile_text_color_primary</color>
<!-- Add-ons colors -->
<color name="mozac_feature_addons_error_text_color">@color/photonRed20</color>
</resources>

@ -353,4 +353,7 @@
<!-- Material Design colors -->
<color name="material_scrim_color">#52000000</color>
<!-- Add-ons colors -->
<color name="mozac_feature_addons_error_text_color" tools:ignore="UnusedResources">@color/photonRed70</color>
</resources>

@ -90,6 +90,7 @@ class InstalledAddonDetailsFragmentTest {
every { fragment.provideEnableSwitch() } returns enableSwitch
every { fragment.providePrivateBrowsingSwitch() } returns privateBrowsingSwitch
every { addon.isDisabledAsBlocklisted() } returns false
every { addon.isDisabledAsNotCorrectlySigned() } returns false
every { addon.isEnabled() } returns true
every { fragment.addon } returns addon
@ -97,4 +98,22 @@ class InstalledAddonDetailsFragmentTest {
verify(exactly = 0) { enableSwitch.isEnabled = false }
}
@Test
fun `GIVEN addon not correctly signed WHEN biding the enable switch THEN disable the switch`() {
val addon = mockk<Addon>()
val enableSwitch = mockk<SwitchMaterial>(relaxed = true)
val privateBrowsingSwitch = mockk<SwitchMaterial>(relaxed = true)
every { fragment.provideEnableSwitch() } returns enableSwitch
every { fragment.providePrivateBrowsingSwitch() } returns privateBrowsingSwitch
every { addon.isEnabled() } returns true
every { addon.isDisabledAsBlocklisted() } returns false
every { addon.isDisabledAsNotCorrectlySigned() } returns true
every { fragment.addon } returns addon
fragment.bindEnableSwitch()
verify { enableSwitch.isEnabled = false }
}
}

Loading…
Cancel
Save