Skip to content

Commit

Permalink
[fenix] Close mozilla-mobile/fenix#27023: Add capability to override …
Browse files Browse the repository at this point in the history
…telemetry URL using local properties
  • Loading branch information
rocketsroger authored and mergify[bot] committed Nov 8, 2022
1 parent 8a2cad0 commit af16949
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
5 changes: 5 additions & 0 deletions fenix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
15 changes: 15 additions & 0 deletions fenix/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
// -------------------------------------------------------------------------------------------------
Expand Down
13 changes: 9 additions & 4 deletions fenix/app/src/main/java/org/mozilla/fenix/ext/Configuration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
}
}

0 comments on commit af16949

Please sign in to comment.