merge mozilla-central to mozilla-inbound. r=merge a=merge
authorSebastian Hengst <archaeopteryx@coole-files.de>
Sat, 27 May 2017 14:05:01 +0200
changeset 409130 2ba8ded0fe690cc55a55e574effff0d41daefaad
parent 409129 b37e4d256cd6c88b48b0223113375f889a748982 (current diff)
parent 409089 66c73b65bf2d02c59f361b89135dc56553c3e4eb (diff)
child 409131 3bfd7a30226705e59fad14d1708a973d72e2a668
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge, merge
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
merge mozilla-central to mozilla-inbound. r=merge a=merge
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -409,25 +409,16 @@ 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/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -890,17 +890,17 @@ public class BrowserApp extends GeckoApp
         new AsyncConfigLoader(context, serverUrl) {
             @Override
             protected Void doInBackground(Void... params) {
                 super.doInBackground(params);
                 SwitchBoard.loadConfig(context, serverUrl);
                 if (SwitchBoard.isInExperiment(context, Experiments.LEANPLUM) &&
                         GeckoPreferences.getBooleanPref(context, GeckoPreferences.PREFS_HEALTHREPORT_UPLOAD_ENABLED, true)) {
                     // Do LeanPlum start/init here
-                    MmaDelegate.init(BrowserApp.this);
+                    MmaDelegate.init(BrowserApp.this.getApplication());
                 }
                 return null;
             }
         }.execute();
     }
 
     private static void initTelemetryUploader(final boolean isInAutomation) {
         TelemetryUploadService.setDisabled(isInAutomation);
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -15,17 +15,16 @@ import org.mozilla.gecko.gfx.FullScreenS
 import org.mozilla.gecko.gfx.LayerView;
 import org.mozilla.gecko.health.HealthRecorder;
 import org.mozilla.gecko.health.SessionInformation;
 import org.mozilla.gecko.health.StubbedHealthRecorder;
 import org.mozilla.gecko.home.HomeConfig.PanelType;
 import org.mozilla.gecko.menu.GeckoMenu;
 import org.mozilla.gecko.menu.GeckoMenuInflater;
 import org.mozilla.gecko.menu.MenuPanel;
-import org.mozilla.gecko.mma.MmaDelegate;
 import org.mozilla.gecko.notifications.NotificationHelper;
 import org.mozilla.gecko.util.IntentUtils;
 import org.mozilla.gecko.mozglue.SafeIntent;
 import org.mozilla.gecko.mozglue.GeckoLoader;
 import org.mozilla.gecko.permissions.Permissions;
 import org.mozilla.gecko.preferences.ClearOnShutdownPref;
 import org.mozilla.gecko.preferences.GeckoPreferences;
 import org.mozilla.gecko.prompts.PromptService;
@@ -117,18 +116,16 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
 import static org.mozilla.gecko.Tabs.INTENT_EXTRA_SESSION_UUID;
 import static org.mozilla.gecko.Tabs.INTENT_EXTRA_TAB_ID;
 import static org.mozilla.gecko.Tabs.INVALID_TAB_ID;
-import static org.mozilla.gecko.mma.MmaDelegate.DOWNLOAD_VIDEOS_OR_ANY_OTHER_MEDIA;
-import static org.mozilla.gecko.mma.MmaDelegate.LOADS_ARTICLES;
 
 public abstract class GeckoApp extends GeckoActivity
                                implements AnchoredPopup.OnVisibilityChangeListener,
                                           BundleEventListener,
                                           ContextGetter,
                                           GeckoMenu.Callback,
                                           GeckoMenu.MenuPresenter,
                                           GeckoView.ContentListener,
@@ -868,25 +865,17 @@ public abstract class GeckoApp extends G
 
         } else if ("Update:Install".equals(event)) {
             UpdateServiceHelper.applyUpdate(this);
 
         } else if ("PluginHelper:playFlash".equals(event)) {
             final SharedPreferences prefs = getSharedPreferences();
             int count = prefs.getInt(PREFS_FLASH_USAGE, 0);
             prefs.edit().putInt(PREFS_FLASH_USAGE, ++count).apply();
-
-        } else if ("Mma:reader_available".equals(event)) {
-            MmaDelegate.track(LOADS_ARTICLES);
-
-        } else if ("Mma:web_save_media".equals(event) || "Mma:web_save_image".equals(event)) {
-            MmaDelegate.track(DOWNLOAD_VIDEOS_OR_ANY_OTHER_MEDIA);
-
         }
