[tor-commits] [Git][tpo/applications/fenix][tor-browser-96.3.0-11.0-1] fixup! Disable features and functionality

Pier Angelo Vendrame (@pierov) gitlab at torproject.org
Fri May 20 17:45:49 UTC 2022



Pier Angelo Vendrame pushed to branch tor-browser-96.3.0-11.0-1 at The Tor Project / Applications / fenix


Commits:
9431b234 by Pier Angelo Vendrame at 2022-05-20T19:45:26+02:00
fixup! Disable features and functionality

Bug 40212: Tor Browser crashing on launch

- - - - -


3 changed files:

- app/src/main/java/org/mozilla/fenix/FenixApplication.kt
- app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt
- app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt


Changes:

=====================================
app/src/main/java/org/mozilla/fenix/FenixApplication.kt
=====================================
@@ -151,6 +151,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})")
 


=====================================
app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt
=====================================
@@ -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.AndroidKeystoreExperiment
@@ -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())
@@ -938,6 +942,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)
@@ -965,10 +975,12 @@ class GleanMetricsService(
     }
 
     override fun track(event: Event) {
-        event.wrapper?.track(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
     }
 }


=====================================
app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt
=====================================
@@ -152,7 +152,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 {



View it on GitLab: https://gitlab.torproject.org/tpo/applications/fenix/-/commit/9431b234d65faa20d6f15433e77d81cfcc692048

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/fenix/-/commit/9431b234d65faa20d6f15433e77d81cfcc692048
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tor-commits/attachments/20220520/e9aeadae/attachment-0001.htm>


More information about the tor-commits mailing list