Qter 发表于 2020-8-26 14:11:27

自动升级更新相关

本帖最后由 Qter 于 2020-8-26 15:52 编辑

aboutDialog.xhtml


MOZ_UPDATER
ac_add_options --enable-updater
ac_add_options --disable-updater
ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}if (AppConstants.MOZ_UPDATER) {
    gAppUpdater = new appUpdater({ buttonAutoFocus: true });

    let defaults = Services.prefs.getDefaultBranch("");
    let channelLabel = document.getElementById("currentChannel");
    channelLabel.value = defaults.getCharPref("app.update.channel");
}MOZ_ARG_DISABLE_BOOL(updater,
[--disable-updater       Disable building of updater],
    MOZ_UPDATER=,
    MOZ_UPDATER=1 )

if test -n "$MOZ_UPDATER"; then
    AC_DEFINE(MOZ_UPDATER)
fi
aboutDialog-appUpdater.jsfunction appUpdater(options = {}) {
XPCOMUtils.defineLazyServiceGetter(
    this,
    "aus",
    "@mozilla.org/updates/update-service;1",
    "nsIApplicationUpdateService"
);
XPCOMUtils.defineLazyServiceGetter(
    this,
    "checker",
    "@mozilla.org/updates/update-checker;1",
    "nsIUpdateChecker"
);
XPCOMUtils.defineLazyServiceGetter(
    this,
    "um",
    "@mozilla.org/updates/update-manager;1",
    "nsIUpdateManager"
);
....// true when updating has been disabled by enterprise policy
get updateDisabledByPolicy() {
    return Services.policies && !Services.policies.isAllowed("appUpdate");
},

Qter 发表于 2020-8-26 16:26:08

const PREF_APP_UPDATE_AUTO_MIGRATED = "app.update.auto.migrated";
    const FILE_UPDATE_CONFIG_JSON = "update-config.json";
            const CONFIG_APP_UPDATE_AUTO = "app.update.auto";
      
      let configValue = await readUpdateAutoConfig();
          // If we read a value out of this file, don't later perform migration.
          // If the file is deleted, we don't want some stale pref getting
          // written to it just because a different profile performed migration.
          Services.prefs.setBoolPref(PREF_APP_UPDATE_AUTO_MIGRATED, true);
          return configValue;
   
    async function readUpdateAutoConfig() {
      let configFile = FileUtils.getDir("UpdRootD", [], true);
      configFile.append(FILE_UPDATE_CONFIG_JSON);
      let binaryData = await OS.File.read(configFile.path);
      let jsonData = new TextDecoder().decode(binaryData);
      let configData = JSON.parse(jsonData);
      return !!configData;
    }

Qter 发表于 2020-8-26 16:33:40

const PREF_APP_UPDATE_LOG = "app.update.log";
const PREF_APP_UPDATE_LOG_FILE = "app.update.log.file";

Qter 发表于 2020-8-26 17:18:13

XPCOMUtils.defineLazyServiceGetter(
    this,
    "checker",
    "@mozilla.org/updates/update-checker;1",
    "nsIUpdateChecker"
);

根据 update-checker 搜索
https://searchfox.org/comm-central/source/mozilla/toolkit/mozapps/update/components.conf#22

{
      'cid': '{898CDC9B-E43F-422F-9CC4-2F6291B415A3}',
      'contract_ids': ['@mozilla.org/updates/update-checker;1'],
      'jsm': 'resource://gre/modules/UpdateService.jsm',
      'constructor': 'Checker',
    },
   
   
    UpdateService.jsm 实现?
   
   
XPCOMUtils.defineLazyServiceGetter(
    this,
    "aus",
    "@mozilla.org/updates/update-service;1",
    "nsIApplicationUpdateService"
);

https://searchfox.org/comm-central/source/mozilla/toolkit/mozapps/update/components.conf#10

{
      'cid': '{B3C290A6-3943-4B89-8BBE-C01EB7B3B311}',
      'contract_ids': ['@mozilla.org/updates/update-service;1'],
      'jsm': 'resource://gre/modules/UpdateService.jsm',
      'constructor': 'UpdateService',
    },
   
    UpdateService.jsm 实现?
   

const PREF_APP_UPDATE_BACKGROUNDERRORS = "app.update.backgroundErrors";
页: [1]
查看完整版本: 自动升级更新相关