-
     }
 
     /**
      * To get a presenter which will response for text-selection. In preMarshmallow Android we want
      * to provide different UI action when user select a text. Text-selection class will uses this
      * presenter to trigger UI updating.
      *
      * @return a presenter which handle showing/hiding of action mode UI. return *null* if this
@@ -1402,19 +1391,16 @@ public abstract class GeckoApp extends G
             "Image:SetAs",
             null);
 
         getAppEventDispatcher().registerUiThreadListener(this,
             "Contact:Add",
             "DevToolsAuth:Scan",
             "DOMFullScreen:Start",
             "DOMFullScreen:Stop",
-            "Mma:reader_available",
-            "Mma:web_save_image",
-            "Mma:web_save_media",
             "Permissions:Data",
             "PrivateBrowsing:Data",
             "RuntimePermissions:Check",
             "Share:Text",
             "SystemUI:Visibility",
             "ToggleChrome:Focus",
             "ToggleChrome:Hide",
             "ToggleChrome:Show",
@@ -2453,19 +2439,16 @@ public abstract class GeckoApp extends G
             "Image:SetAs",
             null);
 
         getAppEventDispatcher().unregisterUiThreadListener(this,
             "Contact:Add",
             "DevToolsAuth:Scan",
             "DOMFullScreen:Start",
             "DOMFullScreen:Stop",
-            "Mma:reader_available",
-            "Mma:web_save_image",
-            "Mma:web_save_media",
             "Permissions:Data",
             "PrivateBrowsing:Data",
             "RuntimePermissions:Check",
             "Share:Text",
             "SystemUI:Visibility",
             "ToggleChrome:Focus",
             "ToggleChrome:Hide",
             "ToggleChrome:Show",
--- a/mobile/android/base/java/org/mozilla/gecko/Tabs.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tabs.java
@@ -16,21 +16,19 @@ import android.content.SharedPreferences
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
 
 import org.mozilla.gecko.annotation.JNITarget;
 import org.mozilla.gecko.annotation.RobocopTarget;
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.distribution.PartnerBrowserCustomizationsClient;
 import org.mozilla.gecko.gfx.LayerView;
-import org.mozilla.gecko.mma.MmaDelegate;
 import org.mozilla.gecko.mozglue.SafeIntent;
 import org.mozilla.gecko.notifications.WhatsNewReceiver;
 import org.mozilla.gecko.preferences.GeckoPreferences;
-import org.mozilla.gecko.promotion.AddToHomeScreenPromotion;
 import org.mozilla.gecko.reader.ReaderModeUtils;
 import org.mozilla.gecko.util.BundleEventListener;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.GeckoBundle;
 import org.mozilla.gecko.util.JavaUtil;
 import org.mozilla.gecko.util.ThreadUtils;
 import org.mozilla.gecko.webapps.WebAppActivity;
 
@@ -46,17 +44,16 @@ import android.net.Uri;
 import android.os.Handler;
 import android.provider.Browser;
 import android.support.annotation.UiThread;
 import android.support.v4.content.ContextCompat;
 import android.text.TextUtils;
 import android.util.Log;
 
 import static org.mozilla.gecko.Tab.TabType;
-import static org.mozilla.gecko.mma.MmaDelegate.VISITING_A_WEBSITE_WITH_MATCH_TO_PAST_HISTORY;
 
 public class Tabs implements BundleEventListener {
     private static final String LOGTAG = "GeckoTabs";
 
     public static final String INTENT_EXTRA_TAB_ID = "TabId";
     public static final String INTENT_EXTRA_SESSION_UUID = "SessionUUID";
     private static final String PRIVATE_TAB_INTENT_EXTRA = "private_tab";
 
@@ -1086,35 +1083,26 @@ public class Tabs implements BundleEvent
         EventDispatcher.getInstance().dispatch("Tab:Load", data);
 
         if (tabToSelect == null) {
             return null;
         }
 
         if (!delayLoad && !background) {
             selectTab(tabToSelect.getId());
-            tracking(url);
         }
 
         // Load favicon instantly for about:home page because it's already cached
         if (AboutPages.isBuiltinIconPage(url)) {
             tabToSelect.loadFavicon();
         }
 
-
         return tabToSelect;
     }
 
-    private void tracking(String url) {
-        AddToHomeScreenPromotion.URLHistory history = AddToHomeScreenPromotion.getHistoryForURL(mAppContext, url);
-        if (history != null && history.visits > 0) {
-            MmaDelegate.track(VISITING_A_WEBSITE_WITH_MATCH_TO_PAST_HISTORY, history.visits);
-        }
-    }
-
     /**
      * Opens a new tab and loads either about:home or, if PREFS_HOMEPAGE_FOR_EVERY_NEW_TAB is set,
      * the user's homepage.
      */
     public Tab addTab() {
         return loadUrl(getHomepageForNewTab(mAppContext), Tabs.LOADURL_NEW_TAB);
     }
 
