Bug 1419581 - Part 5: Add --without-google-play-services. r=chmanchester draft
authorNick Alexander <nalexander@mozilla.com>
Thu, 04 Jan 2018 15:37:15 -0800
changeset 747340 17a25d2a15868f3661248a06b9048741e5a1dca5
parent 747339 c02766104281a895ab57e58079a1f651e1b9f832
child 747341 4de338a5f8442159b3e80f492b9ff0f46f5635d9
push id96881
push usernalexander@mozilla.com
push dateThu, 25 Jan 2018 22:25:52 +0000
reviewerschmanchester
bugs1419581
milestone60.0a1
Bug 1419581 - Part 5: Add --without-google-play-services. r=chmanchester Historically, we used MOZ_NATIVE_DEVICES to proxy for Google Play Services. (MOZ_NATIVE_DEVICES was the first GPS-consuming feature in Fennec.) With Python moz.configure, we can easily add the real top-level flag that distributions like F-Droid actually want, which is to build without (non-free) Google Play Services entirely. MozReview-Commit-ID: 7YJKw3G1lQA
mobile/android/base/AndroidManifest.xml.in
mobile/android/base/Makefile.in
mobile/android/docs/mma.rst
mobile/android/moz.configure
--- a/mobile/android/base/AndroidManifest.xml.in
+++ b/mobile/android/base/AndroidManifest.xml.in
@@ -38,20 +38,17 @@
                  android:debuggable="false">
 #endif
 
         <meta-data android:name="com.sec.android.support.multiwindow" android:value="true"/>
 
         <meta-data android:name="android.max_aspect" android:value="2.1"/>
 
 #ifdef MOZ_NATIVE_DEVICES
-        <!-- This resources comes from Google Play Services. Required for casting support. -->
-        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
         <service android:name="org.mozilla.gecko.RemotePresentationService" android:exported="false"/>
-
 #endif
 
         <!-- This activity handles all incoming Intents and dispatches them to other activities. -->
         <activity android:name="org.mozilla.gecko.LauncherActivity"
             android:theme="@android:style/Theme.Translucent.NoTitleBar"
             android:relinquishTaskIdentity="true"
             android:taskAffinity=""
             android:exported="true"
@@ -470,10 +467,15 @@
             android:exported="false"
             android:isolatedProcess="false">
         </service>
 
 #ifdef MOZ_ANDROID_MMA
 #include MmaAndroidManifest_services.xml.in
 #endif
 
+#ifdef MOZ_ANDROID_GOOGLE_PLAY_SERVICES
+        <!-- This resources comes from Google Play Services. Required for casting support. -->
+        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
+#endif
+
     </application>
 </manifest>
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -47,22 +47,25 @@ JAVA_CLASSPATH += \
     $(ANDROID_ANIMATED_VECTOR_DRAWABLE_AAR_LIB) \
     $(ANDROID_CARDVIEW_V7_AAR_LIB) \
     $(ANDROID_DESIGN_AAR_LIB) \
     $(ANDROID_RECYCLERVIEW_V7_AAR_LIB) \
     $(ANDROID_CUSTOMTABS_AAR_LIB) \
     $(ANDROID_PALETTE_V7_AAR_LIB) \
     $(NULL)
 
-# If native devices are enabled, add Google Play Services and some of the v7
-# compat libraries.
-ifdef MOZ_NATIVE_DEVICES
+ifdef MOZ_ANDROID_GOOGLE_PLAY_SERVICES
     JAVA_CLASSPATH += \
         $(ANDROID_PLAY_SERVICES_BASE_AAR_LIB) \
         $(ANDROID_PLAY_SERVICES_BASEMENT_AAR_LIB) \
+        $(NULL)
+endif
+
+ifdef MOZ_NATIVE_DEVICES
+    JAVA_CLASSPATH += \
         $(ANDROID_PLAY_SERVICES_CAST_AAR_LIB) \
         $(ANDROID_MEDIAROUTER_V7_AAR_LIB) \
         $(ANDROID_MEDIAROUTER_V7_AAR_INTERNAL_LIB) \
         $(NULL)
 endif
 
 ifdef MOZ_ANDROID_GCM
     JAVA_CLASSPATH += \
@@ -75,17 +78,17 @@ 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_NATIVE_DEVICES,
+# MOZ_ANDROID_MMA requires MOZ_ANDROID_GCM and MOZ_ANDROID_GOOGLE_PLAY_SERVICES,
 # which take care of the Play Services requirements in JAVA_CLASSPATH.
 # Based on the import of
 # `com.google.android.gms.ads.identifier.AdvertisingIdClient` in
 # `com.leanplum.internal.Util` one would assume that
 # `play-services-ads` is required, by in version 8.4.0 (at least) that
 # class is defined in `play-services-basement`.  Therefore, unlike
 # MOZ_INSTALL_TRACKING, we don't need to depend on
 # `play-services-ads`.
