Bug 1351585 - Part 5. Add build flag to inject mma implementation. r?maliu,sebastian,nalexander draft
authorcnevinc <cnevinc@livemail.tw>
Thu, 11 May 2017 23:48:53 -0700
changeset 577594 6f0f4dd642d34548fc4ce13a33b7b295bc0b25b7
parent 577593 e2e90f0f9bd2b0f8539a40106eeba8fa066b5cc6
child 628536 52c2f342514bb46ba45614c6ed2c84336666bf87
push id58727
push userbmo:cnevinchen@gmail.com
push dateMon, 15 May 2017 02:46:37 +0000
reviewersmaliu, sebastian, nalexander
bugs1351585
milestone55.0a1
Bug 1351585 - Part 5. Add build flag to inject mma implementation. r?maliu,sebastian,nalexander MozReview-Commit-ID: HEUPLEaE7tN
mobile/android/app/build.gradle
mobile/android/base/MmaConstants.java.in
mobile/android/base/generate_build_config.py
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/base/moz.build
mobile/android/geckoview/build.gradle
--- a/mobile/android/app/build.gradle
+++ b/mobile/android/app/build.gradle
@@ -159,16 +159,22 @@ android {
                 }
 
                 if (mozconfig.substs.MOZ_INSTALL_TRACKING) {
                     exclude 'org/mozilla/gecko/adjust/StubAdjustHelper.java'
                 } else {
                     exclude 'org/mozilla/gecko/adjust/AdjustHelper.java'
                 }
 
+                if (mozconfig.substs.MOZ_INSTALL_MMA) {
+                    exclude 'org/mozilla/gecko/mma/MmaStubImp.java'
+                } else {
+                    exclude 'org/mozilla/gecko/mma/MmaLeanplumImp.java'
+                }
+
                 if (!mozconfig.substs.MOZ_ANDROID_GCM) {
                     exclude 'org/mozilla/gecko/gcm/**/*.java'
                     exclude 'org/mozilla/gecko/push/**/*.java'
                 }
 
                 srcDir "${project.buildDir}/generated/source/preprocessed_code" // See syncPreprocessedCode.
             }
 
@@ -296,16 +302,17 @@ task checkstyle(type: Checkstyle) {
     classpath = files()
 }
 
 task syncPreprocessedCode(type: Sync, dependsOn: rootProject.generateCodeAndResources) {
     into("${project.buildDir}/generated/source/preprocessed_code")
     from("${topobjdir}/mobile/android/base/generated/preprocessed") {
         // All other preprocessed code is included in the geckoview project.
         include '**/AdjustConstants.java'
+        include '**/MmaConstants.java'
     }
 }
 
 // The localization system uses the moz.build preprocessor to interpolate a .dtd
 // file of XML entity definitions into an XML file of elements referencing those
 // entities.  (Each locale produces its own .dtd file, backstopped by the en-US
 // .dtd file in tree.)  Android Studio (and IntelliJ) don't handle these inline
 // entities smoothly.  This filter merely expands the entities in place, making
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/MmaConstants.java.in
@@ -0,0 +1,31 @@
+//#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;
+
+import org.mozilla.gecko.mma.MmaInterface;
+//#ifdef MOZ_INSTALL_MMA
+import org.mozilla.gecko.mma.MmaLeanplumImp;
+//#else
+import org.mozilla.gecko.mma.MmaStubImp;
+//#endif
+
+public class MmaConstants {
+    public static final String MOZ_INSTALL_MMA_SDK_APP_TOKEN =
+//#ifdef MOZ_INSTALL_MMA_SDK_APP_TOKEN
+    "@MOZ_INSTALL_MMA_SDK_APP_TOKEN@";
+//#else
+    null;
+//#endif
+
+    public static MmaInterface getMma() {
+//#ifdef MOZ_INSTALL_MMA
+        return new MmaLeanplumImp();
+//#else
+        return new MmaStubImp();
+//#endif
+    }
+}
--- a/mobile/android/base/generate_build_config.py
+++ b/mobile/android/base/generate_build_config.py
@@ -44,16 +44,17 @@ def _defines():
                 'MOZ_ANDROID_DOWNLOAD_CONTENT_SERVICE',
                 'MOZ_ANDROID_EXCLUDE_FONTS',
                 'MOZ_ANDROID_GCM',
                 'MOZ_ANDROID_MLS_STUMBLER',
                 'MOZ_ANDROID_SEARCH_ACTIVITY',
                 'MOZ_CRASHREPORTER',
                 'MOZ_DEBUG',
                 'MOZ_INSTALL_TRACKING',
