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

      

  • 相关阅读:
    WordPress搭建的新博客 www.douzujun.club
    调用weka模拟实现 “主动学习“ 算法
    危险!80% 用户正在考虑放弃 Oracle JDK…
    最新!Dubbo 远程代码执行漏洞通告,速度升级
    Tomcat 又爆出高危漏洞!!Tomcat 8.5 ~10 中招…
    Spring Boot 启动,1 秒搞定!
    为什么要重写 hashcode 和 equals 方法?
    详解 Java 中 4 种 IO 模型
    详解GaussDB bufferpool缓存策略,这次彻底懂了!
    【API进阶之路6】一个技术盲点,差点让整个项目翻车
  • 原文地址:https://www.cnblogs.com/code-4-fun/p/4704170.html
Copyright © 2011-2022 走看看