--- a/mobile/android/base/java/org/mozilla/gecko/Telemetry.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Telemetry.java
@@ -6,28 +6,20 @@
 package org.mozilla.gecko;
 
 import org.mozilla.gecko.annotation.RobocopTarget;
 import org.mozilla.gecko.annotation.WrapForJNI;
 import org.mozilla.gecko.TelemetryContract.Event;
 import org.mozilla.gecko.TelemetryContract.Method;
 import org.mozilla.gecko.TelemetryContract.Reason;
 import org.mozilla.gecko.TelemetryContract.Session;
-import org.mozilla.gecko.mma.MmaDelegate;
 
 import android.os.SystemClock;
 import android.util.Log;
 
-import static org.mozilla.gecko.mma.MmaDelegate.INTERACT_WITH_SEARCH_URL_AREA;
-import static org.mozilla.gecko.mma.MmaDelegate.LOAD_BOOKMARK;
-import static org.mozilla.gecko.mma.MmaDelegate.SAVE_BOOKMARK;
-import static org.mozilla.gecko.mma.MmaDelegate.SAVE_PASSWORD;
-import static org.mozilla.gecko.mma.MmaDelegate.WHEN_USER_TAKE_A_SCREENSHOT;
-
-
 /**
  * All telemetry times are relative to one of two clocks:
  *
  * * Real time since the device was booted, including deep sleep. Use this
  *   as a substitute for wall clock.
  * * Uptime since the device was booted, excluding deep sleep. Use this to
  *   avoid timing a user activity when their phone is in their pocket!
  *
@@ -211,34 +203,16 @@ public class Telemetry {
         }
         if (GeckoThread.isRunning()) {
             nativeAddUiEvent(eventName, method.toString(), timestamp, extras);
         } else {
             GeckoThread.queueNativeCall(Telemetry.class, "nativeAddUiEvent",
                                         String.class, eventName, String.class, method.toString(),
                                         timestamp, String.class, extras);
         }
-        mappingMmaTracking(eventName, method, extras);
-    }
-
-    private static void mappingMmaTracking(String eventName, Method method, String extras) {
-        if (eventName == null || method == null || extras == null) {
-            return;
-        }
-        if (eventName.equalsIgnoreCase(Event.SAVE.toString()) && method == Method.MENU && extras.equals("bookmark")) {
-            MmaDelegate.track(SAVE_BOOKMARK);
-        } else if (eventName.equalsIgnoreCase(Event.LOAD_URL.toString()) && method == Method.LIST_ITEM && extras.equals("bookmarks")) {
-            MmaDelegate.track(LOAD_BOOKMARK);
-        } else if (eventName.equalsIgnoreCase(Event.SHOW.toString()) && method == Method.ACTIONBAR && extras.equals("urlbar-url")) {
-            MmaDelegate.track(INTERACT_WITH_SEARCH_URL_AREA);
-        } else if (eventName.equalsIgnoreCase(Event.SHARE.toString()) && method == Method.BUTTON && extras.equals("screenshot")) {
-            MmaDelegate.track(WHEN_USER_TAKE_A_SCREENSHOT);
-        } else if (eventName.equalsIgnoreCase(Event.ACTION.toString()) && method == Method.DOORHANGER && extras.equals("login-positive")) {
-            MmaDelegate.track(SAVE_PASSWORD);
-        }
     }
 
     public static void sendUIEvent(final Event event, final Method method, final long timestamp,
             final String extras) {
         sendUIEvent(event.toString(), method, timestamp, extras);
     }
 
     public static void sendUIEvent(final Event event, final Method method, final long timestamp) {
--- a/mobile/android/base/java/org/mozilla/gecko/mma/MmaDelegate.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaDelegate.java
@@ -1,102 +1,27 @@
 //#filter substitution
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.mma;
 
-import android.app.Activity;
+import android.app.Application;
 import android.content.Context;
-import android.util.Log;
 
-import org.mozilla.gecko.Experiments;
 import org.mozilla.gecko.MmaConstants;
-import org.mozilla.gecko.PrefsHelper;
-import org.mozilla.gecko.preferences.GeckoPreferences;
-import org.mozilla.gecko.switchboard.SwitchBoard;
-
-import java.lang.ref.WeakReference;
 
 
 public class MmaDelegate {
 
-    public static final String LOADS_ARTICLES = "Loads articles";
-    public static final String DOWNLOAD_VIDEOS_OR_ANY_OTHER_MEDIA = "Download videos or any other media";
-    public static final String CLEAR_PRIVATE_DATA = "Clear Private Data";
-    public static final String SAVE_BOOKMARK = "SaveBookmark";
-    public static final String LOAD_BOOKMARK = "LoadBookmark";
-    public static final String INTERACT_WITH_SEARCH_URL_AREA = "Interact with search url area";
-    public static final String WHEN_USER_TAKE_A_SCREENSHOT = "When user take a screenshot";
-    public static final String SAVE_PASSWORD = "SavePassword";
-    public static final String VISITING_A_WEBSITE_WITH_MATCH_TO_PAST_HISTORY = "Visiting a website with match to past history";
-    public static final String LAUNCH_BUT_NOT_DEFAULT_BROWSER = "Launch but not default browser";
-
+    private static MmaInterface mmaHelper = MmaConstants.getMma();
 
-    private static final String TAG = "MmaDelegate";
-    private static final String KEY_PREF_BOOLEAN_MMA_ENABLED = "mma.enabled";
-    private static final String[] PREFS = { KEY_PREF_BOOLEAN_MMA_ENABLED };
-
-
-    private static boolean isGeckoPrefOn = false;
-    private static MmaInterface mmaHelper = MmaConstants.getMma();
-    private static WeakReference<Context> applicationContext;
-
-    public static void init(Activity activity) {
-        applicationContext = new WeakReference<>(activity.getApplicationContext());
-        setupPrefHandler(activity);
-    }
-
-    public static void stop() {
-        mmaHelper.stop();
+    public static void init(Application application) {
+        mmaHelper.init(application);
     }
 
-    private static void setupPrefHandler(final Activity activity) {
-        PrefsHelper.PrefHandler handler = new PrefsHelper.PrefHandlerBase() {
-            @Override
-            public void prefValue(String pref, boolean value) {
-                if (pref.equals(KEY_PREF_BOOLEAN_MMA_ENABLED)) {
-                    Log.d(TAG, "prefValue() called with: pref = [" + pref + "], value = [" + value + "]");
-                    if (value) {
-                        mmaHelper.init(activity);
-                        isGeckoPrefOn = true;
-                    } else {
-                        isGeckoPrefOn = false;
-                    }
-                }
-            }
-        };
-        PrefsHelper.addObserver(PREFS, handler);
-    }
-
-
-    public static void track(String event) {
-        if (isMmaEnabled()) {
-            mmaHelper.track(event);
-        }
+    public void start(Context context) {
+        mmaHelper.start(context);
     }
 
-    public static void track(String event, long value) {
-        if (isMmaEnabled()) {
-            mmaHelper.track(event, value);
-        }
-    }
-
-    private static boolean isMmaEnabled() {
-        if (applicationContext == null) {
-            return false;
-        }
-
-        final Context context = applicationContext.get();
-        if (context == null) {
-            return false;
-        }
-
-        final boolean healthReport = GeckoPreferences.getBooleanPref(context, GeckoPreferences.PREFS_HEALTHREPORT_UPLOAD_ENABLED, true);
-        final boolean inExperiment = SwitchBoard.isInExperiment(context, Experiments.LEANPLUM);
-
-        return inExperiment && healthReport && isGeckoPrefOn;
-    }
-
-
 }
--- a/mobile/android/base/java/org/mozilla/gecko/mma/MmaInterface.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaInterface.java
@@ -1,24 +1,22 @@
 //#filter substitution
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.mma;
 
-import android.app.Activity;
 import android.app.Application;
 import android.content.Context;
 
 
 public interface MmaInterface {
-    void init(Activity Activity);
+    void init(Application application);
 
     void start(Context context);
 
-    void track(String mmaEvent);
+    void track(String leanplumEvent);
 
-    void track(String mmaEvent, double value);
+    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
@@ -1,80 +1,41 @@
 //#filter substitution
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.mma;
 
-import android.app.Activity;
+import android.app.Application;
 import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.net.Uri;
-import android.text.TextUtils;
 
 import com.leanplum.Leanplum;
 import com.leanplum.LeanplumActivityHelper;
+import com.leanplum.annotations.Parser;
 
 import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.MmaConstants;
-import org.mozilla.gecko.util.ContextUtils;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.mozilla.gecko.mma.MmaDelegate.LAUNCH_BUT_NOT_DEFAULT_BROWSER;
 
 
 public class MmaLeanplumImp implements MmaInterface {
     @Override
-    public void init(final Activity activity) {
-        if (activity == null) {
-            return;
-        }
-        Leanplum.setApplicationContext(activity.getApplicationContext());
-
-        LeanplumActivityHelper.enableLifecycleCallbacks(activity.getApplication());
+    public void init(Application application) {
+        Leanplum.setApplicationContext(application);
+        Parser.parseVariables(application);
+        LeanplumActivityHelper.enableLifecycleCallbacks(application);
 
         if (AppConstants.MOZILLA_OFFICIAL) {
             Leanplum.setAppIdForProductionMode(MmaConstants.MOZ_LEANPLUM_SDK_CLIENTID, MmaConstants.MOZ_LEANPLUM_SDK_KEY);
         } else {
             Leanplum.setAppIdForDevelopmentMode(MmaConstants.MOZ_LEANPLUM_SDK_CLIENTID, MmaConstants.MOZ_LEANPLUM_SDK_KEY);
         }
 
-        Map<String, Object> attributes = new HashMap<>();
-        boolean installedFocus = ContextUtils.isPackageInstalled(activity, "org.mozilla.focus");
-        boolean installedKlar = ContextUtils.isPackageInstalled(activity, "org.mozilla.klar");
-        if (installedFocus || installedKlar) {
-            attributes.put("focus", "installed");
-        }
-        Leanplum.start(activity, attributes);
-        if (!isDefaultBrowser(activity)) {
-            Leanplum.track(LAUNCH_BUT_NOT_DEFAULT_BROWSER);
-        }
-
-
-        // this is special to Leanplum. Since we defer LeanplumActivityHelper's onResume call till
-        // switchboard completes loading. We miss the call to LeanplumActivityHelper.onResume.
-        // So I manually call it here.
-        //
-        // There's a risk that if this is called after activity's onPause(Although I've
-        // tested it's seems okay). We  should require their SDK to separate activity call back with
-        // SDK initialization and Activity lifecycle in the future.
-        //
-        // I put it under runOnUiThread because in current Leanplum's SDK design, this should be run in main thread.
-        activity.runOnUiThread(new Runnable() {
-            @Override
-            public void run() {
-                LeanplumActivityHelper.onResume(activity);
-            }
-        });
+        Leanplum.start(application);
     }
 
     @Override
     public void start(Context context) {
 
     }
 
     @Override
@@ -83,26 +44,9 @@ public class MmaLeanplumImp implements M
 
     }
 
     @Override
     public void track(String leanplumEvent, double value) {
         Leanplum.track(leanplumEvent, value);
 
     }
-
-    @Override
-    public void stop() {
-        Leanplum.stop();
-    }
-
-    private boolean isDefaultBrowser(Context context) {
-        final Intent viewIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.mozilla.org"));
-        final ResolveInfo info = context.getPackageManager().resolveActivity(viewIntent, PackageManager.MATCH_DEFAULT_ONLY);
-        if (info == null) {
-            // No default is set
-            return false;
-        }
-
-        final String packageName = info.activityInfo.packageName;
-        return (TextUtils.equals(packageName, context.getPackageName()));
-    }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/mma/MmaStubImp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaStubImp.java
@@ -1,24 +1,23 @@
 //#filter substitution
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.mma;
 
-import android.app.Activity;
 import android.app.Application;
 import android.content.Context;
 
 
 public class MmaStubImp implements MmaInterface {
     @Override
-    public void init(Activity activity) {
+    public void init(Application application) {
 
     }
 
     @Override
     public void start(Context context) {
 
     }
 
@@ -26,14 +25,9 @@ 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,17 +25,16 @@ 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;
@@ -1193,19 +1192,16 @@ 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/base/java/org/mozilla/gecko/preferences/PrivateDataPreference.java
+++ b/mobile/android/base/java/org/mozilla/gecko/preferences/PrivateDataPreference.java
@@ -3,32 +3,28 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.preferences;
 
 import org.mozilla.gecko.EventDispatcher;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
-import org.mozilla.gecko.mma.MmaDelegate;
 import org.mozilla.gecko.util.GeckoBundle;
 
 import org.mozilla.gecko.icons.storage.DiskStorage;
 
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Set;
 
 import android.content.Context;
 import android.util.AttributeSet;
 import android.util.Log;
 
-import static org.mozilla.gecko.mma.MmaDelegate.CLEAR_PRIVATE_DATA;
-
-
 class PrivateDataPreference extends MultiPrefMultiChoicePreference {
     private static final String LOGTAG = "GeckoPrivateDataPreference";
     private static final String PREF_KEY_PREFIX = "private.data.";
 
     public PrivateDataPreference(Context context, AttributeSet attrs) {
         super(context, attrs);
     }
 
@@ -57,11 +53,10 @@ class PrivateDataPreference extends Mult
 
         if (values.contains("private.data.offlineApps")) {
             // Remove all icons from storage if removing "Offline website data" was selected.
             DiskStorage.get(getContext()).evictAll();
         }
 
         // clear private data in gecko
         EventDispatcher.getInstance().dispatch("Sanitize:ClearData", data);
-        MmaDelegate.track(CLEAR_PRIVATE_DATA);
     }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/promotion/AddToHomeScreenPromotion.java
+++ b/mobile/android/base/java/org/mozilla/gecko/promotion/AddToHomeScreenPromotion.java
@@ -31,17 +31,17 @@ import org.mozilla.gecko.util.ThreadUtil
 import java.lang.ref.WeakReference;
 
 import ch.boye.httpclientandroidlib.util.TextUtils;
 
 /**
  * Promote "Add to home screen" if user visits website often.
  */
 public class AddToHomeScreenPromotion extends TabsTrayVisibilityAwareDelegate implements Tabs.OnTabsChangedListener {
-    public static class URLHistory {
+    private static class URLHistory {
         public final long visits;
         public final long lastVisit;
 
         private URLHistory(long visits, long lastVisit) {
             this.visits = visits;
             this.lastVisit = lastVisit;
         }
     }
@@ -208,17 +208,17 @@ public class AddToHomeScreenPromotion ex
         return true;
     }
 
     protected boolean hasAcceptedOrDeclinedHomeScreenShortcut(Context context, String url) {
         final UrlAnnotations urlAnnotations = BrowserDB.from(context).getUrlAnnotations();
         return urlAnnotations.hasAcceptedOrDeclinedHomeScreenShortcut(context.getContentResolver(), url);
     }
 
-    public static URLHistory getHistoryForURL(Context context, String url) {
+    protected URLHistory getHistoryForURL(Context context, String url) {
         final GeckoProfile profile = GeckoProfile.get(context);
         final BrowserDB browserDB = BrowserDB.from(profile);
 
         Cursor cursor = null;
         try {
             cursor = browserDB.getHistoryForURL(context.getContentResolver(), url);
 
             if (cursor.moveToFirst()) {
--- a/mobile/android/chrome/content/Reader.js
+++ b/mobile/android/chrome/content/Reader.js
@@ -190,28 +190,21 @@ var Reader = {
     this._showSystemUI(true);
 
     // Only stop a reader session if the foreground viewer is not visible.
     UITelemetry.stopSession("reader.1", "", null);
 
     if (browser.isArticle) {
       showPageAction("drawable://reader", Strings.reader.GetStringFromName("readerView.enter"));
       UITelemetry.addEvent("show.1", "button", null, "reader_available");
-      this._sendMmaEvent("reader_available");
     } else {
       UITelemetry.addEvent("show.1", "button", null, "reader_unavailable");
     }
   },
 
-  _sendMmaEvent: function(event) {
-      WindowEventDispatcher.sendRequest({
-          type: "Mma:"+event,
-      });
-  },
-
   _showSystemUI: function(visibility) {
       WindowEventDispatcher.sendRequest({
           type: "SystemUI:Visibility",
           visible: visibility
       });
   },
 
   /**
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -883,25 +883,21 @@ var BrowserApp = {
       },
       icon: "drawable://ic_menu_share",
       menu: true,
       callback: function(aTarget) {
         UITelemetry.addEvent("action.1", "contextmenu", null, "web_share_image");
       }
     });
 
-
     NativeWindow.contextmenus.add(stringGetter("contextmenu.saveImage"),
       NativeWindow.contextmenus.imageSaveableContext,
       function(aTarget) {
         UITelemetry.addEvent("action.1", "contextmenu", null, "web_save_image");
         UITelemetry.addEvent("save.1", "contextmenu", null, "image");
-        WindowEventDispatcher.sendRequest({
-          type: "Mma:web_save_image",
-        });
 
         RuntimePermissions.waitForPermissions(RuntimePermissions.WRITE_EXTERNAL_STORAGE).then(function(permissionGranted) {
             if (!permissionGranted) {
                 return;
             }
 
             ContentAreaUtils.saveImageURL(aTarget.currentURI.spec, null, "SaveImageTitle",
                                           false, true, aTarget.ownerDocument.documentURIObject,
@@ -937,19 +933,16 @@ var BrowserApp = {
         } else if (aTarget instanceof HTMLAudioElement) {
           return Strings.browser.GetStringFromName("contextmenu.saveAudio");
         }
         return Strings.browser.GetStringFromName("contextmenu.saveVideo");
       }, NativeWindow.contextmenus.mediaSaveableContext,
       function(aTarget) {
         UITelemetry.addEvent("action.1", "contextmenu", null, "web_save_media");
         UITelemetry.addEvent("save.1", "contextmenu", null, "media");
-        WindowEventDispatcher.sendRequest({
-          type: "Mma:web_save_media",
-        });
 
         let url = aTarget.currentSrc || aTarget.src;
 
         let filePickerTitleKey;
         if (aTarget instanceof HTMLVideoElement) {
           if (aTarget.readyState == aTarget.HAVE_NOTHING) {
             filePickerTitleKey = "SaveMediaTitle";
           } else if (aTarget.videoWidth == 0 || aTarget.videoHeight == 0) {
--- 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.
    */
-  public static void stop() {
+  static void stop() {
     if (Constants.isNoop()) {
       return;
     }
     if (!LeanplumInternal.hasCalledStart()) {
       Log.e("You cannot call stop before calling start");
       return;
     }
 
--- a/mobile/android/thirdparty/com/leanplum/LeanplumActivityHelper.java
+++ b/mobile/android/thirdparty/com/leanplum/LeanplumActivityHelper.java
@@ -204,17 +204,17 @@ public class LeanplumActivityHelper {
       if (!registeredCallbacks) {
         onPause(activity);
       }
     } catch (Throwable t) {
       Util.handleException(t);
     }
   }
 
-  public static void onResume(Activity activity) {
+  private static void onResume(Activity activity) {
     isActivityPaused = false;
     currentActivity = activity;
     if (LeanplumInternal.isPaused() || LeanplumInternal.hasStartedInBackground()) {
       Leanplum.resume();
       LocationManager locationManager = ActionManager.getLocationManager();
       if (locationManager != null) {
         locationManager.updateGeofencing();
         locationManager.updateUserLocation();