Commit d49b5dac 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

Bug 40162: Disable Numbus experiments
parent 275e5be9
......@@ -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
......
......@@ -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" />
......
......@@ -17,7 +17,7 @@ object FeatureFlags {
/**
* Enables the Nimbus experiments library.
*/
const val nimbusExperiments = true
const val nimbusExperiments = false
/**
* Enables the Addresses autofill feature.
......
......@@ -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? {
......
......@@ -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")
}
......
......@@ -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.
......
......@@ -50,7 +50,7 @@ enum class PhoneFeature(val androidPermissionsList: Array<String>) : Parcelable
AUTOPLAY_AUDIBLE ->
when (settings?.getAutoplayUserSetting(default = AUTOPLAY_BLOCK_ALL) ?: AUTOPLAY_BLOCK_ALL) {
AUTOPLAY_ALLOW_ALL -> R.string.preference_option_autoplay_allowed2
AUTOPLAY_ALLOW_ON_WIFI -> R.string.preference_option_autoplay_allowed_wifi_only2
// AUTOPLAY_ALLOW_ON_WIFI -> R.string.preference_option_autoplay_allowed_wifi_only2
AUTOPLAY_BLOCK_AUDIBLE -> R.string.preference_option_autoplay_block_audio2
AUTOPLAY_BLOCK_ALL -> R.string.preference_option_autoplay_blocked3
else -> R.string.preference_option_autoplay_blocked3
......@@ -119,6 +119,7 @@ enum class PhoneFeature(val androidPermissionsList: Array<String>) : Parcelable
return when (this) {
AUTOPLAY_AUDIBLE -> SitePermissionsRules.Action.BLOCKED
AUTOPLAY_INAUDIBLE -> SitePermissionsRules.Action.ALLOWED
LOCATION -> SitePermissionsRules.Action.BLOCKED
else -> SitePermissionsRules.Action.ASK_TO_ALLOW
}
}
......
......@@ -52,6 +52,7 @@ class SitePermissionsFragment : PreferenceFragmentCompat() {
// Autoplay inaudible should be set in the same menu as autoplay audible, so it does
// not need to be bound
.filter { it != PhoneFeature.AUTOPLAY_INAUDIBLE }
.filter { it != PhoneFeature.LOCATION }
.forEach(::initPhoneFeature)
}
......
......@@ -115,6 +115,7 @@ class SitePermissionsManagePhoneFeatureFragment : Fragment() {
saveActionInSettings(AUTOPLAY_ALLOW_ALL)
}
restoreState(AUTOPLAY_ALLOW_ON_WIFI)
visibility = View.GONE
} else {
text = getString(R.string.preference_option_phone_feature_blocked)
setOnClickListener {
......
......@@ -27,7 +27,6 @@ import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.ext.getRootView
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.share.listadapters.AppShareOption
import org.mozilla.fenix.share.listadapters.SyncShareOption
class ShareFragment : AppCompatDialogFragment() {
......@@ -37,7 +36,6 @@ class ShareFragment : AppCompatDialogFragment() {
}
private lateinit var shareInteractor: ShareInteractor
private lateinit var shareCloseView: ShareCloseView
private lateinit var shareToAccountDevicesView: ShareToAccountDevicesView
private lateinit var shareToAppsView: ShareToAppsView
override fun onAttach(context: Context) {
......@@ -92,9 +90,6 @@ class ShareFragment : AppCompatDialogFragment() {
)
view.shareWrapper.setOnClickListener { shareInteractor.onShareClosed() }
shareToAccountDevicesView =
ShareToAccountDevicesView(view.devicesShareLayout, shareInteractor)
if (args.showPage) {
// Show the previous fragment underneath the share background scrim
// by making it translucent.
......@@ -113,9 +108,6 @@ class ShareFragment : AppCompatDialogFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel.devicesList.observe<List<SyncShareOption>>(viewLifecycleOwner) { devicesShareOptions ->
shareToAccountDevicesView.setShareTargets(devicesShareOptions)
}
viewModel.appsList.observe<List<AppShareOption>>(viewLifecycleOwner) { appsToShareTo ->
shareToAppsView.setShareTargets(appsToShareTo)
}
......
......@@ -45,8 +45,9 @@ class PwaOnboardingObserver(
it.content.webAppManifest
}
.collect {
@SuppressWarnings("CollapsibleIfStatements")
if (webAppUseCases.isInstallable() && !settings.userKnowsAboutPwas) {
settings.incrementVisitedInstallableCount()
// settings.incrementVisitedInstallableCount()
if (settings.shouldShowPwaCfr) {
navigateToPwaOnboarding()
settings.lastCfrShownTimeInMillis = System.currentTimeMillis()
......
......@@ -217,17 +217,17 @@ class Settings(private val appContext: Context) : PreferencesHolder {
val isTelemetryEnabled by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_telemetry),
default = true
default = BuildConfig.DATA_COLLECTION_DISABLED == false
)
val isMarketingTelemetryEnabled by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_marketing_telemetry),
default = true
default = BuildConfig.DATA_COLLECTION_DISABLED == false
)
var isExperimentationEnabled by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_experimentation),
default = true
default = BuildConfig.DATA_COLLECTION_DISABLED == false
)
private var trackingProtectionOnboardingShownThisSession = false
......@@ -386,7 +386,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var shouldUseTrackingProtection by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection),
default = true
default = false
)
/**
......@@ -682,7 +682,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var userKnowsAboutPwas by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_user_knows_about_pwa),
default = false
default = true
)
var shouldShowOpenInAppBanner by booleanPreference(
......
......@@ -2,67 +2,25 @@ package org.mozilla.fenix.components.metrics
import android.content.Context
import android.util.Base64
import com.google.android.gms.ads.identifier.AdvertisingIdClient
import com.google.android.gms.common.GooglePlayServicesNotAvailableException
import com.google.android.gms.common.GooglePlayServicesRepairableException
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkObject
import io.mockk.mockkStatic
import io.mockk.slot
import io.mockk.unmockkStatic
import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
import java.io.IOException
class MetricsUtilsTest {
private val context: Context = mockk(relaxed = true)
@Test
fun `getAdvertisingID() returns null if the API throws`() {
mockkStatic("com.google.android.gms.ads.identifier.AdvertisingIdClient")
val exceptions = listOf(
GooglePlayServicesNotAvailableException(1),
GooglePlayServicesRepairableException(0, "", mockk()),
IllegalStateException(),
IOException()
)
exceptions.forEach {
every {
AdvertisingIdClient.getAdvertisingIdInfo(any())
} throws it
assertNull(MetricsUtils.getAdvertisingID(context))
}
unmockkStatic("com.google.android.gms.ads.identifier.AdvertisingIdClient")
}
@Test
fun `getAdvertisingID() returns null if the API returns null info`() {
mockkStatic(AdvertisingIdClient::class)
every { AdvertisingIdClient.getAdvertisingIdInfo(any()) } returns null
assertNull(MetricsUtils.getAdvertisingID(context))
}
@Test
fun `getAdvertisingID() returns a valid string if the API returns a valid ID`() {
val testId = "test-value-id"
mockkStatic(AdvertisingIdClient::class)
every {
AdvertisingIdClient.getAdvertisingIdInfo(any())
} returns AdvertisingIdClient.Info(testId, false)
assertEquals(testId, MetricsUtils.getAdvertisingID(context))
}
@Test
fun `getHashedIdentifier() returns a hashed identifier`() {
val testId = "test-value-id"
......
......@@ -16,6 +16,7 @@ import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.settings.PhoneFeature
import org.mozilla.fenix.settings.deletebrowsingdata.DeleteBrowsingDataOnQuitType
......@@ -150,7 +151,11 @@ class SettingsTest {
fun isTelemetryEnabled() {
// When just created
// Then
assertTrue(settings.isTelemetryEnabled)
if (BuildConfig.DATA_COLLECTION_DISABLED) {
assertFalse(settings.isTelemetryEnabled)
} else {
assertTrue(settings.isTelemetryEnabled)
}
}
@Test
......@@ -442,7 +447,7 @@ class SettingsTest {
settings.incrementVisitedInstallableCount()
// Then
assertTrue(settings.shouldShowPwaCfr)
assertFalse(settings.shouldShowPwaCfr)
}
@Test
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment