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 Oct 10, 2024
1 parent b743886 commit ba0184d
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 2 deletions.
1 change: 1 addition & 0 deletions browser/components/BrowserGlue.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,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 @@ -640,6 +640,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 @@ -48,6 +48,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 @@ -169,6 +172,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 @@ -666,6 +674,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 @@ -2397,7 +2407,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 @@ -2422,6 +2435,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) {
console.error(error);
Expand Down Expand Up @@ -2629,7 +2648,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_UPDATE_AGENT) {
Expand Down
9 changes: 9 additions & 0 deletions toolkit/mozapps/update/AppUpdater.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ export class AppUpdater {
return;
}

if (this.#updateDisabledByPref) {
this.#setStatus(AppUpdater.STATUS.NEVER_CHECKED);
return;
}

if (this.aus.disabled) {
LOG("AppUpdater:check - AUS disabled");
this.#setStatus(AppUpdater.STATUS.UPDATE_DISABLED_BY_POLICY);
Expand Down Expand Up @@ -412,6 +417,10 @@ export class AppUpdater {
return Services.sysinfo.getProperty("isPackagedApp");
}

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

/**
* Downloads an update mar or connects to an in-progress download.
* Doesn't resolve until the update is ready to install, or a failure state
Expand Down
9 changes: 9 additions & 0 deletions toolkit/mozapps/update/UpdateService.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3899,6 +3899,15 @@ export class UpdateService {
* See nsIUpdateService.idl
*/
get canUsuallyCheckForUpdates() {
let prefEnabled = Services.prefs.getBoolPref("app.update.enabled", true);
if (!prefEnabled) {
LOG(
"UpdateService.canUsuallyCheckForUpdates - unable to automatically check " +
"the preference is disabled."
);
return false;
}

if (this.disabled) {
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 ba0184d

Please sign in to comment.