+                'MOZ_INSTALL_MMA'
                 'MOZ_LOCALE_SWITCHER',
                 'MOZ_NATIVE_DEVICES',
                 'MOZ_SWITCHBOARD'):
         if CONFIG[var]:
             DEFINES[var] = 1
 
     for var in ('MOZ_ANDROID_GCM_SENDERID',
                 'MOZ_PKG_SPECIAL',
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -54,16 +54,17 @@ import org.mozilla.gecko.home.HomePager.
 import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
 import org.mozilla.gecko.home.HomePanelsManager;
 import org.mozilla.gecko.home.HomeScreen;
 import org.mozilla.gecko.home.SearchEngine;
 import org.mozilla.gecko.icons.Icons;
 import org.mozilla.gecko.media.VideoPlayer;
 import org.mozilla.gecko.menu.GeckoMenu;
 import org.mozilla.gecko.menu.GeckoMenuItem;
+import org.mozilla.gecko.mma.MmaDelegate;
 import org.mozilla.gecko.mozglue.GeckoLoader;
 import org.mozilla.gecko.mozglue.SafeIntent;
 import org.mozilla.gecko.notifications.NotificationHelper;
 import org.mozilla.gecko.overlays.ui.ShareDialog;
 import org.mozilla.gecko.permissions.Permissions;
 import org.mozilla.gecko.preferences.ClearOnShutdownPref;
 import org.mozilla.gecko.preferences.GeckoPreferences;
 import org.mozilla.gecko.promotion.AddToHomeScreenPromotion;
@@ -861,17 +862,17 @@ public class BrowserApp extends GeckoApp
         final String installerPackageName = getPackageManager().getInstallerPackageName(getPackageName());
         Telemetry.sendUIEvent(TelemetryContract.Event.LAUNCH, TelemetryContract.Method.SYSTEM, "installer_" + installerPackageName);
     }
 
     /**
      * Initializes the default Switchboard URLs the first time.
      * @param intent
      */
