@Test public void mergeRequest_nonExistingDownload_createsNewDownload() throws IOException { byte[] data = new byte[] {1, 2, 3, 4}; DownloadRequest request = new DownloadRequest( "id", TYPE_PROGRESSIVE, Uri.parse("https: asList( new StreamKey( 0, 1, 2), new StreamKey( 3, 4, 5)), "key123", data); ActionFileUpgradeUtil.mergeRequest( request, downloadIndex, false, NOW_MS); assertDownloadIndexContainsRequest(request, Download.STATE_QUEUED); }
static void mergeRequest( DownloadRequest request, DefaultDownloadIndex downloadIndex, boolean addNewDownloadAsCompleted, long nowMs) throws IOException { Download download = downloadIndex.getDownload(request.id); if (download != null) { download = DownloadManager.mergeRequest(download, request, download.stopReason, nowMs); } else { download = new Download( request, addNewDownloadAsCompleted ? Download.STATE_COMPLETED : STATE_QUEUED, nowMs, nowMs, C.LENGTH_UNSET, Download.STOP_REASON_NONE, Download.FAILURE_REASON_NONE); } downloadIndex.putDownload(download); }
ActionFileUpgradeUtil { static void mergeRequest( DownloadRequest request, DefaultDownloadIndex downloadIndex, boolean addNewDownloadAsCompleted, long nowMs) throws IOException { Download download = downloadIndex.getDownload(request.id); if (download != null) { download = DownloadManager.mergeRequest(download, request, download.stopReason, nowMs); } else { download = new Download( request, addNewDownloadAsCompleted ? Download.STATE_COMPLETED : STATE_QUEUED, nowMs, nowMs, C.LENGTH_UNSET, Download.STOP_REASON_NONE, Download.FAILURE_REASON_NONE); } downloadIndex.putDownload(download); } }
ActionFileUpgradeUtil { static void mergeRequest( DownloadRequest request, DefaultDownloadIndex downloadIndex, boolean addNewDownloadAsCompleted, long nowMs) throws IOException { Download download = downloadIndex.getDownload(request.id); if (download != null) { download = DownloadManager.mergeRequest(download, request, download.stopReason, nowMs); } else { download = new Download( request, addNewDownloadAsCompleted ? Download.STATE_COMPLETED : STATE_QUEUED, nowMs, nowMs, C.LENGTH_UNSET, Download.STOP_REASON_NONE, Download.FAILURE_REASON_NONE); } downloadIndex.putDownload(download); } private  ActionFileUpgradeUtil(); }
ActionFileUpgradeUtil { static void mergeRequest( DownloadRequest request, DefaultDownloadIndex downloadIndex, boolean addNewDownloadAsCompleted, long nowMs) throws IOException { Download download = downloadIndex.getDownload(request.id); if (download != null) { download = DownloadManager.mergeRequest(download, request, download.stopReason, nowMs); } else { download = new Download( request, addNewDownloadAsCompleted ? Download.STATE_COMPLETED : STATE_QUEUED, nowMs, nowMs, C.LENGTH_UNSET, Download.STOP_REASON_NONE, Download.FAILURE_REASON_NONE); } downloadIndex.putDownload(download); } private  ActionFileUpgradeUtil(); @SuppressWarnings("deprecation") static void upgradeAndDelete(
      File actionFilePath,
      @Nullable DownloadIdProvider downloadIdProvider,
      DefaultDownloadIndex downloadIndex,
      boolean deleteOnFailure,
      boolean addNewDownloadsAsCompleted); }
ActionFileUpgradeUtil { static void mergeRequest( DownloadRequest request, DefaultDownloadIndex downloadIndex, boolean addNewDownloadAsCompleted, long nowMs) throws IOException { Download download = downloadIndex.getDownload(request.id); if (download != null) { download = DownloadManager.mergeRequest(download, request, download.stopReason, nowMs); } else { download = new Download( request, addNewDownloadAsCompleted ? Download.STATE_COMPLETED : STATE_QUEUED, nowMs, nowMs, C.LENGTH_UNSET, Download.STOP_REASON_NONE, Download.FAILURE_REASON_NONE); } downloadIndex.putDownload(download); } private  ActionFileUpgradeUtil(); @SuppressWarnings("deprecation") static void upgradeAndDelete(
      File actionFilePath,
      @Nullable DownloadIdProvider downloadIdProvider,
      DefaultDownloadIndex downloadIndex,
      boolean deleteOnFailure,
      boolean addNewDownloadsAsCompleted);  }