Backed out changeset f54fb8956671 (bug 1361664) so bug 1358117 can be backed out. r=backout
authorSebastian Hengst <archaeopteryx@coole-files.de>
Fri, 26 May 2017 13:41:23 +0200
changeset 360809 11de121a061f10049f0c4bb63498722d237efe1e
parent 360808 48b319f9d3f25088d45ba7b3bfdda0e57eb6ea8b
child 360810 5a8db189930cedc0ec845ced1970837c187b9003
push id31902
push userryanvm@gmail.com
push dateFri, 26 May 2017 19:43:26 +0000
treeherdermozilla-central@ba1a33add29d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1361664, 1358117
milestone55.0a1
backs outf54fb8956671dfe852517bfaac7e173e8d0ae195
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
Backed out changeset f54fb8956671 (bug 1361664) so bug 1358117 can be backed out. r=backout
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
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/thirdparty/com/leanplum/LeanplumActivityHelper.java
--- 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/mma/MmaDelegate.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaDelegate.java
@@ -1,64 +1,32 @@
 //#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.util.Log;
+import android.app.Application;
+import android.content.Context;
 
 import org.mozilla.gecko.MmaConstants;
-import org.mozilla.gecko.PrefsHelper;
 
 
 public class MmaDelegate {
 
-    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 final String ENABLE_PREF = "mma.enabled";
+
+    private static MmaInterface mmaHelper = MmaConstants.getMma();
+
+    private static final String[] prefs = { ENABLE_PREF };
 
 
-    private static boolean isGeckoPrefOn = false;
-    private static MmaInterface mmaHelper = MmaConstants.getMma();
-
-
-    public static void init(Activity activity) {
-        setupPrefHandler(activity);
+    public static void init(Application application) {
+        setupPrefHandler(application);
     }
 
     public static void stop() {
         mmaHelper.stop();
     }
 
-    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 (isGeckoPrefOn) {
-            mmaHelper.track(event);
-        }
-    }
-
-    public static void track(String event, long value) {
-        if (isGeckoPrefOn) {
-            mmaHelper.track(event, value);
-        }
-    }
 }
--- 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,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 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,58 +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 com.leanplum.Leanplum;
 import com.leanplum.LeanplumActivityHelper;
 import com.leanplum.annotations.Parser;
 
-import org.mozilla.gecko.ActivityHandlerHelper;
 import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.MmaConstants;
-import org.mozilla.gecko.util.ContextUtils;
-
-import java.util.HashMap;
-import java.util.Map;
 
 
 public class MmaLeanplumImp implements MmaInterface {
     @Override
-    public void init(Activity activity) {
-        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);
-        Leanplum.track("Launch");
-        // this is special to Leanplum. Since we defer LeanplumActivityHelper's onResume call till
-        // switchboard completes loading, we manually call it here.
-        LeanplumActivityHelper.onResume(activity);
+        Leanplum.start(application);
     }
 
     @Override
     public void start(Context context) {
 
     }
 
     @Override
--- 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) {
 
     }
 
--- 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();