ftps 上传/下载优化,上传/下载速度限制实现

This commit is contained in:
laoyuyu
2018-07-13 23:40:51 +08:00
parent d1e591b448
commit 5bdc1c881b
41 changed files with 518 additions and 183 deletions

View File

@@ -17,6 +17,7 @@ package com.arialyy.aria.core;
import android.text.TextUtils;
import com.arialyy.aria.core.common.QueueMod;
import com.arialyy.aria.core.queue.DownloadGroupTaskQueue;
import com.arialyy.aria.core.queue.DownloadTaskQueue;
import com.arialyy.aria.core.queue.UploadTaskQueue;
import com.arialyy.aria.util.ALog;
@@ -247,6 +248,21 @@ class Configuration {
*/
int iOTimeOut = 20 * 1000;
/**
* 设置最大下载/上传速度单位kb, 为0表示不限速
*/
int maxSpeed = 0;
public int getMaxSpeed() {
return maxSpeed;
}
public BaseTaskConfig setMaxSpeed(int maxSpeed) {
this.maxSpeed = maxSpeed;
saveKey("maxSpeed", String.valueOf(maxSpeed));
return this;
}
public long getUpdateInterval() {
return updateInterval;
}
@@ -374,11 +390,6 @@ class Configuration {
*/
int threadNum = 3;
/**
* 设置最大下载速度单位kb, 为0表示不限速
*/
int maxSpeed = 0;
/**
* 多线程下载是否使用块下载模式,{@code true}使用,{@code false}不使用
* 注意:
@@ -393,6 +404,13 @@ class Configuration {
return useBlock;
}
@Override public DownloadConfig setMaxSpeed(int maxSpeed) {
super.setMaxSpeed(maxSpeed);
DownloadTaskQueue.getInstance().setMaxSpeed(maxSpeed);
DownloadGroupTaskQueue.getInstance().setMaxSpeed(maxSpeed);
return this;
}
public DownloadConfig setUseBlock(boolean useBlock) {
this.useBlock = useBlock;
saveKey("useBlock", String.valueOf(useBlock));
@@ -407,17 +425,6 @@ class Configuration {
return this;
}
public int getMaxSpeed() {
return maxSpeed;
}
public DownloadConfig setMaxSpeed(int maxSpeed) {
this.maxSpeed = maxSpeed;
saveKey("maxSpeed", String.valueOf(maxSpeed));
DownloadTaskQueue.getInstance().setMaxSpeed(maxSpeed);
return this;
}
public DownloadConfig setThreadNum(int threadNum) {
this.threadNum = threadNum;
saveKey("threadNum", String.valueOf(threadNum));
@@ -478,6 +485,12 @@ class Configuration {
loadConfig();
}
@Override public UploadConfig setMaxSpeed(int maxSpeed) {
super.setMaxSpeed(maxSpeed);
UploadTaskQueue.getInstance().setMaxSpeed(maxSpeed);
return this;
}
public UploadConfig setMaxTaskNum(int maxTaskNum) {
oldMaxTaskNum = this.maxTaskNum;
this.maxTaskNum = maxTaskNum;

View File

@@ -29,7 +29,6 @@ import com.arialyy.aria.util.ALog;
public class UploadTask extends AbsNormalTask<UploadTaskEntity> {
private static final String TAG = "UploadTask";
private SimpleUploadUtil mUtil;
private BaseUListener<UploadEntity, UploadTaskEntity, UploadTask> mListener;
private UploadTask(UploadTaskEntity taskEntity, Handler outHandler) {