Bug 1358117 - Add pref to turn on/off leanplum. r=maliu
☠☠ backed out by 5a8db189930c ☠ ☠
authorNevin Chen <cnevinchen@gmail.com>
Thu, 18 May 2017 19:27:13 +0800
changeset 585278 fba7b035a4f98e9b74aa1e21916822593cc0c39d
parent 585277 2dbd3753567239aa77b72465fd982b3e2f7ad1e0
child 585279 2231d313a521211887a2ca6018af7e3bcc65c92b
push id61093
push userdgottwald@mozilla.com
push dateFri, 26 May 2017 20:16:26 +0000
reviewersmaliu
bugs1358117
milestone55.0a1
Bug 1358117 - Add pref to turn on/off leanplum. r=maliu MozReview-Commit-ID: 8LHvMPSxAdl
mobile/android/app/mobile.js
mobile/android/base/java/org/mozilla/gecko/mma/MmaDelegate.java
mobile/android/base/java/org/mozilla/gecko/mma/MmaInterface.java
mobile/android/base/java/org/mozilla/gecko/mma/MmaLeanplumImp.java
mobile/android/base/java/org/mozilla/gecko/mma/MmaStubImp.java
mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
mobile/android/thirdparty/com/leanplum/Leanplum.java
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -409,16 +409,25 @@ pref("browser.ui.zoom.force-user-scalabl
 // When removing this Nightly flag, also remember to remove the flags surrounding this feature
 // in GeckoPreferences and BrowserApp (see bug 1245930).
 #ifdef NIGHTLY_BUILD
 pref("ui.bookmark.mobilefolder.enabled", true);
 #else
 pref("ui.bookmark.mobilefolder.enabled", false);
 #endif
 
+#if MOZ_UPDATE_CHANNEL == nightly
+pref("mma.enabled", true);
+#elif MOZ_UPDATE_CHANNEL == beta
+pref("mma.enabled", true);
+#else
+pref("mma.enabled", true);
+#endif
+
+
 pref("ui.touch.radius.enabled", false);
 pref("ui.touch.radius.leftmm", 3);
 pref("ui.touch.radius.topmm", 5);
 pref("ui.touch.radius.rightmm", 3);
 pref("ui.touch.radius.bottommm", 2);
 pref("ui.touch.radius.visitedWeight", 120);
 
 pref("ui.mouse.radius.enabled", false);
--- a/mobile/android/base/java/org/mozilla/gecko/mma/MmaDelegate.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaDelegate.java
@@ -9,19 +9,24 @@ package org.mozilla.gecko.mma;
 import android.app.Application;
 import android.content.Context;
 
 import org.mozilla.gecko.MmaConstants;
 
 
 public class MmaDelegate {
 
+    private static final String ENABLE_PREF = "mma.enabled";
+
     private static MmaInterface mmaHelper = MmaConstants.getMma();
 
+    private static final String[] prefs = { ENABLE_PREF };
+
+
     public static void init(Application application) {
-        mmaHelper.init(application);
+        setupPrefHandler(application);
     }
 
-    public void start(Context context) {
-        mmaHelper.start(context);
+    public static void stop() {
+        mmaHelper.stop();
     }
 
 }
--- a/mobile/android/base/java/org/mozilla/gecko/mma/MmaInterface.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaInterface.java
@@ -14,9 +14,10 @@ public interface MmaInterface {
     void init(Application application);
 
     void start(Context context);
 
     void track(String leanplumEvent);
 
     void track(String leanplumEvent, double value);
 
+    void stop();
 }
--- a/mobile/android/base/java/org/mozilla/gecko/mma/MmaLeanplumImp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaLeanplumImp.java
@@ -44,9 +44,14 @@ public class MmaLeanplumImp implements M
 
     }
 
     @Override
     public void track(String leanplumEvent, double value) {
         Leanplum.track(leanplumEvent, value);
 
     }
+
+    @Override
+    public void stop() {
+        Leanplum.stop();
+    }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/mma/MmaStubImp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaStubImp.java
@@ -25,9 +25,14 @@ public class MmaStubImp implements MmaIn
     public void track(String leanplumEvent) {
 
     }
 
     @Override
     public void track(String leanplumEvent, double value) {
 
     }
+
+    @Override
+    public void stop() {
+
+    }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
+++ b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
@@ -25,16 +25,17 @@ import org.mozilla.gecko.R;
 import org.mozilla.gecko.SnackbarBuilder;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.TelemetryContract.Method;
 import org.mozilla.gecko.activitystream.ActivityStream;
 import org.mozilla.gecko.db.BrowserContract.SuggestedSites;
 import org.mozilla.gecko.feeds.FeedService;
 import org.mozilla.gecko.feeds.action.CheckForUpdatesAction;
+import org.mozilla.gecko.mma.MmaDelegate;
 import org.mozilla.gecko.permissions.Permissions;
 import org.mozilla.gecko.restrictions.Restrictable;
 import org.mozilla.gecko.restrictions.Restrictions;
 import org.mozilla.gecko.tabqueue.TabQueueHelper;
 import org.mozilla.gecko.tabqueue.TabQueuePrompt;
 import org.mozilla.gecko.updater.UpdateService;
 import org.mozilla.gecko.updater.UpdateServiceHelper;
 import org.mozilla.gecko.util.BundleEventListener;
@@ -1192,16 +1193,19 @@ public class GeckoPreferences
             setCharEncodingState(((String) newValue).equals("true"));
         } else if (PREFS_UPDATER_AUTODOWNLOAD.equals(prefName)) {
             UpdateServiceHelper.setAutoDownloadPolicy(this, UpdateService.AutoDownloadPolicy.get((String) newValue));
         } else if (PREFS_UPDATER_URL.equals(prefName)) {
             UpdateServiceHelper.setUpdateUrl(this, (String) newValue);
         } else if (PREFS_HEALTHREPORT_UPLOAD_ENABLED.equals(prefName)) {
             final Boolean newBooleanValue = (Boolean) newValue;
             AdjustConstants.getAdjustHelper().setEnabled(newBooleanValue);
+            if (!newBooleanValue) {
+                MmaDelegate.stop();
+            }
         } else if (PREFS_GEO_REPORTING.equals(prefName)) {
             if ((Boolean) newValue) {
                 enableStumbler((CheckBoxPreference) preference);
                 return false;
             } else {
                 broadcastStumblerPref(GeckoPreferences.this, false);
                 return true;
             }
--- a/mobile/android/thirdparty/com/leanplum/Leanplum.java
+++ b/mobile/android/thirdparty/com/leanplum/Leanplum.java
@@ -1016,17 +1016,17 @@ public class Leanplum {
   private static void resumeHeartbeat() {
     startHeartbeat();
   }
 
   /**
    * Call this to explicitly end the session. This should not be used in most cases, so we won't
    * make it public for now.
    */
-  static void stop() {
+  public static void stop() {
     if (Constants.isNoop()) {
       return;
     }
     if (!LeanplumInternal.hasCalledStart()) {
       Log.e("You cannot call stop before calling start");
       return;
     }