laoyuyu 6 years ago
parent 5f4df90f73
commit a63222a220
  1. 2
      Aria/src/main/java/com/arialyy/aria/core/common/ProxyHelper.java
  2. 2
      Aria/src/main/java/com/arialyy/aria/core/download/BaseNormalTarget.java
  3. 14
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java
  4. 9
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/AbsGroupUtil.java
  5. 4
      Aria/src/main/java/com/arialyy/aria/core/manager/ThreadTaskManager.java
  6. 1
      Aria/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulers.java
  7. 9
      Aria/src/main/java/com/arialyy/aria/core/upload/UploadReceiver.java
  8. 6
      Aria/src/main/java/com/arialyy/aria/orm/DelegateUpdate.java
  9. 3
      Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java
  10. 5
      DEV_LOG.md
  11. 13
      README.md
  12. 4
      app/src/main/AndroidManifest.xml
  13. 7
      app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java
  14. 3
      app/src/main/java/com/arialyy/simple/test/AnyRunActivity.java
  15. 10
      app/src/main/java/com/arialyy/simple/test/AnyRunnModule.java
  16. 5
      app/src/main/java/com/arialyy/simple/test/TestFTPActivity.java
  17. 2
      build.gradle

@ -49,7 +49,7 @@ public class ProxyHelper {
public static int PROXY_TYPE_UPLOAD = 0x04;
public Set<String> downloadCounter = new HashSet<>(), uploadCounter = new HashSet<>(),
downloadGroupCounter = new HashSet<>(), downloadGroupSubCounter = new HashSet<>();
private Map<String, Set<Integer>> mProxyCache = new ConcurrentHashMap<>();
public Map<String, Set<Integer>> mProxyCache = new ConcurrentHashMap<>();
public static volatile ProxyHelper INSTANCE = null;
private boolean canLoadClass = false;

@ -86,7 +86,7 @@ abstract class BaseNormalTarget<TARGET extends BaseNormalTarget>
* @return {@code true}任务存在
*/
@Override public boolean taskExists() {
return DownloadTaskQueue.getInstance().getTask(mEntity.getUrl()) != null;
return DownloadTaskQueue.getInstance().getTask(mEntity.getKey()) != null;
}
/**

@ -206,17 +206,17 @@ public class DownloadReceiver extends AbsReceiver {
ALog.e(TAG, String.format("【%s】观察者为空", targetName));
return;
}
Set<String> dCounter = ProxyHelper.getInstance().downloadCounter;
Set<String> dgCounter = ProxyHelper.getInstance().downloadGroupCounter;
Set<String> dgsCounter = ProxyHelper.getInstance().downloadGroupSubCounter;
if (dCounter != null && dCounter.contains(targetName)) {
Set<Integer> set = ProxyHelper.getInstance().mProxyCache.get(obj.getClass().getName());
if (set != null) {
for (Integer integer : set) {
if (integer == ProxyHelper.PROXY_TYPE_DOWNLOAD) {
DownloadSchedulers.getInstance().unRegister(obj);
}
if (dgCounter != null && dgCounter.contains(targetName) || (dgsCounter != null
&& dgsCounter.contains(targetName))) {
} else if (integer == ProxyHelper.PROXY_TYPE_DOWNLOAD_GROUP) {
DownloadGroupSchedulers.getInstance().unRegister(obj);
}
}
}
}
/**
* 通过下载链接获取下载实体

@ -31,6 +31,7 @@ import java.util.Map;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -63,22 +64,22 @@ public abstract class AbsGroupUtil implements IUtil {
/**
* 保存所有没有下载完成的任务key为下载地址
*/
Map<String, DownloadTaskEntity> mExeMap = new HashMap<>();
Map<String, DownloadTaskEntity> mExeMap = new ConcurrentHashMap<>();
/**
* 下载失败的映射表key为下载地址
*/
Map<String, DownloadTaskEntity> mFailMap = new HashMap<>();
Map<String, DownloadTaskEntity> mFailMap = new ConcurrentHashMap<>();
/**
* 该任务组对应的所有任务
*/
private Map<String, DownloadTaskEntity> mTasksMap = new HashMap<>();
private Map<String, DownloadTaskEntity> mTasksMap = new ConcurrentHashMap<>();
/**
* 下载器映射表key为下载地址
*/
private Map<String, Downloader> mDownloaderMap = new HashMap<>();
private Map<String, Downloader> mDownloaderMap = new ConcurrentHashMap<>();
/**
* 是否需要读取文件长度{@code true}需要

@ -0,0 +1,4 @@
package com.arialyy.aria.core.manager;
public class ThreadTaskManager {
}

@ -259,6 +259,7 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, TASK extends Abs
*/
private void handleFailTask(final TASK task) {
if (!task.needRetry || task.isStop() || task.isCancel()) {
callback(FAIL, task);
mQueue.removeTaskFormQueue(task.getKey());
ALog.d(TAG, "fail_next");
startNextTask();

@ -197,9 +197,14 @@ public class UploadReceiver extends AbsReceiver {
ALog.e(TAG, String.format("【%s】观察者为空", targetName));
return;
}
Set<String> dCounter = ProxyHelper.getInstance().uploadCounter;
if (dCounter != null && dCounter.contains(targetName)) {
Set<Integer> set = ProxyHelper.getInstance().mProxyCache.get(obj.getClass().getName());
if (set != null) {
for (Integer integer : set) {
if (integer == ProxyHelper.PROXY_TYPE_UPLOAD) {
UploadSchedulers.getInstance().unRegister(obj);
}
}
}
}
}

@ -82,7 +82,7 @@ class DelegateUpdate extends AbsDelegate {
/**
* 删除某条数据
*/
<T extends DbEntity> void delData(SQLiteDatabase db, Class<T> clazz, String... expression) {
synchronized <T extends DbEntity> void delData(SQLiteDatabase db, Class<T> clazz, String... expression) {
db = checkDb(db);
CheckUtil.checkSqlExpression(expression);
@ -101,7 +101,7 @@ class DelegateUpdate extends AbsDelegate {
/**
* 修改某行数据
*/
void modifyData(SQLiteDatabase db, DbEntity dbEntity) {
synchronized void modifyData(SQLiteDatabase db, DbEntity dbEntity) {
db = checkDb(db);
Class<?> clazz = dbEntity.getClass();
List<Field> fields = CommonUtil.getAllFields(clazz);
@ -141,7 +141,7 @@ class DelegateUpdate extends AbsDelegate {
/**
* 插入数据
*/
void insertData(SQLiteDatabase db, DbEntity dbEntity) {
synchronized void insertData(SQLiteDatabase db, DbEntity dbEntity) {
db = checkDb(db);
Class<?> clazz = dbEntity.getClass();
List<Field> fields = CommonUtil.getAllFields(clazz);

@ -502,12 +502,15 @@ public class CommonUtil {
}
}
}
if (!TextUtils.isEmpty(groupEntity.getDirPath())) {
File dir = new File(groupEntity.getDirPath());
if (dir.exists() && (removeFile || !groupEntity.isComplete())) {
dir.delete();
}
groupEntity.deleteData();
}
}
/**
* 删除任务记录

@ -1,4 +1,9 @@
## 开发日志
+ v_3.4.11
- fix bug https://github.com/AriaLyy/Aria/issues/288
- fix bug https://github.com/AriaLyy/Aria/issues/282
+ v_3.4.10
- fix bug https://github.com/AriaLyy/Aria/issues/280
+ v_3.4.9
- fix bug https://github.com/AriaLyy/Aria/issues/276
+ v_3.4.8

@ -32,8 +32,8 @@ Aria有以下特点:
[![Download](https://api.bintray.com/packages/arialyy/maven/AriaApi/images/download.svg)](https://bintray.com/arialyy/maven/AriaApi/_latestVersion)
[![Download](https://api.bintray.com/packages/arialyy/maven/AriaCompiler/images/download.svg)](https://bintray.com/arialyy/maven/AriaCompiler/_latestVersion)
```java
compile 'com.arialyy.aria:aria-core:3.4.9'
annotationProcessor 'com.arialyy.aria:aria-compiler:3.4.9'
compile 'com.arialyy.aria:aria-core:3.4.11'
annotationProcessor 'com.arialyy.aria:aria-compiler:3.4.11'
```
如果出现android support,请将 `compile 'com.arialyy.aria:aria-core:<last-version>'`替换为
```
@ -101,12 +101,9 @@ protected void onCreate(Bundle savedInstanceState) {
### 版本日志
+ v_3.4.8
- 组合任务新增`updateUrls(List<String>)`用于修改组合子任务的url,[see](https://aria.laoyuyu.me/aria_doc/api/update_url.html)
- 出于安全考虑,FTP数据库去掉密码的保存
- 增加FTPS支持 [see](https://aria.laoyuyu.me/aria_doc/download/ftps.html)
- 增加速度限制支持[see](https://aria.laoyuyu.me/aria_doc/api/speed_handle.html)
- 增加内存空间不足验证
+ v_3.4.11
- fix bug https://github.com/AriaLyy/Aria/issues/288
- fix bug https://github.com/AriaLyy/Aria/issues/282
[更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md)

@ -16,10 +16,10 @@
<!--android:name=".MainActivity"-->
<!--android:name=".download.group.DownloadGroupActivity"-->
<!--android:name=".test.TestFTPDirActivity"-->
<!--android:name=".download.SingleTaskActivity"-->
<!--android:name=".test.TestFTPActivity"-->
<!--android:name=".test.AnyRunActivity"-->
<activity
android:name=".test.AnyRunActivity"
android:name=".download.SingleTaskActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

@ -33,6 +33,7 @@ import com.arialyy.aria.core.common.RequestEnum;
import com.arialyy.aria.core.download.DownloadTarget;
import com.arialyy.aria.core.download.DownloadTask;
import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.frame.util.show.L;
import com.arialyy.frame.util.show.T;
@ -130,6 +131,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
}
@Download.onTaskRunning protected void running(DownloadTask task) {
ALog.d(TAG, String.format("%s_running_%s", getClass().getName(), hashCode()));
if (task.getKey().equals(DOWNLOAD_URL)) {
//Log.d(TAG, task.getKey());
long len = task.getFileSize();
@ -220,8 +222,9 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
startD();
break;
case R.id.stop:
Aria.download(this).load(DOWNLOAD_URL).stop();
//startActivity(new Intent(this, SingleTaskActivity.class));
//Aria.download(this).load(DOWNLOAD_URL).stop();
startActivity(new Intent(this, SingleTaskActivity.class));
Aria.download(this).unRegister();
//Aria.download(this).load(DOWNLOAD_URL).removeRecord();
break;
case R.id.cancel:

@ -26,11 +26,12 @@ public class AnyRunActivity extends BaseActivity<ActivityTestBinding> {
//String URL = "http://d1.showself.com/download/showself_android-s236279_release.apk";
//String URL = "http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk";
//private final String URL = "ftp://192.168.29.140:21/download/AriaPrj.rar";
String URL = "https://dl.genymotion.com/releases/genymotion-2.12.1/genymotion-2.12.1-vbox.exe";
//String URL = "https://dl.genymotion.com/releases/genymotion-2.12.1/genymotion-2.12.1-vbox.exe";
//String URL = "ftp://192.168.29.140:21/download/SDK_Demo-release.apk";
//String URL = "ftps://192.168.29.140:990/download/SDK_Demo-release.apk";
//String URL = "http://d.quanscreen.com/k/down/resourceDownLoad?resourceId=1994&clientId=A000011106034058176";
//String URL = "ftp://z:z@dygod18.com:21211/[电影天堂www.dy2018.com]猩球崛起3:终极之战BD国英双语中英双字.mkv";
String URL = "https://app-dl.byfen.com//app//201810//ef0400d637e768e9c630b4d38633ee06.zip";
//private String URL = "https://www.bilibili.com/bangumi/play/ep77693";
//private String URL = "http://cn-hbsjz-cmcc-v-03.acgvideo.com/upgcxcode/63/82/5108263/5108263-1-80.flv?expires=1530178500&platform=pc&ssig=vr7gLl0duyqWqSMnIpzaDA&oi=3746029570&nfa=BpfiWF+i4mNW8KzjZFHzBQ==&dynamic=1&hfa=2030547937&hfb=Yjk5ZmZjM2M1YzY4ZjAwYTMzMTIzYmIyNWY4ODJkNWI=&trid=3476be01a9254115b15f8cc7198600fe&nfc=1";

@ -64,7 +64,7 @@ public class AnyRunnModule {
void start(String url) {
mUrl = url;
String path = Environment.getExternalStorageDirectory().getPath() + "/mmm1.mp4";
String path = Environment.getExternalStorageDirectory().getPath() + "/mmm2.mp4";
Aria.download(this)
.load(url)
.setRequestMode(RequestEnum.GET)
@ -79,10 +79,10 @@ public class AnyRunnModule {
.loadFtp(url)
.login("lao", "123456")
.setFilePath(Environment.getExternalStorageDirectory().getPath() + "/Download/")
.asFtps()
.setStorePath("/mnt/sdcard/Download/server.crt")
.setAlias("www.laoyuyu.me")
.setStorePass("123456")
//.asFtps()
//.setStorePath("/mnt/sdcard/Download/server.crt")
//.setAlias("www.laoyuyu.me")
//.setStorePass("123456")
.start();
}

@ -25,7 +25,7 @@ public class TestFTPActivity extends BaseActivity<ActivityTestBinding> {
//String URL = "http://58.210.9.131/tpk/sipgt//TDLYZTGH.tpk"; //chunked 下载
//private final String URL = "ftp://192.168.1.3:21/download//AriaPrj.rar";
private final String FILE_PATH = "/mnt/sdcard/mmm.mp4";
private final String URL = "ftps://192.168.29.140:990/aa/你好";
private final String URL = "ftps://9.9.9.59:990/aa/你好";
@Override protected int setLayoutId() {
@ -82,8 +82,7 @@ public class TestFTPActivity extends BaseActivity<ActivityTestBinding> {
.loadFtp(FILE_PATH)
.login("lao", "123456")
.setUploadUrl(URL)
.setExtendField("韩寒哈大双")
.asFtps()
//.asFtps()
//.setStorePath("/mnt/sdcard/Download/server.crt")
//.setAlias("www.laoyuyu.me")
.start();

@ -39,7 +39,7 @@ task clean(type: Delete) {
ext {
userOrg = 'arialyy'
groupId = 'com.arialyy.aria'
publishVersion = '3.4.9'
publishVersion = '3.4.11'
// publishVersion = '1.0.3' //FTP插件
repoName='maven'
desc = 'android 下载框架'

Loading…
Cancel
Save