Skip to content

Commit

Permalink
[WFX-344] Add update check disabling.
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlex94 committed May 4, 2023
1 parent 88df7c0 commit 7524fa4
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 2 deletions.
1 change: 1 addition & 0 deletions browser/components/BrowserGlue.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,7 @@ BrowserGlue.prototype = {
// check for update if our build is old
if (
AppConstants.MOZ_UPDATER &&
Services.prefs.getBoolPref("app.update.enabled") &&
Services.prefs.getBoolPref("app.update.checkInstallTime")
) {
let buildID = Services.appinfo.appBuildID;
Expand Down
3 changes: 3 additions & 0 deletions browser/components/preferences/main.inc.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,9 @@
<radio id="manualDesktop"
value="false"
data-l10n-id="update-application-check-choose"/>
<radio id="disabledDesktop"
value="disabled"
data-l10n-id="update-application-manual"/>
</radiogroup>
<hbox id="updateSettingCrossUserWarningDesc" hidden="true">
<hbox class="info-icon-container">
Expand Down
33 changes: 31 additions & 2 deletions browser/components/preferences/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const ICON_URL_APP =
// was set by us to a custom handler icon and CSS should not try to override it.
const APP_ICON_ATTR_NAME = "appHandlerIcon";

// WATERFOX
const PREF_UPDATE_ENABLED = "app.update.enabled";

Preferences.addAll([
// Startup
{ id: "browser.startup.page", type: "int" },
Expand Down Expand Up @@ -162,6 +165,11 @@ Preferences.addAll([

// Media
{ id: "media.hardwaremediakeys.enabled", type: "bool" },

// WATERFOX
// Enable auto update checking
{ id: "app.update.enabled", type: "bool" },

]);

if (AppConstants.HAVE_SHELL_SERVICE) {
Expand Down Expand Up @@ -663,6 +671,8 @@ var gMainPane = {
// Start with no option selected since we are still reading the value
document.getElementById("autoDesktop").removeAttribute("selected");
document.getElementById("manualDesktop").removeAttribute("selected");
// WATERFOX
document.getElementById("disabledDesktop").removeAttribute("selected");
// Start reading the correct value from the disk
this.readUpdateAutoPref();
setEventListener("updateRadioGroup", "command", event => {
Expand Down Expand Up @@ -1877,7 +1887,10 @@ var gMainPane = {

radiogroup.disabled = true;
let enabled = await UpdateUtils.getAppUpdateAutoEnabled();
radiogroup.value = enabled;
// WATERFOX
// If user sets app.update.enabled to false, set value to disabled, else use enabled
let manualUpdates = Services.prefs.getBoolPref(PREF_UPDATE_ENABLED, true);
radiogroup.value = !manualUpdates ? "disabled" : enabled;
radiogroup.disabled = false;

this.maybeDisableBackgroundUpdateControls();
Expand All @@ -1902,6 +1915,12 @@ var gMainPane = {
try {
await UpdateUtils.setAppUpdateAutoEnabled(updateAutoValue);
await _disableTimeOverPromise;
// WATERFOX
// Ensure enabled pref is updated based on radiogroup value
Services.prefs.setBoolPref(
PREF_UPDATE_ENABLED,
radiogroup.value != "disabled"
);
radiogroup.disabled = false;
} catch (error) {
Cu.reportError(error);
Expand Down Expand Up @@ -2111,7 +2130,17 @@ var gMainPane = {
if (aData != "true" && aData != "false") {
throw new Error("Invalid preference value for app.update.auto");
}
document.getElementById("updateRadioGroup").value = aData;
// WATERFOX
// Going from Auto to Disable needs to be correctly reflected here
// At this point app.update.enabled has not yet been set, so we
// want to set disabled if it is going from true->false and is
// currently true
let manualUpdates = Services.prefs.getBoolPref(
"app.update.enabled",
true
);
document.getElementById("updateRadioGroup").value =
manualUpdates && !(aData === "true") ? "disabled" : aData;
this.maybeDisableBackgroundUpdateControls();
} else if (aTopic == BACKGROUND_UPDATE_CHANGED_TOPIC) {
if (!AppConstants.MOZ_UPDATER || !AppConstants.MOZ_UPDATE_AGENT) {
Expand Down
11 changes: 11 additions & 0 deletions browser/modules/AppUpdater.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class AppUpdater {
return;
}

if (this.updateDisabled) {
this._setStatus(AppUpdater.STATUS.NEVER_CHECKED);
return;
}

if (this.updateDisabledByPolicy) {
this._setStatus(AppUpdater.STATUS.UPDATE_DISABLED_BY_POLICY);
return;
Expand Down Expand Up @@ -175,6 +180,10 @@ class AppUpdater {
);
}

get updateDisabled() {
return !Services.prefs.getBoolPref("app.update.enabled", true);
}

// true when updating has been disabled by enterprise policy
get updateDisabledByPolicy() {
return Services.policies && !Services.policies.isAllowed("appUpdate");
Expand Down Expand Up @@ -463,6 +472,8 @@ class AppUpdater {
if (!this._status) {
if (!AppConstants.MOZ_UPDATER || this.updateDisabledByPackage) {
this._status = AppUpdater.STATUS.NO_UPDATER;
} else if (this.updateDisabled) {
this._status = AppUpdater.STATUS.NEVER_CHECKED;
} else if (this.updateDisabledByPolicy) {
this._status = AppUpdater.STATUS.UPDATE_DISABLED_BY_POLICY;
} else if (this.isReadyForRestart) {
Expand Down
9 changes: 9 additions & 0 deletions toolkit/mozapps/update/UpdateService.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -3647,6 +3647,15 @@ UpdateService.prototype = {
* See nsIUpdateService.idl
*/
get canUsuallyCheckForUpdates() {
var enabled = Services.prefs.getBoolPref("app.update.enabled", true);
if (!enabled) {
LOG(
"gCanCheckForUpdates - unable to automatically check for updates, " +
"the preference is disabled."
);
return false;
}

if (this.disabledByPolicy) {
LOG(
"UpdateService.canUsuallyCheckForUpdates - unable to automatically check " +
Expand Down
1 change: 1 addition & 0 deletions waterfox/browser/app/profile/000-waterfox.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
pref("accessibility.support.url", "https://www.waterfox.net/support/accessibility-services")
pref("app.support.baseURL", "https://www.waterfox.net/support/%OS%/");
pref("app.update.badgeWaitTime", 0);
pref("app.update.enabled", true);
pref("app.update.notifyDuringDownload", true);
pref("app.update.promptWaitTime", 3600);
pref("app.update.url.override", "", sticky);
Expand Down

0 comments on commit 7524fa4

Please sign in to comment.