--- a/toolkit/components/telemetry/TelemetryEnvironment.jsm
+++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm
@@ -179,17 +179,16 @@ const RECORD_PREF_VALUE = TelemetryEnvir
const RECORD_DEFAULTPREF_VALUE = TelemetryEnvironment.RECORD_DEFAULTPREF_VALUE;
const RECORD_DEFAULTPREF_STATE = TelemetryEnvironment.RECORD_DEFAULTPREF_STATE;
const DEFAULT_ENVIRONMENT_PREFS = new Map([
["app.feedback.baseURL", {what: RECORD_PREF_VALUE}],
["app.support.baseURL", {what: RECORD_PREF_VALUE}],
["accessibility.browsewithcaret", {what: RECORD_PREF_VALUE}],
["accessibility.force_disabled", {what: RECORD_PREF_VALUE}],
["app.shield.optoutstudies.enabled", {what: RECORD_PREF_VALUE}],
- ["app.update.auto", {what: RECORD_PREF_VALUE}],
["app.update.interval", {what: RECORD_PREF_VALUE}],
["app.update.service.enabled", {what: RECORD_PREF_VALUE}],
["app.update.silent", {what: RECORD_PREF_VALUE}],
["app.update.url", {what: RECORD_PREF_VALUE}],
["browser.cache.disk.enable", {what: RECORD_PREF_VALUE}],
["browser.cache.disk.capacity", {what: RECORD_PREF_VALUE}],
["browser.cache.memory.enable", {what: RECORD_PREF_VALUE}],
["browser.cache.offline.enable", {what: RECORD_PREF_VALUE}],
@@ -260,28 +259,28 @@ const LOGGER_NAME = "Toolkit.Telemetry";
const PREF_BLOCKLIST_ENABLED = "extensions.blocklist.enabled";
const PREF_DISTRIBUTION_ID = "distribution.id";
const PREF_DISTRIBUTION_VERSION = "distribution.version";
const PREF_DISTRIBUTOR = "app.distributor";
const PREF_DISTRIBUTOR_CHANNEL = "app.distributor.channel";
const PREF_APP_PARTNER_BRANCH = "app.partner.";
const PREF_PARTNER_ID = "mozilla.partner.id";
-const PREF_UPDATE_AUTODOWNLOAD = "app.update.auto";
const PREF_SEARCH_COHORT = "browser.search.cohort";
const COMPOSITOR_CREATED_TOPIC = "compositor:created";
const COMPOSITOR_PROCESS_ABORTED_TOPIC = "compositor:process-aborted";
const DISTRIBUTION_CUSTOMIZATION_COMPLETE_TOPIC = "distribution-customization-complete";
const GFX_FEATURES_READY_TOPIC = "gfx-features-ready";
const SEARCH_ENGINE_MODIFIED_TOPIC = "browser-search-engine-modified";
const SEARCH_SERVICE_TOPIC = "browser-search-service";
const SESSIONSTORE_WINDOWS_RESTORED_TOPIC = "sessionstore-windows-restored";
const PREF_CHANGED_TOPIC = "nsPref:changed";
const BLOCKLIST_LOADED_TOPIC = "blocklist-loaded";
+const AUTO_UPDATE_PREF_CHANGE_TOPIC = "auto-update-pref-change";
/**
* Enforces the parameter to a boolean value.
* @param aValue The input value.
* @return {Boolean|Object} If aValue is a boolean or a number, returns its truthfulness
* value. Otherwise, return null.
*/
function enforceBoolean(aValue) {
@@ -895,16 +894,17 @@ function EnvironmentCache() {
this._addonBuilder = new EnvironmentAddonBuilder(this);
p = [ this._addonBuilder.init() ];
this._currentEnvironment.profile = {};
p.push(this._updateProfile());
if (AppConstants.MOZ_BUILD_APP == "browser") {
p.push(this._loadAttributionAsync());
}
+ p.push(this._loadAutoUpdateAsync());
for (const [id, {branch, options}] of gActiveExperimentStartupBuffer.entries()) {
this.setExperimentActive(id, branch, options);
}
gActiveExperimentStartupBuffer = null;
let setup = () => {
this._initTask = null;
@@ -1145,28 +1145,30 @@ EnvironmentCache.prototype = {
// Watch the search engine change and service topics.
Services.obs.addObserver(this, SESSIONSTORE_WINDOWS_RESTORED_TOPIC);
Services.obs.addObserver(this, COMPOSITOR_CREATED_TOPIC);
Services.obs.addObserver(this, COMPOSITOR_PROCESS_ABORTED_TOPIC);
Services.obs.addObserver(this, DISTRIBUTION_CUSTOMIZATION_COMPLETE_TOPIC);
Services.obs.addObserver(this, GFX_FEATURES_READY_TOPIC);
Services.obs.addObserver(this, SEARCH_ENGINE_MODIFIED_TOPIC);
Services.obs.addObserver(this, SEARCH_SERVICE_TOPIC);
+ Services.obs.addObserver(this, AUTO_UPDATE_PREF_CHANGE_TOPIC);
},
_removeObservers() {
Services.obs.removeObserver(this, SESSIONSTORE_WINDOWS_RESTORED_TOPIC);
Services.obs.removeObserver(this, COMPOSITOR_CREATED_TOPIC);
Services.obs.removeObserver(this, COMPOSITOR_PROCESS_ABORTED_TOPIC);
try {
Services.obs.removeObserver(this, DISTRIBUTION_CUSTOMIZATION_COMPLETE_TOPIC);
} catch (ex) {}
Services.obs.removeObserver(this, GFX_FEATURES_READY_TOPIC);
Services.obs.removeObserver(this, SEARCH_ENGINE_MODIFIED_TOPIC);
Services.obs.removeObserver(this, SEARCH_SERVICE_TOPIC);
+ Services.obs.removeObserver(this, AUTO_UPDATE_PREF_CHANGE_TOPIC);
},
observe(aSubject, aTopic, aData) {
this._log.trace("observe - aTopic: " + aTopic + ", aData: " + aData);
switch (aTopic) {
case SEARCH_ENGINE_MODIFIED_TOPIC:
if (aData != "engine-current") {
return;
@@ -1210,16 +1212,19 @@ EnvironmentCache.prototype = {
this._updateDefaultBrowser();
break;
case PREF_CHANGED_TOPIC:
let options = this._watchedPrefs.get(aData);
if (options && !options.requiresRestart) {
this._onPrefChanged(aData);
}
break;
+ case AUTO_UPDATE_PREF_CHANGE_TOPIC:
+ this._currentEnvironment.settings.update.autoDownload = (aData == "true");
+ break;
}
},
/**
* Get the default search engine.
* @return {String} Returns the search engine identifier, "NONE" if no default search
* engine is defined or "UNDEFINED" if no engine identifier or name can be found.
*/
@@ -1405,28 +1410,28 @@ EnvironmentCache.prototype = {
blocklistEnabled: Services.prefs.getBoolPref(PREF_BLOCKLIST_ENABLED, true),
e10sEnabled: Services.appinfo.browserTabsRemoteAutostart,
e10sMultiProcesses: Services.appinfo.maxWebProcessCount,
telemetryEnabled: Utils.isTelemetryEnabled,
locale: getBrowserLocale(),
update: {
channel: updateChannel,
enabled: !Services.policies || Services.policies.isAllowed("appUpdate"),
- autoDownload: Services.prefs.getBoolPref(PREF_UPDATE_AUTODOWNLOAD, true),
},
userPrefs: this._getPrefData(),
sandbox: this._getSandboxData(),
};
this._currentEnvironment.settings.addonCompatibilityCheckEnabled =
AddonManager.checkCompatibility;
this._updateAttribution();
this._updateDefaultBrowser();
this._updateSearchEngine();
+ this._updateAutoDownload();
},
_getSandboxData() {
let effectiveContentProcessLevel = null;
try {
let sandboxSettings = Cc["@mozilla.org/sandbox/sandbox-settings;1"].
getService(Ci.mozISandboxSettings);
effectiveContentProcessLevel =
@@ -1491,16 +1496,37 @@ EnvironmentCache.prototype = {
for (let key in data) {
attributionData[key] =
limitStringToLength(data[key], MAX_ATTRIBUTION_STRING_LENGTH);
}
this._currentEnvironment.settings.attribution = attributionData;
},
/**
+ * Load the auto update pref and adds it to the environment
+ */
+ async _loadAutoUpdateAsync() {
+ let aus = Cc["@mozilla.org/updates/update-service;1"]
+ .getService(Ci.nsIApplicationUpdateService);
+ this._updateAutoDownloadCache = await aus.autoUpdateIsEnabled();
+ this._updateAutoDownload();
+ },
+
+ /**
+ * Update the environment with the cached value for whether updates can auto-
+ * download.
+ */
+ _updateAutoDownload() {
+ if (this._updateAutoDownloadCache === undefined) {
+ return;
+ }
+ this._currentEnvironment.settings.update.autoDownload = this._updateAutoDownloadCache;
+ },
+
+ /**
* Get the partner data in object form.
* @return Object containing the partner data.
*/
_getPartner() {
let partnerData = {
distributionId: Services.prefs.getStringPref(PREF_DISTRIBUTION_ID, null),
distributionVersion: Services.prefs.getStringPref(PREF_DISTRIBUTION_VERSION, null),
partnerId: Services.prefs.getStringPref(PREF_PARTNER_ID, null),