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

      UpdatePrompt接收Gaia返回的'update-available-result'消息,进行下一步处理。

    1. UpdatePrompt.handleEvent

      handleEvent: function UP_handleEvent(evt) {
        if (evt.type !== "mozContentEvent") {
          return;
        }
    
        let detail = evt.detail;
        if (!detail) {
          return;
        }
    
        switch (detail.type) {
          case "force-update-check":
            this.forceUpdateCheck();
            break;
          case "update-available-result":
            this.handleAvailableResult(detail);
            // If we started the apply prompt timer, this means that we're waiting
            // for the user to press Later or Install Now. In this situation we
            // don't want to clear this._update, becuase handleApplyPromptResult
            // needs it.
            if (this._applyPromptTimer == null && !this._waitingForIdle) {
              this._update = null;
            }
            break;
          case "update-download-cancel":
            this.handleDownloadCancel();
            break;
          case "update-prompt-apply-result":
            this.handleApplyPromptResult(detail);
            break;
        }
      },

    2. UpdatePrompt.handleAvailableResult

      handleAvailableResult: function UP_handleAvailableResult(aDetail) {
        // If the user doesn't choose "download", the updater will implicitly call
        // showUpdateAvailable again after a certain period of time
        switch (aDetail.result) {
          case "download":
        // 这个this._update就是从之前分析过的Checker返回数据中得到的一个Update对象。
    this.downloadUpdate(this._update); break; } },

    3. UpdatePrompt.downloadUpdate

      downloadUpdate: function UP_downloadUpdate(aUpdate) {
        if (!aUpdate) {
          aUpdate = Services.um.activeUpdate;
          if (!aUpdate) {
            log("No active update found to download");
            return;
          }
        }
    
      // 调用UpdateService的downloadUpdate方法,true表示background let status
    = Services.aus.downloadUpdate(aUpdate, true); if (status == STATE_DOWNLOADING) {
        // 为UpdateService设置DownloadListener Services.aus.addDownloadListener(
    this); return; } // If the update has already been downloaded and applied, then // Services.aus.downloadUpdate will return immediately and not // call showUpdateDownloaded, so we detect this. if (aUpdate.state == "applied" && aUpdate.errorCode == 0) { this.showUpdateDownloaded(aUpdate, true); return; } log("Error downloading update " + aUpdate.name + ": " + aUpdate.errorCode); let errorCode = aUpdate.errorCode >>> 0; if (errorCode == Cr.NS_ERROR_FILE_TOO_BIG) { aUpdate.statusText = "file-too-big"; } this.showUpdateError(aUpdate); },
  • 相关阅读:
    关于echarts图表在tab页中width:100%失效的问题
    easyui
    小程序中点击事件传参
    微信小程序实现滚动分页加载更多
    使用jquery如何获取现在时间、并且格式化
    只需两步获取任何微信小程序源码
    怎样修改已经审核通过发布成功的微信小程序
    小程序开发swiper如何实现点击图片自定义跳转
    微信小程序如何提交审核并发布?发布问题:小程序只支持https访问
    小程序填坑之路—读取用户信息、缓存其数据、读取其数据
  • 原文地址:https://www.cnblogs.com/code-4-fun/p/4704618.html
Copyright © 2011-2022 走看看