Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3871d8f056 | ||
|
|
669aa6981c | ||
|
|
91daecd039 | ||
|
|
297cc99f2b | ||
|
|
f5f8e9b528 | ||
|
|
94c3e8bb58 |
39
.github/ISSUE_TEMPLATE/Custom.md
vendored
39
.github/ISSUE_TEMPLATE/Custom.md
vendored
@@ -1,35 +1,26 @@
|
||||
---
|
||||
name: 问题描述
|
||||
about: 请详细描述你遇到的问题
|
||||
about: 提交问题前,请先阅读文档和搜索issue
|
||||
|
||||
---
|
||||
|
||||
<!-- 请详细描述以下信息,即使是一个简单的bug,没有充足的信息,作者却需要花费大量的时间去查找可能的原因!! -->
|
||||
|
||||
## 预期行为
|
||||
|
||||
|
||||
## 当前行为
|
||||
|
||||
|
||||
## 可能的解决方案
|
||||
<!-- 不是强制性的,针对该错误的修复/原因的建议-->
|
||||
|
||||
|
||||
## 重现步骤
|
||||
<!-- 请提供明确的步骤 -->
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
4.
|
||||
|
||||
|
||||
## 错误日志
|
||||
|
||||
<!-- 提交问题前,请先阅读文档和搜索相应问题的issue -->
|
||||
|
||||
## 版本
|
||||
* 框架版本
|
||||
|
||||
* 系统版本
|
||||
|
||||
## 错误日志
|
||||
<!-- 请提供详细的错误日志 -->
|
||||
|
||||
|
||||
## 重现步骤
|
||||
<!-- 请提供明确的步骤 -->
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
4.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.widget.PopupWindow;
|
||||
import com.arialyy.aria.core.command.CommandManager;
|
||||
import com.arialyy.aria.core.common.QueueMod;
|
||||
@@ -76,7 +74,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
*/
|
||||
private Map<String, List<String>> mSubClass = new ConcurrentHashMap<>();
|
||||
private static Context APP;
|
||||
private Handler mAriaHandler;
|
||||
private DelegateWrapper mDbWrapper;
|
||||
private AriaConfig mConfig;
|
||||
|
||||
@@ -98,9 +95,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
}
|
||||
|
||||
public static AriaManager getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
throw new NullPointerException("请使用AriaManager.init(context)初始化管理器");
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@@ -171,13 +165,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized Handler getAriaHandler() {
|
||||
if (mAriaHandler == null) {
|
||||
mAriaHandler = new Handler(Looper.getMainLooper());
|
||||
}
|
||||
return mAriaHandler;
|
||||
}
|
||||
|
||||
public Map<String, AbsReceiver> getReceiver() {
|
||||
return mReceivers;
|
||||
}
|
||||
@@ -295,7 +282,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
RecordUtil.delTaskRecord(key, IRecordHandler.TYPE_DOWNLOAD, removeFile, true);
|
||||
break;
|
||||
case 2:
|
||||
RecordUtil.delGroupTaskRecord(key, removeFile);
|
||||
RecordUtil.delGroupTaskRecordByHash(key, removeFile);
|
||||
break;
|
||||
case 3:
|
||||
RecordUtil.delTaskRecord(key, IRecordHandler.TYPE_UPLOAD);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.arialyy.aria.core.command;
|
||||
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.task.DownloadTask;
|
||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||
@@ -41,7 +42,7 @@ final class HighestPriorityCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T>
|
||||
|
||||
@Override public void executeCmd() {
|
||||
if (!canExeCmd) return;
|
||||
if (!NetUtils.isConnected(AriaManager.getInstance().getAPP())){
|
||||
if (!NetUtils.isConnected(AriaConfig.getInstance().getAPP())){
|
||||
ALog.e(TAG, "启动任务失败,网络未连接");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.arialyy.aria.core.command;
|
||||
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.inf.IEntity;
|
||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
@@ -36,7 +36,7 @@ final class ResumeAllCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
|
||||
}
|
||||
|
||||
@Override public void executeCmd() {
|
||||
if (!NetUtils.isConnected(AriaManager.getInstance().getAPP())) {
|
||||
if (!NetUtils.isConnected(AriaConfig.getInstance().getAPP())) {
|
||||
ALog.w(TAG, "恢复任务失败,网络未连接");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.arialyy.aria.core.command;
|
||||
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.common.QueueMod;
|
||||
import com.arialyy.aria.core.inf.IEntity;
|
||||
import com.arialyy.aria.core.task.AbsTask;
|
||||
@@ -37,6 +37,7 @@ final public class StartCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
|
||||
|
||||
/**
|
||||
* 立即执行任务
|
||||
*
|
||||
* @param newStart true 立即执行任务,无论执行队列是否满了
|
||||
*/
|
||||
public void setNewStart(boolean newStart) {
|
||||
@@ -45,17 +46,17 @@ final public class StartCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
|
||||
|
||||
@Override public void executeCmd() {
|
||||
if (!canExeCmd) return;
|
||||
if (!NetUtils.isConnected(AriaManager.getInstance().getAPP())) {
|
||||
if (!NetUtils.isConnected(AriaConfig.getInstance().getAPP())) {
|
||||
ALog.e(TAG, "启动任务失败,网络未连接");
|
||||
return;
|
||||
}
|
||||
String mod;
|
||||
int maxTaskNum = mQueue.getMaxTaskNum();
|
||||
AriaManager manager = AriaManager.getInstance();
|
||||
AriaConfig config = AriaConfig.getInstance();
|
||||
if (isDownloadCmd) {
|
||||
mod = manager.getDownloadConfig().getQueueMod();
|
||||
mod = config.getDConfig().getQueueMod();
|
||||
} else {
|
||||
mod = manager.getUploadConfig().getQueueMod();
|
||||
mod = config.getUConfig().getQueueMod();
|
||||
}
|
||||
|
||||
AbsTask task = getTask();
|
||||
@@ -81,9 +82,9 @@ final public class StartCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
|
||||
startTask();
|
||||
}
|
||||
} else {
|
||||
if (newStart){
|
||||
if (newStart) {
|
||||
startTask();
|
||||
}else {
|
||||
} else {
|
||||
sendWaitState(task);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package com.arialyy.aria.core.common;
|
||||
|
||||
import com.arialyy.aria.core.common.controller.IStartFeature;
|
||||
import com.arialyy.aria.core.common.controller.BuilderController;
|
||||
import com.arialyy.aria.core.common.controller.IStartFeature;
|
||||
import com.arialyy.aria.core.inf.AbsTarget;
|
||||
|
||||
/**
|
||||
* 处理第一次下载
|
||||
* 处理第一次创建的任务
|
||||
*/
|
||||
public abstract class AbsBuilderTarget<TARGET extends AbsBuilderTarget> extends AbsTarget<TARGET>
|
||||
implements IStartFeature {
|
||||
@@ -34,6 +34,23 @@ public abstract class AbsBuilderTarget<TARGET extends AbsBuilderTarget> extends
|
||||
return mStartController;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否忽略权限检查
|
||||
*/
|
||||
public TARGET ignoreCheckPermissions() {
|
||||
getController().ignoreCheckPermissions();
|
||||
return (TARGET) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 忽略文件占用,不管文件路径是否被其它任务占用,都执行上传\下载任务
|
||||
* 需要注意的是:如果文件被其它任务占用,并且还调用了该方法,将自动删除占用了该文件路径的任务
|
||||
*/
|
||||
public TARGET ignoreFilePathOccupy() {
|
||||
getController().ignoreFilePathOccupy();
|
||||
return (TARGET) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加任务
|
||||
*
|
||||
|
||||
@@ -31,6 +31,14 @@ import com.arialyy.aria.util.RecordUtil;
|
||||
public abstract class AbsNormalTarget<TARGET extends AbsNormalTarget> extends AbsTarget<TARGET>
|
||||
implements INormalFeature {
|
||||
|
||||
/**
|
||||
* 是否忽略权限检查
|
||||
*/
|
||||
public TARGET ignoreCheckPermissions() {
|
||||
getController().ignoreCheckPermissions();
|
||||
return (TARGET) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务是否在执行
|
||||
*
|
||||
|
||||
@@ -19,21 +19,21 @@ import android.Manifest;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.common.AbsEntity;
|
||||
import com.arialyy.aria.core.download.CheckDEntityUtil;
|
||||
import com.arialyy.aria.core.download.CheckDGEntityUtil;
|
||||
import com.arialyy.aria.core.download.CheckFtpDirEntityUtil;
|
||||
import com.arialyy.aria.core.download.DGTaskWrapper;
|
||||
import com.arialyy.aria.core.download.DTaskWrapper;
|
||||
import com.arialyy.aria.core.common.AbsEntity;
|
||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||
import com.arialyy.aria.core.inf.ICheckEntityUtil;
|
||||
import com.arialyy.aria.core.task.ITask;
|
||||
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
||||
import com.arialyy.aria.core.listener.ISchedulers;
|
||||
import com.arialyy.aria.core.scheduler.TaskSchedulers;
|
||||
import com.arialyy.aria.core.task.ITask;
|
||||
import com.arialyy.aria.core.upload.CheckUEntityUtil;
|
||||
import com.arialyy.aria.core.upload.UTaskWrapper;
|
||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import java.lang.reflect.Constructor;
|
||||
@@ -46,6 +46,10 @@ public abstract class FeatureController {
|
||||
private final String TAG;
|
||||
|
||||
private AbsTaskWrapper mTaskWrapper;
|
||||
/**
|
||||
* 是否忽略权限检查 true 忽略权限检查
|
||||
*/
|
||||
private boolean ignoreCheckPermissions = false;
|
||||
|
||||
FeatureController(AbsTaskWrapper wrapper) {
|
||||
mTaskWrapper = wrapper;
|
||||
@@ -87,6 +91,20 @@ public abstract class FeatureController {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否忽略权限检查
|
||||
*/
|
||||
public void ignoreCheckPermissions() {
|
||||
this.ignoreCheckPermissions = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 强制执行任务,不管文件路径是否被占用
|
||||
*/
|
||||
public void ignoreFilePathOccupy() {
|
||||
mTaskWrapper.setIgnoreFilePathOccupy(true);
|
||||
}
|
||||
|
||||
protected AbsTaskWrapper getTaskWrapper() {
|
||||
return mTaskWrapper;
|
||||
}
|
||||
@@ -111,7 +129,7 @@ public abstract class FeatureController {
|
||||
* 如果检查实体失败,将错误回调
|
||||
*/
|
||||
boolean checkConfig() {
|
||||
if (!checkPermission()) {
|
||||
if (!ignoreCheckPermissions && !checkPermission()) {
|
||||
return false;
|
||||
}
|
||||
boolean b = checkEntity();
|
||||
@@ -134,21 +152,21 @@ public abstract class FeatureController {
|
||||
*/
|
||||
private boolean checkPermission() {
|
||||
|
||||
if (AriaManager.getInstance()
|
||||
if (AriaConfig.getInstance()
|
||||
.getAPP()
|
||||
.checkCallingOrSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
ALog.e(TAG, "启动失败,缺少权限:Manifest.permission.WRITE_EXTERNAL_STORAGE");
|
||||
return false;
|
||||
}
|
||||
if (AriaManager.getInstance()
|
||||
if (AriaConfig.getInstance()
|
||||
.getAPP()
|
||||
.checkCallingOrSelfPermission(Manifest.permission.INTERNET)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
ALog.e(TAG, "启动失败,缺少权限:Manifest.permission.INTERNET");
|
||||
return false;
|
||||
}
|
||||
if (AriaManager.getInstance()
|
||||
if (AriaConfig.getInstance()
|
||||
.getAPP()
|
||||
.checkCallingOrSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CheckUtil;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import com.arialyy.aria.util.FileUtil;
|
||||
import com.arialyy.aria.util.RecordUtil;
|
||||
import java.io.File;
|
||||
|
||||
@@ -65,8 +66,7 @@ public class CheckDEntityUtil implements ICheckEntityUtil {
|
||||
File file = new File(mWrapper.getTempFilePath());
|
||||
Object bw = mWrapper.getM3U8Params().getParam(IOptionConstant.bandWidth);
|
||||
int bandWidth = bw == null ? 0 : (int) bw;
|
||||
// 缓存文件夹格式:问文件夹/.文件名_码率
|
||||
String cacheDir = String.format("%s/.%s_%s", file.getParent(), file.getName(), bandWidth);
|
||||
String cacheDir = FileUtil.getTsCacheDir(file.getPath(), bandWidth);
|
||||
|
||||
mWrapper.getM3U8Params().setParams(IOptionConstant.cacheDir, cacheDir);
|
||||
M3U8Entity m3U8Entity = mEntity.getM3U8Entity();
|
||||
@@ -134,7 +134,7 @@ public class CheckDEntityUtil implements ICheckEntityUtil {
|
||||
//设置文件保存路径,如果新文件路径和旧文件路径不同,则修改路径
|
||||
if (!filePath.equals(mEntity.getFilePath())) {
|
||||
// 检查路径冲突
|
||||
if (!CheckUtil.checkDownloadPathConflicts(mWrapper.isForceDownload(), filePath)) {
|
||||
if (!CheckUtil.checkDPathConflicts(mWrapper.isIgnoreFilePathOccupy(), filePath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
package com.arialyy.aria.core.download;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.arialyy.aria.core.common.ErrorCode;
|
||||
import com.arialyy.aria.core.common.RequestEnum;
|
||||
import com.arialyy.aria.core.inf.ICheckEntityUtil;
|
||||
import com.arialyy.aria.core.inf.IOptionConstant;
|
||||
import com.arialyy.aria.orm.DbEntity;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CheckUtil;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import com.arialyy.aria.util.RecordUtil;
|
||||
import java.io.File;
|
||||
@@ -70,10 +70,9 @@ public class CheckDGEntityUtil implements ICheckEntityUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((mEntity.getDirPath() == null || !mEntity.getDirPath().equals(mWrapper.getDirPathTemp()))
|
||||
&& DbEntity.checkDataExist(DownloadGroupEntity.class, "dirPath=?",
|
||||
// 检查路径冲突
|
||||
if (mWrapper.isNewTask() && !CheckUtil.checkDGPathConflicts(mWrapper.isIgnoreFilePathOccupy(),
|
||||
mWrapper.getDirPathTemp())) {
|
||||
ALog.e(TAG, String.format("文件夹路径【%s】已被其它任务占用,请重新设置文件夹路径", mWrapper.getDirPathTemp()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.arialyy.aria.core.download;
|
||||
import androidx.annotation.CheckResult;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.arialyy.annotations.TaskEnum;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.command.CancelAllCmd;
|
||||
import com.arialyy.aria.core.command.CmdHelper;
|
||||
@@ -64,7 +65,7 @@ public class DownloadReceiver extends AbsReceiver {
|
||||
*/
|
||||
@Deprecated
|
||||
public DownloadReceiver setMaxSpeed(int maxSpeed) {
|
||||
AriaManager.getInstance().getDownloadConfig().setMaxSpeed(maxSpeed);
|
||||
AriaConfig.getInstance().getDConfig().setMaxSpeed(maxSpeed);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -287,10 +288,10 @@ public class DownloadReceiver extends AbsReceiver {
|
||||
* @return 如果实体不存在,返回null
|
||||
*/
|
||||
public DownloadGroupEntity getGroupEntity(List<String> urls) {
|
||||
if (CheckUtil.checkDownloadUrlsIsEmpty(urls)){
|
||||
if (CheckUtil.checkDownloadUrlsIsEmpty(urls)) {
|
||||
return null;
|
||||
}
|
||||
return DbDataHelper.getDGEntity(CommonUtil.getMd5Code(urls));
|
||||
return DbDataHelper.getDGEntityByHash(CommonUtil.getMd5Code(urls));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -303,7 +304,7 @@ public class DownloadReceiver extends AbsReceiver {
|
||||
if (!CheckUtil.checkUrl(url)) {
|
||||
return null;
|
||||
}
|
||||
return DbDataHelper.getDGEntity(url);
|
||||
return DbDataHelper.getDGEntityByHash(url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -93,7 +93,7 @@ class DNormalConfigHandler<TARGET extends AbsTarget> implements IConfigHandler {
|
||||
}
|
||||
|
||||
void setForceDownload(boolean forceDownload) {
|
||||
getWrapper().setForceDownload(forceDownload);
|
||||
getWrapper().setIgnoreFilePathOccupy(forceDownload);
|
||||
}
|
||||
|
||||
void setUrl(String url) {
|
||||
|
||||
@@ -34,6 +34,7 @@ public class FtpBuilderTarget extends AbsBuilderTarget<FtpBuilderTarget> {
|
||||
mConfigHandler = new DNormalConfigHandler<>(this, -1);
|
||||
mConfigHandler.setUrl(url);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.D_FTP);
|
||||
getTaskWrapper().setNewTask(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,7 +71,9 @@ public class FtpBuilderTarget extends AbsBuilderTarget<FtpBuilderTarget> {
|
||||
*
|
||||
* @param filePath 路径必须为文件路径,不能为文件夹路径
|
||||
* @param forceDownload {@code true}强制下载,不考虑文件路径是否被占用
|
||||
* @deprecated 使用 {@link #ignoreFilePathOccupy()}
|
||||
*/
|
||||
@Deprecated
|
||||
@CheckResult(suggest = Suggest.TASK_CONTROLLER)
|
||||
public FtpBuilderTarget setFilePath(@NonNull String filePath, boolean forceDownload) {
|
||||
mConfigHandler.setTempFilePath(filePath);
|
||||
|
||||
@@ -35,6 +35,7 @@ public class FtpDirBuilderTarget extends AbsBuilderTarget<FtpDirBuilderTarget> {
|
||||
this.url = url;
|
||||
mConfigHandler = new FtpDirConfigHandler<>(this, -1);
|
||||
getEntity().setGroupHash(url);
|
||||
getTaskWrapper().setNewTask(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,6 +32,7 @@ public class FtpDirNormalTarget extends AbsNormalTarget<FtpDirNormalTarget> {
|
||||
|
||||
FtpDirNormalTarget(long taskId) {
|
||||
mConfigHandler = new FtpDirConfigHandler<>(this, taskId);
|
||||
getTaskWrapper().setNewTask(false);
|
||||
}
|
||||
|
||||
@Override public boolean isRunning() {
|
||||
|
||||
@@ -34,6 +34,7 @@ public class FtpNormalTarget extends AbsNormalTarget<FtpNormalTarget> {
|
||||
FtpNormalTarget(long taskId) {
|
||||
mConfigHandler = new DNormalConfigHandler<>(this, taskId);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.D_FTP);
|
||||
getTaskWrapper().setNewTask(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,8 +34,9 @@ public class GroupBuilderTarget extends AbsBuilderTarget<GroupBuilderTarget> {
|
||||
|
||||
GroupBuilderTarget(List<String> urls) {
|
||||
mConfigHandler = new HttpGroupConfigHandler<>(this, -1);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.DG_HTTP);
|
||||
mConfigHandler.setGroupUrl(urls);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.DG_HTTP);
|
||||
getTaskWrapper().setNewTask(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,7 @@ public class GroupNormalTarget extends AbsNormalTarget<GroupNormalTarget> {
|
||||
GroupNormalTarget(long taskId) {
|
||||
mConfigHandler = new HttpGroupConfigHandler<>(this, taskId);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.DG_HTTP);
|
||||
getTaskWrapper().setNewTask(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,12 +22,9 @@ import com.arialyy.aria.core.common.HttpOption;
|
||||
import com.arialyy.aria.core.download.DTaskWrapper;
|
||||
import com.arialyy.aria.core.download.m3u8.M3U8LiveOption;
|
||||
import com.arialyy.aria.core.download.m3u8.M3U8VodOption;
|
||||
import com.arialyy.aria.core.inf.IOptionConstant;
|
||||
import com.arialyy.aria.core.inf.Suggest;
|
||||
import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
|
||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
||||
import com.arialyy.aria.util.CheckUtil;
|
||||
|
||||
public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
|
||||
|
||||
@@ -35,13 +32,14 @@ public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
|
||||
|
||||
HttpBuilderTarget(String url) {
|
||||
mConfigHandler = new DNormalConfigHandler<>(this, -1);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.D_HTTP);
|
||||
mConfigHandler.setUrl(url);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.D_HTTP);
|
||||
getTaskWrapper().setNewTask(true);
|
||||
}
|
||||
|
||||
@CheckResult(suggest = Suggest.TASK_CONTROLLER)
|
||||
public HttpBuilderTarget m3u8VodOption(M3U8VodOption m3U8VodOption) {
|
||||
if (m3U8VodOption == null){
|
||||
if (m3U8VodOption == null) {
|
||||
throw new NullPointerException("m3u8任务设置为空");
|
||||
}
|
||||
getTaskWrapper().setRequestType(AbsTaskWrapper.M3U8_VOD);
|
||||
@@ -52,7 +50,7 @@ public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
|
||||
|
||||
@CheckResult(suggest = Suggest.TASK_CONTROLLER)
|
||||
public HttpBuilderTarget m3u8LiveOption(M3U8LiveOption m3U8LiveOption) {
|
||||
if (m3U8LiveOption == null){
|
||||
if (m3U8LiveOption == null) {
|
||||
throw new NullPointerException("m3u8任务设置为空");
|
||||
}
|
||||
getTaskWrapper().setRequestType(AbsTaskWrapper.M3U8_LIVE);
|
||||
@@ -92,7 +90,9 @@ public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
|
||||
*
|
||||
* @param filePath 路径必须为文件路径,不能为文件夹路径
|
||||
* @param forceDownload {@code true}强制下载,不考虑文件路径是否被占用
|
||||
* @deprecated 使用 {@link #ignoreFilePathOccupy()}
|
||||
*/
|
||||
@Deprecated
|
||||
@CheckResult(suggest = Suggest.TASK_CONTROLLER)
|
||||
public HttpBuilderTarget setFilePath(@NonNull String filePath, boolean forceDownload) {
|
||||
mConfigHandler.setTempFilePath(filePath);
|
||||
|
||||
@@ -35,6 +35,7 @@ public class HttpNormalTarget extends AbsNormalTarget<HttpNormalTarget> {
|
||||
HttpNormalTarget(long taskId) {
|
||||
mConfigHandler = new DNormalConfigHandler<>(this, taskId);
|
||||
getTaskWrapper().setRequestType(getTaskWrapper().getEntity().getTaskType());
|
||||
getTaskWrapper().setNewTask(false);
|
||||
}
|
||||
|
||||
@CheckResult(suggest = Suggest.TASK_CONTROLLER)
|
||||
|
||||
@@ -27,6 +27,7 @@ public class M3U8NormalTarget extends AbsNormalTarget<M3U8NormalTarget> {
|
||||
|
||||
M3U8NormalTarget(DTaskWrapper wrapper) {
|
||||
setTaskWrapper(wrapper);
|
||||
getTaskWrapper().setNewTask(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,7 @@ public class TcpBuilderTarget extends AbsBuilderTarget<TcpBuilderTarget> {
|
||||
TcpBuilderTarget(String ip, int port) {
|
||||
mConfigHandler = new DNormalConfigHandler<>(this, -1);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.D_TCP);
|
||||
getTaskWrapper().setNewTask(true);
|
||||
}
|
||||
//
|
||||
///**
|
||||
@@ -56,18 +57,4 @@ public class TcpBuilderTarget extends AbsBuilderTarget<TcpBuilderTarget> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置文件存储路径,如果需要修改新的文件名,修改路径便可。
|
||||
* 如:原文件路径 /mnt/sdcard/test.zip
|
||||
* 如果需要将test.zip改为game.zip,只需要重新设置文件路径为:/mnt/sdcard/game.zip
|
||||
*
|
||||
* @param filePath 路径必须为文件路径,不能为文件夹路径
|
||||
* @param forceDownload {@code true}强制下载,不考虑文件路径是否被占用
|
||||
*/
|
||||
@CheckResult(suggest = Suggest.TASK_CONTROLLER)
|
||||
public TcpBuilderTarget setFilePath(@NonNull String filePath, boolean forceDownload) {
|
||||
mConfigHandler.setTempFilePath(filePath);
|
||||
mConfigHandler.setForceDownload(forceDownload);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
package com.arialyy.aria.core.queue;
|
||||
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.download.DGTaskWrapper;
|
||||
import com.arialyy.aria.core.task.DownloadGroupTask;
|
||||
import com.arialyy.aria.core.event.DGMaxNumEvent;
|
||||
import com.arialyy.aria.core.event.Event;
|
||||
import com.arialyy.aria.core.event.EventMsgUtil;
|
||||
import com.arialyy.aria.core.scheduler.TaskSchedulers;
|
||||
import com.arialyy.aria.core.task.DownloadGroupTask;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
|
||||
/**
|
||||
@@ -57,7 +57,7 @@ public class DGroupTaskQueue
|
||||
}
|
||||
|
||||
@Override public int getMaxTaskNum() {
|
||||
return AriaManager.getInstance().getDGroupConfig().getMaxTaskNum();
|
||||
return AriaConfig.getInstance().getDConfig().getMaxTaskNum();
|
||||
}
|
||||
|
||||
@Override public DownloadGroupTask createTask(DGTaskWrapper wrapper) {
|
||||
@@ -74,6 +74,6 @@ public class DGroupTaskQueue
|
||||
}
|
||||
|
||||
@Override public int getOldMaxNum() {
|
||||
return AriaManager.getInstance().getDGroupConfig().oldMaxTaskNum;
|
||||
return AriaConfig.getInstance().getDGConfig().oldMaxTaskNum;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
package com.arialyy.aria.core.queue;
|
||||
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.download.DTaskWrapper;
|
||||
import com.arialyy.aria.core.task.DownloadTask;
|
||||
import com.arialyy.aria.core.event.DMaxNumEvent;
|
||||
import com.arialyy.aria.core.event.Event;
|
||||
import com.arialyy.aria.core.event.EventMsgUtil;
|
||||
import com.arialyy.aria.core.inf.TaskSchedulerType;
|
||||
import com.arialyy.aria.core.scheduler.TaskSchedulers;
|
||||
import com.arialyy.aria.core.task.DownloadTask;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
@@ -60,7 +60,7 @@ public class DTaskQueue extends AbsTaskQueue<DownloadTask, DTaskWrapper> {
|
||||
}
|
||||
|
||||
@Override public int getOldMaxNum() {
|
||||
return AriaManager.getInstance().getDownloadConfig().oldMaxTaskNum;
|
||||
return AriaConfig.getInstance().getDConfig().oldMaxTaskNum;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ public class DTaskQueue extends AbsTaskQueue<DownloadTask, DTaskWrapper> {
|
||||
}
|
||||
}
|
||||
}
|
||||
int maxSize = AriaManager.getInstance().getDownloadConfig().getMaxTaskNum();
|
||||
int maxSize = AriaConfig.getInstance().getDConfig().getMaxTaskNum();
|
||||
int currentSize = mExecutePool.size();
|
||||
if (currentSize == 0 || currentSize < maxSize) {
|
||||
startTask(task);
|
||||
@@ -126,6 +126,6 @@ public class DTaskQueue extends AbsTaskQueue<DownloadTask, DTaskWrapper> {
|
||||
}
|
||||
|
||||
@Override public int getMaxTaskNum() {
|
||||
return AriaManager.getInstance().getDownloadConfig().getMaxTaskNum();
|
||||
return AriaConfig.getInstance().getDConfig().getMaxTaskNum();
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.arialyy.aria.core.queue;
|
||||
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.event.Event;
|
||||
import com.arialyy.aria.core.event.EventMsgUtil;
|
||||
@@ -55,11 +56,11 @@ public class UTaskQueue extends AbsTaskQueue<UploadTask, UTaskWrapper> {
|
||||
}
|
||||
|
||||
@Override public int getOldMaxNum() {
|
||||
return AriaManager.getInstance().getUploadConfig().oldMaxTaskNum;
|
||||
return AriaConfig.getInstance().getUConfig().oldMaxTaskNum;
|
||||
}
|
||||
|
||||
@Override public int getMaxTaskNum() {
|
||||
return AriaManager.getInstance().getUploadConfig().getMaxTaskNum();
|
||||
return AriaConfig.getInstance().getUConfig().getMaxTaskNum();
|
||||
}
|
||||
|
||||
@Override public UploadTask createTask(UTaskWrapper wrapper) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.arialyy.aria.core.queue.pool;
|
||||
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.task.AbsTask;
|
||||
|
||||
@@ -26,6 +27,6 @@ class DGLoadExecutePool<TASK extends AbsTask> extends DLoadExecutePool<TASK> {
|
||||
private final String TAG = "DGLoadExecutePool";
|
||||
|
||||
@Override protected int getMaxSize() {
|
||||
return AriaManager.getInstance().getDGroupConfig().getMaxTaskNum();
|
||||
return AriaConfig.getInstance().getDGConfig().getMaxTaskNum();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.arialyy.aria.core.queue.pool;
|
||||
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.task.AbsTask;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
@@ -30,7 +30,7 @@ class DLoadExecutePool<TASK extends AbsTask> extends BaseExecutePool<TASK> {
|
||||
private final String TAG = "DownloadExecutePool";
|
||||
|
||||
@Override protected int getMaxSize() {
|
||||
return AriaManager.getInstance().getDownloadConfig().getMaxTaskNum();
|
||||
return AriaConfig.getInstance().getDConfig().getMaxTaskNum();
|
||||
}
|
||||
|
||||
@Override public boolean putTask(TASK task) {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.arialyy.aria.core.queue.pool;
|
||||
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.task.AbsTask;
|
||||
|
||||
/**
|
||||
@@ -23,6 +23,6 @@ import com.arialyy.aria.core.task.AbsTask;
|
||||
*/
|
||||
public class UploadExecutePool<TASK extends AbsTask> extends BaseExecutePool<TASK> {
|
||||
@Override protected int getMaxSize() {
|
||||
return AriaManager.getInstance().getUploadConfig().getMaxTaskNum();
|
||||
return AriaConfig.getInstance().getUConfig().getMaxTaskNum();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
package com.arialyy.aria.core.scheduler;
|
||||
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.common.AbsEntity;
|
||||
import com.arialyy.aria.core.task.ITask;
|
||||
import com.arialyy.aria.core.manager.TaskWrapperManager;
|
||||
import com.arialyy.aria.core.queue.ITaskQueue;
|
||||
import com.arialyy.aria.core.task.ITask;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import java.util.ArrayList;
|
||||
@@ -42,7 +42,6 @@ class FailureTaskHandler<TASK extends ITask> {
|
||||
private TaskSchedulers mSchedulers;
|
||||
private final ReentrantLock LOCK = new ReentrantLock();
|
||||
private Condition mCondition = LOCK.newCondition();
|
||||
private AriaManager mAriaManager;
|
||||
|
||||
static FailureTaskHandler init(TaskSchedulers schedulers) {
|
||||
if (INSTANCE == null) {
|
||||
@@ -57,7 +56,6 @@ class FailureTaskHandler<TASK extends ITask> {
|
||||
|
||||
private FailureTaskHandler(TaskSchedulers schedulers) {
|
||||
mSchedulers = schedulers;
|
||||
mAriaManager = AriaManager.getInstance();
|
||||
new Thread(new Runnable() {
|
||||
@Override public void run() {
|
||||
while (true) {
|
||||
@@ -82,35 +80,46 @@ class FailureTaskHandler<TASK extends ITask> {
|
||||
}
|
||||
|
||||
private void retryTask(final TASK task) {
|
||||
long interval = task.getTaskWrapper().getConfig().getReTryInterval();
|
||||
final int num = task.getTaskWrapper().getConfig().getReTryNum();
|
||||
final ITaskQueue queue = mSchedulers.getQueue(task.getTaskType());
|
||||
mAriaManager.getAriaHandler().postDelayed(new Runnable() {
|
||||
@Override public void run() {
|
||||
AbsEntity entity = task.getTaskWrapper().getEntity();
|
||||
if (entity.getFailNum() <= num) {
|
||||
ALog.d(TAG, String.format("任务【%s】开始重试", task.getTaskName()));
|
||||
queue.reTryStart(task);
|
||||
} else {
|
||||
queue.removeTaskFormQueue(task.getKey());
|
||||
mSchedulers.startNextTask(queue, task.getSchedulerType());
|
||||
TaskWrapperManager.getInstance().removeTaskWrapper(task.getTaskWrapper());
|
||||
}
|
||||
mExeQueue.remove(task);
|
||||
int index = mHashList.indexOf(task.hashCode());
|
||||
if (index != -1) {
|
||||
mHashList.remove(index);
|
||||
}
|
||||
if (LOCK.isLocked()) {
|
||||
try {
|
||||
LOCK.lock();
|
||||
mCondition.signalAll();
|
||||
} finally {
|
||||
LOCK.unlock();
|
||||
if (task.isNeedRetry()){
|
||||
long interval = task.getTaskWrapper().getConfig().getReTryInterval();
|
||||
final int num = task.getTaskWrapper().getConfig().getReTryNum();
|
||||
AriaConfig.getInstance().getAriaHandler().postDelayed(new Runnable() {
|
||||
@Override public void run() {
|
||||
AbsEntity entity = task.getTaskWrapper().getEntity();
|
||||
if (entity.getFailNum() <= num) {
|
||||
ALog.d(TAG, String.format("任务【%s】开始重试", task.getTaskName()));
|
||||
queue.reTryStart(task);
|
||||
} else {
|
||||
queue.removeTaskFormQueue(task.getKey());
|
||||
mSchedulers.startNextTask(queue, task.getSchedulerType());
|
||||
TaskWrapperManager.getInstance().removeTaskWrapper(task.getTaskWrapper());
|
||||
}
|
||||
next(task);
|
||||
}
|
||||
}, interval);
|
||||
}else {
|
||||
queue.removeTaskFormQueue(task.getKey());
|
||||
mSchedulers.startNextTask(queue, task.getSchedulerType());
|
||||
TaskWrapperManager.getInstance().removeTaskWrapper(task.getTaskWrapper());
|
||||
next(task);
|
||||
}
|
||||
}
|
||||
|
||||
private void next(TASK task){
|
||||
mExeQueue.remove(task);
|
||||
int index = mHashList.indexOf(task.hashCode());
|
||||
if (index != -1) {
|
||||
mHashList.remove(index);
|
||||
}
|
||||
if (LOCK.isLocked()) {
|
||||
try {
|
||||
LOCK.lock();
|
||||
mCondition.signalAll();
|
||||
} finally {
|
||||
LOCK.unlock();
|
||||
}
|
||||
}, interval);
|
||||
}
|
||||
}
|
||||
|
||||
void offer(TASK task) {
|
||||
|
||||
@@ -19,7 +19,7 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import com.arialyy.annotations.TaskEnum;
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.common.AbsEntity;
|
||||
import com.arialyy.aria.core.common.AbsNormalEntity;
|
||||
import com.arialyy.aria.core.group.GroupSendParams;
|
||||
@@ -53,10 +53,10 @@ public class TaskSchedulers<TASK extends ITask> implements ISchedulers {
|
||||
private static FailureTaskHandler mFailureTaskHandler;
|
||||
|
||||
private Map<String, Map<TaskEnum, ISchedulerListener>> mObservers = new ConcurrentHashMap<>();
|
||||
private AriaManager mAriaManager;
|
||||
private AriaConfig mAriaConfig;
|
||||
|
||||
private TaskSchedulers() {
|
||||
mAriaManager = AriaManager.getInstance();
|
||||
mAriaConfig = AriaConfig.getInstance();
|
||||
}
|
||||
|
||||
public static TaskSchedulers getInstance() {
|
||||
@@ -230,11 +230,11 @@ public class TaskSchedulers<TASK extends ITask> implements ISchedulers {
|
||||
}
|
||||
}
|
||||
|
||||
boolean canSend = mAriaManager.getAppConfig().isUseBroadcast();
|
||||
boolean canSend = mAriaConfig.getAConfig().isUseBroadcast();
|
||||
if (canSend) {
|
||||
Intent intent = new Intent(ISchedulers.ARIA_TASK_INFO_ACTION);
|
||||
intent.putExtras(data);
|
||||
mAriaManager.getAPP().sendBroadcast(intent);
|
||||
mAriaConfig.getAPP().sendBroadcast(intent);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -284,9 +284,9 @@ public class TaskSchedulers<TASK extends ITask> implements ISchedulers {
|
||||
}
|
||||
}
|
||||
|
||||
boolean canSend = mAriaManager.getAppConfig().isUseBroadcast();
|
||||
boolean canSend = mAriaConfig.getAConfig().isUseBroadcast();
|
||||
if (canSend) {
|
||||
mAriaManager.getAPP().sendBroadcast(
|
||||
mAriaConfig.getAPP().sendBroadcast(
|
||||
createData(msg.what, ITask.DOWNLOAD_GROUP_SUB, params.entity));
|
||||
}
|
||||
|
||||
@@ -353,13 +353,13 @@ public class TaskSchedulers<TASK extends ITask> implements ISchedulers {
|
||||
startNextTask(getQueue(taskType), TaskSchedulerType.TYPE_DEFAULT);
|
||||
|
||||
// 发送广播
|
||||
boolean canSend = mAriaManager.getAppConfig().isUseBroadcast();
|
||||
boolean canSend = mAriaConfig.getAConfig().isUseBroadcast();
|
||||
if (canSend) {
|
||||
Intent intent = new Intent(ISchedulers.ARIA_TASK_INFO_ACTION);
|
||||
Bundle b = new Bundle();
|
||||
b.putInt(ISchedulers.TASK_TYPE, taskType);
|
||||
b.putInt(ISchedulers.TASK_STATE, ISchedulers.FAIL);
|
||||
mAriaManager.getAPP().sendBroadcast(intent);
|
||||
mAriaConfig.getAPP().sendBroadcast(intent);
|
||||
}
|
||||
|
||||
// 处理回调
|
||||
@@ -470,16 +470,16 @@ public class TaskSchedulers<TASK extends ITask> implements ISchedulers {
|
||||
* 发送普通任务的广播
|
||||
*/
|
||||
private void sendNormalBroadcast(int state, TASK task) {
|
||||
boolean canSend = mAriaManager.getAppConfig().isUseBroadcast();
|
||||
boolean canSend = mAriaConfig.getAConfig().isUseBroadcast();
|
||||
if (!canSend) {
|
||||
return;
|
||||
}
|
||||
int type = task.getTaskType();
|
||||
if (type == ITask.DOWNLOAD || type == ITask.DOWNLOAD_GROUP) {
|
||||
mAriaManager.getAPP().sendBroadcast(
|
||||
mAriaConfig.getAPP().sendBroadcast(
|
||||
createData(state, type, task.getTaskWrapper().getEntity()));
|
||||
} else if (type == ITask.UPLOAD) {
|
||||
mAriaManager.getAPP().sendBroadcast(
|
||||
mAriaConfig.getAPP().sendBroadcast(
|
||||
createData(state, type, task.getTaskWrapper().getEntity()));
|
||||
} else {
|
||||
ALog.w(TAG, "发送广播失败,没有对应的任务");
|
||||
@@ -519,9 +519,9 @@ public class TaskSchedulers<TASK extends ITask> implements ISchedulers {
|
||||
}
|
||||
|
||||
int num = task.getTaskWrapper().getConfig().getReTryNum();
|
||||
boolean isNotNetRetry = mAriaManager.getAppConfig().isNotNetRetry();
|
||||
boolean isNotNetRetry = mAriaConfig.getAConfig().isNotNetRetry();
|
||||
|
||||
if ((!NetUtils.isConnected(mAriaManager.getAPP()) && !isNotNetRetry)
|
||||
if ((!NetUtils.isConnected(mAriaConfig.getAPP()) && !isNotNetRetry)
|
||||
|| task.getTaskWrapper().getEntity().getFailNum() > num) {
|
||||
queue.removeTaskFormQueue(task.getKey());
|
||||
startNextTask(queue, task.getSchedulerType());
|
||||
|
||||
@@ -58,9 +58,9 @@ public class CheckUEntityUtil implements ICheckEntityUtil {
|
||||
ALog.e(TAG, "上传失败,文件路径【" + filePath + "】不合法");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查路径冲突
|
||||
if (!CheckUtil.checkUploadPathConflicts(mWrapper.isForceUpload(), filePath)) {
|
||||
// 任务是新任务,并且路径冲突就不会继续执行
|
||||
if (mWrapper.isNewTask() && !CheckUtil.checkUPathConflicts(
|
||||
mWrapper.isIgnoreFilePathOccupy(), filePath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import android.text.TextUtils;
|
||||
import androidx.annotation.CheckResult;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.arialyy.annotations.TaskEnum;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.command.CancelAllCmd;
|
||||
import com.arialyy.aria.core.command.CmdHelper;
|
||||
@@ -58,7 +59,7 @@ public class UploadReceiver extends AbsReceiver {
|
||||
*/
|
||||
@Deprecated
|
||||
public UploadReceiver setMaxSpeed(int maxSpeed) {
|
||||
AriaManager.getInstance().getUploadConfig().setMaxSpeed(maxSpeed);
|
||||
AriaConfig.getInstance().getUConfig().setMaxSpeed(maxSpeed);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,9 +52,12 @@ public class FtpBuilderTarget extends AbsBuilderTarget<FtpBuilderTarget> {
|
||||
|
||||
/**
|
||||
* 如果文件路径被其它任务占用,删除其它任务
|
||||
*
|
||||
* @deprecated 使用 {@link #ignoreFilePathOccupy()}
|
||||
*/
|
||||
@Deprecated
|
||||
public FtpBuilderTarget forceUpload() {
|
||||
((UTaskWrapper)getTaskWrapper()).setForceUpload(true);
|
||||
getTaskWrapper().setIgnoreFilePathOccupy(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ public class FtpNormalTarget extends AbsNormalTarget<FtpNormalTarget> {
|
||||
FtpNormalTarget(long taskId) {
|
||||
mConfigHandler = new UNormalConfigHandler<>(this, taskId);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.U_FTP);
|
||||
getTaskWrapper().setNewTask(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,6 @@ import androidx.annotation.CheckResult;
|
||||
import com.arialyy.aria.core.common.AbsBuilderTarget;
|
||||
import com.arialyy.aria.core.common.HttpOption;
|
||||
import com.arialyy.aria.core.inf.Suggest;
|
||||
import com.arialyy.aria.core.upload.UTaskWrapper;
|
||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||
|
||||
/**
|
||||
@@ -30,12 +29,12 @@ public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
|
||||
private UNormalConfigHandler<HttpBuilderTarget> mConfigHandler;
|
||||
|
||||
HttpBuilderTarget(String filePath) {
|
||||
|
||||
mConfigHandler = new UNormalConfigHandler<>(this, -1);
|
||||
mConfigHandler.setFilePath(filePath);
|
||||
//http暂时不支持断点上传
|
||||
getTaskWrapper().setSupportBP(false);
|
||||
getTaskWrapper().setRequestType(AbsTaskWrapper.U_HTTP);
|
||||
getTaskWrapper().setNewTask(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,9 +63,12 @@ public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
|
||||
|
||||
/**
|
||||
* 如果文件路径被其它任务占用,删除其它任务
|
||||
*
|
||||
* @deprecated 使用 {@link #ignoreFilePathOccupy()}
|
||||
*/
|
||||
@Deprecated
|
||||
public HttpBuilderTarget forceUpload() {
|
||||
((UTaskWrapper) getTaskWrapper()).setForceUpload(true);
|
||||
getTaskWrapper().setIgnoreFilePathOccupy(true);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ public class HttpNormalTarget extends AbsNormalTarget<HttpNormalTarget> {
|
||||
mConfigHandler = new UNormalConfigHandler<>(this, taskId);
|
||||
getTaskWrapper().setSupportBP(false);
|
||||
getTaskWrapper().setRequestType(AbsTaskWrapper.U_HTTP);
|
||||
getTaskWrapper().setNewTask(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
## 开发日志
|
||||
+ v_3.7.10 (2019/12/3)
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/543#issuecomment-559733124
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/542
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/547
|
||||
- 修复下载失败时,中断重试无效的问题
|
||||
- 增加忽略权限检查的api,`ignoreCheckPermissions()`
|
||||
- 增加通用的的忽略文件路径被占用的api,`isIgnoreFilePathOccupy()`
|
||||
+ 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
|
||||
|
||||
@@ -74,7 +74,7 @@ public class FtpDirInfoThread extends AbsFtpInfoThread<DownloadGroupEntity, DGTa
|
||||
entity.setConvertFileSize(CommonUtil.formatFileSize(ftpFile.getSize()));
|
||||
entity.setFileSize(ftpFile.getSize());
|
||||
|
||||
//if(CheckUtil.checkDownloadPathConflicts(mTaskWrapper.is))
|
||||
//if(CheckUtil.checkDPathConflicts(mTaskWrapper.is))
|
||||
|
||||
entity.insert();
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ import java.io.UnsupportedEncodingException;
|
||||
* Created by Aria.Lao on 2017/7/28. D_FTP 单线程上传任务,需要FTP 服务器给用户打开append和write的权限
|
||||
*/
|
||||
class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
||||
private final String TAG = "FtpThreadTask";
|
||||
private String dir, remotePath;
|
||||
|
||||
FtpUThreadTaskAdapter(SubThreadConfig config) {
|
||||
@@ -66,7 +65,8 @@ class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
||||
}
|
||||
|
||||
file =
|
||||
new BufferedRandomAccessFile(getThreadConfig().tempFile, "rwd", getTaskConfig().getBuffSize());
|
||||
new BufferedRandomAccessFile(getThreadConfig().tempFile, "rwd",
|
||||
getTaskConfig().getBuffSize());
|
||||
if (getThreadRecord().startLocation != 0) {
|
||||
//file.skipBytes((int) getThreadConfig().START_LOCATION);
|
||||
file.seek(getThreadRecord().startLocation);
|
||||
@@ -103,10 +103,8 @@ class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
||||
private void initPath() throws UnsupportedEncodingException {
|
||||
dir = CommonUtil.convertFtpChar(charSet, mTaskOption.getUrlEntity().remotePath);
|
||||
|
||||
String fileName =
|
||||
TextUtils.isEmpty(mTaskOption.getNewFileName()) ? CommonUtil.convertFtpChar(charSet,
|
||||
getEntity().getFileName())
|
||||
: CommonUtil.convertFtpChar(charSet, mTaskOption.getNewFileName());
|
||||
String fileName = TextUtils.isEmpty(mTaskOption.getNewFileName()) ? getEntity().getFileName()
|
||||
: mTaskOption.getNewFileName();
|
||||
|
||||
remotePath =
|
||||
CommonUtil.convertFtpChar(charSet,
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.arialyy.aria.m3u8;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.arialyy.aria.core.common.RecordHandler;
|
||||
import com.arialyy.aria.core.download.DTaskWrapper;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
@@ -59,6 +60,9 @@ public abstract class BaseM3U8Loader extends AbsLoader {
|
||||
|
||||
protected String getCacheDir() {
|
||||
String cacheDir = mM3U8Option.getCacheDir();
|
||||
if (TextUtils.isEmpty(cacheDir)) {
|
||||
cacheDir = FileUtil.getTsCacheDir(getEntity().getFilePath(), mM3U8Option.getBandWidth());
|
||||
}
|
||||
if (!new File(cacheDir).exists()) {
|
||||
FileUtil.createDir(cacheDir);
|
||||
}
|
||||
|
||||
@@ -131,7 +131,8 @@ public class M3U8RecordAdapter extends AbsRecordHandlerAdapter {
|
||||
|
||||
@Override public int initTaskThreadNum() {
|
||||
if (getWrapper().getRequestType() == ITaskWrapper.M3U8_VOD) {
|
||||
return mOption.getUrls().size();
|
||||
return
|
||||
mOption.getUrls() == null || mOption.getUrls().isEmpty() ? 1 : mOption.getUrls().size();
|
||||
}
|
||||
if (getWrapper().getRequestType() == ITaskWrapper.M3U8_LIVE) {
|
||||
return 1;
|
||||
|
||||
@@ -23,6 +23,8 @@ import android.net.Network;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkRequest;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import com.arialyy.aria.core.config.AppConfig;
|
||||
import com.arialyy.aria.core.config.Configuration;
|
||||
import com.arialyy.aria.core.config.DGroupConfig;
|
||||
@@ -56,6 +58,7 @@ public class AriaConfig {
|
||||
* 是否已经联网,true 已经联网
|
||||
*/
|
||||
private static boolean isConnectedNet = true;
|
||||
private Handler mAriaHandler;
|
||||
|
||||
private AriaConfig(Context context) {
|
||||
APP = context.getApplicationContext();
|
||||
@@ -105,6 +108,13 @@ public class AriaConfig {
|
||||
return mDGConfig;
|
||||
}
|
||||
|
||||
public synchronized Handler getAriaHandler() {
|
||||
if (mAriaHandler == null) {
|
||||
mAriaHandler = new Handler(Looper.getMainLooper());
|
||||
}
|
||||
return mAriaHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册网络监听,只有配置了检查网络{@link AppConfig#isNetCheck()}才会注册事件
|
||||
*/
|
||||
|
||||
@@ -54,11 +54,6 @@ public class DTaskWrapper extends AbsTaskWrapper<DownloadEntity> {
|
||||
*/
|
||||
private String mTempFilePath;
|
||||
|
||||
/**
|
||||
* {@code true}强制下载,不考虑文件路径是否被占用
|
||||
*/
|
||||
private boolean forceDownload = false;
|
||||
|
||||
public DTaskWrapper(DownloadEntity entity) {
|
||||
super(entity);
|
||||
}
|
||||
@@ -124,12 +119,4 @@ public class DTaskWrapper extends AbsTaskWrapper<DownloadEntity> {
|
||||
public void setTempFilePath(String mTempFilePath) {
|
||||
this.mTempFilePath = mTempFilePath;
|
||||
}
|
||||
|
||||
public boolean isForceDownload() {
|
||||
return forceDownload;
|
||||
}
|
||||
|
||||
public void setForceDownload(boolean forceDownload) {
|
||||
this.forceDownload = forceDownload;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* 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.listener;
|
||||
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
|
||||
/**
|
||||
* Created by lyy on 2017/2/23.
|
||||
*/
|
||||
class UploadListener implements IUploadListener {
|
||||
@Override public void onPre() {
|
||||
|
||||
}
|
||||
|
||||
@Override public void onStart(long startLocation) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void onResume(long resumeLocation) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void onStop(long stopLocation) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void onProgress(long currentLocation) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void onCancel() {
|
||||
|
||||
}
|
||||
|
||||
@Override public void onComplete() {
|
||||
|
||||
}
|
||||
|
||||
@Override public void onFail(boolean needRetry, BaseException e) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class ThreadStateManager implements IThreadState {
|
||||
mFailNum++;
|
||||
if (isFail()) {
|
||||
Bundle b = msg.getData();
|
||||
mListener.onFail(b.getBoolean(KEY_RETRY, true),
|
||||
mListener.onFail(b.getBoolean(KEY_RETRY, false),
|
||||
(BaseException) b.getSerializable(KEY_ERROR_INFO));
|
||||
quitLooper();
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
||||
} else {
|
||||
ALog.e(TAG, String.format("任务【%s】执行失败", getFileName()));
|
||||
ErrorHelp.saveError(TAG, "", ALog.getExceptionString(ex));
|
||||
sendFailMsg(null);
|
||||
sendFailMsg(null, needRetry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -365,7 +365,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
||||
boolean isConnected = NetUtils.isConnected(AriaConfig.getInstance().getAPP());
|
||||
if (!isConnected && !isNotNetRetry) {
|
||||
ALog.w(TAG, String.format("ts切片【%s】重试失败,网络未连接", getFileName()));
|
||||
sendFailMsg(null);
|
||||
sendFailMsg(null, false);
|
||||
return;
|
||||
}
|
||||
if (mFailTimes < RETRY_NUM && needRetry && (NetUtils.isConnected(
|
||||
@@ -377,7 +377,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
||||
FileUtil.createFile(mConfig.tempFile);
|
||||
ThreadTaskManager.getInstance().retryThread(this);
|
||||
} else {
|
||||
sendFailMsg(null);
|
||||
sendFailMsg(null, needRetry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
||||
private void retryBlockTask(boolean needRetry) {
|
||||
if (!NetUtils.isConnected(AriaConfig.getInstance().getAPP()) && !isNotNetRetry) {
|
||||
ALog.w(TAG, String.format("分块【%s】重试失败,网络未连接", getFileName()));
|
||||
sendFailMsg(null);
|
||||
sendFailMsg(null, false);
|
||||
return;
|
||||
}
|
||||
if (mFailTimes < RETRY_NUM && needRetry && (NetUtils.isConnected(
|
||||
@@ -400,7 +400,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
||||
handleBlockRecord();
|
||||
ThreadTaskManager.getInstance().retryThread(this);
|
||||
} else {
|
||||
sendFailMsg(null);
|
||||
sendFailMsg(null, needRetry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,13 +448,14 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
||||
/**
|
||||
* 发送失败信息
|
||||
*/
|
||||
private void sendFailMsg(@Nullable BaseException e) {
|
||||
private void sendFailMsg(@Nullable BaseException e,boolean needRetry) {
|
||||
Bundle b = new Bundle();
|
||||
b.putBoolean(IThreadState.KEY_RETRY, needRetry);
|
||||
if (e != null) {
|
||||
Bundle b = new Bundle();
|
||||
b.putSerializable(IThreadState.KEY_ERROR_INFO, e);
|
||||
updateState(IThreadState.STATE_FAIL, b);
|
||||
} else {
|
||||
updateState(IThreadState.STATE_FAIL, null);
|
||||
updateState(IThreadState.STATE_FAIL, b);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,11 +29,6 @@ public class UTaskWrapper extends AbsTaskWrapper<UploadEntity> {
|
||||
*/
|
||||
private String tempUrl;
|
||||
|
||||
/**
|
||||
* 如果文件路径被其它任务占用,设置为true时,删除其它任务
|
||||
*/
|
||||
private boolean forceUpload = false;
|
||||
|
||||
public UTaskWrapper(UploadEntity entity) {
|
||||
super(entity);
|
||||
}
|
||||
@@ -53,14 +48,6 @@ public class UTaskWrapper extends AbsTaskWrapper<UploadEntity> {
|
||||
return getEntity().getKey();
|
||||
}
|
||||
|
||||
public boolean isForceUpload() {
|
||||
return forceUpload;
|
||||
}
|
||||
|
||||
public void setForceUpload(boolean forceUpload) {
|
||||
this.forceUpload = forceUpload;
|
||||
}
|
||||
|
||||
@Override public UploadConfig getConfig() {
|
||||
return Configuration.getInstance().uploadCfg;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.arialyy.aria.core.event.ErrorEvent;
|
||||
import com.arialyy.aria.core.inf.IEntity;
|
||||
import com.arialyy.aria.core.inf.ITaskOption;
|
||||
import com.arialyy.aria.core.upload.UploadEntity;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.ComponentUtil;
|
||||
|
||||
/**
|
||||
@@ -85,6 +84,19 @@ public abstract class AbsTaskWrapper<ENTITY extends AbsEntity>
|
||||
*/
|
||||
private TaskOptionParams optionParams = new TaskOptionParams();
|
||||
|
||||
/**
|
||||
* {@code true}强制下载\上传,不考虑文件路径是否被占用
|
||||
*/
|
||||
private boolean ignoreFilePathOccupy = false;
|
||||
|
||||
public boolean isIgnoreFilePathOccupy() {
|
||||
return ignoreFilePathOccupy;
|
||||
}
|
||||
|
||||
public void setIgnoreFilePathOccupy(boolean ignoreFilePathOccupy) {
|
||||
this.ignoreFilePathOccupy = ignoreFilePathOccupy;
|
||||
}
|
||||
|
||||
public void setTaskOption(ITaskOption option) {
|
||||
this.taskOption = option;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.Map;
|
||||
class DBConfig {
|
||||
/*adb pull /mnt/sdcard/Android/data/com.arialyy.simple/files/DB/AriaLyyDb d:/db*/
|
||||
static boolean DEBUG = false;
|
||||
static Map<String, Class> mapping = new LinkedHashMap<>();
|
||||
static Map<String, Class<? extends DbEntity>> mapping = new LinkedHashMap<>();
|
||||
static String DB_NAME;
|
||||
static int VERSION = 56;
|
||||
|
||||
@@ -51,8 +51,8 @@ class DBConfig {
|
||||
}
|
||||
|
||||
static {
|
||||
mapping.put("DownloadGroupEntity", DownloadGroupEntity.class);
|
||||
mapping.put("DownloadEntity", DownloadEntity.class);
|
||||
mapping.put("DownloadGroupEntity", DownloadGroupEntity.class);
|
||||
mapping.put("UploadEntity", UploadEntity.class);
|
||||
mapping.put("ThreadRecord", ThreadRecord.class);
|
||||
mapping.put("TaskRecord", TaskRecord.class);
|
||||
|
||||
@@ -221,4 +221,22 @@ class DelegateCommon extends AbsDelegate {
|
||||
db.execSQL(str);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过class 获取该class的表字段
|
||||
*
|
||||
* @return 表字段列表
|
||||
*/
|
||||
List<String> getColumns(Class<? extends DbEntity> clazz) {
|
||||
List<String> columns = new ArrayList<>();
|
||||
List<Field> fields = CommonUtil.getAllFields(clazz);
|
||||
for (Field field : fields) {
|
||||
field.setAccessible(true);
|
||||
if (SqlUtil.isIgnore(field)) {
|
||||
continue;
|
||||
}
|
||||
columns.add(field.getName());
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,14 +100,14 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
} else if (oldVersion < 53) {
|
||||
handle366Update(db);
|
||||
} else {
|
||||
handleDbUpdate(db, null, null);
|
||||
handleDbUpdate(db, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
if (oldVersion > newVersion) {
|
||||
handleDbUpdate(db, null, null);
|
||||
handleDbUpdate(db, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,10 +145,8 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
*
|
||||
* @param modifyColumns 需要修改的表字段的映射,key为表名,
|
||||
* value{@code Map<String, String>}中的Map的key为老字段名称,value为该老字段对应的新字段名称
|
||||
* @param delColumns 需要删除的表字段,key为表名,value{@code List<String>}为需要删除的字段列表
|
||||
*/
|
||||
private void handleDbUpdate(SQLiteDatabase db, Map<String, Map<String, String>> modifyColumns,
|
||||
Map<String, List<String>> delColumns) {
|
||||
private void handleDbUpdate(SQLiteDatabase db, Map<String, Map<String, String>> modifyColumns) {
|
||||
if (db == null) {
|
||||
ALog.e("SqlHelper", "db 为 null");
|
||||
return;
|
||||
@@ -161,7 +159,7 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
db.beginTransaction();
|
||||
Set<String> tables = DBConfig.mapping.keySet();
|
||||
for (String tableName : tables) {
|
||||
Class clazz = DBConfig.mapping.get(tableName);
|
||||
Class<? extends DbEntity> clazz = DBConfig.mapping.get(tableName);
|
||||
if (mDelegate.tableExists(db, clazz)) {
|
||||
//修改表名为中介表名
|
||||
String alertSql = String.format("ALTER TABLE %s RENAME TO %s_temp", tableName, tableName);
|
||||
@@ -178,46 +176,57 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
|
||||
// 复制数据
|
||||
if (count > 0) {
|
||||
// 获取旧表的所有字段名称
|
||||
Cursor columnC =
|
||||
db.rawQuery(String.format("PRAGMA table_info(%s_temp)", tableName), null);
|
||||
StringBuilder params = new StringBuilder();
|
||||
|
||||
// 获取新表的所有字段名称
|
||||
List<String> newTabColumns = mDelegate.getColumns(clazz);
|
||||
// 获取旧表的所有字段名称
|
||||
List<String> oldTabColumns = new ArrayList<>();
|
||||
|
||||
while (columnC.moveToNext()) {
|
||||
String columnName = columnC.getString(columnC.getColumnIndex("name"));
|
||||
if (delColumns != null && delColumns.get(tableName) != null) {
|
||||
List<String> delColumn = delColumns.get(tableName);
|
||||
if (delColumn != null && !delColumn.isEmpty()) {
|
||||
if (delColumn.contains(columnName)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
params.append(columnName).append(",");
|
||||
oldTabColumns.add(columnName);
|
||||
}
|
||||
columnC.close();
|
||||
|
||||
// 旧表需要删除的字段,删除旧表有而新表没的字段
|
||||
List<String> diffTab = getDiffColumn(newTabColumns, oldTabColumns);
|
||||
StringBuilder params = new StringBuilder();
|
||||
|
||||
// 需要修改的列名映射表
|
||||
Map<String, String> modifyMap = null;
|
||||
if (modifyColumns != null) {
|
||||
modifyMap = modifyColumns.get(tableName);
|
||||
}
|
||||
|
||||
for (String column : oldTabColumns) {
|
||||
if (!diffTab.isEmpty() && diffTab.contains(column)
|
||||
&& (modifyMap != null && !modifyMap.containsKey(column))) { // 如果旧表字段有修改,忽略这个删除
|
||||
continue;
|
||||
}
|
||||
params.append(column).append(",");
|
||||
}
|
||||
|
||||
String oldParamStr = params.toString();
|
||||
oldParamStr = oldParamStr.substring(0, oldParamStr.length() - 1);
|
||||
String newParamStr = oldParamStr;
|
||||
// 处理字段名称改变
|
||||
if (modifyColumns != null) {
|
||||
Map<String, String> columnMap = modifyColumns.get(tableName);
|
||||
if (columnMap != null && !columnMap.isEmpty()) {
|
||||
Set<String> keys = columnMap.keySet();
|
||||
for (String key : keys) {
|
||||
if (newParamStr.contains(key)) {
|
||||
newParamStr = newParamStr.replace(key, columnMap.get(key));
|
||||
}
|
||||
if (modifyMap != null && !modifyMap.isEmpty()) {
|
||||
Set<String> keys = modifyMap.keySet();
|
||||
for (String key : keys) {
|
||||
if (newParamStr.contains(key)) {
|
||||
newParamStr = newParamStr.replace(key, modifyMap.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//恢复数据
|
||||
String insertSql =
|
||||
String.format("INSERT INTO %s (%s) SELECT %s FROM %s_temp", tableName, newParamStr,
|
||||
oldParamStr, tableName);
|
||||
ALog.d(TAG, "insertSql = " + insertSql);
|
||||
|
||||
db.execSQL(insertSql);
|
||||
}
|
||||
//删除中介表
|
||||
@@ -234,6 +243,19 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取新表差值(需要删除的字段):旧表有而新表没的字段
|
||||
*
|
||||
* @param newTab 新表字段
|
||||
* @param oldTab 旧表字段
|
||||
* @return 旧表有而新表没的字段
|
||||
*/
|
||||
private List<String> getDiffColumn(List<String> newTab, List<String> oldTab) {
|
||||
List<String> temp = new ArrayList<>(oldTab); // 拷贝旧表字段
|
||||
temp.removeAll(newTab);
|
||||
return temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除重复的repeat数据
|
||||
*/
|
||||
@@ -256,7 +278,7 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
modifyMap.put("ThreadRecord", threadRecordModify);
|
||||
|
||||
// 执行升级操作
|
||||
handleDbUpdate(db, modifyMap, null);
|
||||
handleDbUpdate(db, modifyMap);
|
||||
delRepeatThreadRecord(db);
|
||||
}
|
||||
|
||||
@@ -273,7 +295,7 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
modifyMap.put("ThreadRecord", threadRecordModify);
|
||||
|
||||
// 执行升级操作
|
||||
handleDbUpdate(db, modifyMap, null);
|
||||
handleDbUpdate(db, modifyMap);
|
||||
delRepeatThreadRecord(db);
|
||||
}
|
||||
|
||||
@@ -307,7 +329,7 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
modifyMap.put("ThreadRecord", threadRecordModify);
|
||||
|
||||
// 执行升级操作
|
||||
handleDbUpdate(db, modifyMap, null);
|
||||
handleDbUpdate(db, modifyMap);
|
||||
delRepeatThreadRecord(db);
|
||||
}
|
||||
|
||||
@@ -360,15 +382,6 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
dGEntityModifyMap.put("groupName", "groupHash");
|
||||
modifyMap.put("DownloadGroupEntity", dGEntityModifyMap);
|
||||
|
||||
// 删除字段
|
||||
Map<String, List<String>> delColumnMap = new HashMap<>();
|
||||
List<String> dEntityDel = new ArrayList<>();
|
||||
dEntityDel.add("taskKey");
|
||||
delColumnMap.put("DownloadEntity", dEntityDel);
|
||||
List<String> dgEntityDel = new ArrayList<>();
|
||||
dgEntityDel.add("subtask");
|
||||
delColumnMap.put("DownloadGroupEntity", dgEntityDel);
|
||||
|
||||
handleDbUpdate(db, modifyMap, delColumnMap);
|
||||
handleDbUpdate(db, modifyMap);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package com.arialyy.aria.util;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.download.DownloadGroupEntity;
|
||||
import com.arialyy.aria.core.inf.IRecordHandler;
|
||||
import com.arialyy.aria.core.upload.UploadEntity;
|
||||
import com.arialyy.aria.orm.DbEntity;
|
||||
@@ -32,13 +33,13 @@ public class CheckUtil {
|
||||
private static final String TAG = "CheckUtil";
|
||||
|
||||
/**
|
||||
* 检查和处理路径冲突
|
||||
* 检查和处理下载任务的路径冲突
|
||||
*
|
||||
* @param isForceDownload true,如果路径冲突,将删除其它任务的记录的
|
||||
* @param filePath 文件保存路径
|
||||
* @return false 任务不再执行,true 任务继续执行
|
||||
*/
|
||||
public static boolean checkDownloadPathConflicts(boolean isForceDownload, String filePath) {
|
||||
public static boolean checkDPathConflicts(boolean isForceDownload, String filePath) {
|
||||
if (DbEntity.checkDataExist(DownloadEntity.class, "downloadPath=?", filePath)) {
|
||||
if (!isForceDownload) {
|
||||
ALog.e(TAG, String.format("下载失败,保存路径【%s】已经被其它任务占用,请设置其它保存路径", filePath));
|
||||
@@ -53,16 +54,16 @@ public class CheckUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查和处理路径冲突
|
||||
* 检查和处理上传任务的路径冲突
|
||||
*
|
||||
* @param isForceUpload true,如果路径冲突,将删除其它任务的记录的
|
||||
* @param filePath 文件保存路径
|
||||
* @return false 任务不再执行,true 任务继续执行
|
||||
*/
|
||||
public static boolean checkUploadPathConflicts(boolean isForceUpload, String filePath) {
|
||||
public static boolean checkUPathConflicts(boolean isForceUpload, String filePath) {
|
||||
if (DbEntity.checkDataExist(UploadEntity.class, "filePath=?", filePath)) {
|
||||
if (!isForceUpload) {
|
||||
ALog.e(TAG, String.format("上传失败,文件路径【%s】已经被其它任务占用,请设置其它保存路径", filePath));
|
||||
ALog.e(TAG, String.format("上传失败,文件路径【%s】已经被其它任务占用,请设置其它文件路径", filePath));
|
||||
return false;
|
||||
} else {
|
||||
ALog.w(TAG, String.format("文件路径【%s】已经被其它任务占用,当前任务将覆盖该路径的文件", filePath));
|
||||
@@ -73,6 +74,27 @@ public class CheckUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查和处理组合任务的路径冲突
|
||||
*
|
||||
* @param isForceDownload true,如果路径冲突,将删除其它任务的记录的
|
||||
* @param dirPath 文件保存路径
|
||||
* @return false 任务不再执行,true 任务继续执行
|
||||
*/
|
||||
public static boolean checkDGPathConflicts(boolean isForceDownload, String dirPath) {
|
||||
if (DbEntity.checkDataExist(DownloadGroupEntity.class, "dirPath=?", dirPath)) {
|
||||
if (!isForceDownload) {
|
||||
ALog.e(TAG, String.format("下载失败,文件夹路径【%s】已经被其它任务占用,请设置其它文件路径", dirPath));
|
||||
return false;
|
||||
} else {
|
||||
ALog.w(TAG, String.format("文件夹路径【%s】已经被其它任务占用,当前任务将覆盖该路径", dirPath));
|
||||
RecordUtil.delGroupTaskRecordByPath(dirPath, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查成员类是否是静态和public
|
||||
*/
|
||||
|
||||
@@ -52,7 +52,7 @@ public class DbDataHelper {
|
||||
* @param groupHash 组合任务Hash
|
||||
* @return 实体不存在,返回null
|
||||
*/
|
||||
public static DownloadGroupEntity getDGEntity(String groupHash) {
|
||||
public static DownloadGroupEntity getDGEntityByHash(String groupHash) {
|
||||
List<DGEntityWrapper> wrapper =
|
||||
DbEntity.findRelationData(DGEntityWrapper.class, "DownloadGroupEntity.groupHash=?",
|
||||
groupHash);
|
||||
@@ -60,6 +60,20 @@ public class DbDataHelper {
|
||||
return wrapper == null || wrapper.size() == 0 ? null : wrapper.get(0).groupEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组合任务实体、ftpDir任务实体
|
||||
*
|
||||
* @param dirPath 组合任务Hash
|
||||
* @return 实体不存在,返回null
|
||||
*/
|
||||
public static DownloadGroupEntity getDGEntityByPath(String dirPath) {
|
||||
List<DGEntityWrapper> wrapper =
|
||||
DbEntity.findRelationData(DGEntityWrapper.class, "DownloadGroupEntity.dirPath=?",
|
||||
dirPath);
|
||||
|
||||
return wrapper == null || wrapper.size() == 0 ? null : wrapper.get(0).groupEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组合任务实体、ftpDir任务实体
|
||||
*
|
||||
|
||||
@@ -38,6 +38,8 @@ import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.SequenceInputStream;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.FileChannel;
|
||||
@@ -61,6 +63,21 @@ public class FileUtil {
|
||||
private static final String EXTERNAL_STORAGE_PATH =
|
||||
Environment.getExternalStorageDirectory().getPath();
|
||||
|
||||
/**
|
||||
* 获取m3u8 ts文件的缓存目录。
|
||||
* 缓存文件夹格式:父文件夹/.文件名_码率
|
||||
*
|
||||
* @param path m3u8 文件下载路径
|
||||
* @return m3u8 ts文件的缓存目录
|
||||
*/
|
||||
public static String getTsCacheDir(String path, int bandWidth) {
|
||||
if (TextUtils.isEmpty(path)) {
|
||||
throw new NullPointerException("m3u8文保存路径为空");
|
||||
}
|
||||
File file = new File(path);
|
||||
return String.format("%s/.%s_%s", file.getParent(), file.getName(), bandWidth);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建目录 当目录不存在的时候创建文件,否则返回false
|
||||
*/
|
||||
@@ -409,9 +426,19 @@ public class FileUtil {
|
||||
* 获取SD卡目录列表
|
||||
*/
|
||||
public static List<String> getSDPathList(Context context) {
|
||||
List<String> paths;
|
||||
List<String> paths = null;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
paths = getVolumeList(context);
|
||||
try {
|
||||
paths = getVolumeList(context);
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
List<String> mounts = readMountsFile();
|
||||
List<String> volds = readVoldFile();
|
||||
@@ -471,16 +498,26 @@ public class FileUtil {
|
||||
/**
|
||||
* getSDPathList
|
||||
*/
|
||||
private static List<String> getVolumeList(final Context context) {
|
||||
private static List<String> getVolumeList(final Context context)
|
||||
throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException,
|
||||
IllegalAccessException {
|
||||
List<String> pathList = new ArrayList<>();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
StorageManager manager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
|
||||
List<StorageVolume> volumes = manager.getStorageVolumes();
|
||||
|
||||
Class<?> volumeClass = StorageVolume.class;
|
||||
Method getPath = volumeClass.getDeclaredMethod("getPath");
|
||||
//Method isRemovable = volumeClass.getDeclaredMethod("isRemovable");
|
||||
getPath.setAccessible(true);
|
||||
//isRemovable.setAccessible(true);
|
||||
|
||||
for (StorageVolume volume : volumes) {
|
||||
String state = volume.getState();
|
||||
|
||||
if (state.equals(Environment.MEDIA_MOUNTED)) {
|
||||
pathList.add(volume.toString());
|
||||
pathList.add((String) getPath.invoke(volume));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -42,12 +42,28 @@ public class RecordUtil {
|
||||
* @param removeFile {@code true} 无论任务是否完成,都会删除记录和文件;
|
||||
* {@code false} 如果任务已经完成,则只删除记录,不删除文件;任务未完成,记录和文件都会删除。
|
||||
*/
|
||||
public static void delGroupTaskRecord(String groupHash, boolean removeFile) {
|
||||
public static void delGroupTaskRecordByHash(String groupHash, boolean removeFile) {
|
||||
if (TextUtils.isEmpty(groupHash)) {
|
||||
ALog.e(TAG, "删除下载任务组记录失败,groupHash为null");
|
||||
return;
|
||||
}
|
||||
DownloadGroupEntity groupEntity = DbDataHelper.getDGEntity(groupHash);
|
||||
DownloadGroupEntity groupEntity = DbDataHelper.getDGEntityByHash(groupHash);
|
||||
|
||||
delGroupTaskRecord(groupEntity, removeFile, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据路径删除组合任务记录
|
||||
*
|
||||
* @param removeFile {@code true} 无论任务是否完成,都会删除记录和文件;
|
||||
* {@code false} 如果任务已经完成,则只删除记录,不删除文件;任务未完成,记录和文件都会删除。
|
||||
*/
|
||||
public static void delGroupTaskRecordByPath(String dirPath, boolean removeFile) {
|
||||
if (TextUtils.isEmpty(dirPath)) {
|
||||
ALog.e(TAG, "删除下载任务组记录失败,组合任务路径为空");
|
||||
return;
|
||||
}
|
||||
DownloadGroupEntity groupEntity = DbDataHelper.getDGEntityByPath(dirPath);
|
||||
|
||||
delGroupTaskRecord(groupEntity, removeFile, true);
|
||||
}
|
||||
|
||||
33
README.md
33
README.md
@@ -44,16 +44,16 @@ Aria有以下特点:
|
||||
|
||||
## 引入库
|
||||
[](https://github.com/AriaLyy/Aria/blob/master/LICENSE)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
|
||||
```java
|
||||
implementation 'com.arialyy.aria:core:3.7.8'
|
||||
annotationProcessor 'com.arialyy.aria:compiler:3.7.8'
|
||||
implementation 'com.arialyy.aria:ftpComponent:3.7.8' # 如果需要使用ftp,请增加该组件
|
||||
implementation 'com.arialyy.aria:m3u8Component:3.7.8' # 如果需要使用m3u8下载功能,请增加该组件
|
||||
implementation 'com.arialyy.aria:core:3.7.10'
|
||||
annotationProcessor 'com.arialyy.aria:compiler:3.7.10'
|
||||
implementation 'com.arialyy.aria:ftpComponent:3.7.10' # 如果需要使用ftp,请增加该组件
|
||||
implementation 'com.arialyy.aria:m3u8Component:3.7.10' # 如果需要使用m3u8下载功能,请增加该组件
|
||||
```
|
||||
如果出现android support依赖错误,请将 `compile 'com.arialyy.aria:core:<last-version>'`替换为
|
||||
```
|
||||
@@ -137,15 +137,14 @@ protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
|
||||
### 版本日志
|
||||
+ 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.10 (2019/12/3)
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/543#issuecomment-559733124
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/542
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/547
|
||||
- 修复下载失败时,中断重试无效的问题
|
||||
- 增加忽略权限检查的api,`ignoreCheckPermissions()`
|
||||
- 增加通用的的忽略文件路径被占用的api,`isIgnoreFilePathOccupy()`
|
||||
|
||||
[更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md)
|
||||
|
||||
## 混淆配置
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
+ "/tttt.apk";
|
||||
+ "/update.zip";
|
||||
|
||||
private MutableLiveData<DownloadEntity> liveData = new MutableLiveData<>();
|
||||
private DownloadEntity singDownloadInfo;
|
||||
@@ -51,10 +51,15 @@ public class HttpDownloadModule extends BaseViewModule {
|
||||
//String url = AppUtil.getConfigValue(context, HTTP_URL_KEY, defUrl);
|
||||
//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 = "http://image.totwoo.com/totwoo-TOTWOO-v3.5.6.apk";
|
||||
//String url = "http://fdfs.speedata.cn:9989/group1/M00/00/05/rBGFrl3fdAKAVJwfMtSa9R18wLU139.zip";
|
||||
//String url = "http://9.9.9.28:8088/files/update.zip";
|
||||
String url = "https://ss1.baidu.com/-4o3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=a9e671b9a551f3dedcb2bf64a4eff0ec/4610b912c8fcc3cef70d70409845d688d53f20f7.jpg";
|
||||
//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);
|
||||
//String filePath = AppUtil.getConfigValue(context, HTTP_PATH_KEY, defFilePath);
|
||||
String filePath = "/mnt/sdcard/gg.png";
|
||||
//String filePath = "/mnt/sdcard/update.zip";
|
||||
|
||||
singDownloadInfo = Aria.download(context).getFirstDownloadEntity(url);
|
||||
if (singDownloadInfo == null) {
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
|
||||
import com.arialyy.aria.core.task.DownloadTask;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import com.arialyy.aria.util.FileUtil;
|
||||
import com.arialyy.frame.util.show.T;
|
||||
import com.arialyy.simple.R;
|
||||
import com.arialyy.simple.base.BaseActivity;
|
||||
@@ -274,11 +275,13 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
break;
|
||||
}
|
||||
if (Aria.download(this).load(mTaskId).isRunning()) {
|
||||
Aria.download(this).load(mTaskId).stop();
|
||||
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(mUrl)
|
||||
//.updateUrl(mUrl)
|
||||
.resume();
|
||||
}
|
||||
break;
|
||||
@@ -297,6 +300,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
.load(mUrl)
|
||||
.setFilePath(mFilePath, true)
|
||||
.option(option)
|
||||
.ignoreCheckPermissions()
|
||||
.create();
|
||||
}
|
||||
|
||||
|
||||
@@ -96,11 +96,11 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
|
||||
.loadGroup(mUrls)
|
||||
.setDirPath(
|
||||
Environment.getExternalStorageDirectory().getPath() + "/Download/group_imgs")
|
||||
.setGroupAlias("图片测试")
|
||||
//.setSubFileName(getModule(GroupModule.class).getSubName2())
|
||||
//.setSubFileName(getModule(GroupModule.class).getSubName())
|
||||
.unknownSize()
|
||||
.option(getHttpOption())
|
||||
.ignoreFilePathOccupy()
|
||||
//.setFileSize(114981416)
|
||||
//.updateUrls(temp)
|
||||
.create();
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -35,9 +35,9 @@ public class UploadModule extends BaseViewModule {
|
||||
* 获取Ftp上传信息
|
||||
*/
|
||||
LiveData<UploadEntity> getFtpInfo(Context context) {
|
||||
String url = AppUtil.getConfigValue(context, FTP_URL_KEY, "ftp://9.9.9.50:2121/aa/你好");
|
||||
String url = AppUtil.getConfigValue(context, FTP_URL_KEY, "ftp://9.9.9.72:2121/aa/你好");
|
||||
String filePath = AppUtil.getConfigValue(context, FTP_PATH_KEY,
|
||||
Environment.getExternalStorageDirectory().getPath() + "/Download/Folx P58.zip");
|
||||
Environment.getExternalStorageDirectory().getPath() + "/Download/AndroidAria.db");
|
||||
|
||||
UploadEntity entity = Aria.upload(context).getFirstUploadEntity(filePath);
|
||||
if (entity != null) {
|
||||
|
||||
@@ -44,8 +44,8 @@ task clean(type: Delete) {
|
||||
}
|
||||
|
||||
ext {
|
||||
versionCode = 378
|
||||
versionName = '3.7.8'
|
||||
versionCode = 380
|
||||
versionName = '3.7.10'
|
||||
userOrg = 'arialyy'
|
||||
groupId = 'com.arialyy.aria'
|
||||
publishVersion = versionName
|
||||
|
||||
15
py/.vscode/launch.json
vendored
15
py/.vscode/launch.json
vendored
@@ -1,15 +0,0 @@
|
||||
{
|
||||
// 使用 IntelliSense 了解相关属性。
|
||||
// 悬停以查看现有属性的描述。
|
||||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: 当前文件",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${file}",
|
||||
"console": "integratedTerminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
6
py/.vscode/settings.json
vendored
6
py/.vscode/settings.json
vendored
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"python.linting.pylintEnabled": false,
|
||||
"python.linting.pep8Enabled": true,
|
||||
"python.linting.enabled": true,
|
||||
"python.pythonPath": "/usr/local/bin/python3.7"
|
||||
}
|
||||
BIN
test/347/AndroidAria.db
Normal file
BIN
test/347/AndroidAria.db
Normal file
Binary file not shown.
Reference in New Issue
Block a user