Commit 42131500 authored by Matthew Finkel's avatar Matthew Finkel
Browse files

Disable features and functionality

Bug 33594: Disable data collection by default (Glean)

Bug 40019: Adjust is disabled on Release when data collection is disabled

Bug 34338: Disable the crash reporter

Bug 40014: Neuter Google Advertising ID

Bug 40018: Disable Push service

Bug 40034: Disable PWA onboading

Bug 40072: Disable Tracking Protection

Bug 40061: Do not show "Send to device" in sharing menu

Bug 40109: Reduce requested permissions

Exclude LOCATION and NETWORK_STATE
parent 00002797
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -68,6 +68,8 @@ android {
        } else {
            buildConfigField "boolean", "MOZILLA_ONLINE", "false"
        }

        buildConfigField "boolean", "DATA_COLLECTION_DISABLED", "true"
    }

    def releaseTemplate = {
@@ -245,6 +247,8 @@ android.applicationVariants.all { variant ->
// -------------------------------------------------------------------------------------------------

    def isDebug = variant.buildType.resValues['IS_DEBUG']?.value ?: false
    def isDataCollectionDisabled = variant.buildType.buildConfigFields['DATA_COLLECTION_DISABLED']?.value ?: true
    def isDebugOrDCD = isDebug || isDataCollectionDisabled
    def useReleaseVersioning = variant.buildType.buildConfigFields['USE_RELEASE_VERSIONING']?.value ?: false
    def versionName = Config.releaseVersionName(project)

@@ -253,7 +257,7 @@ android.applicationVariants.all { variant ->
    println("Application ID:    " + [variant.mergedFlavor.applicationId, variant.buildType.applicationIdSuffix].findAll().join())
    println("Build type:        " + variant.buildType.name)
    println("Flavor:            " + variant.flavorName)
    println("Telemetry enabled: " + !isDebug)
    println("Telemetry enabled: " + !isDebugOrDCD)

    if (useReleaseVersioning) {
        // The Google Play Store does not allow multiple APKs for the same app that all have the
@@ -278,7 +282,7 @@ android.applicationVariants.all { variant ->
// -------------------------------------------------------------------------------------------------

    buildConfigField 'String', 'SENTRY_TOKEN', 'null'
    if (!isDebug) {
    if (!isDebugOrDCD) {
        buildConfigField 'boolean', 'CRASH_REPORTING', 'true'
        // Reading sentry token from local file (if it exists). In a release task on taskcluster it will be available.
        try {
@@ -289,7 +293,7 @@ android.applicationVariants.all { variant ->
        buildConfigField 'boolean', 'CRASH_REPORTING', 'false'
    }

    if (!isDebug) {
    if (!isDebugOrDCD) {
        buildConfigField 'boolean', 'TELEMETRY', 'true'
    } else {
        buildConfigField 'boolean', 'TELEMETRY', 'false'
@@ -310,7 +314,7 @@ android.applicationVariants.all { variant ->

    print("Adjust token: ")

    if (!isDebug) {
    if (!isDebugOrDCD) {
        try {
            def token = new File("${rootDir}/.adjust_token").text.trim()
            buildConfigField 'String', 'ADJUST_TOKEN', '"' + token + '"'
@@ -554,8 +558,6 @@ dependencies {
    implementation Deps.adjust
    implementation Deps.installreferrer // Required by Adjust

    implementation Deps.google_ads_id // Required for the Google Advertising ID

    implementation Deps.google_play_store // Required for in-app reviews

    androidTestImplementation Deps.uiautomator
+1 −3
Original line number Diff line number Diff line
@@ -4,11 +4,8 @@
    package="org.mozilla.fenix">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
@@ -274,6 +271,7 @@

        <service
            android:name=".push.FirebasePushService"
            android:enabled="false"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
+2 −1
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ class Analytics(
                appName = context.getString(R.string.app_name),
                organizationName = "Mozilla"
            ),
            enabled = true,
            enabled = !isDataColectionDisabled(),
            nonFatalCrashIntent = pendingIntent
        )
    }
@@ -114,6 +114,7 @@ class Analytics(
    }
}

fun isDataColectionDisabled() = BuildConfig.DATA_COLLECTION_DISABLED
fun isSentryEnabled() = !BuildConfig.SENTRY_TOKEN.isNullOrEmpty()

private fun getSentryProjectUrl(): String? {
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ class AdjustMetricsService(private val application: Application) : MetricsServic
        if ((BuildConfig.ADJUST_TOKEN.isNullOrBlank())) {
            Log.i(LOGTAG, "No adjust token defined")

            if (Config.channel.isReleased) {
            if (Config.channel.isReleased && !BuildConfig.DATA_COLLECTION_DISABLED) {
                throw IllegalStateException("No adjust token defined for release build")
            }

+1 −10
Original line number Diff line number Diff line
@@ -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.state.search.SearchEngine
@@ -87,14 +84,8 @@ object MetricsUtils {
     */
    @Suppress("TooGenericExceptionCaught")
    @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
    internal fun getAdvertisingID(context: Context): String? {
    internal fun getAdvertisingID(@Suppress("UNUSED_PARAMETER") 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.
Loading