Verified Commit 7bdfdab5 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame 🎃
Browse files

fixup! Disable features and functionality

Bug 40212: Tor Browser crashing on launch
parent 14c96c7e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -157,6 +157,10 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
    @OptIn(DelicateCoroutinesApi::class) // GlobalScope usage
    protected open fun initializeGlean() {
        val telemetryEnabled = settings().isTelemetryEnabled
        if (!telemetryEnabled) {
            logger.debug("Preventing Glean from initializing, since telemetry is disabled")
            return
        }

        logger.debug("Initializing Glean (uploadEnabled=$telemetryEnabled, isFennec=${Config.channel.isFennec})")

+14 −2
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ import android.content.Context
import mozilla.components.service.glean.Glean
import mozilla.components.service.glean.private.NoExtraKeys
import mozilla.components.support.base.log.logger.Logger
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.GleanMetrics.Addons
import org.mozilla.fenix.GleanMetrics.AndroidAutofill
import org.mozilla.fenix.GleanMetrics.AppTheme
@@ -85,6 +86,9 @@ private class EventWrapper<T : Enum<T>>(
    }

    fun track(event: Event) {
        if (BuildConfig.DATA_COLLECTION_DISABLED) {
            return
        }
        val extras = if (keyMapper != null) {
            event.extras?.mapKeys { (key) ->
                keyMapper.invoke(key.toString().asCamelCase())
@@ -1002,6 +1006,12 @@ class GleanMetricsService(
    private val installationPing = FirstSessionPing(context)

    override fun start() {
        if (BuildConfig.DATA_COLLECTION_DISABLED) {
            Logger.debug("Data collection is disabled, not initializing Glean.")
            initialized = true
            return
        }

        logger.debug("Enabling Glean.")
        // Initialization of Glean already happened in FenixApplication.
        Glean.setUploadEnabled(true)
@@ -1029,10 +1039,12 @@ class GleanMetricsService(
    }

    override fun track(event: Event) {
        if (!BuildConfig.DATA_COLLECTION_DISABLED) {
            event.wrapper?.track(event)
        }
    }

    override fun shouldTrack(event: Event): Boolean {
        return event.wrapper != null
        return !BuildConfig.DATA_COLLECTION_DISABLED && event.wrapper != null
    }
}
+5 −1
Original line number Diff line number Diff line
@@ -151,7 +151,11 @@ internal class ReleaseMetricController(

    private fun isInitialized(type: MetricServiceType): Boolean = initialized.contains(type)

    private fun isTelemetryEnabled(@Suppress("UNUSED_PARAMETER") type: MetricServiceType): Boolean = false
    private fun isTelemetryEnabled(type: MetricServiceType): Boolean =
        !BuildConfig.DATA_COLLECTION_DISABLED && when (type) {
            MetricServiceType.Data -> isDataTelemetryEnabled()
            MetricServiceType.Marketing -> isMarketingDataTelemetryEnabled()
        }

    @Suppress("LongMethod", "MaxLineLength")
    private fun Fact.toEvent(): Event? = when {