|
|
@ -28,7 +28,6 @@ import com.arialyy.aria.util.CommonUtil; |
|
|
|
import java.io.BufferedInputStream; |
|
|
|
import java.io.BufferedInputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.RandomAccessFile; |
|
|
|
|
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.net.MalformedURLException; |
|
|
|
import java.net.MalformedURLException; |
|
|
|
import java.net.URL; |
|
|
|
import java.net.URL; |
|
|
@ -39,6 +38,11 @@ import java.net.URL; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
final class HttpThreadTask extends AbsThreadTask<DownloadEntity, DownloadTaskEntity> { |
|
|
|
final class HttpThreadTask extends AbsThreadTask<DownloadEntity, DownloadTaskEntity> { |
|
|
|
private final String TAG = "HttpThreadTask"; |
|
|
|
private final String TAG = "HttpThreadTask"; |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 2M的动态长度 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private final int LEN_INTERVAL = 1024 * 1024 * 2; |
|
|
|
|
|
|
|
private boolean useVirtualFile = false; |
|
|
|
|
|
|
|
|
|
|
|
HttpThreadTask(StateConstance constance, IDownloadListener listener, |
|
|
|
HttpThreadTask(StateConstance constance, IDownloadListener listener, |
|
|
|
SubThreadConfig<DownloadTaskEntity> downloadInfo) { |
|
|
|
SubThreadConfig<DownloadTaskEntity> downloadInfo) { |
|
|
@ -48,6 +52,7 @@ final class HttpThreadTask extends AbsThreadTask<DownloadEntity, DownloadTaskEnt |
|
|
|
mReadTimeOut = manager.getDownloadConfig().getIOTimeOut(); |
|
|
|
mReadTimeOut = manager.getDownloadConfig().getIOTimeOut(); |
|
|
|
mBufSize = manager.getDownloadConfig().getBuffSize(); |
|
|
|
mBufSize = manager.getDownloadConfig().getBuffSize(); |
|
|
|
isNotNetRetry = manager.getDownloadConfig().isNotNetRetry(); |
|
|
|
isNotNetRetry = manager.getDownloadConfig().isNotNetRetry(); |
|
|
|
|
|
|
|
useVirtualFile = STATE.TASK_RECORD.isUseVirtualFile; |
|
|
|
setMaxSpeed(manager.getDownloadConfig().getMaxSpeed()); |
|
|
|
setMaxSpeed(manager.getDownloadConfig().getMaxSpeed()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -143,6 +148,11 @@ final class HttpThreadTask extends AbsThreadTask<DownloadEntity, DownloadTaskEnt |
|
|
|
if (mSleepTime > 0) { |
|
|
|
if (mSleepTime > 0) { |
|
|
|
Thread.sleep(mSleepTime); |
|
|
|
Thread.sleep(mSleepTime); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (useVirtualFile) { |
|
|
|
|
|
|
|
file.setLength( |
|
|
|
|
|
|
|
STATE.CURRENT_LOCATION + LEN_INTERVAL < mEntity.getFileSize() ? STATE.CURRENT_LOCATION |
|
|
|
|
|
|
|
+ LEN_INTERVAL : mEntity.getFileSize()); |
|
|
|
|
|
|
|
} |
|
|
|
file.write(buffer, 0, len); |
|
|
|
file.write(buffer, 0, len); |
|
|
|
progress(len); |
|
|
|
progress(len); |
|
|
|
} |
|
|
|
} |
|
|
|