-    private static void initSwitchboard(final Context context, final SafeIntent intent, final boolean isInAutomation) {
+    private void initSwitchboard(final Context context, final SafeIntent intent, final boolean isInAutomation) {
         if (isInAutomation) {
             Log.d(LOGTAG, "Switchboard disabled - in automation");
             return;
         } else if (!AppConstants.MOZ_SWITCHBOARD) {
             Log.d(LOGTAG, "Switchboard compile-time disabled");
             return;
         }
 
@@ -879,16 +880,17 @@ public class BrowserApp extends GeckoApp
         final String serverUrl = TextUtils.isEmpty(serverExtra) ? SWITCHBOARD_SERVER : serverExtra;
         new AsyncConfigLoader(context, serverUrl) {
             @Override
             protected Void doInBackground(Void... params) {
                 super.doInBackground(params);
                 if (SwitchBoard.isInExperiment(context, Experiments.LEANPLUM) &&
                         GeckoPreferences.getBooleanPref(context, GeckoPreferences.PREFS_HEALTHREPORT_UPLOAD_ENABLED, true)) {
                     // Do LeanPlum start/init here
+                    MmaDelegate.init(BrowserApp.this.getApplication());
                 }
                 return null;
             }
         }.execute();
     }
 
     private static void initTelemetryUploader(final boolean isInAutomation) {
         TelemetryUploadService.setDisabled(isInAutomation);
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaDelegate.java
@@ -0,0 +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.Application;
+import android.content.Context;
+
+import org.mozilla.gecko.MmaConstants;
+
+
+public class MmaDelegate {
+
+    private static MmaInterface mmaHelper = MmaConstants.getMma();
+
+    public static String FIRST_RUN = "First Run";
+    public static String SECOND_RUN = "Second Run";
+    public static String OPENED_APP = "Opened App";
+    public static String OPENED_LOGIN_MANAGER = "Opened Login Manager";
+    public static String OPENED_BOOKMARK = "Opened Bookmark";
+    public static String OPENED_NEW_TAB = "Opened New Tab";
+    public static String INTERACT_WITH_SEARCH_URL_AREA = "Interact With Search URL Area";
+    public static String SAVED_BOOKMARK = "saved bookmark";
+    public static String OPENED_TELEPHONE_LINK = "Opened Telephone Link";
+    public static String OPENED_MAILTO_LINK = "Opened Mailto Link";
+    public static String SAVED_IMAGE = "Download Media - Saved Image";
+    public static String CLEAR_PRIVATE_DATA = "Closed Private Tabs When Leaving Private Browsing";
+    public static String CLOSED_PRIVATE_TABS = "Closed Private Tabs";
+    public static String SAVED_LOGIN_AND_PASSWORD = "Saved Login and Password";
+
+    public static void init(Application application) {
+        mmaHelper.init(application);
+    }
+
+    public void start(Context context) {
+        mmaHelper.start(context);
+    }
+
+}
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaInterface.java
@@ -0,0 +1,17 @@
+//#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.Application;
+import android.content.Context;
+
+
+public interface MmaInterface {
+    void init(Application application);
+
+    void start(Context context);
+
+}
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaLeanplumImp.java
@@ -0,0 +1,20 @@
+//#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.Application;
+import android.content.Context;
+
+
+public class MmaLeanplumImp implements MmaInterface {
+    @Override public void init(Application application) {
+
+    }
+
+    @Override public void start(Context context) {
+
+    }
+}
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaStubImp.java
@@ -0,0 +1,20 @@
+//#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.Application;
+import android.content.Context;
+
+
+public class MmaStubImp implements MmaInterface {
+    @Override public void init(Application application) {
+
+    }
+
+    @Override public void start(Context context) {
+
+    }
+}
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -114,26 +114,32 @@ with Files('resources/menu/browsersearch
 
 DIRS += ['locales']
 
 GENERATED_FILES += [
     '../geckoview/generated/preprocessed/org/mozilla/geckoview/BuildConfig.java',
     'AndroidManifest.xml',
     'generated/preprocessed/org/mozilla/gecko/AdjustConstants.java',
     'generated/preprocessed/org/mozilla/gecko/AppConstants.java',
+    'generated/preprocessed/org/mozilla/gecko/MmaConstants.java',
 ]
 w = GENERATED_FILES['../geckoview/generated/preprocessed/org/mozilla/geckoview/BuildConfig.java']
 w.script = 'generate_build_config.py:generate_java'
 w.inputs += ['../geckoview/BuildConfig.java.in']
 x = GENERATED_FILES['generated/preprocessed/org/mozilla/gecko/AdjustConstants.java']
 x.script = 'generate_build_config.py:generate_java'
 x.inputs += ['AdjustConstants.java.in']
 y = GENERATED_FILES['generated/preprocessed/org/mozilla/gecko/AppConstants.java']
 y.script = 'generate_build_config.py:generate_java'
 y.inputs += ['AppConstants.java.in']
+
+y1 = GENERATED_FILES['generated/preprocessed/org/mozilla/gecko/MmaConstants.java']
+y1.script = 'generate_build_config.py:generate_java'
+y1.inputs += ['MmaConstants.java.in']
+
 z = GENERATED_FILES['AndroidManifest.xml']
 z.script = 'generate_build_config.py:generate_android_manifest'
 z.inputs += ['AndroidManifest.xml.in']
 
 include('android-services.mozbuild')
 
 geckoview_source_dir = TOPSRCDIR + '/mobile/android/geckoview/src/main/'
 geckoview_thirdparty_source_dir = TOPSRCDIR + '/mobile/android/geckoview/src/thirdparty/'
@@ -149,21 +155,23 @@ constants_jar.sources += [geckoview_sour
     'SysInfo.java',
 ]]
 constants_jar.sources += ['java/org/mozilla/gecko/' + x for x in [
     'adjust/AdjustHelperInterface.java',
     'adjust/AttributionHelperListener.java',
     'db/BrowserContract.java',
     'LocaleManager.java',
     'Locales.java',
+    'mma/MmaInterface.java',
 ]]
 constants_jar.generated_sources = [
     '../geckoview/generated/preprocessed/org/mozilla/geckoview/BuildConfig.java',
     'generated/preprocessed/org/mozilla/gecko/AdjustConstants.java',
     'generated/preprocessed/org/mozilla/gecko/AppConstants.java',
+    'generated/preprocessed/org/mozilla/gecko/MmaConstants.java',
 ]
 constants_jar.extra_jars = [
     CONFIG['ANDROID_SUPPORT_ANNOTATIONS_JAR_LIB'],
     CONFIG['ANDROID_SUPPORT_V4_AAR_LIB'],
     CONFIG['ANDROID_SUPPORT_V4_AAR_INTERNAL_LIB'],
     CONFIG['ANDROID_APPCOMPAT_V7_AAR_LIB'],
 ]
 
@@ -174,16 +182,27 @@ if CONFIG['MOZ_INSTALL_TRACKING']:
     constants_jar.extra_jars += [
         'gecko-thirdparty-adjust_sdk.jar',
     ]
 else:
     constants_jar.sources += ['java/org/mozilla/gecko/' + x for x in [
         'adjust/StubAdjustHelper.java',
     ]]
 
+if CONFIG['MOZ_INSTALL_MMA']:
+    constants_jar.sources += ['java/org/mozilla/gecko/' + x for x in [
+        'mma/MmaLeanplumImp.java',
+    ]]
+    constants_jar.extra_jars += [
+        'gecko-thirdparty-leanplum_sdk.jar'
+    ]
+else:
+    constants_jar.sources += ['java/org/mozilla/gecko/' + x for x in [
+        'mma/MmaStubImp.java',
+    ]]
 
 resjar = add_java_jar('gecko-R')
 resjar.sources = []
 resjar.generated_sources += [
     'generated/org/mozilla/gecko/R.java',
 ]
 
 if CONFIG['ANDROID_SUPPORT_V4_AAR']:
@@ -741,16 +760,17 @@ gbjar.sources += ['java/org/mozilla/geck
     'menu/GeckoMenuInflater.java',
     'menu/GeckoMenuItem.java',
     'menu/GeckoSubMenu.java',
     'menu/MenuItemActionBar.java',
     'menu/MenuItemDefault.java',
     'menu/MenuItemSwitcherLayout.java',
     'menu/MenuPanel.java',
     'menu/MenuPopup.java',
+    'mma/MmaDelegate.java',
     'MotionEventInterceptor.java',
     'notifications/NotificationClient.java',
     'notifications/NotificationHelper.java',
     'notifications/NotificationReceiver.java',
     'notifications/NotificationService.java',
     'notifications/WhatsNewReceiver.java',
     'overlays/OverlayConstants.java',
     'overlays/service/OverlayActionService.java',
@@ -970,17 +990,16 @@ gbjar.sources += ['java/org/mozilla/geck
 ]]
 android_package_dir = CONFIG['ANDROID_PACKAGE_NAME'].replace('.', '/')
 gbjar.generated_sources = [] # Keep it this way.
 gbjar.extra_jars += [
     CONFIG['ANDROID_SUPPORT_ANNOTATIONS_JAR_LIB'],
     CONFIG['ANDROID_SUPPORT_V4_AAR_LIB'],
     CONFIG['ANDROID_SUPPORT_V4_AAR_INTERNAL_LIB'],
     'constants.jar',
-    'gecko-thirdparty-leanplum_sdk.jar'
 ]
 if CONFIG['MOZ_CRASHREPORTER']:
     gbjar.sources += [ 'java/org/mozilla/gecko/CrashReporter.java' ]
     ANDROID_RES_DIRS += [ 'crashreporter/res' ]
 
 if CONFIG['MOZ_ANDROID_GCM']:
     gbjar.sources += ['java/org/mozilla/gecko/' + x for x in [
         'gcm/GcmInstanceIDListenerService.java',
@@ -1206,130 +1225,130 @@ if CONFIG['MOZ_INSTALL_TRACKING']:
         'com/adjust/sdk/UnitTestActivity.java',
         'com/adjust/sdk/Util.java'
     ] ]
     adjustjar.extra_jars += [
         'sync-thirdparty.jar',
     ]
 
 
-
-lpjar = add_java_jar('gecko-thirdparty-leanplum_sdk')
-lpjar.sources += [ thirdparty_source_dir + f for f in [
-    'com/leanplum/ActionArgs.java',
-    'com/leanplum/ActionContext.java',
-    'com/leanplum/activities/LeanplumAccountAuthenticatorActivity.java',
-    'com/leanplum/activities/LeanplumActionBarActivity.java',
-    'com/leanplum/activities/LeanplumActivity.java',
-    'com/leanplum/activities/LeanplumActivityGroup.java',
-    'com/leanplum/activities/LeanplumAliasActivity.java',
-    'com/leanplum/activities/LeanplumAppCompatActivity.java',
-    'com/leanplum/activities/LeanplumExpandableListActivity.java',
-    'com/leanplum/activities/LeanplumFragmentActivity.java',
-    'com/leanplum/activities/LeanplumLauncherActivity.java',
-    'com/leanplum/activities/LeanplumListActivity.java',
-    'com/leanplum/activities/LeanplumNativeActivity.java',
-    'com/leanplum/activities/LeanplumPreferenceActivity.java',
-    'com/leanplum/activities/LeanplumTabActivity.java',
-    'com/leanplum/annotations/File.java',
-    'com/leanplum/annotations/Parser.java',
-    'com/leanplum/annotations/Variable.java',
-    'com/leanplum/CacheUpdateBlock.java',
-    'com/leanplum/callbacks/ActionCallback.java',
-    'com/leanplum/callbacks/InboxChangedCallback.java',
-    'com/leanplum/callbacks/NewsfeedChangedCallback.java',
-    'com/leanplum/callbacks/PostponableAction.java',
-    'com/leanplum/callbacks/RegisterDeviceCallback.java',
-    'com/leanplum/callbacks/RegisterDeviceFinishedCallback.java',
-    'com/leanplum/callbacks/StartCallback.java',
-    'com/leanplum/callbacks/VariableCallback.java',
-    'com/leanplum/callbacks/VariablesChangedCallback.java',
-    'com/leanplum/internal/ActionArg.java',
-    'com/leanplum/internal/ActionManager.java',
-    'com/leanplum/internal/AESCrypt.java',
-    'com/leanplum/internal/BaseActionContext.java',
-    'com/leanplum/internal/CollectionUtil.java',
-    'com/leanplum/internal/Constants.java',
-    'com/leanplum/internal/FileManager.java',
-    'com/leanplum/internal/HybiParser.java',
-    'com/leanplum/internal/JsonConverter.java',
-    'com/leanplum/internal/LeanplumInternal.java',
-    'com/leanplum/internal/LeanplumManifestHelper.java',
-    'com/leanplum/internal/LeanplumManifestParser.java',
-    'com/leanplum/internal/LeanplumMessageMatchFilter.java',
-    'com/leanplum/internal/LeanplumUIEditorWrapper.java',
-    'com/leanplum/internal/Log.java',
-    'com/leanplum/internal/OsHandler.java',
-    'com/leanplum/internal/Registration.java',
-    'com/leanplum/internal/Request.java',
-    'com/leanplum/internal/RequestFactory.java',
-    'com/leanplum/internal/ResourceQualifiers.java',
-    'com/leanplum/internal/Socket.java',
-    'com/leanplum/internal/SocketIOClient.java',
-    'com/leanplum/internal/Util.java',
-    'com/leanplum/internal/VarCache.java',
-    'com/leanplum/internal/WebSocketClient.java',
-    'com/leanplum/Leanplum.java',
-    'com/leanplum/LeanplumActivityHelper.java',
-    'com/leanplum/LeanplumApplication.java',
-    'com/leanplum/LeanplumCloudMessagingProvider.java',
-    'com/leanplum/LeanplumDeviceIdMode.java',
-    'com/leanplum/LeanplumEditorMode.java',
-    'com/leanplum/LeanplumException.java',
-    'com/leanplum/LeanplumGcmProvider.java',
-    'com/leanplum/LeanplumInbox.java',
-    'com/leanplum/LeanplumInboxMessage.java',
-    'com/leanplum/LeanplumInflater.java',
-    'com/leanplum/LeanplumLocalPushListenerService.java',
-    'com/leanplum/LeanplumLocationAccuracyType.java',
-    'com/leanplum/LeanplumManualProvider.java',
-    'com/leanplum/LeanplumPushInstanceIDService.java',
-    'com/leanplum/LeanplumPushListenerService.java',
-    'com/leanplum/LeanplumPushNotificationCustomizer.java',
-    'com/leanplum/LeanplumPushReceiver.java',
-    'com/leanplum/LeanplumPushRegistrationService.java',
-    'com/leanplum/LeanplumPushService.java',
-    'com/leanplum/LeanplumResources.java',
-    'com/leanplum/LeanplumUIEditor.java',
-    'com/leanplum/LocationManager.java',
-    'com/leanplum/messagetemplates/Alert.java',
-    'com/leanplum/messagetemplates/BaseMessageDialog.java',
-    'com/leanplum/messagetemplates/BaseMessageOptions.java',
-    'com/leanplum/messagetemplates/CenterPopup.java',
-    'com/leanplum/messagetemplates/CenterPopupOptions.java',
-    'com/leanplum/messagetemplates/Confirm.java',
-    'com/leanplum/messagetemplates/HTMLOptions.java',
-    'com/leanplum/messagetemplates/HTMLTemplate.java',
-    'com/leanplum/messagetemplates/Interstitial.java',
-    'com/leanplum/messagetemplates/InterstitialOptions.java',
-    'com/leanplum/messagetemplates/MessageTemplates.java',
-    'com/leanplum/messagetemplates/OpenURL.java',
-    'com/leanplum/messagetemplates/WebInterstitial.java',
-    'com/leanplum/messagetemplates/WebInterstitialOptions.java',
-    'com/leanplum/Newsfeed.java',
-    'com/leanplum/NewsfeedMessage.java',
-    'com/leanplum/UIEditorBridge.java',
-    'com/leanplum/utils/BitmapUtil.java',
-    'com/leanplum/utils/SharedPreferencesUtil.java',
-    'com/leanplum/utils/SizeUtil.java',
-    'com/leanplum/Var.java',
-    'com/leanplum/views/BackgroundImageView.java',
-    'com/leanplum/views/CloseButton.java',
-] ]
-lpjar.extra_jars += [
-    CONFIG['ANDROID_PLAY_SERVICES_BASE_AAR_LIB'],
-    CONFIG['ANDROID_PLAY_SERVICES_BASEMENT_AAR_LIB'],
-    CONFIG['ANDROID_PLAY_SERVICES_GCM_AAR_LIB'],
-    CONFIG['ANDROID_SUPPORT_ANNOTATIONS_JAR_LIB'],
-    CONFIG['ANDROID_SUPPORT_V4_AAR_LIB'],
-    CONFIG['ANDROID_SUPPORT_V4_AAR_INTERNAL_LIB'],
-    CONFIG['ANDROID_APPCOMPAT_V7_AAR_LIB'],
-    CONFIG['ANDROID_PLAY_SERVICES_ADS_AAR_LIB'],
-    'sync-thirdparty.jar',
-]
+if CONFIG['MOZ_INSTALL_MMA']:
+    lpjar = add_java_jar('gecko-thirdparty-leanplum_sdk')
+    lpjar.sources += [ thirdparty_source_dir + f for f in [
+        'com/leanplum/ActionArgs.java',
+        'com/leanplum/ActionContext.java',
+        'com/leanplum/activities/LeanplumAccountAuthenticatorActivity.java',
+        'com/leanplum/activities/LeanplumActionBarActivity.java',
+        'com/leanplum/activities/LeanplumActivity.java',
+        'com/leanplum/activities/LeanplumActivityGroup.java',
+        'com/leanplum/activities/LeanplumAliasActivity.java',
+        'com/leanplum/activities/LeanplumAppCompatActivity.java',
+        'com/leanplum/activities/LeanplumExpandableListActivity.java',
+        'com/leanplum/activities/LeanplumFragmentActivity.java',
+        'com/leanplum/activities/LeanplumLauncherActivity.java',
+        'com/leanplum/activities/LeanplumListActivity.java',
+        'com/leanplum/activities/LeanplumNativeActivity.java',
+        'com/leanplum/activities/LeanplumPreferenceActivity.java',
+        'com/leanplum/activities/LeanplumTabActivity.java',
+        'com/leanplum/annotations/File.java',
+        'com/leanplum/annotations/Parser.java',
+        'com/leanplum/annotations/Variable.java',
+        'com/leanplum/CacheUpdateBlock.java',
+        'com/leanplum/callbacks/ActionCallback.java',
+        'com/leanplum/callbacks/InboxChangedCallback.java',
+        'com/leanplum/callbacks/NewsfeedChangedCallback.java',
+        'com/leanplum/callbacks/PostponableAction.java',
+        'com/leanplum/callbacks/RegisterDeviceCallback.java',
+        'com/leanplum/callbacks/RegisterDeviceFinishedCallback.java',
+        'com/leanplum/callbacks/StartCallback.java',
+        'com/leanplum/callbacks/VariableCallback.java',
+        'com/leanplum/callbacks/VariablesChangedCallback.java',
+        'com/leanplum/internal/ActionArg.java',
+        'com/leanplum/internal/ActionManager.java',
+        'com/leanplum/internal/AESCrypt.java',
+        'com/leanplum/internal/BaseActionContext.java',
+        'com/leanplum/internal/CollectionUtil.java',
+        'com/leanplum/internal/Constants.java',
+        'com/leanplum/internal/FileManager.java',
+        'com/leanplum/internal/HybiParser.java',
+        'com/leanplum/internal/JsonConverter.java',
+        'com/leanplum/internal/LeanplumInternal.java',
+        'com/leanplum/internal/LeanplumManifestHelper.java',
+        'com/leanplum/internal/LeanplumManifestParser.java',
+        'com/leanplum/internal/LeanplumMessageMatchFilter.java',
+        'com/leanplum/internal/LeanplumUIEditorWrapper.java',
+        'com/leanplum/internal/Log.java',
+        'com/leanplum/internal/OsHandler.java',
+        'com/leanplum/internal/Registration.java',
+        'com/leanplum/internal/Request.java',
+        'com/leanplum/internal/RequestFactory.java',
+        'com/leanplum/internal/ResourceQualifiers.java',
+        'com/leanplum/internal/Socket.java',
+        'com/leanplum/internal/SocketIOClient.java',
+        'com/leanplum/internal/Util.java',
+        'com/leanplum/internal/VarCache.java',
+        'com/leanplum/internal/WebSocketClient.java',
+        'com/leanplum/Leanplum.java',
+        'com/leanplum/LeanplumActivityHelper.java',
+        'com/leanplum/LeanplumApplication.java',
+        'com/leanplum/LeanplumCloudMessagingProvider.java',
+        'com/leanplum/LeanplumDeviceIdMode.java',
+        'com/leanplum/LeanplumEditorMode.java',
+        'com/leanplum/LeanplumException.java',
+        'com/leanplum/LeanplumGcmProvider.java',
+        'com/leanplum/LeanplumInbox.java',
+        'com/leanplum/LeanplumInboxMessage.java',
+        'com/leanplum/LeanplumInflater.java',
+        'com/leanplum/LeanplumLocalPushListenerService.java',
+        'com/leanplum/LeanplumLocationAccuracyType.java',
+        'com/leanplum/LeanplumManualProvider.java',
+        'com/leanplum/LeanplumPushInstanceIDService.java',
+        'com/leanplum/LeanplumPushListenerService.java',
+        'com/leanplum/LeanplumPushNotificationCustomizer.java',
+        'com/leanplum/LeanplumPushReceiver.java',
+        'com/leanplum/LeanplumPushRegistrationService.java',
+        'com/leanplum/LeanplumPushService.java',
+        'com/leanplum/LeanplumResources.java',
+        'com/leanplum/LeanplumUIEditor.java',
+        'com/leanplum/LocationManager.java',
+        'com/leanplum/messagetemplates/Alert.java',
+        'com/leanplum/messagetemplates/BaseMessageDialog.java',
+        'com/leanplum/messagetemplates/BaseMessageOptions.java',
+        'com/leanplum/messagetemplates/CenterPopup.java',
+        'com/leanplum/messagetemplates/CenterPopupOptions.java',
+        'com/leanplum/messagetemplates/Confirm.java',
+        'com/leanplum/messagetemplates/HTMLOptions.java',
+        'com/leanplum/messagetemplates/HTMLTemplate.java',
+        'com/leanplum/messagetemplates/Interstitial.java',
+        'com/leanplum/messagetemplates/InterstitialOptions.java',
+        'com/leanplum/messagetemplates/MessageTemplates.java',
+        'com/leanplum/messagetemplates/OpenURL.java',
+        'com/leanplum/messagetemplates/WebInterstitial.java',
+        'com/leanplum/messagetemplates/WebInterstitialOptions.java',
+        'com/leanplum/Newsfeed.java',
+        'com/leanplum/NewsfeedMessage.java',
+        'com/leanplum/UIEditorBridge.java',
+        'com/leanplum/utils/BitmapUtil.java',
+        'com/leanplum/utils/SharedPreferencesUtil.java',
+        'com/leanplum/utils/SizeUtil.java',
+        'com/leanplum/Var.java',
+        'com/leanplum/views/BackgroundImageView.java',
+        'com/leanplum/views/CloseButton.java',
+    ] ]
+    lpjar.extra_jars += [
+        CONFIG['ANDROID_PLAY_SERVICES_BASE_AAR_LIB'],
+        CONFIG['ANDROID_PLAY_SERVICES_BASEMENT_AAR_LIB'],
+        CONFIG['ANDROID_PLAY_SERVICES_GCM_AAR_LIB'],
+        CONFIG['ANDROID_SUPPORT_ANNOTATIONS_JAR_LIB'],
+        CONFIG['ANDROID_SUPPORT_V4_AAR_LIB'],
+        CONFIG['ANDROID_SUPPORT_V4_AAR_INTERNAL_LIB'],
+        CONFIG['ANDROID_APPCOMPAT_V7_AAR_LIB'],
+        CONFIG['ANDROID_PLAY_SERVICES_ADS_AAR_LIB'],
+        'sync-thirdparty.jar',
+    ]
 
 # Putting branding earlier allows branders to override default resources.
 ANDROID_RES_DIRS += [
     '/' + CONFIG['MOZ_BRANDING_DIRECTORY'] + '/res',
     'resources',
     '/mobile/android/services/src/main/res',
     '!res',
 ]
--- a/mobile/android/geckoview/build.gradle
+++ b/mobile/android/geckoview/build.gradle
@@ -94,16 +94,17 @@ dependencies {
     compile "com.android.support:support-v4:${mozconfig.substs.ANDROID_SUPPORT_LIBRARY_VERSION}"
 }
 
 task syncPreprocessedCode(type: Sync, dependsOn: rootProject.generateCodeAndResources) {
     into("${project.buildDir}/generated/source/preprocessed_code")
     from("${topobjdir}/mobile/android/base/generated/preprocessed") {
         // AdjustConstants is included in the main app project.
         exclude '**/AdjustConstants.java'
+        exclude '**/MmaConstants.java'
     }
 }
 
 apply from: "${topsrcdir}/mobile/android/gradle/with_gecko_binaries.gradle"
 
 android.libraryVariants.all { variant ->
     variant.preBuild.dependsOn syncPreprocessedCode