Fixes #675: Integrate Adjust SDK (for Greenfield flavor)
parent
c4fe44529a
commit
b9aee25edd
|
@ -0,0 +1 @@
|
||||||
|
--
|
|
@ -106,6 +106,11 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
android.applicationVariants.all { variant ->
|
android.applicationVariants.all { variant ->
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
// Set up kotlin-allopen plugin for writing tests
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
boolean hasTest = gradle.startParameter.taskNames.find {it.contains("test") || it.contains("Test")} != null
|
boolean hasTest = gradle.startParameter.taskNames.find {it.contains("test") || it.contains("Test")} != null
|
||||||
if (hasTest) {
|
if (hasTest) {
|
||||||
apply plugin: 'kotlin-allopen'
|
apply plugin: 'kotlin-allopen'
|
||||||
|
@ -113,12 +118,14 @@ android.applicationVariants.all { variant ->
|
||||||
annotation("org.mozilla.fenix.test.Mockable")
|
annotation("org.mozilla.fenix.test.Mockable")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
android.applicationVariants.all { variant ->
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
// Generate version codes for builds
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
def buildType = variant.buildType.name
|
def buildType = variant.buildType.name
|
||||||
|
|
||||||
if (buildType == "release" || buildType == "nightly") {
|
if (buildType == "release") {
|
||||||
def versionCode = generatedVersionCode
|
def versionCode = generatedVersionCode
|
||||||
|
|
||||||
// The Google Play Store does not allow multiple APKs for the same app that all have the
|
// The Google Play Store does not allow multiple APKs for the same app that all have the
|
||||||
|
@ -144,6 +151,57 @@ android.applicationVariants.all { variant ->
|
||||||
println("Build type: " + buildType)
|
println("Build type: " + buildType)
|
||||||
println("Flavor: " + variant.flavorName)
|
println("Flavor: " + variant.flavorName)
|
||||||
println("Version code: " + variant.mergedFlavor.versionCode)
|
println("Version code: " + variant.mergedFlavor.versionCode)
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
// BuildConfig: Set variables for Sentry, Crash Reporting, and Telemetry
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Reading sentry token from local file (if it exists). In a release task on taskcluster it will be available.
|
||||||
|
try {
|
||||||
|
def token = new File("${rootDir}/.sentry_token").text.trim()
|
||||||
|
buildConfigField 'String', 'SENTRY_TOKEN', '"' + token + '"'
|
||||||
|
} catch (FileNotFoundException ignored) {
|
||||||
|
buildConfigField 'String', 'SENTRY_TOKEN', 'null'
|
||||||
|
}
|
||||||
|
|
||||||
|
// Activating crash reporting only if command line parameter was provided (in automation)
|
||||||
|
if (project.hasProperty("crashReports") && project.property("crashReports") == "true") {
|
||||||
|
buildConfigField 'boolean', 'CRASH_REPORTING', 'true'
|
||||||
|
} else {
|
||||||
|
buildConfigField 'boolean', 'CRASH_REPORTING', 'false'
|
||||||
|
}
|
||||||
|
|
||||||
|
// Activating telemetry only if command line parameter was provided (in automation)
|
||||||
|
if (project.hasProperty("telemetry") && project.property("telemetry") == "true") {
|
||||||
|
buildConfigField 'boolean', 'TELEMETRY', 'true'
|
||||||
|
} else {
|
||||||
|
buildConfigField 'boolean', 'TELEMETRY', 'false'
|
||||||
|
}
|
||||||
|
|
||||||
|
def buildDate = Config.generateBuildDate()
|
||||||
|
buildConfigField 'String', 'BUILD_DATE', '"' + buildDate + '"'
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
// Adjust: Read token from locale file if it exists (Only release builds)
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
def variantName = variant.getName()
|
||||||
|
|
||||||
|
print("Adjust token: ")
|
||||||
|
|
||||||
|
if (variantName.contains("Release")) {
|
||||||
|
try {
|
||||||
|
def token = new File("${rootDir}/.adjust_token").text.trim()
|
||||||
|
buildConfigField 'String', 'ADJUST_TOKEN', '"' + token + '"'
|
||||||
|
println "(Added from .adjust_token file)"
|
||||||
|
} catch (FileNotFoundException ignored) {
|
||||||
|
buildConfigField 'String', 'ADJUST_TOKEN', 'null'
|
||||||
|
println("X_X")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
buildConfigField 'String', 'ADJUST_TOKEN', 'null'
|
||||||
|
println("--")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
androidExtensions {
|
androidExtensions {
|
||||||
|
@ -219,6 +277,9 @@ dependencies {
|
||||||
|
|
||||||
implementation Deps.autodispose
|
implementation Deps.autodispose
|
||||||
|
|
||||||
|
implementation Deps.adjust
|
||||||
|
implementation Deps.installreferrer // Required by Adjust
|
||||||
|
|
||||||
androidTestImplementation Deps.tools_test_runner
|
androidTestImplementation Deps.tools_test_runner
|
||||||
androidTestImplementation Deps.tools_espresso_core
|
androidTestImplementation Deps.tools_espresso_core
|
||||||
|
|
||||||
|
@ -234,34 +295,6 @@ dependencies {
|
||||||
annotationProcessor Deps.glideAnnotationProcessor
|
annotationProcessor Deps.glideAnnotationProcessor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
android.applicationVariants.all { variant ->
|
|
||||||
// Reading sentry token from local file (if it exists). In a release task on taskcluster it will be available.
|
|
||||||
try {
|
|
||||||
def token = new File("${rootDir}/.sentry_token").text.trim()
|
|
||||||
buildConfigField 'String', 'SENTRY_TOKEN', '"' + token + '"'
|
|
||||||
} catch (FileNotFoundException ignored) {
|
|
||||||
buildConfigField 'String', 'SENTRY_TOKEN', 'null'
|
|
||||||
}
|
|
||||||
|
|
||||||
// Activating crash reporting only if command line parameter was provided (in automation)
|
|
||||||
if (project.hasProperty("crashReports") && project.property("crashReports") == "true") {
|
|
||||||
buildConfigField 'boolean', 'CRASH_REPORTING', 'true'
|
|
||||||
} else {
|
|
||||||
buildConfigField 'boolean', 'CRASH_REPORTING', 'false'
|
|
||||||
}
|
|
||||||
|
|
||||||
// Activating telemetry only if command line parameter was provided (in automation)
|
|
||||||
if (project.hasProperty("telemetry") && project.property("telemetry") == "true") {
|
|
||||||
buildConfigField 'boolean', 'TELEMETRY', 'true'
|
|
||||||
} else {
|
|
||||||
buildConfigField 'boolean', 'TELEMETRY', 'false'
|
|
||||||
}
|
|
||||||
|
|
||||||
def buildDate = Config.generateBuildDate()
|
|
||||||
buildConfigField 'String', 'BUILD_DATE', '"' + buildDate + '"'
|
|
||||||
}
|
|
||||||
|
|
||||||
if (project.hasProperty("raptor")) {
|
if (project.hasProperty("raptor")) {
|
||||||
android.defaultConfig.manifestPlaceholders.isRaptorEnabled = "true"
|
android.defaultConfig.manifestPlaceholders.isRaptorEnabled = "true"
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,3 +41,34 @@
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
|
||||||
-keep class mozilla.appservices.FenixMegazord { *; }
|
-keep class mozilla.appservices.FenixMegazord { *; }
|
||||||
|
|
||||||
|
####################################################################################################
|
||||||
|
# Adjust
|
||||||
|
####################################################################################################
|
||||||
|
|
||||||
|
-keep public class com.adjust.sdk.** { *; }
|
||||||
|
-keep class com.google.android.gms.common.ConnectionResult {
|
||||||
|
int SUCCESS;
|
||||||
|
}
|
||||||
|
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
|
||||||
|
com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
|
||||||
|
}
|
||||||
|
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
|
||||||
|
java.lang.String getId();
|
||||||
|
boolean isLimitAdTrackingEnabled();
|
||||||
|
}
|
||||||
|
-keep public class com.android.installreferrer.** { *; }
|
||||||
|
-keep class dalvik.system.VMRuntime {
|
||||||
|
java.lang.String getRuntime();
|
||||||
|
}
|
||||||
|
-keep class android.os.Build {
|
||||||
|
java.lang.String[] SUPPORTED_ABIS;
|
||||||
|
java.lang.String CPU_ABI;
|
||||||
|
}
|
||||||
|
-keep class android.content.res.Configuration {
|
||||||
|
android.os.LocaledList getLocales();
|
||||||
|
java.util.Locale locale;
|
||||||
|
}
|
||||||
|
-keep class android.os.LocaleList {
|
||||||
|
java.util.Locale get(int);
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
|
||||||
|
object AdjustHelper {
|
||||||
|
fun setupAdjustIfNeeded(context: Context) {
|
||||||
|
// DEBUG: No Adjust - This class has different implementations for all build types.
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,6 +20,7 @@ import mozilla.components.support.base.log.Log
|
||||||
import mozilla.components.support.base.log.logger.Logger
|
import mozilla.components.support.base.log.logger.Logger
|
||||||
import mozilla.components.support.base.log.sink.AndroidLogSink
|
import mozilla.components.support.base.log.sink.AndroidLogSink
|
||||||
import mozilla.components.support.rustlog.RustLog
|
import mozilla.components.support.rustlog.RustLog
|
||||||
|
import org.mozilla.fenix.AdjustHelper.setupAdjustIfNeeded
|
||||||
import org.mozilla.fenix.components.Components
|
import org.mozilla.fenix.components.Components
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
@ -47,6 +48,7 @@ open class FenixApplication : Application() {
|
||||||
setupLeakCanary()
|
setupLeakCanary()
|
||||||
setupGlean(this)
|
setupGlean(this)
|
||||||
loadExperiments()
|
loadExperiments()
|
||||||
|
setupAdjustIfNeeded(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun setupLeakCanary() {
|
protected open fun setupLeakCanary() {
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
/* 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
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.app.Application
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.text.TextUtils
|
||||||
|
|
||||||
|
import com.adjust.sdk.Adjust
|
||||||
|
import com.adjust.sdk.AdjustConfig
|
||||||
|
import com.adjust.sdk.LogLevel
|
||||||
|
import mozilla.components.service.glean.Glean
|
||||||
|
|
||||||
|
object AdjustHelper {
|
||||||
|
fun setupAdjustIfNeeded(application: FenixApplication) {
|
||||||
|
// RELEASE: Enable Adjust - This class has different implementations for all build types.
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(BuildConfig.ADJUST_TOKEN)) {
|
||||||
|
throw IllegalStateException("No adjust token defined for release build")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Glean.getUploadEnabled()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val config = AdjustConfig(
|
||||||
|
application,
|
||||||
|
BuildConfig.ADJUST_TOKEN,
|
||||||
|
AdjustConfig.ENVIRONMENT_PRODUCTION,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
|
config.setLogLevel(LogLevel.SUPRESS)
|
||||||
|
|
||||||
|
Adjust.onCreate(config)
|
||||||
|
|
||||||
|
application.registerActivityLifecycleCallbacks(AdjustLifecycleCallbacks())
|
||||||
|
}
|
||||||
|
|
||||||
|
private class AdjustLifecycleCallbacks : Application.ActivityLifecycleCallbacks {
|
||||||
|
override fun onActivityResumed(activity: Activity) {
|
||||||
|
Adjust.onResume()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityPaused(activity: Activity) {
|
||||||
|
Adjust.onPause()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle) {}
|
||||||
|
|
||||||
|
override fun onActivityStarted(activity: Activity) {}
|
||||||
|
|
||||||
|
override fun onActivityStopped(activity: Activity) {}
|
||||||
|
|
||||||
|
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
|
||||||
|
|
||||||
|
override fun onActivityDestroyed(activity: Activity) {}
|
||||||
|
}
|
||||||
|
}
|
|
@ -53,7 +53,8 @@ def generate_build_task(apks, is_staging):
|
||||||
checkout +
|
checkout +
|
||||||
' && python automation/taskcluster/helper/get-secret.py'
|
' && python automation/taskcluster/helper/get-secret.py'
|
||||||
' -s {} -k dsn -f .sentry_token'.format(sentry_secret) +
|
' -s {} -k dsn -f .sentry_token'.format(sentry_secret) +
|
||||||
' && ./gradlew --no-daemon -PcrashReports=true clean test assembleRelease'),
|
' && python automation/taskcluster/adjust/get-secret.py get-secret.py -s project/mobile/fenix/adjust -k Greenfield -f .adjust_token' if not is_staging else '' +
|
||||||
|
' && ./gradlew --no-daemon -PcrashReports=true clean test assembleGreenfieldRelease'),
|
||||||
features={
|
features={
|
||||||
"chainOfTrust": True,
|
"chainOfTrust": True,
|
||||||
"taskclusterProxy": True
|
"taskclusterProxy": True
|
||||||
|
|
|
@ -30,6 +30,8 @@ private object Versions {
|
||||||
const val android_arch_navigation = "1.0.0-rc02"
|
const val android_arch_navigation = "1.0.0-rc02"
|
||||||
|
|
||||||
const val autodispose = "1.1.0"
|
const val autodispose = "1.1.0"
|
||||||
|
const val adjust = "4.11.4"
|
||||||
|
const val installreferrer = "1.0"
|
||||||
|
|
||||||
const val junit_jupiter = "5.3.2"
|
const val junit_jupiter = "5.3.2"
|
||||||
const val mockito = "2.23.0"
|
const val mockito = "2.23.0"
|
||||||
|
@ -128,6 +130,9 @@ object Deps {
|
||||||
const val autodispose_android_aac = "com.uber.autodispose:autodispose-android-archcomponents:${Versions.autodispose}"
|
const val autodispose_android_aac = "com.uber.autodispose:autodispose-android-archcomponents:${Versions.autodispose}"
|
||||||
const val autodispose_android_aac_test = "com.uber.autodispose:autodispose-android-archcomponents-test:${Versions.autodispose}"
|
const val autodispose_android_aac_test = "com.uber.autodispose:autodispose-android-archcomponents-test:${Versions.autodispose}"
|
||||||
|
|
||||||
|
const val adjust = "com.adjust.sdk:adjust-android:${Versions.adjust}"
|
||||||
|
const val installreferrer = "com.android.installreferrer:installreferrer:${Versions.installreferrer}"
|
||||||
|
|
||||||
const val junit_jupiter_api = "org.junit.jupiter:junit-jupiter-api:${Versions.junit_jupiter}"
|
const val junit_jupiter_api = "org.junit.jupiter:junit-jupiter-api:${Versions.junit_jupiter}"
|
||||||
const val junit_jupiter_params = "org.junit.jupiter:junit-jupiter-params:${Versions.junit_jupiter}"
|
const val junit_jupiter_params = "org.junit.jupiter:junit-jupiter-params:${Versions.junit_jupiter}"
|
||||||
const val junit_jupiter_engine = "org.junit.jupiter:junit-jupiter-engine:${Versions.junit_jupiter}"
|
const val junit_jupiter_engine = "org.junit.jupiter:junit-jupiter-engine:${Versions.junit_jupiter}"
|
||||||
|
|
Loading…
Reference in New Issue