12 Commits
3.7.6 ... 3.7.9

Author SHA1 Message Date
laoyuyu
91daecd039 Merge branch 'master' of github.com:AriaLyy/Aria 2019-11-28 19:49:26 +08:00
laoyuyu
297cc99f2b fix bug https://github.com/AriaLyy/Aria/issues/537 2019-11-28 19:48:50 +08:00
lyy
f5f8e9b528 Update Custom.md 2019-11-28 16:39:46 +08:00
lyy
94c3e8bb58 Update Custom.md 2019-11-28 16:37:04 +08:00
laoyuyu
ee5ee6e080 增加m3u8密钥url转换器 2019-11-28 09:59:08 +08:00
laoyuyu
c4cc804c67 增加立即恢复任务的接口,正常来说,当执行队列满时,调用恢复任务接口,只能将任务放到缓存队列中。如果希望调用恢复接口,马上进入执行队列,需要调用resume(true)这个重载方法。
修复一个非分块模式下,无法恢复下载的问题
增加M3U8加密密钥的下载地址转换器 https://github.com/AriaLyy/Aria/issues/522
2019-11-27 21:38:25 +08:00
laoyuyu
c9c00c38c6 Merge branch 'master' of github.com:AriaLyy/Aria 2019-11-26 19:32:16 +08:00
laoyuyu
846235a826 fix bug https://github.com/AriaLyy/Aria/issues/533
fix bug https://github.com/AriaLyy/Aria/issues/535
2019-11-26 19:28:06 +08:00
lyy
06dd6b35e0 Update README.md 2019-11-26 15:39:47 +08:00
lyy
944d69a1af Update README.md 2019-11-21 10:37:21 +08:00
laoyuyu
1ee36e0bc1 fix bug https://github.com/AriaLyy/Aria/issues/526 2019-11-20 21:33:56 +08:00
laoyuyu
0765ab67f7 3.7.7 2019-11-20 10:17:08 +08:00
43 changed files with 264 additions and 172 deletions

View File

@@ -1,35 +1,26 @@
---
name: 问题描述
about: 请详细描述你遇到的问题
about: 提交问题前请先阅读文档和搜索issue
---
<!-- 请详细描述以下信息即使是一个简单的bug没有充足的信息作者却需要花费大量的时间去查找可能的原因 -->
## 预期行为
## 当前行为
## 可能的解决方案
<!-- 不是强制性的,针对该错误的修复/原因的建议-->
## 重现步骤
<!-- 请提供明确的步骤 -->
1.
2.
3.
4.
## 错误日志
<!-- 提交问题前请先阅读文档和搜索相应问题的issue -->
## 版本
* 框架版本
* 系统版本
## 错误日志
<!-- 请提供详细的错误日志 -->
## 重现步骤
<!-- 请提供明确的步骤 -->
1.
2.
3.
4.

View File

@@ -98,9 +98,6 @@ import java.util.concurrent.ConcurrentHashMap;
}
public static AriaManager getInstance() {
if (INSTANCE == null) {
throw new NullPointerException("请使用AriaManager.init(context)初始化管理器");
}
return INSTANCE;
}

View File

@@ -15,6 +15,7 @@
*/
package com.arialyy.aria.core.command;
import com.arialyy.aria.core.task.ITask;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
/**
@@ -25,8 +26,7 @@ public abstract class AbsCmdFactory<TASK_ENTITY extends AbsTaskWrapper, CMD exte
/**
* @param entity 下载实体
* @param taskType {@link ICmd#TASK_TYPE_DOWNLOAD}、{@link ICmd#TASK_TYPE_DOWNLOAD_GROUP}、{@link
* ICmd#TASK_TYPE_UPLOAD}
* {@link ITask#DOWNLOAD}、{@link ITask#DOWNLOAD_GROUP}、{@link ITask#UPLOAD}
*/
public abstract CMD createCmd(TASK_ENTITY entity, int type, int taskType);
}

View File

