From 19a6825aa80c8fc48b91179b936bfe1060dd25c3 Mon Sep 17 00:00:00 2001 From: Gilbert Gilb's Date: Mon, 10 Aug 2020 13:49:56 +0200 Subject: [PATCH 01/11] For #162 - Add build flag to exclude proprietary dependencies. --- app/build.gradle | 23 ++++++--- .../components/metrics/AdvertisingIDImpl.kt | 13 +++++ .../metrics/LeanplumMetricsServiceImpl.kt | 19 +++++++ .../org/mozilla/fenix/push/PushServiceImpl.kt | 15 ++++++ .../settings/about/OssLicensesMenuImpl.kt | 14 ++++++ app/src/main/AndroidManifest.xml | 2 +- .../org/mozilla/fenix/components/Analytics.kt | 4 +- .../java/org/mozilla/fenix/components/Push.kt | 4 +- .../fenix/components/metrics/MetricsUtils.kt | 50 +++++-------------- .../fenix/settings/about/AboutFragment.kt | 16 +++--- .../fenix/settings/about/OssLicensesMenu.kt | 11 ++++ .../components/metrics/AdvertisingIDImpl.kt | 37 ++++++++++++++ .../metrics/LeanplumMetricsServiceImpl.kt} | 2 +- .../push/LeanplumNotificationCustomizer.kt | 0 .../mozilla/fenix/push/PushServiceImpl.kt} | 2 +- .../settings/about/OssLicensesMenuImpl.kt | 16 ++++++ gradle.properties | 2 + 17 files changed, 170 insertions(+), 60 deletions(-) create mode 100644 app/src/free/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt create mode 100644 app/src/free/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt create mode 100644 app/src/free/java/org/mozilla/fenix/push/PushServiceImpl.kt create mode 100644 app/src/free/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt create mode 100644 app/src/main/java/org/mozilla/fenix/settings/about/OssLicensesMenu.kt create mode 100644 app/src/nonFree/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt rename app/src/{main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt => nonFree/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt} (99%) rename app/src/{main => nonFree}/java/org/mozilla/fenix/push/LeanplumNotificationCustomizer.kt (100%) rename app/src/{main/java/org/mozilla/fenix/push/FirebasePushService.kt => nonFree/java/org/mozilla/fenix/push/PushServiceImpl.kt} (97%) create mode 100644 app/src/nonFree/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt diff --git a/app/build.gradle b/app/build.gradle index 2035810be84d..5e83c3aa6603 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -17,6 +17,8 @@ import org.mozilla.fenix.gradle.tasks.LintUnitTestRunner import static org.gradle.api.tasks.testing.TestResult.ResultType +def useFreeImplementation = project.properties['org.mozilla.fenix.useFreeImplementation'].toBoolean() + android { compileSdkVersion Config.compileSdkVersion defaultConfig { @@ -31,6 +33,7 @@ android { resValue "bool", "IS_DEBUG", "false" buildConfigField "boolean", "USE_RELEASE_VERSIONING", "false" buildConfigField "String", "AMO_COLLECTION", "\"3204bb44a6ef44d39ee34917f28055\"" + buildConfigField "boolean", "USE_FREE_IMPLEMENTATION", useFreeImplementation.toString() def deepLinkSchemeValue = "fenix-dev" buildConfigField "String", "DEEP_LINK_SCHEME", "\"$deepLinkSchemeValue\"" manifestPlaceholders = [ @@ -142,6 +145,13 @@ android { java.srcDirs = ['src/migration/java', 'src/geckoRelease/java'] manifest.srcFile "src/migration/AndroidManifest.xml" } + main { + if (useFreeImplementation) { + java.srcDirs += ["src/free"] + } else { + java.srcDirs += ["src/nonFree"] + } + } } splits { @@ -330,10 +340,6 @@ dependencies { implementation Deps.androidx_coordinatorlayout implementation Deps.sentry - implementation Deps.osslicenses_library - - implementation Deps.leanplum_core - implementation Deps.leanplum_fcm implementation Deps.mozilla_concept_engine implementation Deps.mozilla_concept_menu @@ -412,7 +418,6 @@ dependencies { implementation Deps.mozilla_ui_widgets implementation Deps.mozilla_lib_crash - implementation Deps.mozilla_lib_push_firebase implementation Deps.mozilla_lib_dataprotect debugImplementation Deps.leakcanary @@ -441,7 +446,13 @@ dependencies { implementation Deps.adjust implementation Deps.installreferrer // Required by Adjust - implementation Deps.google_ads_id // Required for the Google Advertising ID + if (!useFreeImplementation) { + implementation Deps.leanplum_core + implementation Deps.leanplum_fcm + implementation Deps.mozilla_lib_push_firebase + implementation Deps.osslicenses_library + implementation Deps.google_ads_id // Required for the Google Advertising ID + } androidTestImplementation Deps.uiautomator // Removed pending AndroidX fixes diff --git a/app/src/free/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt b/app/src/free/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt new file mode 100644 index 000000000000..3b801a9a6931 --- /dev/null +++ b/app/src/free/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt @@ -0,0 +1,13 @@ +/* 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.fenix.components.metrics + +import android.content.Context + +interface AdvertisingIDImpl : AdvertisingID { + override fun getAdvertisingID(context: Context): String? { + return null + } +} diff --git a/app/src/free/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt b/app/src/free/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt new file mode 100644 index 000000000000..614d79e2dfad --- /dev/null +++ b/app/src/free/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt @@ -0,0 +1,19 @@ +/* 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.fenix.components.metrics + +import android.app.Application +import java.util.UUID + +class LeanplumMetricsServiceImpl( + private val application: Application, + private val deviceIdGenerator: () -> String = { UUID.randomUUID().toString() } +) : MetricsService { + override val type = MetricServiceType.Marketing + override fun start() {} + override fun stop() {} + override fun track(event: Event) {} + override fun shouldTrack(event: Event): Boolean {return false;} +} diff --git a/app/src/free/java/org/mozilla/fenix/push/PushServiceImpl.kt b/app/src/free/java/org/mozilla/fenix/push/PushServiceImpl.kt new file mode 100644 index 000000000000..769144375214 --- /dev/null +++ b/app/src/free/java/org/mozilla/fenix/push/PushServiceImpl.kt @@ -0,0 +1,15 @@ +/* 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.fenix.push + +import android.content.Context +import mozilla.components.concept.push.PushService + +class PushServiceImpl : PushService { + override fun deleteToken() {} + override fun isServiceAvailable(context: Context): Boolean { return false } + override fun start(context: Context) {} + override fun stop() {} +} diff --git a/app/src/free/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt b/app/src/free/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt new file mode 100644 index 000000000000..e09e299b89f1 --- /dev/null +++ b/app/src/free/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt @@ -0,0 +1,14 @@ +/* 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.fenix.settings.about + +import android.content.Context +import android.content.Intent + +class OssLicensesMenuImpl : OssLicensesMenu { + override fun getIntent(context: Context?, title: String): Intent { + throw NotImplementedError() + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index bb20352e0903..196bdb77bb05 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -264,7 +264,7 @@ android:exported="false" /> diff --git a/app/src/main/java/org/mozilla/fenix/components/Analytics.kt b/app/src/main/java/org/mozilla/fenix/components/Analytics.kt index d9512579661e..6cb1aa9658a9 100644 --- a/app/src/main/java/org/mozilla/fenix/components/Analytics.kt +++ b/app/src/main/java/org/mozilla/fenix/components/Analytics.kt @@ -20,7 +20,7 @@ import org.mozilla.fenix.R import org.mozilla.fenix.ReleaseChannel import org.mozilla.fenix.components.metrics.AdjustMetricsService import org.mozilla.fenix.components.metrics.GleanMetricsService -import org.mozilla.fenix.components.metrics.LeanplumMetricsService +import org.mozilla.fenix.components.metrics.LeanplumMetricsServiceImpl import org.mozilla.fenix.components.metrics.MetricController import org.mozilla.fenix.ext.settings import org.mozilla.fenix.utils.Mockable @@ -88,7 +88,7 @@ class Analytics( MetricController.create( listOf( GleanMetricsService(context), - LeanplumMetricsService(context as Application), + LeanplumMetricsServiceImpl(context as Application), AdjustMetricsService(context) ), isDataTelemetryEnabled = { context.settings().isTelemetryEnabled }, diff --git a/app/src/main/java/org/mozilla/fenix/components/Push.kt b/app/src/main/java/org/mozilla/fenix/components/Push.kt index 7f712a7aeda2..c323660e0b6e 100644 --- a/app/src/main/java/org/mozilla/fenix/components/Push.kt +++ b/app/src/main/java/org/mozilla/fenix/components/Push.kt @@ -10,7 +10,7 @@ import mozilla.components.feature.push.PushConfig import mozilla.components.lib.crash.CrashReporter import mozilla.components.support.base.log.logger.Logger import org.mozilla.fenix.R -import org.mozilla.fenix.push.FirebasePushService +import org.mozilla.fenix.push.PushServiceImpl /** * Component group for push services. These components use services that strongly depend on @@ -42,5 +42,5 @@ class Push(context: Context, crashReporter: CrashReporter) { PushConfig(projectId) } - private val pushService by lazy { FirebasePushService() } + private val pushService by lazy { PushServiceImpl() } } diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/MetricsUtils.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/MetricsUtils.kt index 2c9bf3eff72c..ffcef5da421f 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/MetricsUtils.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/MetricsUtils.kt @@ -7,9 +7,6 @@ package org.mozilla.fenix.components.metrics import android.content.Context import android.util.Base64 import androidx.annotation.VisibleForTesting -import com.google.android.gms.ads.identifier.AdvertisingIdClient -import com.google.android.gms.common.GooglePlayServicesNotAvailableException -import com.google.android.gms.common.GooglePlayServicesRepairableException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import mozilla.components.browser.search.SearchEngine @@ -17,13 +14,24 @@ import mozilla.components.support.base.log.logger.Logger import org.mozilla.fenix.components.metrics.Event.PerformedSearch.SearchAccessPoint import org.mozilla.fenix.components.searchengine.CustomSearchEngineStore import org.mozilla.fenix.ext.searchEngineManager -import java.io.IOException import java.security.NoSuchAlgorithmException import java.security.spec.InvalidKeySpecException import javax.crypto.SecretKeyFactory import javax.crypto.spec.PBEKeySpec -object MetricsUtils { +interface AdvertisingID { + /** + * Query the Google Advertising API to get the Google Advertising ID. + * + * This is meant to be used off the main thread. The API will throw an + * exception and we will print a log message otherwise. + * + * @return a String containing the Google Advertising ID or null. + */ + fun getAdvertisingID(context: Context): String? +} + +object MetricsUtils : AdvertisingIDImpl { fun createSearchEvent( engine: SearchEngine, context: Context, @@ -72,38 +80,6 @@ object MetricsUtils { @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) internal fun getHashingSalt(): String = "org.mozilla.fenix-salt" - /** - * Query the Google Advertising API to get the Google Advertising ID. - * - * This is meant to be used off the main thread. The API will throw an - * exception and we will print a log message otherwise. - * - * @return a String containing the Google Advertising ID or null. - */ - @Suppress("TooGenericExceptionCaught") - @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) - internal fun getAdvertisingID(context: Context): String? { - return try { - AdvertisingIdClient.getAdvertisingIdInfo(context).id - } catch (e: GooglePlayServicesNotAvailableException) { - Logger.debug("ActivationPing - Google Play not installed on the device") - null - } catch (e: GooglePlayServicesRepairableException) { - Logger.debug("ActivationPing - recoverable error connecting to Google Play Services") - null - } catch (e: IllegalStateException) { - // This is unlikely to happen, as this should be running off the main thread. - Logger.debug("ActivationPing - AdvertisingIdClient must be called off the main thread") - null - } catch (e: IOException) { - Logger.debug("ActivationPing - unable to connect to Google Play Services") - null - } catch (e: NullPointerException) { - Logger.debug("ActivationPing - no Google Advertising ID available") - null - } - } - /** * Produces a hashed version of the Google Advertising ID. * We want users using more than one of our products to report a different diff --git a/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt index ece022c027a7..c30995c41ee3 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt @@ -13,7 +13,6 @@ import android.view.ViewGroup import androidx.core.content.pm.PackageInfoCompat import androidx.fragment.app.Fragment import androidx.recyclerview.widget.DividerItemDecoration -import com.google.android.gms.oss.licenses.OssLicensesMenuActivity import kotlinx.android.synthetic.main.fragment_about.* import org.mozilla.fenix.BrowserDirection import org.mozilla.fenix.BuildConfig @@ -119,7 +118,7 @@ class AboutFragment : Fragment(), AboutPageListener { private fun populateAboutList(): List { val context = requireContext() - return listOf( + return listOfNotNull( AboutPageItem( AboutItem.ExternalLink( WHATS_NEW, @@ -152,7 +151,7 @@ class AboutFragment : Fragment(), AboutPageListener { AboutItem.ExternalLink(LICENSING_INFO, ABOUT_LICENSE_URL), getString(R.string.about_licensing_information) ), - AboutPageItem( + if (BuildConfig.USE_FREE_IMPLEMENTATION) null else AboutPageItem( AboutItem.Libraries, getString(R.string.about_other_open_source_libraries) ) @@ -168,13 +167,10 @@ class AboutFragment : Fragment(), AboutPageListener { } private fun openLibrariesPage() { - startActivity(Intent(context, OssLicensesMenuActivity::class.java)) - OssLicensesMenuActivity.setActivityTitle( - getString( - R.string.open_source_licenses_title, - appName - ) - ) + val title = getString(R.string.open_source_licenses_title, appName) + val ossLicensesMenu = OssLicensesMenuImpl() + val intent = ossLicensesMenu.getIntent(context, title) + startActivity(intent) } override fun onAboutItemClicked(item: AboutItem) { diff --git a/app/src/main/java/org/mozilla/fenix/settings/about/OssLicensesMenu.kt b/app/src/main/java/org/mozilla/fenix/settings/about/OssLicensesMenu.kt new file mode 100644 index 000000000000..c0b8d9d11c21 --- /dev/null +++ b/app/src/main/java/org/mozilla/fenix/settings/about/OssLicensesMenu.kt @@ -0,0 +1,11 @@ +/* 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.fenix.settings.about + +import android.content.Context +import android.content.Intent + +interface OssLicensesMenu { + fun getIntent(context: Context?, title: String): Intent +} diff --git a/app/src/nonFree/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt b/app/src/nonFree/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt new file mode 100644 index 000000000000..fae0c354768d --- /dev/null +++ b/app/src/nonFree/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt @@ -0,0 +1,37 @@ +/* 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.fenix.components.metrics + +import android.content.Context +import com.google.android.gms.ads.identifier.AdvertisingIdClient +import com.google.android.gms.common.GooglePlayServicesNotAvailableException +import com.google.android.gms.common.GooglePlayServicesRepairableException +import mozilla.components.support.base.log.logger.Logger +import java.io.IOException + +interface AdvertisingIDImpl : AdvertisingID { + @Suppress("TooGenericExceptionCaught") + override fun getAdvertisingID(context: Context): String? { + return try { + AdvertisingIdClient.getAdvertisingIdInfo(context).id + } catch (e: GooglePlayServicesNotAvailableException) { + Logger.debug("ActivationPing - Google Play not installed on the device") + null + } catch (e: GooglePlayServicesRepairableException) { + Logger.debug("ActivationPing - recoverable error connecting to Google Play Services") + null + } catch (e: IllegalStateException) { + // This is unlikely to happen, as this should be running off the main thread. + Logger.debug("ActivationPing - AdvertisingIdClient must be called off the main thread") + null + } catch (e: IOException) { + Logger.debug("ActivationPing - unable to connect to Google Play Services") + null + } catch (e: NullPointerException) { + Logger.debug("ActivationPing - no Google Advertising ID available") + null + } + } +} diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt b/app/src/nonFree/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt similarity index 99% rename from app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt rename to app/src/nonFree/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt index 4d9ca393eed7..cb56be2d208f 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt +++ b/app/src/nonFree/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt @@ -52,7 +52,7 @@ private val Event.name: String? else -> null } -class LeanplumMetricsService( +class LeanplumMetricsServiceImpl( private val application: Application, private val deviceIdGenerator: () -> String = { randomUUID().toString() } ) : MetricsService { diff --git a/app/src/main/java/org/mozilla/fenix/push/LeanplumNotificationCustomizer.kt b/app/src/nonFree/java/org/mozilla/fenix/push/LeanplumNotificationCustomizer.kt similarity index 100% rename from app/src/main/java/org/mozilla/fenix/push/LeanplumNotificationCustomizer.kt rename to app/src/nonFree/java/org/mozilla/fenix/push/LeanplumNotificationCustomizer.kt diff --git a/app/src/main/java/org/mozilla/fenix/push/FirebasePushService.kt b/app/src/nonFree/java/org/mozilla/fenix/push/PushServiceImpl.kt similarity index 97% rename from app/src/main/java/org/mozilla/fenix/push/FirebasePushService.kt rename to app/src/nonFree/java/org/mozilla/fenix/push/PushServiceImpl.kt index 2c060a2b4d13..68c9da0a496d 100644 --- a/app/src/main/java/org/mozilla/fenix/push/FirebasePushService.kt +++ b/app/src/nonFree/java/org/mozilla/fenix/push/PushServiceImpl.kt @@ -41,7 +41,7 @@ import mozilla.components.feature.push.AutoPushFeature * that lets us easily delegate the implementation to that, as well as make invocations when FCM * receives new messages. */ -class FirebasePushService : LeanplumPushFirebaseMessagingService(), +class PushServiceImpl : LeanplumPushFirebaseMessagingService(), PushService by AutoPushService { override fun onCreate() { diff --git a/app/src/nonFree/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt b/app/src/nonFree/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt new file mode 100644 index 000000000000..af695c799c5c --- /dev/null +++ b/app/src/nonFree/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt @@ -0,0 +1,16 @@ +/* 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.fenix.settings.about + +import android.content.Context +import android.content.Intent +import com.google.android.gms.oss.licenses.OssLicensesMenuActivity + +class OssLicensesMenuImpl : OssLicensesMenu { + override fun getIntent(context: Context?, title: String): Intent { + OssLicensesMenuActivity.setActivityTitle(title) + return Intent(context, OssLicensesMenuActivity::class.java) + } +} diff --git a/gradle.properties b/gradle.properties index 03d5464256aa..f9e5e7152778 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,3 +19,5 @@ android.enableR8=true android.enableR8.fullMode=true android.enableUnitTestBinaryResources=false org.gradle.parallel=false + +org.mozilla.fenix.useFreeImplementation=false From 3e021e492d1680becbf9191db7795aa1f35591e6 Mon Sep 17 00:00:00 2001 From: Gilbert Gilb's Date: Mon, 10 Aug 2020 18:19:02 +0200 Subject: [PATCH 02/11] Make LeanplumService implementations derive from the same class. This is to ensure both free and non-free implementations are updated when an interface is added to the base service, like in 77263aad7. --- .../components/metrics/LeanplumMetricsServiceImpl.kt | 10 ++++++---- .../fenix/settings/about/OssLicensesMenuImpl.kt | 1 + .../components/metrics/LeanplumMetricsService.kt | 11 +++++++++++ .../components/metrics/LeanplumMetricsServiceImpl.kt | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt diff --git a/app/src/free/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt b/app/src/free/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt index 614d79e2dfad..ce897c0da881 100644 --- a/app/src/free/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt +++ b/app/src/free/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt @@ -5,15 +5,17 @@ package org.mozilla.fenix.components.metrics import android.app.Application +import android.net.Uri import java.util.UUID class LeanplumMetricsServiceImpl( - private val application: Application, - private val deviceIdGenerator: () -> String = { UUID.randomUUID().toString() } -) : MetricsService { + application: Application, + deviceIdGenerator: () -> String = { UUID.randomUUID().toString() } +) : LeanplumMetricsService(application, deviceIdGenerator) { override val type = MetricServiceType.Marketing override fun start() {} override fun stop() {} override fun track(event: Event) {} - override fun shouldTrack(event: Event): Boolean {return false;} + override fun shouldTrack(event: Event): Boolean { return false } + override fun verifyDeepLink(deepLink: Uri): Boolean { return false } } diff --git a/app/src/free/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt b/app/src/free/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt index e09e299b89f1..90ab8e69dda4 100644 --- a/app/src/free/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt +++ b/app/src/free/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt @@ -9,6 +9,7 @@ import android.content.Intent class OssLicensesMenuImpl : OssLicensesMenu { override fun getIntent(context: Context?, title: String): Intent { + // This menu shouldn't displayed on the free variant anyways. throw NotImplementedError() } } diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt new file mode 100644 index 000000000000..2cb83f0ce790 --- /dev/null +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt @@ -0,0 +1,11 @@ +package org.mozilla.fenix.components.metrics + +import android.app.Application +import org.mozilla.fenix.home.intent.DeepLinkIntentProcessor +import java.util.UUID + +abstract class LeanplumMetricsService( + private val application: Application, + private val deviceIdGenerator: () -> String = { UUID.randomUUID().toString() } +) : MetricsService, DeepLinkIntentProcessor.DeepLinkVerifier + diff --git a/app/src/nonFree/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt b/app/src/nonFree/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt index 5396a787b09a..ccb0f88d000b 100644 --- a/app/src/nonFree/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt +++ b/app/src/nonFree/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt @@ -57,7 +57,7 @@ private val Event.name: String? class LeanplumMetricsServiceImpl( private val application: Application, private val deviceIdGenerator: () -> String = { randomUUID().toString() } -) : MetricsService, DeepLinkIntentProcessor.DeepLinkVerifier { +) : LeanplumMetricsService(application, deviceIdGenerator) { val scope = CoroutineScope(Dispatchers.IO) var leanplumJob: Job? = null From 11131204bfcf29beb87db2af97ec8d8362327cab Mon Sep 17 00:00:00 2001 From: Gilbert Gilb's Date: Tue, 11 Aug 2020 16:31:44 +0200 Subject: [PATCH 03/11] Replace play-services-oss-licenses library with AboutLibraries. --- app/build.gradle | 4 ++-- .../fenix/settings/about/OssLicensesMenuImpl.kt | 15 --------------- .../fenix/settings/about/AboutFragment.kt | 12 +++++++----- .../fenix/settings/about/OssLicensesMenu.kt | 11 ----------- .../fenix/settings/about/OssLicensesMenuImpl.kt | 16 ---------------- build.gradle | 11 ++++++++++- buildSrc/src/main/java/Dependencies.kt | 7 +++---- 7 files changed, 22 insertions(+), 54 deletions(-) delete mode 100644 app/src/free/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt delete mode 100644 app/src/main/java/org/mozilla/fenix/settings/about/OssLicensesMenu.kt delete mode 100644 app/src/nonFree/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt diff --git a/app/build.gradle b/app/build.gradle index 5e83c3aa6603..36cc2131ee8d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,7 +7,7 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'jacoco' apply plugin: 'androidx.navigation.safeargs.kotlin' -apply plugin: 'com.google.android.gms.oss-licenses-plugin' +apply plugin: 'com.mikepenz.aboutlibraries.plugin' import com.android.build.OutputFile @@ -340,6 +340,7 @@ dependencies { implementation Deps.androidx_coordinatorlayout implementation Deps.sentry + implementation Deps.aboutlibraries implementation Deps.mozilla_concept_engine implementation Deps.mozilla_concept_menu @@ -450,7 +451,6 @@ dependencies { implementation Deps.leanplum_core implementation Deps.leanplum_fcm implementation Deps.mozilla_lib_push_firebase - implementation Deps.osslicenses_library implementation Deps.google_ads_id // Required for the Google Advertising ID } diff --git a/app/src/free/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt b/app/src/free/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt deleted file mode 100644 index 90ab8e69dda4..000000000000 --- a/app/src/free/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt +++ /dev/null @@ -1,15 +0,0 @@ -/* 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.fenix.settings.about - -import android.content.Context -import android.content.Intent - -class OssLicensesMenuImpl : OssLicensesMenu { - override fun getIntent(context: Context?, title: String): Intent { - // This menu shouldn't displayed on the free variant anyways. - throw NotImplementedError() - } -} diff --git a/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt index c30995c41ee3..d56780c908ae 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt @@ -13,6 +13,7 @@ import android.view.ViewGroup import androidx.core.content.pm.PackageInfoCompat import androidx.fragment.app.Fragment import androidx.recyclerview.widget.DividerItemDecoration +import com.mikepenz.aboutlibraries.LibsBuilder import kotlinx.android.synthetic.main.fragment_about.* import org.mozilla.fenix.BrowserDirection import org.mozilla.fenix.BuildConfig @@ -151,7 +152,7 @@ class AboutFragment : Fragment(), AboutPageListener { AboutItem.ExternalLink(LICENSING_INFO, ABOUT_LICENSE_URL), getString(R.string.about_licensing_information) ), - if (BuildConfig.USE_FREE_IMPLEMENTATION) null else AboutPageItem( + AboutPageItem( AboutItem.Libraries, getString(R.string.about_other_open_source_libraries) ) @@ -167,10 +168,11 @@ class AboutFragment : Fragment(), AboutPageListener { } private fun openLibrariesPage() { - val title = getString(R.string.open_source_licenses_title, appName) - val ossLicensesMenu = OssLicensesMenuImpl() - val intent = ossLicensesMenu.getIntent(context, title) - startActivity(intent) + val ctx = context + if (ctx != null) { + val title = getString(R.string.open_source_licenses_title, appName) + LibsBuilder().withAboutAppName(title).start(ctx) + } } override fun onAboutItemClicked(item: AboutItem) { diff --git a/app/src/main/java/org/mozilla/fenix/settings/about/OssLicensesMenu.kt b/app/src/main/java/org/mozilla/fenix/settings/about/OssLicensesMenu.kt deleted file mode 100644 index c0b8d9d11c21..000000000000 --- a/app/src/main/java/org/mozilla/fenix/settings/about/OssLicensesMenu.kt +++ /dev/null @@ -1,11 +0,0 @@ -/* 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.fenix.settings.about - -import android.content.Context -import android.content.Intent - -interface OssLicensesMenu { - fun getIntent(context: Context?, title: String): Intent -} diff --git a/app/src/nonFree/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt b/app/src/nonFree/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt deleted file mode 100644 index af695c799c5c..000000000000 --- a/app/src/nonFree/java/org/mozilla/fenix/settings/about/OssLicensesMenuImpl.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* 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.fenix.settings.about - -import android.content.Context -import android.content.Intent -import com.google.android.gms.oss.licenses.OssLicensesMenuActivity - -class OssLicensesMenuImpl : OssLicensesMenu { - override fun getIntent(context: Context?, title: String): Intent { - OssLicensesMenuActivity.setActivityTitle(title) - return Intent(context, OssLicensesMenuActivity::class.java) - } -} diff --git a/build.gradle b/build.gradle index a236dc19118d..ee8834d986f4 100644 --- a/build.gradle +++ b/build.gradle @@ -62,13 +62,22 @@ buildscript { classpath Deps.tools_kotlingradle classpath Deps.androidx_safeargs classpath Deps.allopen - classpath Deps.osslicenses_plugin + classpath Deps.aboutlibraries_plugin classpath "org.mozilla.components:tooling-glean-gradle:${Versions.mozilla_android_components}" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } + + // AboutLibraries depends on Android gradle plugin 4.0+, but we can't update it for now + // It should be safe to remove this block once android gradle plugin is updated + // See https://github.com/mozilla-mobile/fenix/issues/13262 + configurations.classpath { + resolutionStrategy { + force Deps.tools_androidgradle + } + } } plugins { diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 876e537dd311..200c682fd00f 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -9,8 +9,7 @@ object Versions { const val sentry = "1.7.10" const val leakcanary = "2.4" const val leanplum = "5.4.0" - const val osslicenses_plugin = "0.9.5" - const val osslicenses_library = "17.0.0" + const val aboutlibraries = "8.3.0" const val detekt = "1.9.1" const val androidx_appcompat = "1.2.0-rc01" @@ -58,8 +57,8 @@ object Deps { const val kotlin_coroutines_android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutines}" const val allopen = "org.jetbrains.kotlin:kotlin-allopen:${Versions.kotlin}" - const val osslicenses_plugin = "com.google.android.gms:oss-licenses-plugin:${Versions.osslicenses_plugin}" - const val osslicenses_library = "com.google.android.gms:play-services-oss-licenses:${Versions.osslicenses_library}" + const val aboutlibraries = "com.mikepenz:aboutlibraries:${Versions.aboutlibraries}" + const val aboutlibraries_plugin = "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:${Versions.aboutlibraries}" const val mozilla_concept_engine = "org.mozilla.components:concept-engine:${Versions.mozilla_android_components}" const val mozilla_concept_menu = "org.mozilla.components:concept-menu:${Versions.mozilla_android_components}" From 3dffa78164f642bad4918e8c635e64d9dd3f4a9c Mon Sep 17 00:00:00 2001 From: Gilbert Gilb's Date: Tue, 11 Aug 2020 16:56:50 +0200 Subject: [PATCH 04/11] Use a class instead of an interface for AdvertisingID. --- .../components/metrics/AdvertisingIDImpl.kt | 4 ++-- .../fenix/components/metrics/AdvertisingID.kt | 19 +++++++++++++++++++ .../fenix/components/metrics/MetricsUtils.kt | 16 ++-------------- .../components/metrics/AdvertisingIDImpl.kt | 4 ++-- 4 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 app/src/main/java/org/mozilla/fenix/components/metrics/AdvertisingID.kt diff --git a/app/src/free/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt b/app/src/free/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt index 3b801a9a6931..8b22732f4229 100644 --- a/app/src/free/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt +++ b/app/src/free/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt @@ -6,8 +6,8 @@ package org.mozilla.fenix.components.metrics import android.content.Context -interface AdvertisingIDImpl : AdvertisingID { - override fun getAdvertisingID(context: Context): String? { +class AdvertisingIDImpl : AdvertisingID() { + override fun query(context: Context): String? { return null } } diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/AdvertisingID.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/AdvertisingID.kt new file mode 100644 index 000000000000..60e821bfda46 --- /dev/null +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/AdvertisingID.kt @@ -0,0 +1,19 @@ +/* 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.fenix.components.metrics + +import android.content.Context + +abstract class AdvertisingID { + /** + * Query the Google Advertising API to get the Google Advertising ID. + * + * This is meant to be used off the main thread. The API will throw an + * exception and we will print a log message otherwise. + * + * @return a String containing the Google Advertising ID or null. + */ + abstract fun query(context: Context): String? +} diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/MetricsUtils.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/MetricsUtils.kt index ffcef5da421f..bd58234d80f2 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/MetricsUtils.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/MetricsUtils.kt @@ -19,19 +19,7 @@ import java.security.spec.InvalidKeySpecException import javax.crypto.SecretKeyFactory import javax.crypto.spec.PBEKeySpec -interface AdvertisingID { - /** - * Query the Google Advertising API to get the Google Advertising ID. - * - * This is meant to be used off the main thread. The API will throw an - * exception and we will print a log message otherwise. - * - * @return a String containing the Google Advertising ID or null. - */ - fun getAdvertisingID(context: Context): String? -} - -object MetricsUtils : AdvertisingIDImpl { +object MetricsUtils { fun createSearchEvent( engine: SearchEngine, context: Context, @@ -90,7 +78,7 @@ object MetricsUtils : AdvertisingIDImpl { */ @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) suspend fun getHashedIdentifier(context: Context): String? = withContext(Dispatchers.Default) { - getAdvertisingID(context)?.let { unhashedID -> + AdvertisingIDImpl().query(context)?.let { unhashedID -> // Add some salt to the ID, before hashing. For this specific use-case, it's ok // to use the same salt value for all the hashes. We want hashes to be stable // within a single product, but we don't want hashes to be the same across different diff --git a/app/src/nonFree/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt b/app/src/nonFree/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt index fae0c354768d..9d9100924bd0 100644 --- a/app/src/nonFree/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt +++ b/app/src/nonFree/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt @@ -11,9 +11,9 @@ import com.google.android.gms.common.GooglePlayServicesRepairableException import mozilla.components.support.base.log.logger.Logger import java.io.IOException -interface AdvertisingIDImpl : AdvertisingID { +class AdvertisingIDImpl : AdvertisingID() { @Suppress("TooGenericExceptionCaught") - override fun getAdvertisingID(context: Context): String? { + override fun query(context: Context): String? { return try { AdvertisingIdClient.getAdvertisingIdInfo(context).id } catch (e: GooglePlayServicesNotAvailableException) { From 6b2434f65b9e21af188a23670d0988f0100ab138 Mon Sep 17 00:00:00 2001 From: Gilbert Gilb's Date: Tue, 11 Aug 2020 17:05:20 +0200 Subject: [PATCH 05/11] Rename PushService to FirebasePushService --- .../push/{PushServiceImpl.kt => FirebasePushServiceImpl.kt} | 2 +- app/src/main/AndroidManifest.xml | 2 +- app/src/main/java/org/mozilla/fenix/components/Push.kt | 4 ++-- .../push/{PushServiceImpl.kt => FirebasePushServiceImpl.kt} | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename app/src/free/java/org/mozilla/fenix/push/{PushServiceImpl.kt => FirebasePushServiceImpl.kt} (91%) rename app/src/nonFree/java/org/mozilla/fenix/push/{PushServiceImpl.kt => FirebasePushServiceImpl.kt} (97%) diff --git a/app/src/free/java/org/mozilla/fenix/push/PushServiceImpl.kt b/app/src/free/java/org/mozilla/fenix/push/FirebasePushServiceImpl.kt similarity index 91% rename from app/src/free/java/org/mozilla/fenix/push/PushServiceImpl.kt rename to app/src/free/java/org/mozilla/fenix/push/FirebasePushServiceImpl.kt index 769144375214..9bcd96f408b7 100644 --- a/app/src/free/java/org/mozilla/fenix/push/PushServiceImpl.kt +++ b/app/src/free/java/org/mozilla/fenix/push/FirebasePushServiceImpl.kt @@ -7,7 +7,7 @@ package org.mozilla.fenix.push import android.content.Context import mozilla.components.concept.push.PushService -class PushServiceImpl : PushService { +class FirebasePushServiceImpl : PushService { override fun deleteToken() {} override fun isServiceAvailable(context: Context): Boolean { return false } override fun start(context: Context) {} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 196bdb77bb05..edd997d34e3d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -264,7 +264,7 @@ android:exported="false" /> diff --git a/app/src/main/java/org/mozilla/fenix/components/Push.kt b/app/src/main/java/org/mozilla/fenix/components/Push.kt index c323660e0b6e..60603445a8e1 100644 --- a/app/src/main/java/org/mozilla/fenix/components/Push.kt +++ b/app/src/main/java/org/mozilla/fenix/components/Push.kt @@ -10,7 +10,7 @@ import mozilla.components.feature.push.PushConfig import mozilla.components.lib.crash.CrashReporter import mozilla.components.support.base.log.logger.Logger import org.mozilla.fenix.R -import org.mozilla.fenix.push.PushServiceImpl +import org.mozilla.fenix.push.FirebasePushServiceImpl /** * Component group for push services. These components use services that strongly depend on @@ -42,5 +42,5 @@ class Push(context: Context, crashReporter: CrashReporter) { PushConfig(projectId) } - private val pushService by lazy { PushServiceImpl() } + private val pushService by lazy { FirebasePushServiceImpl() } } diff --git a/app/src/nonFree/java/org/mozilla/fenix/push/PushServiceImpl.kt b/app/src/nonFree/java/org/mozilla/fenix/push/FirebasePushServiceImpl.kt similarity index 97% rename from app/src/nonFree/java/org/mozilla/fenix/push/PushServiceImpl.kt rename to app/src/nonFree/java/org/mozilla/fenix/push/FirebasePushServiceImpl.kt index 68c9da0a496d..1782c5acc6fd 100644 --- a/app/src/nonFree/java/org/mozilla/fenix/push/PushServiceImpl.kt +++ b/app/src/nonFree/java/org/mozilla/fenix/push/FirebasePushServiceImpl.kt @@ -41,7 +41,7 @@ import mozilla.components.feature.push.AutoPushFeature * that lets us easily delegate the implementation to that, as well as make invocations when FCM * receives new messages. */ -class PushServiceImpl : LeanplumPushFirebaseMessagingService(), +class FirebasePushServiceImpl : LeanplumPushFirebaseMessagingService(), PushService by AutoPushService { override fun onCreate() { From 5f3de6e7b415d1c1c29e247841c2954e367caffd Mon Sep 17 00:00:00 2001 From: Gilbert Gilb's Date: Tue, 11 Aug 2020 17:17:56 +0200 Subject: [PATCH 06/11] Add missing license header. --- .../fenix/components/metrics/LeanplumMetricsService.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt index 2cb83f0ce790..42668d06935b 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt @@ -1,3 +1,7 @@ +/* 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.fenix.components.metrics import android.app.Application From f0dfa282ccc6b8c022bb5e957c737914508278dc Mon Sep 17 00:00:00 2001 From: Gilbert Gilb's Date: Tue, 11 Aug 2020 21:55:12 +0200 Subject: [PATCH 07/11] Declare OSS variant as a build flavor and fix tests. --- app/build.gradle | 38 +++++++++++-------- .../components/metrics/AdvertisingIDImpl.kt | 0 .../metrics/LeanplumMetricsServiceImpl.kt | 0 .../fenix/push/FirebasePushServiceImpl.kt | 0 .../push/LeanplumNotificationCustomizer.kt | 0 .../components/metrics/AdvertisingIDImpl.kt | 0 .../metrics/LeanplumMetricsServiceImpl.kt | 0 .../fenix/push/FirebasePushServiceImpl.kt | 0 .../metrics/LeanplumMetricsServiceTest.kt | 4 +- .../components/metrics/MetricsUtilsTest.kt | 10 ++--- .../metrics/MetricsUtilsTestRoboelectric.kt | 0 .../LeanplumNotificationCustomizerTest.kt | 0 12 files changed, 29 insertions(+), 23 deletions(-) rename app/src/{nonFree => nonOss}/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt (100%) rename app/src/{nonFree => nonOss}/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt (100%) rename app/src/{nonFree => nonOss}/java/org/mozilla/fenix/push/FirebasePushServiceImpl.kt (100%) rename app/src/{nonFree => nonOss}/java/org/mozilla/fenix/push/LeanplumNotificationCustomizer.kt (100%) rename app/src/{free => oss}/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt (100%) rename app/src/{free => oss}/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt (100%) rename app/src/{free => oss}/java/org/mozilla/fenix/push/FirebasePushServiceImpl.kt (100%) rename app/src/{test => testNonOss}/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceTest.kt (86%) rename app/src/{test => testNonOss}/java/org/mozilla/fenix/components/metrics/MetricsUtilsTest.kt (91%) rename app/src/{test => testNonOss}/java/org/mozilla/fenix/components/metrics/MetricsUtilsTestRoboelectric.kt (100%) rename app/src/{test => testNonOss}/java/org/mozilla/fenix/push/LeanplumNotificationCustomizerTest.kt (100%) diff --git a/app/build.gradle b/app/build.gradle index 36cc2131ee8d..9140584ce33c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -17,8 +17,6 @@ import org.mozilla.fenix.gradle.tasks.LintUnitTestRunner import static org.gradle.api.tasks.testing.TestResult.ResultType -def useFreeImplementation = project.properties['org.mozilla.fenix.useFreeImplementation'].toBoolean() - android { compileSdkVersion Config.compileSdkVersion defaultConfig { @@ -33,7 +31,6 @@ android { resValue "bool", "IS_DEBUG", "false" buildConfigField "boolean", "USE_RELEASE_VERSIONING", "false" buildConfigField "String", "AMO_COLLECTION", "\"3204bb44a6ef44d39ee34917f28055\"" - buildConfigField "boolean", "USE_FREE_IMPLEMENTATION", useFreeImplementation.toString() def deepLinkSchemeValue = "fenix-dev" buildConfigField "String", "DEEP_LINK_SCHEME", "\"$deepLinkSchemeValue\"" manifestPlaceholders = [ @@ -125,7 +122,19 @@ android { animationsDisabled = true } - flavorDimensions "engine" + flavorDimensions "version" + productFlavors { + oss { + dimension "version" + applicationIdSuffix ".oss" + versionNameSuffix "-oss" + buildConfigField "boolean", "OSS_FLAVOR", "true" + } + nonOss { + dimension "version" + buildConfigField "boolean", "OSS_FLAVOR", "false" + } + } sourceSets { androidTest { @@ -145,12 +154,11 @@ android { java.srcDirs = ['src/migration/java', 'src/geckoRelease/java'] manifest.srcFile "src/migration/AndroidManifest.xml" } - main { - if (useFreeImplementation) { - java.srcDirs += ["src/free"] - } else { - java.srcDirs += ["src/nonFree"] - } + oss { + java.srcDirs += ["src/oss"] + } + nonOss { + java.srcDirs += ["src/nonOss"] } } @@ -447,12 +455,10 @@ dependencies { implementation Deps.adjust implementation Deps.installreferrer // Required by Adjust - if (!useFreeImplementation) { - implementation Deps.leanplum_core - implementation Deps.leanplum_fcm - implementation Deps.mozilla_lib_push_firebase - implementation Deps.google_ads_id // Required for the Google Advertising ID - } + nonOssImplementation Deps.leanplum_core + nonOssImplementation Deps.leanplum_fcm + nonOssImplementation Deps.mozilla_lib_push_firebase + nonOssImplementation Deps.google_ads_id // Required for the Google Advertising ID androidTestImplementation Deps.uiautomator // Removed pending AndroidX fixes diff --git a/app/src/nonFree/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt b/app/src/nonOss/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt similarity index 100% rename from app/src/nonFree/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt rename to app/src/nonOss/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt diff --git a/app/src/nonFree/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt b/app/src/nonOss/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt similarity index 100% rename from app/src/nonFree/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt rename to app/src/nonOss/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt diff --git a/app/src/nonFree/java/org/mozilla/fenix/push/FirebasePushServiceImpl.kt b/app/src/nonOss/java/org/mozilla/fenix/push/FirebasePushServiceImpl.kt similarity index 100% rename from app/src/nonFree/java/org/mozilla/fenix/push/FirebasePushServiceImpl.kt rename to app/src/nonOss/java/org/mozilla/fenix/push/FirebasePushServiceImpl.kt diff --git a/app/src/nonFree/java/org/mozilla/fenix/push/LeanplumNotificationCustomizer.kt b/app/src/nonOss/java/org/mozilla/fenix/push/LeanplumNotificationCustomizer.kt similarity index 100% rename from app/src/nonFree/java/org/mozilla/fenix/push/LeanplumNotificationCustomizer.kt rename to app/src/nonOss/java/org/mozilla/fenix/push/LeanplumNotificationCustomizer.kt diff --git a/app/src/free/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt b/app/src/oss/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt similarity index 100% rename from app/src/free/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt rename to app/src/oss/java/org/mozilla/fenix/components/metrics/AdvertisingIDImpl.kt diff --git a/app/src/free/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt b/app/src/oss/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt similarity index 100% rename from app/src/free/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt rename to app/src/oss/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceImpl.kt diff --git a/app/src/free/java/org/mozilla/fenix/push/FirebasePushServiceImpl.kt b/app/src/oss/java/org/mozilla/fenix/push/FirebasePushServiceImpl.kt similarity index 100% rename from app/src/free/java/org/mozilla/fenix/push/FirebasePushServiceImpl.kt rename to app/src/oss/java/org/mozilla/fenix/push/FirebasePushServiceImpl.kt diff --git a/app/src/test/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceTest.kt b/app/src/testNonOss/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceTest.kt similarity index 86% rename from app/src/test/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceTest.kt rename to app/src/testNonOss/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceTest.kt index 6027a100afcd..846813c71f5c 100644 --- a/app/src/test/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceTest.kt +++ b/app/src/testNonOss/java/org/mozilla/fenix/components/metrics/LeanplumMetricsServiceTest.kt @@ -30,10 +30,10 @@ class LeanplumMetricsServiceTest { assertNull(sharedPreferences.getString("LP_DEVICE_ID", null)) - val leanplumMetricService = LeanplumMetricsService(testContext.application, idGenerator) + val leanplumMetricService = LeanplumMetricsServiceImpl(testContext.application, idGenerator) assertEquals("TEST_DEVICE_ID", leanplumMetricService.deviceId) - val leanplumMetricService2 = LeanplumMetricsService(testContext.application, idGenerator) + val leanplumMetricService2 = LeanplumMetricsServiceImpl(testContext.application, idGenerator) assertEquals("TEST_DEVICE_ID", leanplumMetricService2.deviceId) assertEquals(1, callCount) diff --git a/app/src/test/java/org/mozilla/fenix/components/metrics/MetricsUtilsTest.kt b/app/src/testNonOss/java/org/mozilla/fenix/components/metrics/MetricsUtilsTest.kt similarity index 91% rename from app/src/test/java/org/mozilla/fenix/components/metrics/MetricsUtilsTest.kt rename to app/src/testNonOss/java/org/mozilla/fenix/components/metrics/MetricsUtilsTest.kt index 0ffb5526165f..da193ae32822 100644 --- a/app/src/test/java/org/mozilla/fenix/components/metrics/MetricsUtilsTest.kt +++ b/app/src/testNonOss/java/org/mozilla/fenix/components/metrics/MetricsUtilsTest.kt @@ -22,7 +22,7 @@ class MetricsUtilsTest { private val context: Context = mockk(relaxed = true) @Test - fun `getAdvertisingID() returns null if the API throws`() { + fun `query advertisingID returns null if the API throws`() { mockkStatic("com.google.android.gms.ads.identifier.AdvertisingIdClient") val exceptions = listOf( @@ -37,7 +37,7 @@ class MetricsUtilsTest { AdvertisingIdClient.getAdvertisingIdInfo(any()) } throws it - assertNull(MetricsUtils.getAdvertisingID(context)) + assertNull(AdvertisingIDImpl().query(context)) } unmockkStatic("com.google.android.gms.ads.identifier.AdvertisingIdClient") @@ -48,7 +48,7 @@ class MetricsUtilsTest { mockkStatic(AdvertisingIdClient::class) every { AdvertisingIdClient.getAdvertisingIdInfo(any()) } returns null - assertNull(MetricsUtils.getAdvertisingID(context)) + assertNull(AdvertisingIDImpl().query(context)) } @Test @@ -60,7 +60,7 @@ class MetricsUtilsTest { AdvertisingIdClient.getAdvertisingIdInfo(any()) } returns AdvertisingIdClient.Info(testId, false) - assertEquals(testId, MetricsUtils.getAdvertisingID(context)) + assertEquals(testId, AdvertisingIDImpl().query(context)) } @Test @@ -81,7 +81,7 @@ class MetricsUtilsTest { // Get the hash identifier. mockkObject(MetricsUtils) - every { MetricsUtils.getAdvertisingID(context) } returns testId + every { AdvertisingIDImpl().query(context) } returns testId every { MetricsUtils.getHashingSalt() } returns testPackageName runBlocking { assertEquals(mockedHexReturn, MetricsUtils.getHashedIdentifier(context)) diff --git a/app/src/test/java/org/mozilla/fenix/components/metrics/MetricsUtilsTestRoboelectric.kt b/app/src/testNonOss/java/org/mozilla/fenix/components/metrics/MetricsUtilsTestRoboelectric.kt similarity index 100% rename from app/src/test/java/org/mozilla/fenix/components/metrics/MetricsUtilsTestRoboelectric.kt rename to app/src/testNonOss/java/org/mozilla/fenix/components/metrics/MetricsUtilsTestRoboelectric.kt diff --git a/app/src/test/java/org/mozilla/fenix/push/LeanplumNotificationCustomizerTest.kt b/app/src/testNonOss/java/org/mozilla/fenix/push/LeanplumNotificationCustomizerTest.kt similarity index 100% rename from app/src/test/java/org/mozilla/fenix/push/LeanplumNotificationCustomizerTest.kt rename to app/src/testNonOss/java/org/mozilla/fenix/push/LeanplumNotificationCustomizerTest.kt From fa935283a2424d646b196e6fa5469c7c838de1ea Mon Sep 17 00:00:00 2001 From: Gilbert Gilb's Date: Tue, 11 Aug 2020 22:08:59 +0200 Subject: [PATCH 08/11] Remove dropped gradle property. --- gradle.properties | 2 -- 1 file changed, 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index f9e5e7152778..03d5464256aa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,5 +19,3 @@ android.enableR8=true android.enableR8.fullMode=true android.enableUnitTestBinaryResources=false org.gradle.parallel=false - -org.mozilla.fenix.useFreeImplementation=false From 27e6bacb0a63841ce3492015e555467072cc1e05 Mon Sep 17 00:00:00 2001 From: Gilbert Gilb's Date: Tue, 11 Aug 2020 22:58:20 +0200 Subject: [PATCH 09/11] Remove redundant srcDirs declaration. --- app/build.gradle | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9140584ce33c..fcfbaaef9fb1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -154,12 +154,6 @@ android { java.srcDirs = ['src/migration/java', 'src/geckoRelease/java'] manifest.srcFile "src/migration/AndroidManifest.xml" } - oss { - java.srcDirs += ["src/oss"] - } - nonOss { - java.srcDirs += ["src/nonOss"] - } } splits { From e78c98d2a0d6b4a8e932cafaced7ee52df5b5e5c Mon Sep 17 00:00:00 2001 From: Gilbert Gilb's Date: Wed, 15 Jul 2020 17:25:12 +0200 Subject: [PATCH 10/11] Rename flavors and setup scripts to use them. --- README.md | 2 +- app/build.gradle | 49 ++++++++++++------- .../metrics/LeanplumMetricsService.kt | 1 - config/pre-push-recommended.sh | 6 +-- taskcluster/ci/build/kind.yml | 6 +-- taskcluster/fenix_taskgraph/gradle.py | 3 +- .../fenix_taskgraph/transforms/build.py | 7 ++- 7 files changed, 44 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index b93808d9a802..176f28c923fa 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Pre-requisites: 2. **Import** the project into Android Studio **or** build on the command line: ```shell - ./gradlew clean app:assembleDebug + ./gradlew clean app:assembleFenixDebug ``` If this errors out, make sure that you have an `ANDROID_SDK_ROOT` environment diff --git a/app/build.gradle b/app/build.gradle index fcfbaaef9fb1..347c9b1a2947 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -122,21 +122,27 @@ android { animationsDisabled = true } - flavorDimensions "version" + flavorDimensions "flavor" productFlavors { - oss { - dimension "version" + fenix { + dimension "flavor" + buildConfigField "boolean", "OSS_FLAVOR", "false" + } + fenixOss { + dimension "flavor" applicationIdSuffix ".oss" versionNameSuffix "-oss" buildConfigField "boolean", "OSS_FLAVOR", "true" } - nonOss { - dimension "version" - buildConfigField "boolean", "OSS_FLAVOR", "false" - } } sourceSets { + fenix { + java.srcDirs += ['src/nonOss'] + } + fenixOss { + java.srcDirs += ['src/oss'] + } androidTest { resources.srcDirs += ['src/androidTest/resources'] } @@ -449,10 +455,10 @@ dependencies { implementation Deps.adjust implementation Deps.installreferrer // Required by Adjust - nonOssImplementation Deps.leanplum_core - nonOssImplementation Deps.leanplum_fcm - nonOssImplementation Deps.mozilla_lib_push_firebase - nonOssImplementation Deps.google_ads_id // Required for the Google Advertising ID + fenixImplementation Deps.leanplum_core + fenixImplementation Deps.leanplum_fcm + fenixImplementation Deps.mozilla_lib_push_firebase + fenixImplementation Deps.google_ads_id // Required for the Google Advertising ID androidTestImplementation Deps.uiautomator // Removed pending AndroidX fixes @@ -556,17 +562,22 @@ task printVariants { fileName: it.outputFileName, ]}, build_type: it.buildType.name, + build_flavor: it.getFlavorName(), name: it.name, ]} // AndroidTest is a special case not included above - variants.add([ - apks: [[ - abi: 'noarch', - fileName: 'app-debug-androidTest.apk', - ]], - build_type: 'androidTest', - name: 'androidTest', - ]) + android.productFlavors.all { flavor -> + def flavorName = flavor.name + variants.add([ + apks: [[ + abi: 'noarch', + fileName: "app-${flavorName}-debug-androidTest.apk", + ]], + build_type: 'androidTest', + build_flavor: flavorName, + name: flavorName + 'AndroidTest', + ]) + } println 'variants: ' + groovy.json.JsonOutput.toJson(variants) } } diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt index 42668d06935b..2729ebe65a93 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt @@ -12,4 +12,3 @@ abstract class LeanplumMetricsService( private val application: Application, private val deviceIdGenerator: () -> String = { UUID.randomUUID().toString() } ) : MetricsService, DeepLinkIntentProcessor.DeepLinkVerifier - diff --git a/config/pre-push-recommended.sh b/config/pre-push-recommended.sh index 39ae24c4d806..780f3e60469a 100755 --- a/config/pre-push-recommended.sh +++ b/config/pre-push-recommended.sh @@ -17,9 +17,9 @@ ./gradlew -q \ ktlint \ detekt \ - assembleDebug \ - assembleDebugAndroidTest \ - testDebug + assembleFenixDebug \ + assembleFenixDebugAndroidTest \ + testFenixDebug # Tasks omitted because they take a long time to run: # - assembling all variants diff --git a/taskcluster/ci/build/kind.yml b/taskcluster/ci/build/kind.yml index bf412f1fc2e4..50edf15f4f3c 100644 --- a/taskcluster/ci/build/kind.yml +++ b/taskcluster/ci/build/kind.yml @@ -21,7 +21,7 @@ job-defaults: apk-artifact-template: type: file name: public/build/{abi}/target.apk - path: '/builds/worker/checkouts/src/app/build/outputs/apk/{gradle_build_type}/{fileName}' + path: '/builds/worker/checkouts/src/app/build/outputs/apk/{gradle_build_flavor}/{gradle_build_type}/{fileName}' description: Build Fenix from source code. fetches: toolchain: @@ -61,7 +61,7 @@ jobs: gradle-build-type: androidTest apk-artifact-template: # 2 differences here: "androidTest/" is added and "{gradle_build_type}" is forced to "debug" - path: '/builds/worker/checkouts/src/app/build/outputs/apk/androidTest/debug/{fileName}' + path: '/builds/worker/checkouts/src/app/build/outputs/apk/androidTest/fenix/debug/{fileName}' treeherder: symbol: debug(Bat) @@ -79,7 +79,7 @@ jobs: gradle-build-type: androidTest apk-artifact-template: # 2 differences here: "androidTest/" is added and "{gradle_build_type}" is forced to "debug" - path: '/builds/worker/checkouts/src/app/build/outputs/apk/androidTest/debug/{fileName}' + path: '/builds/worker/checkouts/src/app/build/outputs/apk/androidTest/fenix/debug/{fileName}' treeherder: symbol: nightly(Bat) diff --git a/taskcluster/fenix_taskgraph/gradle.py b/taskcluster/fenix_taskgraph/gradle.py index f4eea11597c0..0291866da740 100644 --- a/taskcluster/fenix_taskgraph/gradle.py +++ b/taskcluster/fenix_taskgraph/gradle.py @@ -11,11 +11,12 @@ -def get_variant(build_type): +def get_variant(build_type, build_flavor='fenix'): all_variants = _fetch_all_variants() matching_variants = [ variant for variant in all_variants if variant["build_type"] == build_type + and variant["build_flavor"] == build_flavor ] number_of_matching_variants = len(matching_variants) if number_of_matching_variants == 0: diff --git a/taskcluster/fenix_taskgraph/transforms/build.py b/taskcluster/fenix_taskgraph/transforms/build.py index ebc4b94def75..3ed3287f0438 100644 --- a/taskcluster/fenix_taskgraph/transforms/build.py +++ b/taskcluster/fenix_taskgraph/transforms/build.py @@ -67,7 +67,8 @@ def add_shippable_secrets(config, tasks): def build_gradle_command(config, tasks): for task in tasks: gradle_build_type = task["run"]["gradle-build-type"] - variant_config = get_variant(gradle_build_type) + gradle_build_flavor = task["run"].get("gradle-build-flavor", "fenix") + variant_config = get_variant(gradle_build_type, gradle_build_flavor) task["run"]["gradlew"] = [ "clean", @@ -103,7 +104,8 @@ def add_release_version(config, tasks): def add_artifacts(config, tasks): for task in tasks: gradle_build_type = task["run"].pop("gradle-build-type") - variant_config = get_variant(gradle_build_type) + gradle_build_flavor = task["run"].pop("gradle-build-flavor", "fenix") + variant_config = get_variant(gradle_build_type, gradle_build_flavor) artifacts = task.setdefault("worker", {}).setdefault("artifacts", []) task["attributes"]["apks"] = apks = {} @@ -118,6 +120,7 @@ def add_artifacts(config, tasks): "name": apk_name, "path": artifact_template["path"].format( gradle_build_type=gradle_build_type, + gradle_build_flavor=gradle_build_flavor, **apk ), }) From 8d948bf330441670dd7250c61bb3230f7bbe22ed Mon Sep 17 00:00:00 2001 From: Gilbert Gilb's Date: Thu, 13 Aug 2020 01:39:14 +0200 Subject: [PATCH 11/11] Revert implementation of AboutLibraries. This will be done in a separate PR: https://github.com/mozilla-mobile/fenix/pull/13767 --- app/build.gradle | 4 ++-- .../fenix/settings/about/AboutFragment.kt | 16 +++++++++------- build.gradle | 11 +---------- buildSrc/src/main/java/Dependencies.kt | 7 ++++--- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 347c9b1a2947..cf8b7b99b2b7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,7 +7,7 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'jacoco' apply plugin: 'androidx.navigation.safeargs.kotlin' -apply plugin: 'com.mikepenz.aboutlibraries.plugin' +apply plugin: 'com.google.android.gms.oss-licenses-plugin' import com.android.build.OutputFile @@ -348,7 +348,7 @@ dependencies { implementation Deps.androidx_coordinatorlayout implementation Deps.sentry - implementation Deps.aboutlibraries + implementation Deps.osslicenses_library implementation Deps.mozilla_concept_engine implementation Deps.mozilla_concept_menu diff --git a/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt index d56780c908ae..ece022c027a7 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt @@ -13,7 +13,7 @@ import android.view.ViewGroup import androidx.core.content.pm.PackageInfoCompat import androidx.fragment.app.Fragment import androidx.recyclerview.widget.DividerItemDecoration -import com.mikepenz.aboutlibraries.LibsBuilder +import com.google.android.gms.oss.licenses.OssLicensesMenuActivity import kotlinx.android.synthetic.main.fragment_about.* import org.mozilla.fenix.BrowserDirection import org.mozilla.fenix.BuildConfig @@ -119,7 +119,7 @@ class AboutFragment : Fragment(), AboutPageListener { private fun populateAboutList(): List { val context = requireContext() - return listOfNotNull( + return listOf( AboutPageItem( AboutItem.ExternalLink( WHATS_NEW, @@ -168,11 +168,13 @@ class AboutFragment : Fragment(), AboutPageListener { } private fun openLibrariesPage() { - val ctx = context - if (ctx != null) { - val title = getString(R.string.open_source_licenses_title, appName) - LibsBuilder().withAboutAppName(title).start(ctx) - } + startActivity(Intent(context, OssLicensesMenuActivity::class.java)) + OssLicensesMenuActivity.setActivityTitle( + getString( + R.string.open_source_licenses_title, + appName + ) + ) } override fun onAboutItemClicked(item: AboutItem) { diff --git a/build.gradle b/build.gradle index ee8834d986f4..a236dc19118d 100644 --- a/build.gradle +++ b/build.gradle @@ -62,22 +62,13 @@ buildscript { classpath Deps.tools_kotlingradle classpath Deps.androidx_safeargs classpath Deps.allopen - classpath Deps.aboutlibraries_plugin + classpath Deps.osslicenses_plugin classpath "org.mozilla.components:tooling-glean-gradle:${Versions.mozilla_android_components}" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } - - // AboutLibraries depends on Android gradle plugin 4.0+, but we can't update it for now - // It should be safe to remove this block once android gradle plugin is updated - // See https://github.com/mozilla-mobile/fenix/issues/13262 - configurations.classpath { - resolutionStrategy { - force Deps.tools_androidgradle - } - } } plugins { diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 200c682fd00f..876e537dd311 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -9,7 +9,8 @@ object Versions { const val sentry = "1.7.10" const val leakcanary = "2.4" const val leanplum = "5.4.0" - const val aboutlibraries = "8.3.0" + const val osslicenses_plugin = "0.9.5" + const val osslicenses_library = "17.0.0" const val detekt = "1.9.1" const val androidx_appcompat = "1.2.0-rc01" @@ -57,8 +58,8 @@ object Deps { const val kotlin_coroutines_android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutines}" const val allopen = "org.jetbrains.kotlin:kotlin-allopen:${Versions.kotlin}" - const val aboutlibraries = "com.mikepenz:aboutlibraries:${Versions.aboutlibraries}" - const val aboutlibraries_plugin = "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:${Versions.aboutlibraries}" + const val osslicenses_plugin = "com.google.android.gms:oss-licenses-plugin:${Versions.osslicenses_plugin}" + const val osslicenses_library = "com.google.android.gms:play-services-oss-licenses:${Versions.osslicenses_library}" const val mozilla_concept_engine = "org.mozilla.components:concept-engine:${Versions.mozilla_android_components}" const val mozilla_concept_menu = "org.mozilla.components:concept-menu:${Versions.mozilla_android_components}"