fix 1b3f2cf0 o draft Bug 1351585 - Part 2. Change our existing build system to reference leanplum r?nalexander,maliu,sebastian draft
authorNick Alexander <nalexander@mozilla.com>
Mon, 15 May 2017 21:39:00 -0700
changeset 578523 703700a400767bdaf3e4f2ca55a42b6d540d4985
parent 578522 631494f37ff3dc14921a0130883fa0f3effc8e5a
child 628738 1f652f23f7ae83a766bac2424b45681a7da97f2a
push id58945
push usernalexander@mozilla.com
push dateTue, 16 May 2017 04:41:39 +0000
reviewersnalexander, maliu, sebastian
bugs1351585
milestone55.0a1
fix 1b3f2cf0 o draft Bug 1351585 - Part 2. Change our existing build system to reference leanplum r?nalexander,maliu,sebastian MozReview-Commit-ID: FMqSLg2TQHb
mobile/android/app/build.gradle
mobile/android/base/AndroidManifest.xml.in
mobile/android/base/Makefile.in
mobile/android/base/MmaAndroidManifest_services.xml.in
mobile/android/base/MmaConstants.java.in
mobile/android/base/generate_build_config.py
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,17 +159,17 @@ 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) {
+                if (mozconfig.substs.MOZ_ANDROID_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'
--- a/mobile/android/base/AndroidManifest.xml.in
+++ b/mobile/android/base/AndroidManifest.xml.in
@@ -468,46 +468,14 @@
         <service
             android:name="org.mozilla.gecko.process.GeckoServiceChildProcess$tab"
             android:enabled="true"
             android:exported="false"
             android:process=":tab"
             android:isolatedProcess="false">
         </service>
 
-#ifdef MOZ_INSTALL_MMA
-        <receiver android:name="com.leanplum.LeanplumPushReceiver" android:exported="false"
-            android:enabled="true">
-            <intent-filter>
-                <action android:name="com.leanplum.LeanplumPushListenerService" />
-            </intent-filter>
-        </receiver>
-
-        <!-- Leanplum Local Push Notification Service-->
-        <service android:name="com.leanplum.LeanplumLocalPushListenerService" />
-
-        <!-- Leanplum GCM Message Handling Service -->
-        <service android:name="com.leanplum.LeanplumPushListenerService" android:exported="false"
-            android:enabled="false">
-            <intent-filter>
-                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
-            </intent-filter>
-        </service>
-
-        <!-- Leanplum GCM Instance ID Service -->
-        <service android:name="com.leanplum.LeanplumPushInstanceIDService" android:exported="false"
-            android:enabled="false">
-            <intent-filter>
-                <action android:name="com.google.android.gms.iid.InstanceID" />
-            </intent-filter>
-        </service>
-
-        <!-- Leanplum GCM/FCM Registration Service -->
-        <service android:name="com.leanplum.LeanplumPushRegistrationService" />
-
-
-        <!-- Geofencing Service -->
-        <service android:name="com.leanplum.ReceiveTransitionsIntentService" />
+#ifdef MOZ_ANDROID_MMA
+#include MmaAndroidManifest_services.xml.in
 #endif
 
-
     </application>
 </manifest>
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -73,16 +73,21 @@ endif
 
 ifdef MOZ_INSTALL_TRACKING
     JAVA_CLASSPATH += \
         $(ANDROID_PLAY_SERVICES_ADS_AAR_LIB) \
         $(ANDROID_PLAY_SERVICES_BASEMENT_AAR_LIB) \
         $(NULL)
 endif
 
+
+# MOZ_ANDROID_MMA requires MOZ_ANDROID_GCM and MOZ_INSTALL_TRACKING,
+# so we don't need a separate clause adding to JAVA_CLASSPATH for
+# MMA (Leanplum) support.
+
 JAVA_CLASSPATH := $(subst $(NULL) ,:,$(strip $(JAVA_CLASSPATH)))
 
 # Library jars that we're bundling: these are subject to Proguard before inclusion
 # into classes.dex.
 java_bundled_libs := \
     $(ANDROID_SUPPORT_V4_AAR_LIB) \
     $(ANDROID_SUPPORT_V4_AAR_INTERNAL_LIB) \
     $(ANDROID_APPCOMPAT_V7_AAR_LIB) \
@@ -116,16 +121,20 @@ endif
 
 ifdef MOZ_INSTALL_TRACKING
     java_bundled_libs += \
         $(ANDROID_PLAY_SERVICES_ADS_AAR_LIB) \
         $(ANDROID_PLAY_SERVICES_BASEMENT_AAR_LIB) \
         $(NULL)
 endif
 
+# MOZ_ANDROID_MMA requires MOZ_ANDROID_GCM and MOZ_INSTALL_TRACKING,
+# so we don't need a separate clause adding to java_bundled_libs for
+# MMA (Leanplum) support.
+
 # uniq purloined from http://stackoverflow.com/a/16151140.
 uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
 
 java_bundled_libs := $(call uniq,$(java_bundled_libs))
 java_bundled_libs := $(subst $(NULL) ,:,$(strip $(java_bundled_libs)))
 
 GECKOVIEW_JARS = \
   constants.jar \
@@ -135,16 +144,19 @@ GECKOVIEW_JARS = \
   gecko-view.jar \
   sync-thirdparty.jar \
   $(NULL)
 
 ifdef MOZ_INSTALL_TRACKING
 GECKOVIEW_JARS += gecko-thirdparty-adjust_sdk.jar
 endif
 
+ifdef MOZ_ANDROID_MMA
+GECKOVIEW_JARS += gecko-thirdparty-leanplum_sdk.jar
+endif
 
 geckoview_jars_classpath := $(subst $(NULL) ,:,$(strip $(GECKOVIEW_JARS)))
 
 FENNEC_JARS = \
   gecko-browser.jar \
   gecko-thirdparty.jar \
   services.jar \
   $(NULL)
@@ -193,16 +205,19 @@ library_jars := \
 # code doesn't reference the package anymore.  However, we do need to Proguard
 # against the deprecated package.  If we don't, Proguard -- which is a global
 # optimization -- sees Google libraries referencing "non-existent" libraries and
 # complains.  The solution is to mimic the `useLibraries` directive by declaring
 # the legacy package as a provided library jar.
 #
 # See https://bugzilla.mozilla.org/show_bug.cgi?id=1233238#c19 for symptoms and
 # more discussion.
+#
+# MOZ_ANDROID_MMA requires MOZ_INSTALL_TRACKING, so we don't need a
+# separate clause for MMA (Leanplum) support.
 ifdef MOZ_INSTALL_TRACKING
 library_jars += $(ANDROID_SDK)/optional/org.apache.http.legacy.jar
 endif # MOZ_INSTALL_TRACKING
 
 library_jars := $(subst $(NULL) ,:,$(strip $(library_jars)))
 
 gradle_dir := $(topobjdir)/gradle/build/mobile/android
 
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/MmaAndroidManifest_services.xml.in
@@ -0,0 +1,32 @@
+        <receiver android:name="com.leanplum.LeanplumPushReceiver" android:exported="false"
+            android:enabled="true">
+            <intent-filter>
+                <action android:name="com.leanplum.LeanplumPushListenerService" />
+            </intent-filter>
+        </receiver>
+
+        <!-- Leanplum Local Push Notification Service-->
+        <service android:name="com.leanplum.LeanplumLocalPushListenerService" />
+
+        <!-- Leanplum GCM Message Handling Service -->
+        <service android:name="com.leanplum.LeanplumPushListenerService" android:exported="false"
+            android:enabled="false">
+            <intent-filter>
+                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
+            </intent-filter>
+        </service>
+
+        <!-- Leanplum GCM Instance ID Service -->
+        <service android:name="com.leanplum.LeanplumPushInstanceIDService" android:exported="false"
+            android:enabled="false">
+            <intent-filter>
+                <action android:name="com.google.android.gms.iid.InstanceID" />
+            </intent-filter>
+        </service>
+
+        <!-- Leanplum GCM/FCM Registration Service -->
+        <service android:name="com.leanplum.LeanplumPushRegistrationService" />
+
+
+        <!-- Geofencing Service -->
+        <service android:name="com.leanplum.ReceiveTransitionsIntentService" />
--- a/mobile/android/base/MmaConstants.java.in
+++ b/mobile/android/base/MmaConstants.java.in
@@ -2,30 +2,30 @@
 /* -*- 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
+//#ifdef MOZ_ANDROID_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@";
+    public static final String MOZ_LEANPLUM_SDK_KEY =
+//#ifdef MOZ_LEANPLUM_SDK_KEY
+    "@MOZ_LEANPLUM_SDK_KEY@";
 //#else
     null;
 //#endif
 
     public static MmaInterface getMma() {
-//#ifdef MOZ_INSTALL_MMA
+//#ifdef MOZ_ANDROID_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
@@ -40,21 +40,21 @@ def _defines():
                 'MOZ_ANDROID_ANR_REPORTER',
                 'MOZ_ANDROID_BEAM',
                 'MOZ_ANDROID_CUSTOM_TABS',
                 'MOZ_ANDROID_DOWNLOADS_INTEGRATION',
                 'MOZ_ANDROID_DOWNLOAD_CONTENT_SERVICE',
                 'MOZ_ANDROID_EXCLUDE_FONTS',
                 'MOZ_ANDROID_GCM',
                 'MOZ_ANDROID_MLS_STUMBLER',
+                'MOZ_ANDROID_MMA',
                 '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/mma/MmaDelegate.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaDelegate.java
@@ -1,13 +1,14 @@
 //#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;
 
 
--- a/mobile/android/base/java/org/mozilla/gecko/mma/MmaInterface.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaInterface.java
@@ -1,13 +1,14 @@
 //#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);
--- a/mobile/android/base/java/org/mozilla/gecko/mma/MmaLeanplumImp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaLeanplumImp.java
@@ -1,13 +1,14 @@
 //#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) {
--- a/mobile/android/base/java/org/mozilla/gecko/mma/MmaStubImp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaStubImp.java
@@ -1,13 +1,14 @@
 //#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) {
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -125,21 +125,19 @@ w = GENERATED_FILES['../geckoview/genera
 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']
-
+y = GENERATED_FILES['generated/preprocessed/org/mozilla/gecko/MmaConstants.java']
+y.script = 'generate_build_config.py:generate_java'
+y.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/'
@@ -182,17 +180,17 @@ 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']:
+if CONFIG['MOZ_ANDROID_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 [
@@ -1225,17 +1223,17 @@ if CONFIG['MOZ_INSTALL_TRACKING']:
         'com/adjust/sdk/UnitTestActivity.java',
         'com/adjust/sdk/Util.java'
     ] ]
     adjustjar.extra_jars += [
         'sync-thirdparty.jar',
     ]
 
 
-if CONFIG['MOZ_INSTALL_MMA']:
+if CONFIG['MOZ_ANDROID_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',
@@ -1329,24 +1327,24 @@ if CONFIG['MOZ_INSTALL_MMA']:
         '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_APPCOMPAT_V7_AAR_LIB'],
+        CONFIG['ANDROID_PLAY_SERVICES_ADS_AAR_LIB'],
+        CONFIG['ANDROID_PLAY_SERVICES_BASEMENT_AAR_LIB'],
         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_INTERNAL_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',
--- a/mobile/android/geckoview/build.gradle
+++ b/mobile/android/geckoview/build.gradle
@@ -92,17 +92,17 @@ android {
 
 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.
+        // These constants files are 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 ->