@@ -102,16 +105,23 @@ java_bundled_libs := \
     $(ANDROID_ANIMATED_VECTOR_DRAWABLE_AAR_LIB) \
     $(ANDROID_CARDVIEW_V7_AAR_LIB) \
     $(ANDROID_DESIGN_AAR_LIB) \
     $(ANDROID_RECYCLERVIEW_V7_AAR_LIB) \
     $(ANDROID_CUSTOMTABS_AAR_LIB) \
     $(ANDROID_PALETTE_V7_AAR_LIB) \
     $(NULL)
 
+ifdef MOZ_ANDROID_GOOGLE_PLAY_SERVICES
+    java_bundled_libs += \
+        $(ANDROID_PLAY_SERVICES_BASE_AAR_LIB) \
+        $(ANDROID_PLAY_SERVICES_BASEMENT_AAR_LIB) \
+        $(NULL)
+endif
+
 ifdef MOZ_NATIVE_DEVICES
     java_bundled_libs += \
         $(ANDROID_PLAY_SERVICES_BASE_AAR_LIB) \
         $(ANDROID_PLAY_SERVICES_BASEMENT_AAR_LIB) \
         $(ANDROID_PLAY_SERVICES_CAST_AAR_LIB) \
         $(ANDROID_MEDIAROUTER_V7_AAR_LIB) \
         $(ANDROID_MEDIAROUTER_V7_AAR_INTERNAL_LIB) \
         $(NULL)
@@ -128,17 +138,17 @@ 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_NATIVE_DEVICES,
+# MOZ_ANDROID_MMA requires MOZ_ANDROID_GCM and MOZ_ANDROID_GOOGLE_PLAY_SERVICES,
 # which take care of the Play Services requirements in
 # java_bundled_libs.  See the note above.
 
 # 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)))
--- a/mobile/android/docs/mma.rst
+++ b/mobile/android/docs/mma.rst
@@ -197,17 +197,17 @@ Technical notes
 Build flags controlling the Leanplum SDK integration
 ======================================================
 
 To test this locally, add lines like:
 
 export MOZ_ANDROID_MMA=1
 ac_add_options --with-leanplum-sdk-keyfile=/path/to/leanplum-sdk-developer.token
 
-MOZ_ANDROID_MMA depends on MOZ_NATIVE_DEVICES and MOZ_ANDROID_GCM.
+MOZ_ANDROID_MMA depends on MOZ_ANDROID_GOOGLE_PLAY_SERVICES and MOZ_ANDROID_GCM.
 Since Leanplum requires Google Play Services library, those flags are a proxy for it, and enable respectively.
 
 We want to enable MOZ_ANDROID_MMA in Nightly, but only for
 MOZILLA_OFFICIAL builds.  Since MOZILLA_OFFICIAL is still defined in
 old-configure.in, we can't integrate it in
 mobile/android/moz.configure, and therefore we enable using the
 automation mozconfigs.
 
--- a/mobile/android/moz.configure
+++ b/mobile/android/moz.configure
@@ -3,39 +3,51 @@
 # 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/.
 
 project_flag('MOZ_ANDROID_EXCLUDE_FONTS',
              help='Whether to exclude font files from the build',
              default=True)
 
+option('--with-google-play-services',
+       help='Enable features that depend on non-free Google Play Services',
+       default=True)
+
+@depends('--with-google-play-services')
+def google_play_services(value):
+    return bool(value)
+
+set_config('MOZ_ANDROID_GOOGLE_PLAY_SERVICES', depends_if(google_play_services)(lambda _: True))
+
+set_config('ANDROID_GOOGLE_PLAY_SERVICES_VERSION', '8.4.0')
+add_old_configure_assignment('ANDROID_GOOGLE_PLAY_SERVICES_VERSION', '8.4.0')
+
 option(env='MOZ_ANDROID_GCM',
        help='Enable GCM (Google Cloud Messaging) registration',
-       default=True)
+       default=google_play_services)
 
 set_config('MOZ_ANDROID_GCM',
            depends_if('MOZ_ANDROID_GCM')(lambda _: True))
 add_old_configure_assignment('MOZ_ANDROID_GCM',
                              depends_if('MOZ_ANDROID_GCM')(lambda _: True))
 
 option(env='MOZ_NATIVE_DEVICES',
        help='Enable second screen support using native Android libraries.',
-       default=True)
+       default=google_play_services)
 
 set_config('MOZ_NATIVE_DEVICES',
            depends_if('MOZ_NATIVE_DEVICES')(lambda _: True))
 add_old_configure_assignment('MOZ_NATIVE_DEVICES',
                              depends_if('MOZ_NATIVE_DEVICES')(lambda _: True))
 
