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); } },

      

  • 相关阅读:
    用strings命令查看kafka-log内容 过滤二进制编码
    Kafka+Storm+HDFS整合实践
    kafka 在阿里云部署
    oracle中的类似BIN$MrkCYT9eTTK+0sStMwn7+Q==$0的表的作用
    Oracle 分区表的新增、修改、删除、合并。普通表转分区表方法
    ORACLE分区表删除分区数据
    graylog 市场
    三种方法解决 Failed to start LSB: Bring up/down networking 问题
    【项目积累】对JSON数据的处理
    【CTO俱乐部研修班开课】看板先驱David J. Anderson:看板核心在于创造一种能力——提升敏捷性
  • 原文地址:https://www.cnblogs.com/code-4-fun/p/4704170.html
Copyright © 2011-2022 走看看