@@ -157,14 +157,6 @@ public abstract class AbsNormalCmd<T extends AbsTaskWrapper> extends AbsCmd<T> {
mQueue.resumeTask(task);
}
/**
* 启动指定任务
*
* @param task 指定任务
*/
void startTask(AbsTask task) {
mQueue.startTask(task);
}
/**
* 从队列中获取任务

View File

@@ -16,6 +16,7 @@
package com.arialyy.aria.core.command;
import com.arialyy.aria.core.task.ITask;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
/**
@@ -83,8 +84,7 @@ public class NormalCmdFactory extends AbsCmdFactory<AbsTaskWrapper, AbsNormalCmd
* @param entity 下载实体
* @param type 命令类型{@link #TASK_CREATE}、{@link #TASK_START}、{@link #TASK_CANCEL}、{@link
* #TASK_STOP}、{@link #TASK_HIGHEST_PRIORITY}、{@link #TASK_STOP_ALL}、{@link #TASK_RESUME_ALL}
* @param taskType {@link ICmd#TASK_TYPE_DOWNLOAD}、{@link ICmd#TASK_TYPE_DOWNLOAD_GROUP}、{@link
* ICmd#TASK_TYPE_UPLOAD}
* @param taskType {@link ITask#DOWNLOAD}、{@link ITask#DOWNLOAD_GROUP}、{@link ITask#UPLOAD}
*/
public AbsNormalCmd createCmd(AbsTaskWrapper entity, int type, int taskType) {
switch (type) {

View File

@@ -16,29 +16,10 @@
package com.arialyy.aria.core.command;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.common.AbsEntity;
import com.arialyy.aria.core.download.DGTaskWrapper;
import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadGroupEntity;
import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.inf.IOptionConstant;
import com.arialyy.aria.core.manager.TaskWrapperManager;
import com.arialyy.aria.core.queue.DGroupTaskQueue;
import com.arialyy.aria.core.queue.DTaskQueue;
import com.arialyy.aria.core.queue.UTaskQueue;
import com.arialyy.aria.core.task.AbsTask;
import com.arialyy.aria.core.upload.UTaskWrapper;
import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.core.wrapper.ITaskWrapper;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.util.NetUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
/**
* Created by AriaL on 2017/6/13.
@@ -50,7 +31,6 @@ import java.util.concurrent.Executors;
*/
final class ResumeAllCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
ResumeAllCmd(T entity, int taskType) {
super(entity, taskType);
}
@@ -60,8 +40,7 @@ final class ResumeAllCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
ALog.w(TAG, "恢复任务失败,网络未连接");
return;
}
new Thread(new ResumeThread(isDownloadCmd, IEntity.STATE_COMPLETE)).start();
new Thread(new ResumeThread(isDownloadCmd,
String.format("state!=%s", IEntity.STATE_COMPLETE))).start();
}
}

View File

@@ -47,11 +47,11 @@ public class ResumeThread implements Runnable {
private String TAG = CommonUtil.getClassName(getClass());
private List<AbsTaskWrapper> mWaitList = new ArrayList<>();
private boolean isDownloadCmd;
private int excludeState;
private String sqlCondition;
ResumeThread(boolean isDownload, int excludeState) {
ResumeThread(boolean isDownload, String sqlCondition) {
this.isDownloadCmd = isDownload;
this.excludeState = excludeState;
this.sqlCondition = sqlCondition;
}
/**
@@ -63,8 +63,8 @@ public class ResumeThread implements Runnable {
if (type == 1) {
List<DownloadEntity> entities =
DbEntity.findDatas(DownloadEntity.class,
"isGroupChild=? AND state!=? ORDER BY stopTime DESC", "false",
String.valueOf(excludeState));
String.format("NOT(isGroupChild) AND NOT(isComplete) AND %s ORDER BY stopTime DESC",
sqlCondition));
if (entities != null && !entities.isEmpty()) {
for (DownloadEntity entity : entities) {
addResumeEntity(TaskWrapperManager.getInstance()
@@ -73,8 +73,9 @@ public class ResumeThread implements Runnable {
}
} else if (type == 2) {
List<DownloadGroupEntity> entities =
DbEntity.findDatas(DownloadGroupEntity.class, "state!=? ORDER BY stopTime DESC",
String.valueOf(excludeState));
DbEntity.findDatas(DownloadGroupEntity.class,
String.format("NOT(isComplete) AND %s ORDER BY stopTime DESC",
sqlCondition));
if (entities != null && !entities.isEmpty()) {
for (DownloadGroupEntity entity : entities) {
addResumeEntity(
@@ -84,8 +85,9 @@ public class ResumeThread implements Runnable {
}
} else if (type == 3) {
List<UploadEntity> entities =
DbEntity.findDatas(UploadEntity.class, "state!=? ORDER BY stopTime DESC",
String.valueOf(excludeState));
DbEntity.findDatas(UploadEntity.class,
String.format("NOT(isComplete) AND %s ORDER BY stopTime DESC",
sqlCondition));
if (entities != null && !entities.isEmpty()) {
for (UploadEntity entity : entities) {
addResumeEntity(TaskWrapperManager.getInstance()
@@ -125,7 +127,7 @@ public class ResumeThread implements Runnable {
queue = DGroupTaskQueue.getInstance();
}
if (queue == null){
if (queue == null) {
ALog.e(TAG, "任务类型错误");
continue;
}

View File

@@ -27,12 +27,22 @@ import com.arialyy.aria.util.NetUtils;
/**
* Created by lyy on 2016/8/22. 开始命令 队列模型{@link QueueMod#NOW}、{@link QueueMod#WAIT}
*/
final class StartCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
final public class StartCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
private boolean newStart = false;
StartCmd(T entity, int taskType) {
super(entity, taskType);
}
/**
* 立即执行任务
* @param newStart true 立即执行任务,无论执行队列是否满了
*/
public void setNewStart(boolean newStart) {
this.newStart = newStart;
}
@Override public void executeCmd() {
if (!canExeCmd) return;
if (!NetUtils.isConnected(AriaManager.getInstance().getAPP())) {
@@ -71,7 +81,11 @@ final class StartCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
startTask();
}
} else {
sendWaitState(task);
if (newStart){
startTask();
}else {
sendWaitState(task);
}
}
}
} else {
@@ -91,6 +105,7 @@ final class StartCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
* 当缓冲队列为null时查找数据库中所有等待中的任务
*/
private void findAllWaitTask() {
new Thread(new ResumeThread(isDownloadCmd, IEntity.STATE_WAIT)).start();
new Thread(
new ResumeThread(isDownloadCmd, String.format("state=%s", IEntity.STATE_WAIT))).start();
}
}

