diff --git a/Cargo.lock b/Cargo.lock index c23bf33da67a..f8f366fab94b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1204,6 +1204,7 @@ dependencies = [ "glean-preview 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "nserror 0.1.0", "nsstring 0.1.0", + "static_prefs 0.1.0", ] [[package]] diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 1018c55d2de4..127aa9b58ee7 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -1190,6 +1190,16 @@ value: 0 mirror: always +#--------------------------------------------------------------------------- +# Prefs starting with "datareporting." +#--------------------------------------------------------------------------- + +- name: datareporting.healthreport.uploadEnabled + type: RelaxedAtomicBool + value: false + mirror: always + rust: true + #--------------------------------------------------------------------------- # Prefs starting with "device." #--------------------------------------------------------------------------- diff --git a/modules/libpref/moz.build b/modules/libpref/moz.build index d278138ea751..330b64a5b121 100644 --- a/modules/libpref/moz.build +++ b/modules/libpref/moz.build @@ -34,6 +34,7 @@ pref_groups = [ 'channelclassifier', 'clipboard', 'content', + 'datareporting', 'device', 'devtools', 'docshell', diff --git a/toolkit/components/telemetry/core/Telemetry.cpp b/toolkit/components/telemetry/core/Telemetry.cpp index 6358e43667f4..d07c061f2e47 100644 --- a/toolkit/components/telemetry/core/Telemetry.cpp +++ b/toolkit/components/telemetry/core/Telemetry.cpp @@ -1171,7 +1171,7 @@ TelemetryImpl::GetIsOfficialTelemetry(bool* ret) { // C functions with the "fog_" prefix. // See toolkit/components/telemetry/fog/*. extern "C" { -nsresult fog_init(bool useTelemetry, const nsAString* dataDir); +nsresult fog_init(const nsAString* dataDir); } static void internal_initFogotype(bool aUseTelemetry) { @@ -1187,7 +1187,7 @@ static void internal_initFogotype(bool aUseTelemetry) { NS_WARNING("Couldn't get data path. Bailing on FOGotype."); return; } - NS_WARN_IF(NS_FAILED(fog_init(aUseTelemetry, &path))); + NS_WARN_IF(NS_FAILED(fog_init(&path))); } #endif // defined(MOZ_FOGOTYPE) diff --git a/toolkit/components/telemetry/fog/Cargo.toml b/toolkit/components/telemetry/fog/Cargo.toml index b2a4f38e2fc3..f3ed6995587f 100644 --- a/toolkit/components/telemetry/fog/Cargo.toml +++ b/toolkit/components/telemetry/fog/Cargo.toml @@ -11,3 +11,4 @@ license = "MPL-2.0" glean-preview = "0.0.2" nserror = { path = "../../../../xpcom/rust/nserror" } nsstring = { path = "../../../../xpcom/rust/nsstring" } +static_prefs = { path = "../../../../modules/libpref/init/static_prefs" } diff --git a/toolkit/components/telemetry/fog/src/lib.rs b/toolkit/components/telemetry/fog/src/lib.rs index 57fdea5c158a..16baf6862955 100644 --- a/toolkit/components/telemetry/fog/src/lib.rs +++ b/toolkit/components/telemetry/fog/src/lib.rs @@ -11,7 +11,10 @@ use std::io::Error; use std::thread::JoinHandle; #[no_mangle] -pub unsafe extern "C" fn fog_init(upload_enabled: bool, data_dir: &nsAString) -> nsresult { +pub unsafe extern "C" fn fog_init(data_dir: &nsAString) -> nsresult { + + let upload_enabled = static_prefs::pref!("datareporting.healthreport.uploadEnabled"); + let cfg = Configuration { data_path: data_dir.to_string(), application_id: "org.mozilla.fogotype".into(), @@ -41,6 +44,8 @@ fn prototype_ping_init() -> Result, Error> { let an_hour = time::Duration::from_secs(60 * 60); loop { thread::sleep(an_hour); + let upload_enabled = static_prefs::pref!("datareporting.healthreport.uploadEnabled"); + glean_preview::set_upload_enabled(upload_enabled); prototype_ping.send(); } })