-# Enable install tracking SDK if we have Google Play support; MOZ_NATIVE_DEVICES
-# is a proxy flag for that support.
-@depends(milestone, 'MOZ_NATIVE_DEVICES', '--help')
-def install_tracking_default(milestone, native_devices, help):
-    return bool(milestone.is_release_or_beta and native_devices)
+# Enable install tracking SDK if we have Google Play support.
+@depends(milestone, google_play_services, '--help')
+def install_tracking_default(milestone, google_play_services, help):
+    return bool(milestone.is_release_or_beta and google_play_services)
 
 option(env='MOZ_INSTALL_TRACKING',
        help='Enable install tracking (currently using the Adjust SDK).',
        default=install_tracking_default)
 
 set_config('MOZ_INSTALL_TRACKING',
            depends_if('MOZ_INSTALL_TRACKING')(lambda _: True))
 add_old_configure_assignment('MOZ_INSTALL_TRACKING',
@@ -102,72 +114,69 @@ set_config('MOZ_ANDROID_MOZILLA_ONLINE',
 
 imply_option('MOZ_SERVICES_HEALTHREPORT', True)
 imply_option('MOZ_ANDROID_HISTORY', True)
 imply_option('--enable-small-chunk-size', True)
 
 set_config('ANDROID_SUPPORT_LIBRARY_VERSION', '23.4.0')
 add_old_configure_assignment('ANDROID_SUPPORT_LIBRARY_VERSION', '23.4.0')
 
-set_config('ANDROID_GOOGLE_PLAY_SERVICES_VERSION', '8.4.0')
-add_old_configure_assignment('ANDROID_GOOGLE_PLAY_SERVICES_VERSION', '8.4.0')
-
 @depends(target)
 def check_target(target):
     if target.os != 'Android':
         log.error('You must specify --target=arm-linux-androideabi (or some '
                   'other valid Android target) when building mobile/android.')
         die('See https://developer.mozilla.org/docs/Mozilla/Developer_guide/'
             'Build_Instructions/Simple_Firefox_for_Android_build '
             'for more information about the necessary options.')
 
 include('../../toolkit/moz.configure')
 include('../../build/moz.configure/java.configure')
 include('gradle.configure')
 
 # Must come after the ../../toolkit/moz.configure.
-@depends('MOZ_INSTALL_TRACKING', 'MOZ_NATIVE_DEVICES', '--with-adjust-sdk-keyfile')
+@depends('MOZ_INSTALL_TRACKING', google_play_services, '--with-adjust-sdk-keyfile')
 def check_install_tracking(install_tracking,
-                           native_devices,
+                           google_play_services,
                            adjust_sdk_keyfile):
     if install_tracking:
-        if not native_devices:
-            die('You must specify MOZ_NATIVE_DEVICES=1 when'
+        if not google_play_services:
+            die('You must specify --with-google-play-services when'
                 ' building with MOZ_INSTALL_TRACKING=1')
         if not adjust_sdk_keyfile:
             die('You must specify --with-adjust-sdk-keyfile=/path/to/keyfile when'
                 ' building with MOZ_INSTALL_TRACKING=1')
 
 # Must come after the ../../toolkit/moz.configure.
 @depends('MOZ_ANDROID_MMA',
-         'MOZ_NATIVE_DEVICES',
+         google_play_services,
          'MOZ_ANDROID_GCM',
          '--with-leanplum-sdk-keyfile')
 def check_android_mma(android_mma,
-                      native_devices,
+                      google_play_services,
                       android_gcm,
                       leanplum_sdk_keyfile):
     if android_mma:
-        if not native_devices:
-            die('You must specify MOZ_NATIVE_DEVICES=1 when'
+        if not google_play_services:
+            die('You must specify --with-google-play-services when'
                 ' building with MOZ_ANDROID_MMA=1')
         if not android_gcm:
             die('You must specify MOZ_ANDROID_GCM=1 when'
                 ' building with MOZ_ANDROID_MMA=1')
         if not leanplum_sdk_keyfile:
             die('You must specify --with-leanplum-sdk-keyfile=/path/to/keyfile when'
                 ' building with MOZ_ANDROID_MMA=1')
 
 @depends('MOZ_ANDROID_POCKET',
          '--with-pocket-api-keyfile')
 def check_android_pocket(android_pocket, pocket_api_keyfile):
     if android_pocket and not pocket_api_keyfile:
         die('You must specify --with-pocket-api-keyfile=/path/to/keyfile when'
             ' building with MOZ_ANDROID_POCKET=1')
 
 # Must come after the ../../toolkit/moz.configure.
-@depends('MOZ_ANDROID_GCM', 'MOZ_NATIVE_DEVICES')
+@depends('MOZ_ANDROID_GCM', google_play_services)
 def check_android_gcm(android_gcm,
-                      native_devices):
+                      google_play_services):
     if android_gcm:
-        if not native_devices:
-            die('You must specify MOZ_NATIVE_DEVICES=1 when'
+        if not google_play_services:
+            die('You must specify --with-google-play-services when'
                 ' building with MOZ_ANDROID_GCM=1')