diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8Option.java b/Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8Option.java index 77e329a5..3deabb75 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8Option.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8Option.java @@ -15,10 +15,12 @@ */ package com.arialyy.aria.core.download.m3u8; +import android.text.TextUtils; 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.ALog; import com.arialyy.aria.util.CheckUtil; import com.arialyy.aria.util.ComponentUtil; @@ -34,12 +36,27 @@ public class M3U8Option extends BaseOption { private IBandWidthUrlConverter bandWidthUrlConverter; private IKeyUrlConverter keyUrlConverter; private boolean ignoreFailureTs = false; + private String keyPath; M3U8Option() { super(); ComponentUtil.getInstance().checkComponentExist(ComponentUtil.COMPONENT_TYPE_M3U8); } + /** + * 设置密钥文件的保存路径 + * + * @param keyPath 密钥文件的保存路径 + */ + public OP setKeyPath(String keyPath) { + if (TextUtils.isEmpty(keyPath)) { + ALog.e(TAG, "密钥文件保存路径为空"); + return (OP) this; + } + this.keyPath = keyPath; + return (OP) this; + } + /** * 忽略下载失败的ts切片,即使有失败的切片,下载完成后也要合并所有切片,并进入complete回调 */ diff --git a/Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java b/Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java index 695c7bf4..749d2732 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java +++ b/Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java @@ -33,6 +33,7 @@ import com.arialyy.aria.core.task.DownloadTask; import com.arialyy.aria.core.task.UploadTask; import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.util.ALog; +import com.arialyy.aria.util.CommonUtil; import java.util.ArrayList; import java.util.List; @@ -45,7 +46,7 @@ public abstract class AbsTaskQueue mCachePool; BaseExecutePool mExecutePool; diff --git a/Aria/src/main/java/com/arialyy/aria/core/queue/DGroupTaskQueue.java b/Aria/src/main/java/com/arialyy/aria/core/queue/DGroupTaskQueue.java index fe2829d7..b52821a4 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/queue/DGroupTaskQueue.java +++ b/Aria/src/main/java/com/arialyy/aria/core/queue/DGroupTaskQueue.java @@ -24,6 +24,7 @@ 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; +import com.arialyy.aria.util.CommonUtil; /** * Created by AriaL on 2017/6/29. 任务组下载队列 @@ -32,7 +33,7 @@ public class DGroupTaskQueue extends AbsTaskQueue { private static volatile DGroupTaskQueue INSTANCE = null; - private final String TAG = "DownloadGroupTaskQueue"; + private final String TAG = CommonUtil.getClassName(this); public static DGroupTaskQueue getInstance() { if (INSTANCE == null) { @@ -57,7 +58,7 @@ public class DGroupTaskQueue } @Override public int getMaxTaskNum() { - return AriaConfig.getInstance().getDConfig().getMaxTaskNum(); + return AriaConfig.getInstance().getDGConfig().getMaxTaskNum(); } @Override public DownloadGroupTask createTask(DGTaskWrapper wrapper) { diff --git a/DEV_LOG.md b/DEV_LOG.md index fac48057..796b5c2c 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -1,5 +1,5 @@ ## 开发日志 - + v_3.8.3 + + v_3.8.3 (2020/1/9) - fix bug https://github.com/AriaLyy/Aria/issues/573 - android P适配 https://github.com/AriaLyy/Aria/issues/581 - 添加ftp服务器标志 https://github.com/AriaLyy/Aria/issues/580 @@ -7,6 +7,7 @@ - 修复ftp上传完成后,删除服务器端的文件,无法重新下载的问题 - 增加获取执行中的任务api,详情见:https://aria.laoyuyu.me/aria_doc/api/task_list.html - 增加获取剩余时间的api,详情见:https://aria.laoyuyu.me/aria_doc/start/task_explain.html + - fix bug https://github.com/AriaLyy/Aria/issues/595 + v_3.8.1 (2019/12/22) - 修复一个表创建失败的问题 https://github.com/AriaLyy/Aria/issues/570 - 修复一个非分块模式下导致下载失败的问题 https://github.com/AriaLyy/Aria/issues/571 diff --git a/FtpComponent/src/main/java/com/arialyy/aria/ftp/download/FtpDGLoader.java b/FtpComponent/src/main/java/com/arialyy/aria/ftp/download/FtpDGLoader.java index 33adbf9e..2a04a48c 100644 --- a/FtpComponent/src/main/java/com/arialyy/aria/ftp/download/FtpDGLoader.java +++ b/FtpComponent/src/main/java/com/arialyy/aria/ftp/download/FtpDGLoader.java @@ -80,7 +80,8 @@ final class FtpDGLoader extends AbsGroupLoader { } @Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) { - getListener().onFail(needRetry, e); + //getListener().onFail(needRetry, e); + fail(e, needRetry); } }); } diff --git a/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDGInfoTask.java b/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDGInfoTask.java index 5698df6c..f8f5028e 100644 --- a/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDGInfoTask.java +++ b/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDGInfoTask.java @@ -89,6 +89,9 @@ public final class HttpDGInfoTask implements IInfoTask { } catch (InterruptedException e) { e.printStackTrace(); } + if (!mPool.isShutdown()){ + mPool.shutdown(); + } } else { for (DTaskWrapper wrapper : wrapper.getSubTaskWrapper()) { cloneHeader(wrapper); diff --git a/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDGLoader.java b/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDGLoader.java index 14d4d201..e2b3f9b3 100644 --- a/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDGLoader.java +++ b/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDGLoader.java @@ -66,7 +66,7 @@ final class HttpDGLoader extends AbsGroupLoader { } @Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) { - getListener().onFail(needRetry, e); + fail(e, needRetry); } }); } diff --git a/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDThreadTaskAdapter.java b/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDThreadTaskAdapter.java index 1ae4cdee..3557af0f 100644 --- a/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDThreadTaskAdapter.java +++ b/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDThreadTaskAdapter.java @@ -24,7 +24,6 @@ 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; @@ -112,7 +111,7 @@ final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter { new BufferedRandomAccessFile(getThreadConfig().tempFile, "rwd", getTaskConfig().getBuffSize()); //设置每条线程写入文件的位置 - if (getThreadRecord().startLocation > 0){ + if (getThreadRecord().startLocation > 0) { file.seek(getThreadRecord().startLocation); } readNormal(is, file); @@ -199,6 +198,7 @@ final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter { fos = new FileOutputStream(getThreadConfig().tempFile, true); foc = fos.getChannel(); fic = Channels.newChannel(is); + ByteBuffer bf = ByteBuffer.allocate(getTaskConfig().getBuffSize()); //如果要通过 Future 的 cancel 方法取消正在运行的任务,那么该任务必定是可以 对线程中断做出响应 的任务。 diff --git a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8InfoTask.java b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8InfoTask.java index 2b1799ed..096dc671 100644 --- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8InfoTask.java +++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8InfoTask.java @@ -258,9 +258,14 @@ final public class M3U8InfoTask implements IInfoTask { m3U8Entity.method = param.split("=")[1]; } else if (param.startsWith("URI")) { m3U8Entity.keyUrl = param.split("=")[1].replaceAll("\"", ""); - m3U8Entity.keyPath = - new File(mEntity.getFilePath()).getParent() + "/" + CommonUtil.getStrMd5( - m3U8Entity.keyUrl) + ".key"; + String keyPath; + if (((M3U8TaskOption) mTaskWrapper.getM3u8Option()).getKeyPath() == null) { + keyPath = new File(mEntity.getFilePath()).getParent() + "/" + + CommonUtil.getStrMd5(m3U8Entity.keyUrl) + ".key"; + } else { + keyPath = ((M3U8TaskOption) mTaskWrapper.getM3u8Option()).getKeyPath(); + } + m3U8Entity.keyPath = keyPath; } else if (param.startsWith("IV")) { m3U8Entity.iv = param.split("=")[1]; } else if (param.startsWith("KEYFORMAT")) { diff --git a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8TaskOption.java b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8TaskOption.java index 37c36ae8..28573d69 100644 --- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8TaskOption.java +++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8TaskOption.java @@ -115,6 +115,15 @@ public final class M3U8TaskOption implements ITaskOption { */ private boolean ignoreFailureTs = false; + /** + * 密钥文件保存路径 + */ + private String keyPath; + + public String getKeyPath() { + return keyPath; + } + public boolean isIgnoreFailureTs() { return ignoreFailureTs; } diff --git a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8ThreadTaskAdapter.java b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8ThreadTaskAdapter.java index 82f5d517..4f8659d0 100644 --- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8ThreadTaskAdapter.java +++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8ThreadTaskAdapter.java @@ -15,6 +15,8 @@ */ package com.arialyy.aria.m3u8; +import android.net.Uri; +import android.text.TextUtils; import com.arialyy.aria.core.common.RequestEnum; import com.arialyy.aria.core.common.SubThreadConfig; import com.arialyy.aria.core.download.DownloadEntity; @@ -24,6 +26,7 @@ import com.arialyy.aria.exception.TaskException; import com.arialyy.aria.http.ConnectionHelp; import com.arialyy.aria.http.HttpTaskOption; import com.arialyy.aria.util.ALog; +import com.arialyy.aria.util.CheckUtil; import java.io.BufferedInputStream; import java.io.FileOutputStream; import java.io.IOException; @@ -46,6 +49,7 @@ import java.util.Set; public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter { private final String TAG = "M3U8ThreadTask"; private HttpTaskOption mHttpTaskOption; + private BufferedInputStream is = null; public M3U8ThreadTaskAdapter(SubThreadConfig config) { super(config); @@ -58,19 +62,15 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter { return; } HttpURLConnection conn = null; - BufferedInputStream is = null; try { URL url = ConnectionHelp.handleUrl(getThreadConfig().url, mHttpTaskOption); conn = ConnectionHelp.handleConnection(url, mHttpTaskOption); ALog.d(TAG, String.format("分片【%s】开始下载", getThreadRecord().threadId)); - ConnectionHelp.setConnectParam(mHttpTaskOption, conn); - conn.setConnectTimeout(getTaskConfig().getConnectTimeOut()); - conn.setReadTimeout(getTaskConfig().getIOTimeOut()); //设置读取流的等待时间,必须设置该参数 + if (mHttpTaskOption.isChunked()) { conn.setDoInput(true); conn.setChunkedStreamingMode(0); } - conn.connect(); // 传递参数 if (mHttpTaskOption.getRequestEnum() == RequestEnum.POST) { Map params = mHttpTaskOption.getParams(); @@ -89,20 +89,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter { } } - int code = conn.getResponseCode(); - if (code != HttpURLConnection.HTTP_OK) { - fail(new TaskException(TAG, - String.format("连接错误,http错误码:%s,url:%s", code, getThreadConfig().url)), - false); - return; - } - - is = new BufferedInputStream(ConnectionHelp.convertInputStream(conn)); - if (mHttpTaskOption.isChunked()) { - readChunked(is); - } else if (getThreadConfig().isBlock) { - readDynamicFile(is); - } + handleConn(conn); } catch (MalformedURLException e) { fail(new TaskException(TAG, String.format("分片【%s】下载失败,filePath: %s, url: %s", getThreadRecord().threadId, @@ -129,6 +116,65 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter { } } + private void handleConn(HttpURLConnection conn) throws IOException { + ConnectionHelp.setConnectParam(mHttpTaskOption, conn); + conn.setConnectTimeout(getTaskConfig().getConnectTimeOut()); + conn.setReadTimeout(getTaskConfig().getIOTimeOut()); //设置读取流的等待时间,必须设置该参数 + + conn.connect(); + int code = conn.getResponseCode(); + if (code == HttpURLConnection.HTTP_OK) { + is = new BufferedInputStream(ConnectionHelp.convertInputStream(conn)); + if (mHttpTaskOption.isChunked()) { + readChunked(is); + } else if (getThreadConfig().isBlock) { + readDynamicFile(is); + } + } else if (code == HttpURLConnection.HTTP_MOVED_TEMP + || code == HttpURLConnection.HTTP_MOVED_PERM + || code == HttpURLConnection.HTTP_SEE_OTHER + || code == HttpURLConnection.HTTP_CREATED // 201 跳转 + || code == 307) { + handleUrlReTurn(conn, conn.getHeaderField("Location")); + } else { + fail(new TaskException(TAG, + String.format("连接错误,http错误码:%s,url:%s", code, getThreadConfig().url)), + false); + } + conn.disconnect(); + } + + /** + * 处理30x跳转 + */ + private void handleUrlReTurn(HttpURLConnection conn, String newUrl) throws IOException { + ALog.d(TAG, "30x跳转,新url为【" + newUrl + "】"); + if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) { + fail(new AriaIOException(TAG, "下载失败,重定向url为空"), false); + return; + } + + if (newUrl.startsWith("/")) { + Uri uri = Uri.parse(getThreadConfig().url); + newUrl = uri.getHost() + newUrl; + } + + if (!CheckUtil.checkUrl(newUrl)) { + fail(new AriaIOException(TAG, "下载失败,重定向url错误"), false); + return; + } + String cookies = conn.getHeaderField("Set-Cookie"); + conn.disconnect(); // 关闭上一个连接 + URL url = ConnectionHelp.handleUrl(newUrl, mHttpTaskOption); + conn = ConnectionHelp.handleConnection(url, mHttpTaskOption); + conn.setRequestProperty("Cookie", cookies); + if (mHttpTaskOption.isChunked()) { + conn.setDoInput(true); + conn.setChunkedStreamingMode(0); + } + handleConn(conn); + } + /** * 读取chunked数据 */ diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/common/AbsNormalEntity.java b/PublicComponent/src/main/java/com/arialyy/aria/core/common/AbsNormalEntity.java index 015a0fcf..c4222b2a 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/common/AbsNormalEntity.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/common/AbsNormalEntity.java @@ -51,9 +51,6 @@ public abstract class AbsNormalEntity extends AbsEntity implements Parcelable { */ private int taskType; - @Override public int getTaskType() { - return taskType; - } public void setTaskType(int taskType) { this.taskType = taskType; diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/download/DownloadEntity.java b/PublicComponent/src/main/java/com/arialyy/aria/core/download/DownloadEntity.java index 19d67809..5b6a1d76 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/download/DownloadEntity.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/download/DownloadEntity.java @@ -78,22 +78,26 @@ public class DownloadEntity extends AbsNormalEntity implements Parcelable { return getUrl(); } - //@Override public int getTaskType() { - // int type; - // if (TextUtils.isEmpty(getUrl())) { - // type = ITaskWrapper.ERROR; - // } else if (getUrl().startsWith("ftp")) { - // type = ITaskWrapper.D_FTP; - // } else { - // M3U8Entity temp = getM3U8Entity(); - // if (temp == null) { - // type = ITaskWrapper.D_HTTP; - // } else { - // type = temp.isLive() ? ITaskWrapper.M3U8_LIVE : ITaskWrapper.M3U8_VOD; - // } - // } - // return type; - //} + @Override public int getTaskType() { + int type; + if (TextUtils.isEmpty(getUrl())) { + type = ITaskWrapper.ERROR; + } else if (getUrl().startsWith("http")) { + type = ITaskWrapper.D_HTTP; + } else if (getUrl().startsWith("ftp")) { + type = ITaskWrapper.D_FTP; + } else if (getUrl().startsWith("sftp")) { + type = ITaskWrapper.D_SFTP; + } else { + M3U8Entity temp = getM3U8Entity(); + if (temp == null) { + type = ITaskWrapper.D_HTTP; + } else { + type = temp.isLive() ? ITaskWrapper.M3U8_LIVE : ITaskWrapper.M3U8_VOD; + } + } + return type; + } public DownloadEntity() { } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupLoader.java b/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupLoader.java index bcde1e48..84895214 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupLoader.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupLoader.java @@ -30,6 +30,7 @@ import com.arialyy.aria.core.loader.ILoaderVisitor; import com.arialyy.aria.core.loader.IRecordHandler; import com.arialyy.aria.core.loader.IThreadTaskBuilder; import com.arialyy.aria.core.wrapper.AbsTaskWrapper; +import com.arialyy.aria.exception.BaseException; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.CommonUtil; import java.io.File; @@ -253,8 +254,8 @@ public abstract class AbsGroupLoader implements ILoaderVisitor, ILoader { mListener.onComplete(); return; } - handlerTask(looper); startTimer(); + handlerTask(looper); Looper.loop(); } @@ -320,6 +321,11 @@ public abstract class AbsGroupLoader implements ILoaderVisitor, ILoader { } } + protected void fail(BaseException e, boolean needRetry){ + closeTimer(); + getListener().onFail(needRetry, e); + } + @Override public long getCurrentProgress() { return mCurrentLocation; } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupLoaderUtil.java b/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupLoaderUtil.java index 3cde8aa8..520486e2 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupLoaderUtil.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupLoaderUtil.java @@ -99,8 +99,6 @@ public abstract class AbsGroupLoaderUtil implements IUtil { } buildLoaderStructure(); - // MsgEvent 已经是在线程中使用了,不需要重开线程 - mLoader.run(); - //new Thread(mLoader).start(); + new Thread(mLoader).start(); } } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/inf/IThreadStateManager.java b/PublicComponent/src/main/java/com/arialyy/aria/core/inf/IThreadStateManager.java index 01be3a84..c4eaf027 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/inf/IThreadStateManager.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/inf/IThreadStateManager.java @@ -61,6 +61,7 @@ public interface IThreadStateManager extends ILoaderComponent { /** * 更新当前进度 + * * @param currentProgress 当前进度 */ void updateCurrentProgress(long currentProgress); diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/loader/AbsNormalLoaderUtil.java b/PublicComponent/src/main/java/com/arialyy/aria/core/loader/AbsNormalLoaderUtil.java index c2570d51..a5338441 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/loader/AbsNormalLoaderUtil.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/loader/AbsNormalLoaderUtil.java @@ -115,10 +115,7 @@ public abstract class AbsNormalLoaderUtil implements IUtil { //} BuildLoaderStructure(); - // MsgEvent 已经是在线程中使用了,不需要重开线程 - mLoader.run(); - //new Thread(mLoader).start(); - + new Thread(mLoader).start(); onStart(); } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/upload/UploadEntity.java b/PublicComponent/src/main/java/com/arialyy/aria/core/upload/UploadEntity.java index 16f70083..34a6320f 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/upload/UploadEntity.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/upload/UploadEntity.java @@ -17,7 +17,9 @@ package com.arialyy.aria.core.upload; import android.os.Parcel; import android.os.Parcelable; +import android.text.TextUtils; import com.arialyy.aria.core.common.AbsNormalEntity; +import com.arialyy.aria.core.wrapper.ITaskWrapper; import com.arialyy.aria.orm.annotation.Primary; /** @@ -56,12 +58,12 @@ public class UploadEntity extends AbsNormalEntity implements Parcelable { return filePath; } - //@Override public int getTaskType() { - // if (TextUtils.isEmpty(getUrl())){ - // return ITaskWrapper.ERROR; - // } - // return getUrl().startsWith("ftp") ? ITaskWrapper.U_FTP : ITaskWrapper.U_HTTP; - //} + @Override public int getTaskType() { + if (TextUtils.isEmpty(getUrl())) { + return ITaskWrapper.ERROR; + } + return getUrl().startsWith("ftp") ? ITaskWrapper.U_FTP : ITaskWrapper.U_HTTP; + } public UploadEntity() { } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/orm/SqlHelper.java b/PublicComponent/src/main/java/com/arialyy/aria/orm/SqlHelper.java index ed785f89..0e8caafb 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/orm/SqlHelper.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/orm/SqlHelper.java @@ -182,14 +182,14 @@ final class SqlHelper extends SQLiteOpenHelper { // ----------- 2、为防止字段增加失败的情况,先给旧表增加字段 List newAddColum = getNewColumn(newTabColumns, oldTabColumns); // 删除重命名的字段 - Map modifyMap = null; - if (modifyColumns != null){ + Map modifyMap = null; + if (modifyColumns != null) { modifyMap = modifyColumns.get(tableName); - if (modifyMap != null){ + if (modifyMap != null) { Iterator it = newAddColum.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String s = it.next(); - if (modifyMap.get(s) != null){ + if (modifyMap.get(s) != null) { it.remove(); } } @@ -197,10 +197,11 @@ final class SqlHelper extends SQLiteOpenHelper { } // 给旧表增加字段,防止新增字段失败 - if (newAddColum.size() > 0){ + if (newAddColum.size() > 0) { String sql = "ALTER TABLE %s ADD COLUMN %s %s"; - for (String nc : newAddColum){ - String temp = String.format(sql, tableName, nc, SqlUtil.getColumnTypeByFieldName(clazz, nc)); + for (String nc : newAddColum) { + String temp = + String.format(sql, tableName, nc, SqlUtil.getColumnTypeByFieldName(clazz, nc)); ALog.d(TAG, "添加表字段的sql:" + temp); db.execSQL(temp); } @@ -234,7 +235,8 @@ final class SqlHelper extends SQLiteOpenHelper { for (String column : oldTabColumns) { if (!diffTab.isEmpty() && diffTab.contains(column) - && (modifyMap != null && !modifyMap.containsKey(column))) { // 如果旧表字段有修改,忽略这个删除 + // 如果旧表字段有修改,忽略这个删除 + && !(modifyMap != null && modifyMap.containsKey(column))) { continue; } params.append(column).append(","); diff --git a/README.md b/README.md index 3cc991f4..070bed9f 100644 --- a/README.md +++ b/README.md @@ -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.8.1-blue)](https://github.com/AriaLyy/Aria) -[![Compiler](https://img.shields.io/badge/Compiler-3.8.1-blue)](https://github.com/AriaLyy/Aria) -[![FtpComponent](https://img.shields.io/badge/FtpComponent-3.8.1-orange)](https://github.com/AriaLyy/Aria) -[![M3U8Component](https://img.shields.io/badge/M3U8Component-3.8.1-orange)](https://github.com/AriaLyy/Aria) +[![Core](https://img.shields.io/badge/Core-3.8.3-blue)](https://github.com/AriaLyy/Aria) +[![Compiler](https://img.shields.io/badge/Compiler-3.8.3-blue)](https://github.com/AriaLyy/Aria) +[![FtpComponent](https://img.shields.io/badge/FtpComponent-3.8.3-orange)](https://github.com/AriaLyy/Aria) +[![M3U8Component](https://img.shields.io/badge/M3U8Component-3.8.3-orange)](https://github.com/AriaLyy/Aria) ```java -implementation 'com.arialyy.aria:core:3.8.1' -annotationProcessor 'com.arialyy.aria:compiler:3.8.1' -implementation 'com.arialyy.aria:ftpComponent:3.8.1' # 如果需要使用ftp,请增加该组件 -implementation 'com.arialyy.aria:m3u8Component:3.8.1' # 如果需要使用m3u8下载功能,请增加该组件 +implementation 'com.arialyy.aria:core:3.8.3' +annotationProcessor 'com.arialyy.aria:compiler:3.8.3' +implementation 'com.arialyy.aria:ftpComponent:3.8.3' # 如果需要使用ftp,请增加该组件 +implementation 'com.arialyy.aria:m3u8Component:3.8.3' # 如果需要使用m3u8下载功能,请增加该组件 ``` 如果出现android support依赖错误,请将 `compile 'com.arialyy.aria:core:'`替换为 ``` @@ -139,12 +139,14 @@ protected void onCreate(Bundle savedInstanceState) { ### 版本日志 -+ v_3.8.1 (2019/12/22) - - 修复一个表创建失败的问题 https://github.com/AriaLyy/Aria/issues/570 - - 修复一个非分块模式下导致下载失败的问题 https://github.com/AriaLyy/Aria/issues/571 - - 修复一个服务器端无法创建socket连接,却没有返回码导致客户端卡住的问题 https://github.com/AriaLyy/Aria/issues/569 - - 修复文件删除后,组合任务没有重新下载的问题 https://github.com/AriaLyy/Aria/issues/574 - - 优化缓存队列和执行队列 ++ v_3.8.3 (2020/1/9) + - fix bug https://github.com/AriaLyy/Aria/issues/573 + - android P适配 https://github.com/AriaLyy/Aria/issues/581 + - 添加ftp服务器标志 https://github.com/AriaLyy/Aria/issues/580 + - 重构loader模块,让loader模块的代码更加清晰,去除一些不必要的线程创建 + - 修复ftp上传完成后,删除服务器端的文件,无法重新下载的问题 + - 增加获取执行中的任务api,详情见:https://aria.laoyuyu.me/aria_doc/api/task_list.html + - 增加获取剩余时间的api,详情见:https://aria.laoyuyu.me/aria_doc/start/task_explain.html [更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md) diff --git a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java index d50b754a..122c75b5 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java +++ b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java @@ -305,12 +305,13 @@ public class M3U8VodDLoadActivity extends BaseActivity { private M3U8VodOption getM3U8Option() { M3U8VodOption option = new M3U8VodOption(); option + .setBandWidth(200000) //.generateIndexFile() //.merge(true) .setVodTsUrlConvert(new VodTsUrlConverter()); //.setMergeHandler(new TsMergeHandler()); option.setKeyUrlConverter(new KeyUrlConverter()); - option.setBandWidthUrlConverter(new BandWidthUrlConverter(mUrl)); + //option.setBandWidthUrlConverter(new BandWidthUrlConverter(mUrl)); return option; } @@ -328,7 +329,8 @@ public class M3U8VodDLoadActivity extends BaseActivity { Uri uri = Uri.parse(m3u8Url); //String parentUrl = "http://" + uri.getHost() + "/gear1/"; int index = m3u8Url.lastIndexOf("/"); - String parentUrl = m3u8Url.substring(0, index + 1); + //String parentUrl = m3u8Url.substring(0, index + 1); + String parentUrl = "https://cn7.kankia.com/"; //String parentUrl = "http://" + uri.getHost() + "/"; List newUrls = new ArrayList<>(); for (String url : tsUrls) { diff --git a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java index 979ea085..451a1681 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java +++ b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java @@ -34,7 +34,9 @@ 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://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"; + private final String defUrl = "https://cn7.kankia.com/hls/20200108/e1eaec074274c64fe46a3bdb5d2ba487/1578488360/index.m3u8"; + //private final String defUrl = "https://youku.cdn7-okzy.com/20191213/16167_c3592a02/index.m3u8"; //private final String defUrl = "http://qn.shytong.cn/b83137769ff6b555/11b0c9970f9a3fa0.mp4.m3u8"; private final String filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath() diff --git a/app/src/main/java/com/arialyy/simple/core/download/mutil/DownloadAdapter.java b/app/src/main/java/com/arialyy/simple/core/download/mutil/DownloadAdapter.java index 4d099c82..9ba7f72d 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/mutil/DownloadAdapter.java +++ b/app/src/main/java/com/arialyy/simple/core/download/mutil/DownloadAdapter.java @@ -292,6 +292,7 @@ public class DownloadAdapter extends AbsRVAdapter { dialog.show(getSupportFragmentManager(), "download_num"); break; case R.id.stop_all: - Aria.download(this).stopAllTask(); + //Aria.download(this).stopAllTask(); + List list = Aria.download(this).getTotalTaskList(); + for (AbsEntity entity : list){ + Aria.download(this).load(entity.getId()).cancel(true); + } //Aria.download(this).removeAllTask(false); break; case R.id.turn: diff --git a/build.gradle b/build.gradle index 2320bab2..dd32dd4e 100644 --- a/build.gradle +++ b/build.gradle @@ -45,7 +45,7 @@ task clean(type: Delete) { ext { versionCode = 383 - versionName = '3.8.3_beta_2' + versionName = '3.8.3_beta_5' userOrg = 'arialyy' groupId = 'com.arialyy.aria' publishVersion = versionName