Bug 1371402 - Disable processing of background telemetry if it's disabled in the preferences r=nalexander
authorGrigory Kruglov <gkruglov@mozilla.com>
Thu, 08 Jun 2017 18:16:18 -0400
changeset 413586 0dd4c63082dd9eaf9d0800a34eb575e05c8627fc
parent 413585 a43b9bebbc130260a86de84b06d0cf9f1add6796
child 413587 3db546295a0a2d999e57b4879eee6ad25bc0f277
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1371402
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1371402 - Disable processing of background telemetry if it's disabled in the preferences r=nalexander MozReview-Commit-ID: ANGu2MhQto0
mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryBackgroundReceiver.java
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryBackgroundReceiver.java
+++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryBackgroundReceiver.java
@@ -13,16 +13,17 @@ import android.os.Bundle;
 import android.os.Parcelable;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
 import android.support.v4.content.LocalBroadcastManager;
 import android.util.Log;
 
 import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.Experiments;
+import org.mozilla.gecko.preferences.GeckoPreferences;
 import org.mozilla.gecko.switchboard.SwitchBoard;
 import org.mozilla.gecko.sync.telemetry.TelemetryContract;
 import org.mozilla.gecko.telemetry.pingbuilders.TelemetrySyncEventPingBuilder;
 import org.mozilla.gecko.telemetry.pingbuilders.TelemetrySyncPingBuilder;
 import org.mozilla.gecko.telemetry.pingbuilders.TelemetrySyncPingBundleBuilder;
 import org.mozilla.gecko.telemetry.schedulers.TelemetryUploadAllPingsImmediatelyScheduler;
 import org.mozilla.gecko.telemetry.schedulers.TelemetryUploadScheduler;
 import org.mozilla.gecko.telemetry.stores.TelemetryJSONFilePingStore;
@@ -82,16 +83,25 @@ public class TelemetryBackgroundReceiver
         LocalBroadcastManager.getInstance(context).registerReceiver(
                 this, new IntentFilter(ACTION_BACKGROUND_TELEMETRY));
     }
 
     @Override
     public void onReceive(final Context context, final Intent intent) {
         Log.i(LOG_TAG, "Handling background telemetry broadcast");
 
+        // Do not process incoming background telemetry if user disabled telemetry in preferences.
+        // Background telemetry is opt-out by default. We're using the old FHR pref as that's our
+        // single opt-out telemetry preference flag.
+        // Only Sync users are emitting background telemetry.
+        if (!GeckoPreferences.getBooleanPref(context, GeckoPreferences.PREFS_HEALTHREPORT_UPLOAD_ENABLED, false)) {
+            Log.i(LOG_TAG, "Telemetry is disabled via preferences, dropping background telemetry.");
+            return;
+        }
+
         // This is our kill-switch for background telemetry (or a functionality throttle).
         if (!SwitchBoard.isInExperiment(context, Experiments.ENABLE_PROCESSING_BACKGROUND_TELEMETRY)) {
             Log.i(LOG_TAG, "Background telemetry processing disabled via switchboard.");
             return;
         }
 
         if (!intent.hasExtra(TelemetryContract.KEY_TELEMETRY)) {
             throw new IllegalStateException("Received a background telemetry broadcast without data.");