@Override
 public void onSuccess(ResponseInfo<File> responseInfo) {
   if (downloadInfo.getFileLength() != downloadInfo.getProgress()) { // 不一致 返回
     return;
   }
   if (downloadInfo.getAutoRenameTmp()) { // 成功后改名
     File tarFile = new File(downloadInfo.getFileTmpPath());
     if (tarFile.exists()) {
       File newFile = new File(downloadInfo.getFileSavePath());
       tarFile.renameTo(newFile);
     }
   }
   LogUtils.d(downloadInfo.getPkg() + " onSuccess");
   HttpHandler<File> handler = downloadInfo.getHandler();
   if (handler != null) {
     downloadInfo.setState(handler.getState());
   }
   try {
     db.saveOrUpdate(downloadInfo);
   } catch (DbException e) {
     LogUtils.e(e.getMessage(), e);
   }
   if (baseCallBack != null) {
     baseCallBack.onSuccess(responseInfo);
   }
 }
  public DownloadManager(Context context) {

    mAllTasks = Collections.synchronizedList(new ArrayList());
    mDownloadingTasks = Collections.synchronizedList(new ArrayList());
    mPausingTasks = Collections.synchronizedList(new ArrayList());
    mCompleteTasks = Collections.synchronizedList(new ArrayList());
    mWaitTasks = new ConcurrentLinkedQueue<>();
    mDownloadingTaskMap = Collections.synchronizedMap(new HashMap<String, DownloadHttpTask>());
    mListenerListMap = Collections.synchronizedMap(new HashMap<String, List<DownloadListener>>());
    mDownloadUIHandler = new DownloadUIHandler(mListenerListMap);

    // 初始化目标Download保存目录
    String folder =
        StorageUtils.getCacheDirectory(context).getAbsolutePath() + Constants.DM_TARGET_FOLDER;
    if (!new File(folder).exists()) {
      FileUtils.makeFolders(folder);
    }
    mTargetFolder = folder;

    // 构建下载Downlaod DbHelper
    mDbHelper = createDownloadDb(context);
    // 获取所有任务
    if (mDbHelper != null) {
      try {
        List<DownloadInfo> list = mDbHelper.findAll(DownloadInfo.class);
        if (list != null && list.size() > 0) {

          for (DownloadInfo info : list) {
            if (info.getProgress() == 100) {
              info.setState(DownloadInfo.COMPLETE);
              mCompleteTasks.add(info);
            } else {
              info.setState(DownloadInfo.PAUSE);
              mPausingTasks.add(info);
            }
          }

          mAllTasks.addAll(mPausingTasks);
          mAllTasks.addAll(mCompleteTasks);
        }
      } catch (DbException e) {
        Logger.e(e);
      }
    }
  }