зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1709978 - Disable app update when running as a packaged app. r=agashlin,preferences-reviewers
This patch disables the update service as if it were disabled by policy whenever a package identify is present. User interfaces are treated as if the updater had not been included in the build, because that prevents any of our usual update UI from being shown, and in particular ensures that we do not generate messages about an administrator handling updates, as would normally happen when disabling updates via policy. The telemetry environment's update.enabled flag is deliberately left alone in this patch, because the mere fact of using an app package does not really say anything about whether the user intends to allow automatic updating or not. Differential Revision: https://phabricator.services.mozilla.com/D114886
This commit is contained in:
Родитель
49536da921
Коммит
c797d0b164
|
@ -97,7 +97,10 @@ async function init(aEvent) {
|
||||||
let channelLabel = document.getElementById("currentChannel");
|
let channelLabel = document.getElementById("currentChannel");
|
||||||
let currentChannelText = document.getElementById("currentChannelText");
|
let currentChannelText = document.getElementById("currentChannelText");
|
||||||
channelLabel.value = UpdateUtils.UpdateChannel;
|
channelLabel.value = UpdateUtils.UpdateChannel;
|
||||||
if (/^release($|\-)/.test(channelLabel.value)) {
|
if (
|
||||||
|
/^release($|\-)/.test(channelLabel.value) ||
|
||||||
|
Services.sysinfo.getProperty("hasWinPackageId")
|
||||||
|
) {
|
||||||
currentChannelText.hidden = true;
|
currentChannelText.hidden = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -663,7 +663,20 @@ var gMainPane = {
|
||||||
|
|
||||||
let updateDisabled =
|
let updateDisabled =
|
||||||
Services.policies && !Services.policies.isAllowed("appUpdate");
|
Services.policies && !Services.policies.isAllowed("appUpdate");
|
||||||
if (
|
|
||||||
|
if (Services.sysinfo.getProperty("hasWinPackageId")) {
|
||||||
|
// When we're running inside an app package, there's no point in
|
||||||
|
// displaying any update content here, and it would get confusing if we
|
||||||
|
// did, because our updater is not enabled.
|
||||||
|
// We can't rely on the hidden attribute for the toplevel elements,
|
||||||
|
// because of the pane hiding/showing code interfering.
|
||||||
|
document
|
||||||
|
.getElementById("updatesCategory")
|
||||||
|
.setAttribute("style", "display: none !important");
|
||||||
|
document
|
||||||
|
.getElementById("updateApp")
|
||||||
|
.setAttribute("style", "display: none !important");
|
||||||
|
} else if (
|
||||||
updateDisabled ||
|
updateDisabled ||
|
||||||
UpdateUtils.appUpdateAutoSettingIsLocked() ||
|
UpdateUtils.appUpdateAutoSettingIsLocked() ||
|
||||||
gApplicationUpdateService.manualUpdateOnly
|
gApplicationUpdateService.manualUpdateOnly
|
||||||
|
@ -1804,7 +1817,8 @@ var gMainPane = {
|
||||||
async readUpdateAutoPref() {
|
async readUpdateAutoPref() {
|
||||||
if (
|
if (
|
||||||
AppConstants.MOZ_UPDATER &&
|
AppConstants.MOZ_UPDATER &&
|
||||||
(!Services.policies || Services.policies.isAllowed("appUpdate"))
|
(!Services.policies || Services.policies.isAllowed("appUpdate")) &&
|
||||||
|
!Services.sysinfo.getProperty("hasWinPackageId")
|
||||||
) {
|
) {
|
||||||
let radiogroup = document.getElementById("updateRadioGroup");
|
let radiogroup = document.getElementById("updateRadioGroup");
|
||||||
|
|
||||||
|
@ -1823,7 +1837,8 @@ var gMainPane = {
|
||||||
async writeUpdateAutoPref() {
|
async writeUpdateAutoPref() {
|
||||||
if (
|
if (
|
||||||
AppConstants.MOZ_UPDATER &&
|
AppConstants.MOZ_UPDATER &&
|
||||||
(!Services.policies || Services.policies.isAllowed("appUpdate"))
|
(!Services.policies || Services.policies.isAllowed("appUpdate")) &&
|
||||||
|
!Services.sysinfo.getProperty("hasWinPackageId")
|
||||||
) {
|
) {
|
||||||
let radiogroup = document.getElementById("updateRadioGroup");
|
let radiogroup = document.getElementById("updateRadioGroup");
|
||||||
let updateAutoValue = radiogroup.value == "true";
|
let updateAutoValue = radiogroup.value == "true";
|
||||||
|
@ -1860,6 +1875,7 @@ var gMainPane = {
|
||||||
// properly if per-installation prefs aren't supported.
|
// properly if per-installation prefs aren't supported.
|
||||||
UpdateUtils.PER_INSTALLATION_PREFS_SUPPORTED &&
|
UpdateUtils.PER_INSTALLATION_PREFS_SUPPORTED &&
|
||||||
(!Services.policies || Services.policies.isAllowed("appUpdate")) &&
|
(!Services.policies || Services.policies.isAllowed("appUpdate")) &&
|
||||||
|
!Services.sysinfo.getProperty("hasWinPackageId") &&
|
||||||
!UpdateUtils.appUpdateSettingIsLocked("app.update.background.enabled")
|
!UpdateUtils.appUpdateSettingIsLocked("app.update.background.enabled")
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -60,7 +60,7 @@ class AppUpdater {
|
||||||
* listeners are called.
|
* listeners are called.
|
||||||
*/
|
*/
|
||||||
check() {
|
check() {
|
||||||
if (!AppConstants.MOZ_UPDATER) {
|
if (!AppConstants.MOZ_UPDATER || this.updateDisabledByPackage) {
|
||||||
this._setStatus(AppUpdater.STATUS.NO_UPDATER);
|
this._setStatus(AppUpdater.STATUS.NO_UPDATER);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -180,9 +180,23 @@ class AppUpdater {
|
||||||
return Services.policies && !Services.policies.isAllowed("appUpdate");
|
return Services.policies && !Services.policies.isAllowed("appUpdate");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// true if updating is disabled because we're running in an app package.
|
||||||
|
// This is distinct from updateDisabledByPolicy because we need to avoid
|
||||||
|
// messages being shown to the user about an "administrator" handling
|
||||||
|
// updates; packaged apps may be getting updated by an administrator or they
|
||||||
|
// may not be, and we don't have a good way to tell the difference from here,
|
||||||
|
// so we err to the side of less confusion for unmanaged users.
|
||||||
|
get updateDisabledByPackage() {
|
||||||
|
return Services.sysinfo.getProperty("hasWinPackageId");
|
||||||
|
}
|
||||||
|
|
||||||
// true when updating in background is enabled.
|
// true when updating in background is enabled.
|
||||||
get updateStagingEnabled() {
|
get updateStagingEnabled() {
|
||||||
return !this.updateDisabledByPolicy && this.aus.canStageUpdates;
|
return (
|
||||||
|
!this.updateDisabledByPolicy &&
|
||||||
|
!this.updateDisabledByPackage &&
|
||||||
|
this.aus.canStageUpdates
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -442,7 +456,7 @@ class AppUpdater {
|
||||||
*/
|
*/
|
||||||
get status() {
|
get status() {
|
||||||
if (!this._status) {
|
if (!this._status) {
|
||||||
if (!AppConstants.MOZ_UPDATER) {
|
if (!AppConstants.MOZ_UPDATER || this.updateDisabledByPackage) {
|
||||||
this._status = AppUpdater.STATUS.NO_UPDATER;
|
this._status = AppUpdater.STATUS.NO_UPDATER;
|
||||||
} else if (this.updateDisabledByPolicy) {
|
} else if (this.updateDisabledByPolicy) {
|
||||||
this._status = AppUpdater.STATUS.UPDATE_DISABLED_BY_POLICY;
|
this._status = AppUpdater.STATUS.UPDATE_DISABLED_BY_POLICY;
|
||||||
|
|
|
@ -41,6 +41,10 @@ window.addEventListener("load", function onload(event) {
|
||||||
});
|
});
|
||||||
populateActionBox();
|
populateActionBox();
|
||||||
setupEventListeners();
|
setupEventListeners();
|
||||||
|
if (Services.sysinfo.getProperty("hasWinPackageId")) {
|
||||||
|
$("update-dir-row").hidden = true;
|
||||||
|
$("update-history-row").hidden = true;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Cu.reportError(
|
Cu.reportError(
|
||||||
"stack of load error for about:support: " + e + ": " + e.stack
|
"stack of load error for about:support: " + e + ": " + e.stack
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
|
|
||||||
#ifndef ANDROID
|
#ifndef ANDROID
|
||||||
#ifdef MOZ_UPDATER
|
#ifdef MOZ_UPDATER
|
||||||
<tr id="update-row" class="no-copy">
|
<tr id="update-dir-row" class="no-copy">
|
||||||
<th class="column" data-l10n-id="app-basics-update-dir"/>
|
<th class="column" data-l10n-id="app-basics-update-dir"/>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
@ -103,7 +103,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr class="no-copy">
|
<tr id="update-history-row" class="no-copy">
|
||||||
<th class="column" data-l10n-id="app-basics-update-history"/>
|
<th class="column" data-l10n-id="app-basics-update-history"/>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
|
|
@ -3668,10 +3668,17 @@ UpdateService.prototype = {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// This property reflects any state that should cause the update service to
|
||||||
|
// behave as if it were disabled by policy. This includes the policy itself,
|
||||||
|
// but also other runtime conditions which should in effect disable updates.
|
||||||
|
// This may be distinct from how some of these cases are presented to the
|
||||||
|
// user; for instance, user interfaces should only indicate that policies are
|
||||||
|
// set when policies are actually set, and not under any other condition.
|
||||||
get disabledByPolicy() {
|
get disabledByPolicy() {
|
||||||
return (
|
return (
|
||||||
(Services.policies && !Services.policies.isAllowed("appUpdate")) ||
|
(Services.policies && !Services.policies.isAllowed("appUpdate")) ||
|
||||||
this.disabledForTesting
|
this.disabledForTesting ||
|
||||||
|
Services.sysinfo.getProperty("hasWinPackageId")
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ td {
|
||||||
unicode-bidi: plaintext; /* Make sure file paths will be LTR */
|
unicode-bidi: plaintext; /* Make sure file paths will be LTR */
|
||||||
}
|
}
|
||||||
|
|
||||||
#update-row > td:dir(rtl),
|
#update-dir-row > td:dir(rtl),
|
||||||
#profile-row > td:dir(rtl) {
|
#profile-row > td:dir(rtl) {
|
||||||
unicode-bidi: normal;
|
unicode-bidi: normal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
# include "commonupdatedir.h"
|
# include "commonupdatedir.h"
|
||||||
# include "nsWindowsHelpers.h"
|
# include "nsWindowsHelpers.h"
|
||||||
# include "pathhash.h"
|
# include "pathhash.h"
|
||||||
|
# include "WinUtils.h"
|
||||||
# define getcwd(path, size) _getcwd(path, size)
|
# define getcwd(path, size) _getcwd(path, size)
|
||||||
# define getpid() GetCurrentProcessId()
|
# define getpid() GetCurrentProcessId()
|
||||||
#elif defined(XP_UNIX)
|
#elif defined(XP_UNIX)
|
||||||
|
@ -665,6 +666,13 @@ nsresult ProcessUpdates(nsIFile* greDir, nsIFile* appDir, nsIFile* updRootDir,
|
||||||
bool restart, ProcessType* pid) {
|
bool restart, ProcessType* pid) {
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
|
#ifdef XP_WIN
|
||||||
|
// If we're in a package, we know any updates that we find are not for us.
|
||||||
|
if (mozilla::widget::WinUtils::HasPackageIdentity()) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
nsCOMPtr<nsIFile> updatesDir;
|
nsCOMPtr<nsIFile> updatesDir;
|
||||||
rv = updRootDir->Clone(getter_AddRefs(updatesDir));
|
rv = updRootDir->Clone(getter_AddRefs(updatesDir));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче