Close #27023: Add capability to override telemetry URL using local properties

This commit is contained in:
Roger Yang 2022-11-07 17:36:20 -05:00 committed by mergify[bot]
parent d7e40b2a0c
commit 5af08cd72c
4 changed files with 31 additions and 5 deletions

View File

@ -224,6 +224,11 @@ If you wish to use a Nimbus server during local development, you can add a `http
Testing experimental branches should be possible without a server.
### Using custom Glean servers during local development
If you wish to use a custom Glean server during local development, you can add a `https://` endpoint to the `local.properties` file.
- `glean.custom.server.url`
### GeckoView
Specify a relative path to your local `mozilla-central` checkout via `dependencySubstitutions.geckoviewTopsrcdir`,
and optional a path to m-c object directory via `dependencySubstitutions.geckoviewTopobjdir`.

View File

@ -365,6 +365,21 @@ android.applicationVariants.all { variant ->
println("--")
}
// -------------------------------------------------------------------------------------------------
// Glean: Read custom server URL from local.properties of a local file if it exists
// -------------------------------------------------------------------------------------------------
print("Glean custom server URL: ")
if (gradle.hasProperty("localProperties.glean.custom.server.url")) {
def url=gradle.getProperty("localProperties.glean.custom.server.url")
buildConfigField 'String', 'GLEAN_CUSTOM_URL', url
println "(Added from local.properties file)"
} else {
buildConfigField 'String', 'GLEAN_CUSTOM_URL', 'null'
println("--")
}
// -------------------------------------------------------------------------------------------------
// BuildConfig: Set flag for official builds; similar to MOZILLA_OFFICIAL in mozilla-central.
// -------------------------------------------------------------------------------------------------

View File

@ -7,16 +7,21 @@ package org.mozilla.fenix.ext
import android.content.Context
import androidx.preference.PreferenceManager
import mozilla.components.service.glean.config.Configuration
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.R
/**
* Get custom Glean server URL if available.
*/
fun getCustomGleanServerUrlIfAvailable(context: Context): String? {
return PreferenceManager.getDefaultSharedPreferences(context).getString(
context.getPreferenceKey(R.string.pref_key_custom_glean_server_url),
null,
)
return if (BuildConfig.GLEAN_CUSTOM_URL.isNullOrEmpty()) {
PreferenceManager.getDefaultSharedPreferences(context).getString(
context.getPreferenceKey(R.string.pref_key_custom_glean_server_url),
null,
)
} else {
BuildConfig.GLEAN_CUSTOM_URL
}
}
/**

View File

@ -9,6 +9,7 @@ import androidx.preference.EditTextPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.Config
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.R
@ -58,7 +59,7 @@ class SecretSettingsFragment : PreferenceFragmentCompat() {
// for performance reasons, this is only available in Nightly or Debug builds
requirePreference<EditTextPreference>(R.string.pref_key_custom_glean_server_url).apply {
isVisible = Config.channel.isNightlyOrDebug
isVisible = Config.channel.isNightlyOrDebug && BuildConfig.GLEAN_CUSTOM_URL.isNullOrEmpty()
}
}
}