Bug 1244316 - Don't upload in restricted profiles when admin disables FHR. r=sebastian draft
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 07 Jun 2016 14:04:06 -0700
changeset 376392 95540b8b76f7014544022c7cb0880791ac536721
parent 376390 18da1a9562090d489f8afa8b1b7ebe9a7e346b72
child 523140 1fb2bf05106d55f3b5c60b508d13ae3f72c4ab82
push id20564
push usermichael.l.comella@gmail.com
push dateTue, 07 Jun 2016 21:07:00 +0000
reviewerssebastian
bugs1244316
milestone50.0a1
Bug 1244316 - Don't upload in restricted profiles when admin disables FHR. r=sebastian Edge case: the admin profile can disable health report upload for themselves but (I assume) the new profile won't automatically match these settings. While I'm not sure if this is even possible, it's outside the scope of this bug. MozReview-Commit-ID: 1SkXhL7B5xb
mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryUploadService.java
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryUploadService.java
+++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryUploadService.java
@@ -12,16 +12,18 @@ import android.util.Log;
 import ch.boye.httpclientandroidlib.HttpHeaders;
 import ch.boye.httpclientandroidlib.HttpResponse;
 import ch.boye.httpclientandroidlib.client.ClientProtocolException;
 import ch.boye.httpclientandroidlib.client.methods.HttpRequestBase;
 import ch.boye.httpclientandroidlib.impl.client.DefaultHttpClient;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.GeckoSharedPrefs;
 import org.mozilla.gecko.preferences.GeckoPreferences;
+import org.mozilla.gecko.restrictions.Restrictable;
+import org.mozilla.gecko.restrictions.Restrictions;
 import org.mozilla.gecko.sync.ExtendedJSONObject;
 import org.mozilla.gecko.sync.net.BaseResource;
 import org.mozilla.gecko.sync.net.BaseResourceDelegate;
 import org.mozilla.gecko.sync.net.Resource;
 import org.mozilla.gecko.telemetry.stores.TelemetryPingStore;
 import org.mozilla.gecko.util.DateUtil;
 import org.mozilla.gecko.util.NetworkUtils;
 import org.mozilla.gecko.util.StringUtils;
@@ -197,16 +199,22 @@ public class TelemetryUploadService exte
             return false;
         }
 
         if (!GeckoPreferences.getBooleanPref(context, GeckoPreferences.PREFS_HEALTHREPORT_UPLOAD_ENABLED, true)) {
             Log.d(LOGTAG, "Telemetry upload opt-out");
             return false;
         }
 
+        if (Restrictions.isRestrictedProfile(context) &&
+                !Restrictions.isAllowed(context, Restrictable.HEALTH_REPORT)) {
+            Log.d(LOGTAG, "Telemetry upload feature disabled by admin profile");
+            return false;
+        }
+
         return true;
     }
 
     /**
      * Determines if the telemetry upload feature is enabled via profile & application level configurations. This is the
      * preferred method.
      *
      * You may wish to also check if the network is connected when calling this method.