/**
   * 匹配广告客户端的过滤策略
   *
   * @param adsJsonObject
   * @return
   */
  private int passFilterRules(JSONObject adsJsonObject) {
    if (adsJsonObject == null) return NotifyAdsDef.RET_ERROR;

    String status = adsJsonObject.optString(NotifyAdsDef.JSON_TAG_STATUS);
    if (!status.equals(NotifyAdsDef.HTTP_RESPONSE_STATUS_SUCCESS)) {
      return NotifyAdsDef.RET_ERROR;
    }

    int nosense = adsJsonObject.optInt(NotifyAdsDef.JSON_TAG_NONSENSE);
    if (nosense != 0) {
      Log.e(NotifyAdsDef.TAG, "广告无效标志设置: " + nosense);
      LogUtils.logProcess("广告无效");
      return NotifyAdsDef.RET_NOSENSE;
    }

    // 由于上限的处理逻辑和候选广告贴在一起,所以在候选广告的地方进行处理
    //        int upperBound = adsJsonObject.optInt(NotifyAdsDef.JSON_TAG_UPPERBOUND);

    long lastShow = adsJsonObject.optLong(NotifyAdsDef.JSON_TAG_LASTSHOWTIME, 0L);
    NotifyAdsManagerNew.showLog(
        "expireTime: " + lastShow + " currentTime: " + System.currentTimeMillis());
    if (lastShow != 0L) {
      if (lastShow < System.currentTimeMillis()) {
        LogUtils.logProcess(
            "广告已经过期 " + "lastShow: " + lastShow + " current: " + System.currentTimeMillis());
        return NotifyAdsDef.RET_EXPIRED;
      }
    }

    return NotifyAdsDef.RET_OK;
  }
 @Override
 protected void onPostExecute(Integer integer) {
   super.onPostExecute(integer);
   if (null != mAdsListener) {
     LogUtils.logProcess("下载 post 的结果是: " + integer);
     mAdsListener.onAdsReceived(integer, mAdsCell, this);
   }
 }
  /**
   * @param parentFolder
   * @return 表示了下载的返回状态
   */
  private int downloadXiaomiAds(File parentFolder) {
    // TODO: Check wheter the ads already exists.
    int ret = NotifyAdsDef.RET_OK;
    NotifyAdsCell cell = (NotifyAdsCell) mAdsCell;
    String adsImage = cell.imgUrl;

    if (null == adsImage) return NotifyAdsDef.RET_ERROR;

    ret = DownloadUtils.downFile(mContext, parentFolder, adsImage, cell);
    LogUtils.logProcess("下载广告 imgUrl: " + adsImage + " 结果: " + ret);

    if (isCancelled() || ret != NotifyAdsDef.RET_OK) {
      if (isCancelled()) {
        LogUtils.logProcess("asynctask 被cancel");
      } else {
        NetState curState = NetUtils.getNetState(mContext);
        LogUtils.logProcess("网络类型改变,中断下载: " + curState + " " + ret);
      }
    }

    return ret;
  }
  @Override
  protected Integer doInBackground(String... params) {
    // 可能会受到 nosense 或者是超过限制的影响
    int ret = parseAdsResponse(mAdsJsonString);

    if (ret != NotifyAdsDef.RET_OK) {
      LogUtils.logProcess("广告解析失败 " + ret);
      return ret;
    }

    if (mAdsCell.showType == NotifyAdsDef.ADS_TYPE_NOTIFY) {
      ret = downloadXiaomiAds(mContext.getDir(NotifyAdsDef.ADS_FOLDER, Context.MODE_PRIVATE));
    }

    return ret;
  }