zoukankan      html  css  js  c++  java
  • (FFOS Gecko & Gaia) OTA

      当通过Checker检测到update以后,会通知UpdatePrompt中的updateCheckListener。

    1. UpdateCheckListener.onCheckComplete

    onCheckComplete: function UCL_onCheckComplete(request, updates, updateCount) {
      if (Services.um.activeUpdate) {
        // We're actively downloading an update, that's the update the user should
        // see, even if a newer update is available.
        this._updatePrompt.setUpdateStatus("active-update");
        this._updatePrompt.showUpdateAvailable(Services.um.activeUpdate);
        return;
      }
    
      if (updateCount == 0) {
        this._updatePrompt.setUpdateStatus("no-updates");
    
        if (this._updatePrompt._systemUpdateListener) {
          this._updatePrompt._systemUpdateListener.onError("no-updates");
        }
    
        return;
      }
    
     // Service.aus就是nsUpdateService.js里的UpdateService对象
    // selectUpdate会通过一些预设的policy,返回updates中的某一个合适的update对象
    let update
    = Services.aus.selectUpdate(updates, updateCount); if (!update) { this._updatePrompt.setUpdateStatus("already-latest-version"); if (this._updatePrompt._systemUpdateListener) { this._updatePrompt._systemUpdateListener.onError("already-latest-version"); } return; } this._updatePrompt.setUpdateStatus("check-complete");
    // 通知UpdatePrompt有可用的update
    this._updatePrompt.showUpdateAvailable(update); },

    2. UpdatePrompt.showUpdateAvailable(update)

    showUpdateAvailable: function UP_showUpdateAvailable(aUpdate) {
      let packageInfo = {};
      packageInfo.version = aUpdate.displayVersion;
      packageInfo.description = aUpdate.statusText;
      packageInfo.buildDate = aUpdate.buildID;
      // 返回一个被选择的patch,或者第一个patch
      let patch = aUpdate.selectedPatch;
      if (!patch && aUpdate.patchCount > 0) {
        // For now we just check the first patch to get size information if a
        // patch hasn't been selected yet.
        patch = aUpdate.getPatchAt(0);
      }
    
      if (patch) {
        packageInfo.size = patch.size;
        packageInfo.type = patch.type;
      } else {
        log("Warning: no patches available in update");
      }
    
      this._pendingUpdateAvailablePackageInfo = packageInfo;
    
      if (this._systemUpdateListener) {
        this._systemUpdateListener.onUpdateAvailable(packageInfo.type,
                                               packageInfo.version,
                                               packageInfo.description,
                                               packageInfo.buildDate,
                                               packageInfo.size);
        // Set null since the event is fired.
        this._pendingUpdateAvailablePackageInfo = null;
      }
    
    // 发送'update-available' event,其实就是通过SystemAppProxy发送一个'mozChromeEvent',
    // 还有发送一些附带信息,比如selected patch size和patch type。接收方是谁呢?可以猜到,就是前几篇分析的SystemApp中的UpdateManager。
    if (!this.sendUpdateEvent("update-available", aUpdate)) { log("Unable to prompt for available update, forcing download"); this.downloadUpdate(aUpdate); } },

      

  • 相关阅读:
    Zabbix客户端日志出现(Not all processes could be identified, 解决
    zabbix 本地编译安装
    redis 配置文件解释 以及集群部署
    Unix shell范例精解 课后题
    if __name__ == '__main__':用法
    爬取猫眼电影100榜单 代码
    CentOS编译安装软件过程中遇到zlib.h: No such file or directory
    Codeigniter添加Composer支持
    CodeIgniter composer.json安装第三类库操作
    使用composer命令加载vendor中的第三方类库 的方法
  • 原文地址:https://www.cnblogs.com/code-4-fun/p/4704170.html
Copyright © 2011-2022 走看看