View File

@@ -150,7 +150,17 @@ public abstract class AbsNormalTarget<TARGET extends AbsNormalTarget> extends Ab
*/
@Override
public void resume() {
getController().resume();
resume(false);
}
/**
* 正常来说,当执行队列满时,调用恢复任务接口,只能将任务放到缓存队列中。
* 如果希望调用恢复接口,马上进入执行队列,需要使用该方法
*
* @param newStart true 立即将任务恢复到执行队列中
*/
@Override public void resume(boolean newStart) {
getController().resume(newStart);
}
/**

View File

@@ -30,6 +30,14 @@ public interface INormalFeature {
*/
void resume();
/**
* 正常来说,当执行队列满时,调用恢复任务接口,只能将任务放到缓存队列中。
* 如果希望调用恢复接口,马上进入执行队列,需要使用该方法
*
* @param newStart true 立即将任务恢复到执行队列中
*/
void resume(boolean newStart);
/**
* 删除任务
*/

View File

@@ -16,11 +16,12 @@
package com.arialyy.aria.core.common.controller;
import com.arialyy.aria.core.command.CancelCmd;
import com.arialyy.aria.core.command.CmdHelper;
import com.arialyy.aria.core.command.NormalCmdFactory;
import com.arialyy.aria.core.command.StartCmd;
import com.arialyy.aria.core.event.EventMsgUtil;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.core.command.CmdHelper;
/**
* 启动控制器
@@ -49,10 +50,23 @@ public final class NormalController extends FeatureController implements INormal
*/
@Override
public void resume() {
resume(false);
}
/**
* 正常来说,当执行队列满时,调用恢复任务接口,只能将任务放到缓存队列中。
* 如果希望调用恢复接口,马上进入执行队列,需要使用该方法
*
* @param newStart true 立即将任务恢复到执行队列中
*/
@Override public void resume(boolean newStart) {
if (checkConfig()) {
StartCmd cmd =
(StartCmd) CmdHelper.createNormalCmd(getTaskWrapper(), NormalCmdFactory.TASK_START,
checkTaskType());
cmd.setNewStart(newStart);
EventMsgUtil.getDefault()
.post(CmdHelper.createNormalCmd(getTaskWrapper(), NormalCmdFactory.TASK_START,
checkTaskType()));
.post(cmd);
}
}

View File

