Commit e911562a authored by Matthew Finkel's avatar Matthew Finkel Committed by Pier Angelo Vendrame
Browse files

[android] 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 57c230fa
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ class SettingsTest {
            cookieBannerHandlingDetectOnlyMode = true,
            cookieBannerHandlingGlobalRules = true,
            cookieBannerHandlingGlobalRulesSubFrames = true,
            emailTrackerBlockingPrivateBrowsing = true,
            emailTrackerBlockingPrivateBrowsing = false,
        )

        assertFalse(defaultSettings.domStorageEnabled)
+4 −0
Original line number Diff line number Diff line
@@ -8,6 +8,10 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
    androidResources {
        ignoreAssetsPattern '!<dir>extensions'
    }

    defaultConfig {
        minSdkVersion = config.minSdkVersion
        compileSdk = config.compileSdkVersion
+4 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ class AddonManager(
     * the [addonsProvider] or querying web extension state from the engine / store.
     */
    @Throws(AddonManagerException::class)
    @Suppress("TooGenericExceptionCaught")
    @Suppress("TooGenericExceptionCaught", "UNUSED_PARAMETER")
    suspend fun getAddons(
        waitForPendingActions: Boolean = true,
        allowCache: Boolean = true,
@@ -113,6 +113,8 @@ class AddonManager(
            // Get all the featured add-ons not installed from provider.
            // NB: We're keeping translations only for the default locale.
            var featuredAddons = emptyList<Addon>()
            // tor-browser#40502: Do not recommend addons on Tor Browser
            /*
            try {
                val userLanguage = Locale.getDefault().language
                val locales = listOf(userLanguage)
@@ -124,6 +126,7 @@ class AddonManager(
                // Do not throw when we fail to fetch the featured add-ons since there can be installed add-ons.
                logger.warn("Failed to get the featured add-ons", throwable)
            }
            */

            // Build a list of installed extensions that are not built-in extensions.
            val installedAddons = installedExtensions
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ apply plugin: 'kotlin-android'

android {
    androidResources {
        ignoreAssetsPattern '!amazon*:!azerdict*:!baidu*:!bing*:!ceneje*:!coccoc*:!daum*:!ebay*:!ecosia*:!faclair*:!google*:!gulesider*:!leo*:!mapy*:!mercadolibre*:!odpiralni*:!pazaruvaj*:!prisjakt*:!qwant*:!rakuten*:!salidzinilv*:!seznam*:!vatera*:!wikipedia-*:!wiktionary*:!yahoo*:!yandex*'
        ignoreAssetsPattern '!<dir>extensions:!search_telemetry_v2.json:!amazon*:!azerdict*:!baidu*:!bing*:!ceneje*:!coccoc*:!daum*:!ebay*:!ecosia*:!faclair*:!google*:!gulesider*:!leo*:!mapy*:!mercadolibre*:!odpiralni*:!pazaruvaj*:!prisjakt*:!qwant*:!rakuten*:!salidzinilv*:!seznam*:!vatera*:!wikipedia-*:!wiktionary*:!yahoo*:!yandex*'
    }

    defaultConfig {
+32 −31
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ import mozilla.appservices.remotesettings.RemoteSettingsResponse
import mozilla.components.support.base.log.logger.Logger
import mozilla.components.support.ktx.android.org.json.asSequence
import mozilla.components.support.ktx.android.org.json.toList
import mozilla.components.support.remotesettings.RemoteSettingsClient
//import mozilla.components.support.remotesettings.RemoteSettingsClient
import mozilla.components.support.remotesettings.RemoteSettingsResult
import org.json.JSONArray
import org.json.JSONException
@@ -23,22 +23,22 @@ internal const val REMOTE_ENDPOINT_BUCKET_NAME = "main"
 * Parse SERP Telemetry json from remote config.
 */
class SerpTelemetryRepository(
    rootStorageDirectory: File,
//    rootStorageDirectory: File,
    private val readJson: () -> JSONObject,
    collectionName: String,
    serverUrl: String = REMOTE_PROD_ENDPOINT_URL,
    bucketName: String = REMOTE_ENDPOINT_BUCKET_NAME,
//    collectionName: String,
//    serverUrl: String = REMOTE_PROD_ENDPOINT_URL,
//    bucketName: String = REMOTE_ENDPOINT_BUCKET_NAME,
) {
    val logger = Logger("SerpTelemetryRepository")
    private var providerList: List<SearchProviderModel> = emptyList()

    @VisibleForTesting
    internal var remoteSettingsClient = RemoteSettingsClient(
        serverUrl = serverUrl,
        bucketName = bucketName,
        collectionName = collectionName,
        storageRootDirectory = rootStorageDirectory,
    )
//    @VisibleForTesting
//    internal var remoteSettingsClient = RemoteSettingsClient(
//        serverUrl = serverUrl,
//        bucketName = bucketName,
//        collectionName = collectionName,
//        storageRootDirectory = rootStorageDirectory,
//    )

    /**
     * Provides list of search providers from cache or dump and fetches from remotes server .
@@ -65,7 +65,7 @@ class SerpTelemetryRepository(
        val remoteResponse = fetchRemoteResponse()
        if (remoteResponse.lastModified > cacheLastModified) {
            providerList = parseRemoteResponse(remoteResponse)
            writeToCache(remoteResponse)
            //writeToCache(remoteResponse)
        }
    }

@@ -73,8 +73,9 @@ class SerpTelemetryRepository(
     * Writes data to local cache.
     */
    @VisibleForTesting
    internal suspend fun writeToCache(records: RemoteSettingsResponse): RemoteSettingsResult {
        return remoteSettingsClient.write(records)
    internal suspend fun writeToCache(/*records: RemoteSettingsResponse*/): RemoteSettingsResult {
        return RemoteSettingsResult.NetworkFailure(Exception("Bug-43113: no remote fetching"))
//        return remoteSettingsClient.write(records)
    }

    /**
@@ -104,12 +105,12 @@ class SerpTelemetryRepository(
     */
    @VisibleForTesting
    internal suspend fun fetchRemoteResponse(): RemoteSettingsResponse {
        val result = remoteSettingsClient.fetch()
        return if (result is RemoteSettingsResult.Success) {
            result.response
        } else {
            RemoteSettingsResponse(emptyList(), 0u)
        }
//        val result = remoteSettingsClient.fetch()
//        return if (result is RemoteSettingsResult.Success) {
//            result.response
//        } else {
        return RemoteSettingsResponse(emptyList(), 0u)
//        }
    }

    /**
@@ -117,16 +118,16 @@ class SerpTelemetryRepository(
     */
    @VisibleForTesting
    internal suspend fun loadProvidersFromCache(): Pair<ULong, List<SearchProviderModel>> {
        val result = remoteSettingsClient.read()
        return if (result is RemoteSettingsResult.Success) {
            val response = result.response.records.mapNotNull {
                it.fields.toSearchProviderModel()
            }
            val lastModified = result.response.lastModified
            Pair(lastModified, response)
        } else {
            Pair(0u, emptyList())
        }
//        val result = remoteSettingsClient.read()
//        return if (result is RemoteSettingsResult.Success) {
//            val response = result.response.records.mapNotNull {
//                it.fields.toSearchProviderModel()
//            }
//            val lastModified = result.response.lastModified
//            Pair(lastModified, response)
//        } else {
        return Pair(0u, emptyList())
//        }
    }
}

Loading