Commit b9aee25e authored by Colin Lee's avatar Colin Lee
Browse files

Fixes #675: Integrate Adjust SDK (for Greenfield flavor)

parent c4fe4452
Loading
Loading
Loading
Loading

.adjust_token

0 → 100644
+1 −0
Original line number Diff line number Diff line
--
 No newline at end of file
+64 −31
Original line number Diff line number Diff line
@@ -106,6 +106,11 @@ android {
}

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
    if (hasTest) {
        apply plugin: 'kotlin-allopen'
@@ -113,12 +118,14 @@ android.applicationVariants.all { variant ->
            annotation("org.mozilla.fenix.test.Mockable")
        }
    }
}

android.applicationVariants.all { variant ->
// -------------------------------------------------------------------------------------------------
// Generate version codes for builds
// -------------------------------------------------------------------------------------------------

    def buildType = variant.buildType.name

    if (buildType == "release" || buildType == "nightly") {
    if (buildType == "release") {
        def versionCode = generatedVersionCode

        // 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("Flavor:       " + variant.flavorName)
    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 {
@@ -219,6 +277,9 @@ dependencies {

    implementation Deps.autodispose

    implementation Deps.adjust
    implementation Deps.installreferrer // Required by Adjust

    androidTestImplementation Deps.tools_test_runner
    androidTestImplementation Deps.tools_espresso_core

@@ -234,34 +295,6 @@ dependencies {
    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")) {
    android.defaultConfig.manifestPlaceholders.isRaptorEnabled = "true"
}
+32 −1
Original line number Diff line number Diff line
@@ -41,3 +41,34 @@
####################################################################################################

-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);
}
+13 −0
Original line number Diff line number Diff line
/* 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.
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -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.sink.AndroidLogSink
import mozilla.components.support.rustlog.RustLog
import org.mozilla.fenix.AdjustHelper.setupAdjustIfNeeded
import org.mozilla.fenix.components.Components
import java.io.File

@@ -47,6 +48,7 @@ open class FenixApplication : Application() {
        setupLeakCanary()
        setupGlean(this)
        loadExperiments()
        setupAdjustIfNeeded(this)
    }

    protected open fun setupLeakCanary() {
Loading