зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1612979 - Add functionality to UpdateUtils for automatic app update to be locked by policy r=mhowell,mkaply
Differential Revision: https://phabricator.services.mozilla.com/D63980 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
5dd9f7faf0
Коммит
6023dfad9a
|
@ -163,12 +163,22 @@ var UpdateUtils = {
|
|||
* has selected "Automatically install updates" in about:preferences.
|
||||
*
|
||||
* On Windows, this setting is shared across all profiles for the installation
|
||||
* and is read asynchrnously from the file. On other operating systems, this
|
||||
* and is read asynchronously from the file. On other operating systems, this
|
||||
* setting is stored in a pref and is thus a per-profile setting.
|
||||
*
|
||||
* @return A Promise that resolves with a boolean.
|
||||
*/
|
||||
getAppUpdateAutoEnabled() {
|
||||
if (Services.policies) {
|
||||
if (!Services.policies.isAllowed("app-auto-updates-off")) {
|
||||
// We aren't allowed to turn off auto-update - it is forced on.
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
if (!Services.policies.isAllowed("app-auto-updates-on")) {
|
||||
// We aren't allowed to turn on auto-update - it is forced off.
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
}
|
||||
if (AppConstants.platform != "win") {
|
||||
// On platforms other than Windows the setting is stored in a preference.
|
||||
let prefValue = Services.prefs.getBoolPref(
|
||||
|
@ -242,9 +252,13 @@ var UpdateUtils = {
|
|||
* in about:preferences.
|
||||
*
|
||||
* On Windows, this setting is shared across all profiles for the installation
|
||||
* and is written asynchrnously to the file. On other operating systems, this
|
||||
* and is written asynchronously to the file. On other operating systems, this
|
||||
* setting is stored in a pref and is thus a per-profile setting.
|
||||
*
|
||||
* If this method is called when the setting is locked, the returned promise
|
||||
* will reject. The lock status can be determined with
|
||||
* UpdateUtils.appUpdateAutoSettingIsLocked()
|
||||
*
|
||||
* @param enabled If set to true, automatic download and installation of
|
||||
* updates will be enabled. If set to false, this will be
|
||||
* disabled.
|
||||
|
@ -257,6 +271,12 @@ var UpdateUtils = {
|
|||
* this operation simply sets a pref.
|
||||
*/
|
||||
setAppUpdateAutoEnabled(enabledValue) {
|
||||
if (this.appUpdateAutoSettingIsLocked()) {
|
||||
return Promise.reject(
|
||||
"setAppUpdateAutoEnabled: Unable to change value of setting because " +
|
||||
"it is locked by policy"
|
||||
);
|
||||
}
|
||||
if (AppConstants.platform != "win") {
|
||||
// Only in Windows do we store the update config in the update directory
|
||||
let prefValue = !!enabledValue;
|
||||
|
@ -293,6 +313,21 @@ var UpdateUtils = {
|
|||
updateAutoIOPromise = writePromise;
|
||||
return writePromise;
|
||||
},
|
||||
|
||||
/**
|
||||
* This function should be used to determine if the automatic application
|
||||
* update setting is locked by an enterprise policy
|
||||
*
|
||||
* @return true if the automatic update setting is currently locked.
|
||||
* Otherwise, false.
|
||||
*/
|
||||
appUpdateAutoSettingIsLocked() {
|
||||
return (
|
||||
Services.policies &&
|
||||
(!Services.policies.isAllowed("app-auto-updates-off") ||
|
||||
!Services.policies.isAllowed("app-auto-updates-on"))
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
// Used for serializing reads and writes of the app update json config file so
|
||||
|
|
Загрузка…
Ссылка в новой задаче