@@ -17,6 +17,7 @@ package com.arialyy.aria.core.download.m3u8;
import com.arialyy.aria.core.common.BaseOption;
import com.arialyy.aria.core.processor.IBandWidthUrlConverter;
import com.arialyy.aria.core.processor.IKeyUrlConverter;
import com.arialyy.aria.core.processor.ITsMergeHandler;
import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.ComponentUtil;
@@ -31,6 +32,7 @@ public class M3U8Option<OP extends M3U8Option> extends BaseOption {
private int bandWidth;
private ITsMergeHandler mergeHandler;
private IBandWidthUrlConverter bandWidthUrlConverter;
private IKeyUrlConverter keyUrlConverter;
M3U8Option() {
super();
@@ -88,4 +90,15 @@ public class M3U8Option<OP extends M3U8Option> extends BaseOption {
this.bandWidthUrlConverter = bandWidthUrlConverter;
return (OP) this;
}
/**
* M3U8 密钥url转换器对于某些服务器密钥的下载地址是被加密的因此需要使用该方法将被加密的密钥解密成可被识别的http地址
*
* @param keyUrlConverter {@link IKeyUrlConverter}
*/
public OP setKeyUrlConverter(IKeyUrlConverter keyUrlConverter) {
CheckUtil.checkMemberClass(keyUrlConverter.getClass());
this.keyUrlConverter = keyUrlConverter;
return (OP) this;
}
}

View File

@@ -1,4 +1,17 @@
## 开发日志
+ v_3.7.9 (2019/11/28)
- fix bug https://github.com/AriaLyy/Aria/issues/537
+ v_3.7.8 (2019/11/28)
- fix bug https://github.com/AriaLyy/Aria/issues/526
- fix bug https://github.com/AriaLyy/Aria/issues/533
- fix bug https://github.com/AriaLyy/Aria/issues/535
- 修复ftp无法完成下载的问题
- 修复一个非分块模式下,调用`updateUrl(newUrl)`后无法恢复下载的问题
- 增加立即恢复任务的接口,正常来说,当执行队列满时,调用恢复任务接口,只能将任务放到缓存队列中。如果希望调用恢复接口,马上进入执行队列,需要调用`resume(true)`这个重载方法。
- 增加M3U8加密密钥的下载地址转换器 https://github.com/AriaLyy/Aria/issues/522
+ v_3.7.7 (2019/11/20)
- 修复ftp无法完成下载的问题
- 修复一个http下载崩溃的问题
+ v_3.7.6 (2019/11/19)
- fix bug https://github.com/AriaLyy/Aria/issues/505
- fix bug https://github.com/AriaLyy/Aria/issues/516

View File

@@ -85,6 +85,8 @@ public class FtpDirDLoaderUtil extends AbsGroupUtil {
* @param needCloneInfo 第一次下载,信息已经在{@link FtpDirInfoThread}中clone了
*/
private void startDownload(boolean needCloneInfo) {
// ftp需要获取完成只任务信息才更新只任务数量
getState().setSubSize(getWrapper().getSubTaskWrapper().size());
try {
LOCK.lock();
condition.signalAll();

View File

@@ -73,6 +73,7 @@ public class DGroupLoaderUtil extends AbsGroupUtil {
@Override protected boolean onStart() {
super.onStart();
getState().setSubSize(getWrapper().getSubTaskWrapper().size());
if (getState().getCompleteNum() == getState().getSubSize()) {
mListener.onComplete();
} else {

View File

@@ -24,6 +24,7 @@ import com.arialyy.aria.http.BaseHttpThreadTaskAdapter;
import com.arialyy.aria.http.ConnectionHelp;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.BufferedRandomAccessFile;
import com.arialyy.aria.util.FileUtil;
import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

View File

@@ -26,6 +26,7 @@ import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.M3U8Entity;
import com.arialyy.aria.core.inf.OnFileInfoCallback;
import com.arialyy.aria.core.processor.IBandWidthUrlConverter;
import com.arialyy.aria.core.processor.IKeyUrlConverter;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.core.wrapper.ITaskWrapper;
import com.arialyy.aria.exception.M3U8Exception;
@@ -127,7 +128,7 @@ final public class M3U8InfoThread implements Runnable {
File indexFile = new File(indexPath);
if (!indexFile.exists()) {
FileUtil.createFile(indexPath);
}else {
} else {
//FileUtil.deleteFile(indexPath);
}
fos = new FileOutputStream(indexFile);
@@ -353,7 +354,18 @@ final public class M3U8InfoThread implements Runnable {
} else {
return;
}
URL url = ConnectionHelp.handleUrl(info.keyUrl, mHttpOption);
IKeyUrlConverter keyUrlConverter = mM3U8Option.getKeyUrlConverter();
String keyUrl = info.keyUrl;
if (keyUrlConverter != null) {
keyUrl = keyUrlConverter.convert(keyUrl);
}
if (TextUtils.isEmpty(keyUrl)){
ALog.e(TAG, "m3u8密钥key url 为空");
return;
}
URL url = ConnectionHelp.handleUrl(keyUrl, mHttpOption);
conn = ConnectionHelp.handleConnection(url, mHttpOption);
ConnectionHelp.setConnectParam(mHttpOption, conn);
conn.setConnectTimeout(mConnectTimeOut);

View File

@@ -17,6 +17,7 @@ package com.arialyy.aria.m3u8;
import com.arialyy.aria.core.inf.ITaskOption;
import com.arialyy.aria.core.processor.IBandWidthUrlConverter;
import com.arialyy.aria.core.processor.IKeyUrlConverter;
import com.arialyy.aria.core.processor.ILiveTsUrlConverter;
import com.arialyy.aria.core.processor.ITsMergeHandler;
import com.arialyy.aria.core.processor.IVodTsUrlConverter;
@@ -103,6 +104,19 @@ public class M3U8TaskOption implements ITaskOption {
*/
private boolean generateIndexFile = false;
/**
* 加密密钥的解密处理器
*/
private SoftReference<IKeyUrlConverter> keyUrlConverter;
public IKeyUrlConverter getKeyUrlConverter() {
return keyUrlConverter == null ? null : keyUrlConverter.get();
}
public void setKeyUrlConverter(IKeyUrlConverter keyUrlConverter) {
this.keyUrlConverter = new SoftReference<>(keyUrlConverter);
}
public boolean isGenerateIndexFile() {
return generateIndexFile;
}

View File

@@ -463,7 +463,8 @@ public class M3U8VodLoader extends BaseM3U8Loader {
private int cancelNum = 0; // 已经取消的线程的数
private int stopNum = 0; // 已经停止的线程数
private int failNum = 0; // 失败的线程数
private long progress; //当前总进度,百分比进度
private long percent; //当前总进度,百分比进度
private long progress;
private TaskRecord taskRecord; // 任务记录
private Looper looper;
@@ -480,6 +481,7 @@ public class M3U8VodLoader extends BaseM3U8Loader {
}
}
this.listener = listener;
progress = getEntity().getCurrentProgress();
}
private void updateStateCount() {
@@ -586,7 +588,7 @@ public class M3U8VodLoader extends BaseM3U8Loader {
}
break;
case STATE_RUNNING:
//progress += (long) msg.obj;
progress += (long) msg.obj;
break;
}
return true;
@@ -610,7 +612,7 @@ public class M3U8VodLoader extends BaseM3U8Loader {
int percent = completeNum * 100 / taskRecord.threadRecords.size();
getEntity().setPercent(percent);
getEntity().update();
progress = percent;
this.percent = percent;
}
@Override public boolean isFail() {

View File

@@ -22,6 +22,7 @@ import com.arialyy.aria.core.processor.FtpInterceptHandler;
import com.arialyy.aria.core.processor.IBandWidthUrlConverter;
import com.arialyy.aria.core.processor.IFtpUploadInterceptor;
import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
import com.arialyy.aria.core.processor.IKeyUrlConverter;
import com.arialyy.aria.core.processor.ILiveTsUrlConverter;
import com.arialyy.aria.core.processor.ITsMergeHandler;
import com.arialyy.aria.core.processor.IVodTsUrlConverter;
@@ -61,6 +62,7 @@ public class TaskOptionParams {
PROCESSORES.add(ILiveTsUrlConverter.class);
PROCESSORES.add(ITsMergeHandler.class);
PROCESSORES.add(IVodTsUrlConverter.class);
PROCESSORES.add(IKeyUrlConverter.class);
}
/**

View File

@@ -63,7 +63,8 @@ public class RecordHelper {
fileExists = true;
}
// 处理文件被删除的情况
if (fileExists) {
if (!fileExists) {
ALog.w(TAG, String.format("文件【%s】被删除重新分配线程区间", mTaskRecord.filePath));
for (int i = 0; i < mTaskRecord.threadNum; i++) {
long startL = i * blockSize, endL = (i + 1) * blockSize;
ThreadRecord tr = mTaskRecord.threadRecords.get(i);

View File

@@ -81,8 +81,7 @@ public abstract class AbsGroupUtil implements IUtil, Runnable {
* 初始化组合任务状态
*/
private void initState() {
mState = new GroupRunState(getWrapper().getKey(), mListener,
mGTWrapper.getSubTaskWrapper().size(), mSubQueue);
mState = new GroupRunState(getWrapper().getKey(), mListener, mSubQueue);
for (DTaskWrapper wrapper : mGTWrapper.getSubTaskWrapper()) {
if (wrapper.getEntity().getState() == IEntity.STATE_COMPLETE) {
mState.updateCompleteNum();

View File

@@ -112,30 +112,4 @@ public abstract class AbsSubDLoadUtil implements IUtil {
mSchedulers.obtainMessage(ISchedulers.STOP, this).sendToTarget();
}
}
//@Override public void start() {
// if (mWrapper.getRequestType() == ITaskWrapper.D_HTTP) {
// if (needGetInfo) {
// new Thread(new HttpFileInfoThread(mWrapper, new OnFileInfoCallback() {
//
// @Override public void onComplete(String url, CompleteInfo info) {
// mDLoader = new Downloader(mListener, mWrapper);
// mDLoader.start();
// }
//
// @Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
// mSchedulers.obtainMessage(ISchedulers.FAIL, SubDLoadUtil.this).sendToTarget();
// }
// })).start();
// } else {
// mDLoader = new Downloader(mListener, mWrapper);
// mDLoader.start();
// }
// } else if (mWrapper.getRequestType() == ITaskWrapper.D_FTP) {
// mDLoader = new Downloader(mListener, mWrapper);
// mDLoader.start();
// } else {
// ALog.w(TAG, String.format("不识别的类型requestType%s", mWrapper.getRequestType()));
// }
//}
}

View File

@@ -72,14 +72,16 @@ public class GroupRunState {
private String mGroupHash;
GroupRunState(String groupHash, IDGroupListener listener, int subSize,
SimpleSubQueue queue) {
GroupRunState(String groupHash, IDGroupListener listener, SimpleSubQueue queue) {
this.listener = listener;
this.queue = queue;
mSubSize = subSize;
mGroupHash = groupHash;
}
public void setSubSize(int subSize){
mSubSize = subSize;
}
/**
* 组合任务是否正在自行
*

View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.processor;
import com.arialyy.aria.core.inf.IEventHandler;
/**
* M3U8 密钥下载地址处理器,可用于解密被加密的密钥的下载地址
*/
public interface IKeyUrlConverter extends IEventHandler {
/**
* 将被加密的密钥下载地址转换为可使用的http下载地址
*
* @param keyUrl 加密的url地址
* @return 可正常访问的http地址
*/
String convert(String keyUrl);
}

View File

@@ -34,10 +34,6 @@ public abstract class AbsThreadTaskAdapter implements IThreadTaskAdapter {
* 速度限制工具
*/
protected BandwidthLimiter mSpeedBandUtil;
/**
* 当前线程的下去区间的进度
*/
private long mRangeProgress;
private ThreadRecord mThreadRecord;
private IThreadTaskObserver mObserver;
private AbsTaskWrapper mWrapper;
@@ -48,7 +44,6 @@ public abstract class AbsThreadTaskAdapter implements IThreadTaskAdapter {
mThreadRecord = config.record;
mWrapper = config.taskWrapper;
mThreadConfig = config;
mRangeProgress = mThreadRecord.startLocation;
if (getTaskConfig().getMaxSpeed() > 0) {
mSpeedBandUtil = new BandwidthLimiter(getTaskConfig().getMaxSpeed(), config.startThreadNum);
}
@@ -68,7 +63,7 @@ public abstract class AbsThreadTaskAdapter implements IThreadTaskAdapter {
* 当前线程的下去区间的进度
*/
protected long getRangeProgress() {
return mRangeProgress;
return mObserver.getThreadProgress();
}
protected ThreadRecord getThreadRecord() {

View File

@@ -53,4 +53,9 @@ public interface IThreadTaskObserver {
* @param len 新增的长度
*/
void updateProgress(long len);
/**
* 获取线程当前进度
*/
long getThreadProgress();
}

View File

@@ -318,6 +318,11 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
}
}
@Override
public long getThreadProgress() {
return mRangeProgress;
}
/**
* 取消任务
*/

View File

@@ -71,15 +71,15 @@ public class CommonUtil {
ALog.e(TAG, "sql语句表达式不能为null");
return false;
}
if (expression.length == 1) {
ALog.e(TAG, String.format("表达式需要写入参数,参数信息:%s", Arrays.toString(expression)));
return false;
}
//if (expression.length == 1) {
// ALog.e(TAG, String.format("表达式需要写入参数,参数信息:%s", Arrays.toString(expression)));
// return false;
//}
String where = expression[0];
if (!where.contains("?")) {
ALog.e(TAG, String.format("请在where语句的'='后编写?,参数信息:%s", Arrays.toString(expression)));
return false;
}
//if (!where.contains("?")) {
// ALog.e(TAG, String.format("请在where语句的'='后编写?,参数信息:%s", Arrays.toString(expression)));
// return false;
//}
Pattern pattern = Pattern.compile("\\?");
Matcher matcher = pattern.matcher(where);
int count = 0;

View File

@@ -101,9 +101,6 @@ public class ComponentUtil {
public <T extends IUtil> T buildUtil(AbsTaskWrapper wrapper, IEventListener listener) {
int requestType = wrapper.getRequestType();
String className = null;
if (requestType == 1){
throw new IllegalArgumentException("xxxx");
}
switch (requestType) {
case ITaskWrapper.M3U8_LIVE:
className = "com.arialyy.aria.m3u8.live.M3U8LiveUtil";

View File

@@ -44,16 +44,16 @@ Aria有以下特点
## 引入库
[![license](http://img.shields.io/badge/license-Apache2.0-brightgreen.svg?style=flat)](https://github.com/AriaLyy/Aria/blob/master/LICENSE)
[![Core](https://img.shields.io/badge/Core-3.7.6-blue)](https://github.com/AriaLyy/Aria)
[![Compiler](https://img.shields.io/badge/Compiler-3.7.6-blue)](https://github.com/AriaLyy/Aria)
[![FtpComponent](https://img.shields.io/badge/FtpComponent-3.7.6-orange)](https://github.com/AriaLyy/Aria)
[![M3U8Component](https://img.shields.io/badge/M3U8Component-3.7.6-orange)](https://github.com/AriaLyy/Aria)
[![Core](https://img.shields.io/badge/Core-3.7.9-blue)](https://github.com/AriaLyy/Aria)
[![Compiler](https://img.shields.io/badge/Compiler-3.7.9-blue)](https://github.com/AriaLyy/Aria)
[![FtpComponent](https://img.shields.io/badge/FtpComponent-3.7.9-orange)](https://github.com/AriaLyy/Aria)
[![M3U8Component](https://img.shields.io/badge/M3U8Component-3.7.9-orange)](https://github.com/AriaLyy/Aria)
```java
implementation 'com.arialyy.aria:core:3.7.6'
annotationProcessor 'com.arialyy.aria:compiler:3.7.6'
implementation 'com.arialyy.aria:ftpComponent:3.7.6' # 如果需要使用ftp请增加该组件
implementation 'com.arialyy.aria:m3u8Component:3.7.6' # 如果需要使用m3u8下载功能请增加该组件
implementation 'com.arialyy.aria:core:3.7.9'
annotationProcessor 'com.arialyy.aria:compiler:3.7.9'
implementation 'com.arialyy.aria:ftpComponent:3.7.9' # 如果需要使用ftp请增加该组件
implementation 'com.arialyy.aria:m3u8Component:3.7.9' # 如果需要使用m3u8下载功能请增加该组件
```
如果出现android support依赖错误请将 `compile 'com.arialyy.aria:core:<last-version>'`替换为
```
@@ -137,15 +137,9 @@ protected void onCreate(Bundle savedInstanceState) {
### 版本日志
+ v_3.7.6 (2019/11/19)
- fix bug https://github.com/AriaLyy/Aria/issues/505
- fix bug https://github.com/AriaLyy/Aria/issues/516
- fix bug https://github.com/AriaLyy/Aria/issues/515
- 增加强制上传的api`forceUpload()`
- 修复for循环上传文件出现的问题
- 移除创建任务的500ms间隔限制
- 修复多线程读写时可能出现的`database is locked`的问题
+ v_3.7.9 (2019/11/28)
- fix bug https://github.com/AriaLyy/Aria/issues/537
[更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md)
## 混淆配置

View File

@@ -29,5 +29,5 @@ dependencies {
implementation "com.jcraft:jsch:0.1.55"
implementation "com.jcraft:jzlib:1.1.3"
implementation project(path: ':FtpComponent')
compile project(path: ':PublicComponent')
implementation project(path: ':PublicComponent')
}

View File

@@ -72,6 +72,8 @@ dependencies {
implementation project(':M3U8Component')
implementation project(':FtpComponent')
implementation project(path: ':AriaAnnotations')
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
}
repositories {
mavenCentral()

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:sharedUserId="com.arialyy"
package="com.arialyy.simple">
<uses-permission android:name="android.permission.INTERNET"/>

View File

@@ -34,7 +34,7 @@ public class BaseApplication extends Application {
super.onCreate();
INSTANCE = this;
AbsFrame.init(this);
Aria.init(this);
//Aria.init(this);
if (BuildConfig.DEBUG) {
//StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
// .detectAll()

View File

@@ -39,7 +39,7 @@ public class HttpDownloadModule extends BaseViewModule {
//"http://202.98.201.103:7000/vrs/TPK/ZTC440402001Z.tpk";
private final String defFilePath =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()
+ "/TOTWOO-v3.5.6.apk";
+ "/tttt.apk";
private MutableLiveData<DownloadEntity> liveData = new MutableLiveData<>();
private DownloadEntity singDownloadInfo;
@@ -52,6 +52,7 @@ public class HttpDownloadModule extends BaseViewModule {
//String url =
// "http://sdkdown.muzhiwan.com/openfile/2019/05/21/com.netease.tom.mzw_5ce3ef8754d05.apk";
String url = "http://image.totwoo.com/totwoo-TOTWOO-v3.5.6.apk";
//String url = "https://imtt.dd.qq.com/16891/apk/70BFFDB05AB8686F2A4CF3E07588A377.apk?fsname=com.tencent.tmgp.speedmobile_1.16.0.33877_1160033877.apk&csr=1bbd";
//String url = "https://ss1.baidu.com/-4o3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=a9e671b9a551f3dedcb2bf64a4eff0ec/4610b912c8fcc3cef70d70409845d688d53f20f7.jpg";
String filePath = AppUtil.getConfigValue(context, HTTP_PATH_KEY, defFilePath);

View File

@@ -276,8 +276,9 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
if (Aria.download(this).load(mTaskId).isRunning()) {
Aria.download(this).load(mTaskId).stop();
} else {
mUrl = "http://sdkdown.muzhiwan.com/openfile/2019/07/11/com.netease.syfz.mzw_5d26f8d9cee27.apk";
Aria.download(this).load(mTaskId)
//.updateUrl("http://sdkdown.muzhiwan.com/openfile/2019/07/11/com.netease.syfz.mzw_5d26f8d9cee27.apk")
.updateUrl(mUrl)
.resume();
}
break;

View File

@@ -32,10 +32,10 @@ public class GroupModule extends BaseModule {
public List<String> getUrls() {
List<String> urls = new ArrayList<>();
urls.add("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1574141924275&di=a7ea1497a4a2528a45ce7103bf61adf4&imgtype=0&src=http%3A%2F%2Fg.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fc2cec3fdfc03924590b2a9b58d94a4c27d1e2500.jpg");
urls.add("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1574141924272&di=7861479e7cb3cea98d585eaf108f056f&imgtype=0&src=http%3A%2F%2Fd.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F562c11dfa9ec8a13c0741f5afd03918fa0ecc01a.jpg");
//String[] str = getContext().getResources().getStringArray(R.array.group_urls_1);
//Collections.addAll(urls, str);
//urls.add("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1574141924275&di=a7ea1497a4a2528a45ce7103bf61adf4&imgtype=0&src=http%3A%2F%2Fg.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fc2cec3fdfc03924590b2a9b58d94a4c27d1e2500.jpg");
//urls.add("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1574141924272&di=7861479e7cb3cea98d585eaf108f056f&imgtype=0&src=http%3A%2F%2Fd.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F562c11dfa9ec8a13c0741f5afd03918fa0ecc01a.jpg");
String[] str = getContext().getResources().getStringArray(R.array.group_urls_1);
Collections.addAll(urls, str);
return urls;
}

View File

@@ -49,6 +49,7 @@ public class M3U8LiveDLoadActivity extends BaseActivity<ActivityM3u8LiveBinding>
private String mFilePath;
private M3U8LiveModule mModule;
private DownloadEntity mEntity;
private long mTaskId;
@Override
protected void init(Bundle savedInstanceState) {
@@ -63,6 +64,7 @@ public class M3U8LiveDLoadActivity extends BaseActivity<ActivityM3u8LiveBinding>
return;
}
mEntity = entity;
mTaskId = mEntity.getId();
getBinding().setStateStr(getString(R.string.start));
getBinding().setUrl(entity.getUrl());
getBinding().setFilePath(entity.getFilePath());
@@ -213,22 +215,23 @@ public class M3U8LiveDLoadActivity extends BaseActivity<ActivityM3u8LiveBinding>
public void onClick(View view) {
switch (view.getId()) {
case R.id.start:
if (Aria.download(this).load(mEntity.getId()).isRunning()) {
if (Aria.download(this).load(mTaskId).isRunning()) {
Aria.download(this).load(mEntity.getId()).stop();
} else {
startD();
}
break;
case R.id.cancel:
if (AppUtil.chekEntityValid(mEntity)) {
if (mTaskId != -1){
Aria.download(this).load(mEntity.getId()).cancel(true);
mTaskId = -1;
}
break;
}
}
private void startD() {
Aria.download(M3U8LiveDLoadActivity.this)
mTaskId = Aria.download(M3U8LiveDLoadActivity.this)
.load(mUrl)
.setFilePath(mFilePath, true)
.m3u8LiveOption(getLiveoption())

View File

@@ -36,6 +36,7 @@ import com.arialyy.aria.core.download.M3U8Entity;
import com.arialyy.aria.core.download.m3u8.M3U8VodOption;
import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.processor.IBandWidthUrlConverter;
import com.arialyy.aria.core.processor.IKeyUrlConverter;
import com.arialyy.aria.core.processor.ITsMergeHandler;
import com.arialyy.aria.core.processor.IVodTsUrlConverter;
import com.arialyy.aria.core.task.DownloadTask;
@@ -308,7 +309,8 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
//.merge(true)
.setVodTsUrlConvert(new VodTsUrlConverter());
//.setMergeHandler(new TsMergeHandler());
//.setBandWidthUrlConverter(new BandWidthUrlConverter(mUrl));
option.setKeyUrlConverter(new KeyUrlConverter());
option.setBandWidthUrlConverter(new BandWidthUrlConverter(mUrl));
return option;
}
@@ -324,7 +326,10 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
static class VodTsUrlConverter implements IVodTsUrlConverter {
@Override public List<String> convert(String m3u8Url, List<String> tsUrls) {
Uri uri = Uri.parse(m3u8Url);
String parentUrl = "http://" + uri.getHost();
//String parentUrl = "http://" + uri.getHost() + "/gear1/";
int index = m3u8Url.lastIndexOf("/");
String parentUrl = m3u8Url.substring(0, index + 1);
//String parentUrl = "http://" + uri.getHost() + "/";
List<String> newUrls = new ArrayList<>();
for (String url : tsUrls) {
newUrls.add(parentUrl + url);
@@ -354,4 +359,12 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
return url.substring(0, index + 1) + bandWidthUrl;
}
}
static class KeyUrlConverter implements IKeyUrlConverter{
@Override public String convert(String keyUrl) {
ALog.d("TAG", "convertUrl....");
return null;
}
}
}

View File

@@ -34,9 +34,8 @@ public class M3U8VodModule extends BaseViewModule {
// m3u8测试集合http://www.voidcn.com/article/p-snaliarm-ct.html
//private final String defUrl = "https://www.gaoya123.cn/2019/1557993797897.m3u8";
// 多码率地址:
//private final String defUrl = "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8";
//private final String defUrl = "http://cn1.fa1244.cn/hls/20190516/6d271eaa73b2e4cb51d13831b0c1ab4c/1557976262/index.m3u8";
private final String defUrl = "http://qn.shytong.cn/b83137769ff6b555/11b0c9970f9a3fa0.mp4.m3u8";
private final String defUrl = "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8";
//private final String defUrl = "http://qn.shytong.cn/b83137769ff6b555/11b0c9970f9a3fa0.mp4.m3u8";
private final String filePath =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()
//+ "/道士下山.ts";

View File

@@ -307,17 +307,17 @@ public class DownloadAdapter extends AbsRVAdapter<AbsEntity, DownloadAdapter.Sim
switch (entity.getTaskType()) {
case ITaskWrapper.D_FTP:
//Aria.download(getContext()).loadFtp((DownloadEntity) entity).login("lao", "123456").create();
Aria.download(getContext()).loadFtp(entity.getId()).resume();
Aria.download(getContext()).loadFtp(entity.getId()).resume(true);
break;
case ITaskWrapper.D_FTP_DIR:
Aria.download(getContext()).loadFtpDir(entity.getId()).resume();
Aria.download(getContext()).loadFtpDir(entity.getId()).resume(true);
break;
case ITaskWrapper.D_HTTP:
case ITaskWrapper.M3U8_VOD:
Aria.download(getContext()).load(entity.getId()).resume();
Aria.download(getContext()).load(entity.getId()).resume(true);
break;
case ITaskWrapper.DG_HTTP:
Aria.download(getContext()).loadGroup(entity.getId()).resume();
Aria.download(getContext()).loadGroup(entity.getId()).resume(true);
break;
}
}

View File

@@ -44,8 +44,8 @@ task clean(type: Delete) {
}
ext {
versionCode = 376
versionName = '3.7.6'
versionCode = 379
versionName = '3.7.9'
userOrg = 'arialyy'
groupId = 'com.arialyy.aria'
publishVersion = versionName