Verified Commit 9cb478b0 authored by Matthew Finkel's avatar Matthew Finkel Committed by Pier Angelo Vendrame
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 fbd44564
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -75,6 +75,8 @@ android {
        } else {
            buildConfigField "boolean", "MOZILLA_ONLINE", "false"
        }

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

    def releaseTemplate = {
@@ -236,6 +238,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

    println("----------------------------------------------")
@@ -243,7 +247,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
@@ -280,7 +284,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 {
@@ -291,7 +295,7 @@ android.applicationVariants.all { variant ->
        buildConfigField 'boolean', 'CRASH_REPORTING', 'false'
    }

    if (!isDebug) {
    if (!isDebugOrDCD) {
        buildConfigField 'boolean', 'TELEMETRY', 'true'
    } else {
        buildConfigField 'boolean', 'TELEMETRY', 'false'
@@ -312,7 +316,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 + '"'
@@ -585,8 +589,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,15 +4,12 @@
    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"
        android:maxSdkVersion="28"
        tools:ignore="ScopedStorage"
        />
    <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" />
@@ -307,6 +304,7 @@

        <service
            android:name=".push.FirebasePushService"
            android:enabled="false"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
+5 −3
Original line number Diff line number Diff line
@@ -137,6 +137,10 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
    @OptIn(DelicateCoroutinesApi::class) // GlobalScope usage
    protected open fun initializeGlean() {
        val telemetryEnabled = settings().isTelemetryEnabled
        if (!telemetryEnabled) {
            logger.debug("Preventing Glean from initializing, since telemetry is disabled")
            return
        }

        logger.debug("Initializing Glean (uploadEnabled=$telemetryEnabled})")

@@ -820,8 +824,6 @@ open class FenixApplication : LocaleAwareApplication(), Provider {

    @OptIn(DelicateCoroutinesApi::class)
    open fun downloadWallpapers() {
        GlobalScope.launch {
            components.wallpaperManager.downloadAllRemoteWallpapers()
        }
        // IN TOR BROWSER: we don't download wallpapers.
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ class Analytics(
                appName = context.getString(R.string.app_name),
                organizationName = "Mozilla"
            ),
            enabled = true,
            enabled = !isDataColectionDisabled(),
            nonFatalCrashIntent = pendingIntent
        )
    }
@@ -141,6 +141,7 @@ class Analytics(
    }
}

fun isDataColectionDisabled() = BuildConfig.DATA_COLLECTION_DISABLED
private 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")
            }

Loading