diff --git a/DEV_LOG.md b/DEV_LOG.md index 679ff954..33259882 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -1,4 +1,7 @@ ## 开发日志 + + v_3.8.6 + - fix bug https://github.com/AriaLyy/Aria/issues/608 + - 优化异常提示 + v_3.8.5 (2020/1/18) - fix bug https://github.com/AriaLyy/Aria/issues/599 - 增加密钥url转换器的参数 https://github.com/AriaLyy/Aria/issues/603 diff --git a/FtpComponent/src/main/java/com/arialyy/aria/ftp/AbsFtpInfoTask.java b/FtpComponent/src/main/java/com/arialyy/aria/ftp/AbsFtpInfoTask.java index 6b53ed70..145453aa 100644 --- a/FtpComponent/src/main/java/com/arialyy/aria/ftp/AbsFtpInfoTask.java +++ b/FtpComponent/src/main/java/com/arialyy/aria/ftp/AbsFtpInfoTask.java @@ -31,8 +31,7 @@ import com.arialyy.aria.core.common.FtpConnectionMode; import com.arialyy.aria.core.loader.IInfoTask; import com.arialyy.aria.core.loader.ILoaderVisitor; import com.arialyy.aria.core.wrapper.AbsTaskWrapper; -import com.arialyy.aria.exception.AriaIOException; -import com.arialyy.aria.exception.TaskException; +import com.arialyy.aria.exception.AriaFTPException; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.CheckUtil; import com.arialyy.aria.util.CommonUtil; @@ -161,9 +160,9 @@ public abstract class AbsFtpInfoTask 0) { @@ -66,7 +65,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter { //发送第二次指令时,还需要再做一次判断 int reply = client.getReplyCode(); if (!FTPReply.isPositivePreliminary(reply) && reply != FTPReply.COMMAND_OK) { - fail(new AriaIOException(TAG, + fail(new AriaFTPException(TAG, String.format("获取文件信息错误,错误码为:%s,msg:%s", reply, client.getReplyString())), false); client.disconnect(); return; @@ -77,7 +76,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter { is = client.retrieveFileStream(remotePath); reply = client.getReplyCode(); if (!FTPReply.isPositivePreliminary(reply)) { - fail(new AriaIOException(TAG, + fail(new AriaFTPException(TAG, String.format("获取流失败,错误码为:%s,msg:%s", reply, client.getReplyString())), true); client.disconnect(); return; @@ -90,9 +89,9 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter { handleComplete(); } } catch (IOException e) { - fail(new AriaIOException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), true); + fail(new AriaFTPException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), true); } catch (Exception e) { - fail(new AriaIOException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), false); + fail(new AriaFTPException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), false); } finally { try { if (is != null) { @@ -154,7 +153,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter { } handleComplete(); } catch (IOException e) { - fail(new AriaIOException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), true); + fail(new AriaFTPException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), true); } finally { try { if (fos != null) { @@ -179,8 +178,9 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter { BufferedRandomAccessFile file = null; try { file = - new BufferedRandomAccessFile(getThreadConfig().tempFile, "rwd", getTaskConfig().getBuffSize()); - if (getThreadRecord().startLocation > 0){ + new BufferedRandomAccessFile(getThreadConfig().tempFile, "rwd", + getTaskConfig().getBuffSize()); + if (getThreadRecord().startLocation > 0) { file.seek(getThreadRecord().startLocation); } byte[] buffer = new byte[getTaskConfig().getBuffSize()]; @@ -203,7 +203,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter { } } } catch (IOException e) { - fail(new AriaIOException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), true); + fail(new AriaFTPException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), true); } finally { try { if (file != null) { diff --git a/FtpComponent/src/main/java/com/arialyy/aria/ftp/upload/FtpULoader.java b/FtpComponent/src/main/java/com/arialyy/aria/ftp/upload/FtpULoader.java index 4d5d334f..07278e60 100644 --- a/FtpComponent/src/main/java/com/arialyy/aria/ftp/upload/FtpULoader.java +++ b/FtpComponent/src/main/java/com/arialyy/aria/ftp/upload/FtpULoader.java @@ -26,7 +26,7 @@ import com.arialyy.aria.core.loader.NormalLoader; import com.arialyy.aria.core.manager.ThreadTaskManager; import com.arialyy.aria.core.task.IThreadTask; import com.arialyy.aria.core.upload.UTaskWrapper; -import com.arialyy.aria.exception.BaseException; +import com.arialyy.aria.exception.AriaException; final class FtpULoader extends NormalLoader { private FTPFile ftpFile; @@ -79,7 +79,7 @@ final class FtpULoader extends NormalLoader { } } - @Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) { + @Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) { getListener().onFail(needRetry, e); } }); diff --git a/FtpComponent/src/main/java/com/arialyy/aria/ftp/upload/FtpUThreadTaskAdapter.java b/FtpComponent/src/main/java/com/arialyy/aria/ftp/upload/FtpUThreadTaskAdapter.java index c948a6be..fb8dffa7 100644 --- a/FtpComponent/src/main/java/com/arialyy/aria/ftp/upload/FtpUThreadTaskAdapter.java +++ b/FtpComponent/src/main/java/com/arialyy/aria/ftp/upload/FtpUThreadTaskAdapter.java @@ -21,7 +21,7 @@ import aria.apache.commons.net.ftp.FTPReply; import aria.apache.commons.net.ftp.OnFtpInputStreamListener; import com.arialyy.aria.core.common.SubThreadConfig; import com.arialyy.aria.core.upload.UploadEntity; -import com.arialyy.aria.exception.AriaIOException; +import com.arialyy.aria.exception.AriaFTPException; import com.arialyy.aria.ftp.BaseFtpThreadTaskAdapter; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.BufferedRandomAccessFile; @@ -63,7 +63,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter { client.setRestartOffset(getThreadRecord().startLocation); int reply = client.getReplyCode(); if (!FTPReply.isPositivePreliminary(reply) && reply != FTPReply.FILE_ACTION_OK) { - fail(new AriaIOException(TAG, + fail(new AriaFTPException(TAG, String.format("文件上传错误,错误码为:%s, msg:%s, filePath: %s", reply, client.getReplyString(), getEntity().getFilePath())), false); client.disconnect(); @@ -80,8 +80,8 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter { if (getThreadTask().isBreak()) { return; } - if (!complete){ - fail(new AriaIOException(TAG, "ftp文件上传失败"), false); + if (!complete) { + fail(new AriaFTPException(TAG, "ftp文件上传失败"), false); return; } ALog.i(TAG, @@ -89,11 +89,11 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter { complete(); } catch (IOException e) { e.printStackTrace(); - fail(new AriaIOException(TAG, + fail(new AriaFTPException(TAG, String.format("上传失败,filePath: %s, uploadUrl: %s", getEntity().getFilePath(), getThreadConfig().url)), true); } catch (Exception e) { - fail(new AriaIOException(TAG, null, e), false); + fail(new AriaFTPException(TAG, null, e), false); } finally { try { if (file != null) { @@ -132,7 +132,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter { @Override public void run() { try { if (isTimeOut) { - fail(new AriaIOException(TAG, "socket连接失败,该问题一般出现于网络断开,客户端重新连接," + fail(new AriaFTPException(TAG, "socket连接失败,该问题一般出现于网络断开,客户端重新连接," + "但是服务器端无法创建socket缺没有返回错误码的情况。"), false); if (fa != null) { fa.close(); @@ -195,7 +195,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter { if (e.getMessage().contains("AriaIOException caught while copying")) { e.printStackTrace(); } else { - fail(new AriaIOException(TAG, msg, e), !storeSuccess); + fail(new AriaFTPException(TAG, msg, e), !storeSuccess); } return false; } finally { @@ -204,7 +204,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter { int reply = client.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { if (reply != FTPReply.TRANSFER_ABORTED) { - fail(new AriaIOException(TAG, + fail(new AriaFTPException(TAG, String.format("文件上传错误,错误码为:%s, msg:%s, filePath: %s", reply, client.getReplyString(), getEntity().getFilePath())), false); } diff --git a/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDFileInfoTask.java b/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDFileInfoTask.java index cc9f1bc1..eb4a6be0 100644 --- a/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDFileInfoTask.java +++ b/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDFileInfoTask.java @@ -27,9 +27,7 @@ import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.loader.IInfoTask; import com.arialyy.aria.core.loader.ILoaderVisitor; import com.arialyy.aria.core.processor.IHttpFileLenAdapter; -import com.arialyy.aria.exception.AriaIOException; -import com.arialyy.aria.exception.BaseException; -import com.arialyy.aria.exception.TaskException; +import com.arialyy.aria.exception.AriaHTTPException; import com.arialyy.aria.http.ConnectionHelp; import com.arialyy.aria.http.HttpTaskOption; import com.arialyy.aria.util.ALog; @@ -40,6 +38,7 @@ import com.arialyy.aria.util.RecordUtil; import java.io.BufferedReader; import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; @@ -85,14 +84,16 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable { conn.connect(); handleConnect(conn); } catch (IOException e) { - e.printStackTrace(); - failDownload(new AriaIOException(TAG, - String.format("下载失败,filePath: %s, url: %s", mEntity.getFilePath(), mEntity.getUrl())), - true); + failDownload(new AriaHTTPException(TAG, + String.format("下载失败,filePath: %s, url: %s", mEntity.getFilePath(), mEntity.getUrl()), + e), true); } finally { if (conn != null) { try { - conn.getInputStream().close(); + InputStream is = conn.getInputStream(); + if (is != null){ + is.close(); + } } catch (IOException e) { e.printStackTrace(); } @@ -132,7 +133,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable { long len = lenAdapter.handleFileLen(conn.getHeaderFields()); if (!FileUtil.checkMemorySpace(mEntity.getFilePath(), len)) { - failDownload(new TaskException(TAG, + failDownload(new AriaHTTPException(TAG, String.format("下载失败,内存空间不足;filePath: %s, url: %s", mEntity.getFilePath(), mEntity.getUrl())), false); return; @@ -176,7 +177,8 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable { if (!checkLen(len) && !isChunked) { if (len < 0) { failDownload( - new AriaIOException(TAG, String.format("任务下载失败,文件长度小于0, url: %s", mEntity.getUrl())), + new AriaHTTPException(TAG, + String.format("任务下载失败,文件长度小于0, url: %s", mEntity.getUrl())), false); } return; @@ -203,7 +205,8 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable { } else if (!checkLen(len) && !isChunked) { if (len < 0) { failDownload( - new AriaIOException(TAG, String.format("任务下载失败,文件长度小于0, url: %s", mEntity.getUrl())), + new AriaHTTPException(TAG, + String.format("任务下载失败,文件长度小于0, url: %s", mEntity.getUrl())), false); } ALog.d(TAG, "len < 0"); @@ -214,8 +217,8 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable { mTaskWrapper.setSupportBP(false); end = true; } else if (code == HttpURLConnection.HTTP_NOT_FOUND) { - failDownload(new AriaIOException(TAG, - String.format("任务下载失败,errorCode:404, url: %s", mEntity.getUrl())), true); + failDownload(new AriaHTTPException(TAG, + String.format("任务下载失败,errorCode:404, url: %s", mEntity.getUrl())), false); } else if (code == HttpURLConnection.HTTP_MOVED_TEMP || code == HttpURLConnection.HTTP_MOVED_PERM || code == HttpURLConnection.HTTP_SEE_OTHER @@ -223,7 +226,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable { || code == 307) { handleUrlReTurn(conn, conn.getHeaderField("Location")); } else { - failDownload(new AriaIOException(TAG, + failDownload(new AriaHTTPException(TAG, String.format("任务下载失败,errorCode:%s, errorMsg: %s, url: %s", code, conn.getResponseMessage(), mEntity.getUrl())), !CheckUtil.httpIsBadRequest(code)); } @@ -298,7 +301,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable { ALog.d(TAG, "30x跳转,新url为【" + newUrl + "】"); if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) { if (callback != null) { - callback.onFail(mEntity, new TaskException(TAG, "获取重定向链接失败"), false); + callback.onFail(mEntity, new AriaHTTPException(TAG, "获取重定向链接失败"), false); } return; } @@ -308,7 +311,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable { } if (!CheckUtil.checkUrl(newUrl)) { - failDownload(new TaskException(TAG, "下载失败,重定向url错误"), false); + failDownload(new AriaHTTPException(TAG, "下载失败,重定向url错误"), false); return; } taskOption.setRedirectUrl(newUrl); @@ -341,7 +344,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable { return true; } - private void failDownload(BaseException e, boolean needRetry) { + private void failDownload(AriaHTTPException e, boolean needRetry) { if (callback != null) { callback.onFail(mEntity, 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 f8f5028e..8c8cdd21 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 @@ -23,8 +23,8 @@ import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.listener.DownloadGroupListener; import com.arialyy.aria.core.loader.IInfoTask; import com.arialyy.aria.core.loader.ILoaderVisitor; -import com.arialyy.aria.exception.AriaIOException; -import com.arialyy.aria.exception.BaseException; +import com.arialyy.aria.exception.AriaException; +import com.arialyy.aria.exception.AriaHTTPException; import com.arialyy.aria.http.HttpTaskOption; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.CommonUtil; @@ -55,11 +55,11 @@ public final class HttpDGInfoTask implements IInfoTask { ALog.d(TAG, "获取子任务信息完成"); } - @Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) { + @Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) { ALog.e(TAG, String.format("获取文件信息失败,url:%s", ((DownloadEntity) entity).getUrl())); count++; failCount++; - listener.onSubFail((DownloadEntity) entity, new AriaIOException(TAG, + listener.onSubFail((DownloadEntity) entity, new AriaHTTPException(TAG, String.format("子任务获取文件长度失败,url:%s", ((DownloadEntity) entity).getUrl()))); checkGetSizeComplete(count, failCount); } @@ -121,7 +121,7 @@ public final class HttpDGInfoTask implements IInfoTask { */ private void checkGetSizeComplete(int count, int failCount) { if (failCount == wrapper.getSubTaskWrapper().size()) { - callback.onFail(wrapper.getEntity(), new AriaIOException(TAG, "获取子任务长度失败"), false); + callback.onFail(wrapper.getEntity(), new AriaHTTPException(TAG, "获取子任务长度失败"), false); notifyLock(); return; } 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 e2b3f9b3..de2517c9 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 @@ -25,7 +25,7 @@ import com.arialyy.aria.core.group.AbsSubDLoadUtil; import com.arialyy.aria.core.listener.DownloadGroupListener; import com.arialyy.aria.core.loader.IInfoTask; import com.arialyy.aria.core.wrapper.AbsTaskWrapper; -import com.arialyy.aria.exception.BaseException; +import com.arialyy.aria.exception.AriaException; /** * http 组合任务加载器 @@ -65,7 +65,7 @@ final class HttpDGLoader extends AbsGroupLoader { startSub(); } - @Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) { + @Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) { 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 3557af0f..745a07b6 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 @@ -18,8 +18,7 @@ package com.arialyy.aria.http.download; import com.arialyy.aria.core.common.RequestEnum; import com.arialyy.aria.core.common.SubThreadConfig; import com.arialyy.aria.core.download.DTaskWrapper; -import com.arialyy.aria.exception.AriaIOException; -import com.arialyy.aria.exception.TaskException; +import com.arialyy.aria.exception.AriaHTTPException; import com.arialyy.aria.http.BaseHttpThreadTaskAdapter; import com.arialyy.aria.http.ConnectionHelp; import com.arialyy.aria.util.ALog; @@ -118,19 +117,19 @@ final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter { handleComplete(); } } catch (MalformedURLException e) { - fail(new TaskException(TAG, + fail(new AriaHTTPException(TAG, String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(), getEntity().getFilePath(), getEntity().getUrl()), e), false); } catch (IOException e) { - fail(new TaskException(TAG, + fail(new AriaHTTPException(TAG, String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(), getEntity().getFilePath(), getEntity().getUrl()), e), true); } catch (ArrayIndexOutOfBoundsException e) { - fail(new TaskException(TAG, + fail(new AriaHTTPException(TAG, String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(), getEntity().getFilePath(), getEntity().getUrl()), e), false); } catch (Exception e) { - fail(new TaskException(TAG, + fail(new AriaHTTPException(TAG, String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(), getEntity().getFilePath(), getEntity().getUrl()), e), false); } finally { @@ -172,9 +171,9 @@ final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter { } handleComplete(); } catch (IOException e) { - fail(new AriaIOException(TAG, + fail(new AriaHTTPException(TAG, String.format("文件下载失败,savePath: %s, url: %s", getEntity().getFilePath(), - getThreadConfig().url)), true); + getThreadConfig().url), e), true); } finally { if (fos != null) { try { @@ -225,7 +224,7 @@ final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter { } handleComplete(); } catch (IOException e) { - fail(new AriaIOException(TAG, + fail(new AriaHTTPException(TAG, String.format("文件下载失败,savePath: %s, url: %s", getEntity().getFilePath(), getThreadConfig().url), e), true); } finally { diff --git a/HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpULoader.java b/HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpULoader.java index ff2e6672..fbddde7b 100644 --- a/HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpULoader.java +++ b/HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpULoader.java @@ -26,7 +26,7 @@ import com.arialyy.aria.core.loader.IThreadTaskBuilder; import com.arialyy.aria.core.manager.ThreadTaskManager; import com.arialyy.aria.core.task.IThreadTask; import com.arialyy.aria.core.upload.UTaskWrapper; -import com.arialyy.aria.exception.AriaIOException; +import com.arialyy.aria.exception.AriaHTTPException; import com.arialyy.aria.util.ALog; import java.util.List; @@ -62,7 +62,7 @@ final class HttpULoader extends AbsNormalLoader { new Handler(looper, mStateManager.getHandlerCallback())); if (tt == null || tt.isEmpty()) { ALog.e(TAG, "创建线程任务失败"); - getListener().onFail(false, new AriaIOException(TAG, "创建线程任务失败")); + getListener().onFail(false, new AriaHTTPException(TAG, "创建线程任务失败")); return; } diff --git a/HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpUThreadTaskAdapter.java b/HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpUThreadTaskAdapter.java index bfa972cc..4fb10d50 100644 --- a/HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpUThreadTaskAdapter.java +++ b/HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpUThreadTaskAdapter.java @@ -18,9 +18,7 @@ package com.arialyy.aria.http.upload; import android.text.TextUtils; import com.arialyy.aria.core.common.SubThreadConfig; import com.arialyy.aria.core.upload.UploadEntity; -import com.arialyy.aria.exception.AriaIOException; -import com.arialyy.aria.exception.BaseException; -import com.arialyy.aria.exception.TaskException; +import com.arialyy.aria.exception.AriaHTTPException; import com.arialyy.aria.http.BaseHttpThreadTaskAdapter; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.CommonUtil; @@ -56,7 +54,7 @@ final class HttpUThreadTaskAdapter extends BaseHttpThreadTaskAdapter { @Override protected void handlerThreadTask() { File uploadFile = new File(getEntity().getFilePath()); if (!uploadFile.exists()) { - fail(new TaskException(TAG, + fail(new AriaHTTPException(TAG, String.format("上传失败,文件不存在;filePath: %s, url: %s", getEntity().getFilePath(), getEntity().getUrl()))); return; @@ -106,13 +104,13 @@ final class HttpUThreadTaskAdapter extends BaseHttpThreadTaskAdapter { getEntity().setResponseStr(finish(writer)); } catch (Exception e) { e.printStackTrace(); - fail(new TaskException(TAG, + fail(new AriaHTTPException(TAG, String.format("上传失败,filePath: %s, url: %s", getEntity().getFilePath(), getEntity().getUrl()), e)); } } - private void fail(BaseException e1) { + private void fail(AriaHTTPException e1) { try { fail(e1, false); if (mOutputStream != null) { @@ -222,7 +220,7 @@ final class HttpUThreadTaskAdapter extends BaseHttpThreadTaskAdapter { } else { String msg = "response msg: " + mHttpConn.getResponseMessage() + ",code: " + status; ALog.e(TAG, msg); - fail(new AriaIOException(TAG, msg), false); + fail(new AriaHTTPException(TAG, msg), false); } writer.flush(); writer.close(); 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 7e7fb816..2d986cd8 100644 --- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8InfoTask.java +++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8InfoTask.java @@ -30,8 +30,7 @@ import com.arialyy.aria.core.processor.IBandWidthUrlConverter; import com.arialyy.aria.core.processor.IKeyUrlConverter; import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.core.wrapper.ITaskWrapper; -import com.arialyy.aria.exception.M3U8Exception; -import com.arialyy.aria.exception.TaskException; +import com.arialyy.aria.exception.AriaM3U8Exception; import com.arialyy.aria.http.ConnectionHelp; import com.arialyy.aria.http.HttpTaskOption; import com.arialyy.aria.util.ALog; @@ -296,7 +295,7 @@ final public class M3U8InfoTask implements IInfoTask { ALog.d(TAG, "30x跳转,新url为【" + newUrl + "】"); if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) { if (mCallback != null) { - mCallback.onFail(mEntity, new TaskException(TAG, "获取重定向链接失败"), false); + mCallback.onFail(mEntity, new AriaM3U8Exception(TAG, "获取重定向链接失败"), false); } return; } @@ -354,7 +353,7 @@ final public class M3U8InfoTask implements IInfoTask { } private void failDownload(String errorInfo, boolean needRetry) { - mCallback.onFail(mEntity, new M3U8Exception(TAG, errorInfo), needRetry); + mCallback.onFail(mEntity, new AriaM3U8Exception(TAG, errorInfo), needRetry); } /** 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 0f716273..496cf2c1 100644 --- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8ThreadTaskAdapter.java +++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8ThreadTaskAdapter.java @@ -21,8 +21,7 @@ import com.arialyy.aria.core.common.RequestEnum; import com.arialyy.aria.core.common.SubThreadConfig; import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.task.AbsThreadTaskAdapter; -import com.arialyy.aria.exception.AriaIOException; -import com.arialyy.aria.exception.TaskException; +import com.arialyy.aria.exception.AriaM3U8Exception; import com.arialyy.aria.http.ConnectionHelp; import com.arialyy.aria.http.HttpTaskOption; import com.arialyy.aria.util.ALog; @@ -92,15 +91,15 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter { handleConn(conn); } catch (MalformedURLException e) { - fail(new TaskException(TAG, + fail(new AriaM3U8Exception(TAG, String.format("分片【%s】下载失败,filePath: %s, url: %s", getThreadRecord().threadId, getThreadConfig().tempFile.getPath(), getEntity().getUrl()), e), false); } catch (IOException e) { - fail(new TaskException(TAG, + fail(new AriaM3U8Exception(TAG, String.format("分片【%s】下载失败,filePath: %s, url: %s", getThreadRecord().threadId, getThreadConfig().tempFile.getPath(), getEntity().getUrl()), e), true); } catch (Exception e) { - fail(new TaskException(TAG, + fail(new AriaM3U8Exception(TAG, String.format("分片【%s】下载失败,filePath: %s, url: %s", getThreadRecord().threadId, getThreadConfig().tempFile.getPath(), getEntity().getUrl()), e), false); } finally { @@ -138,7 +137,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter { || code == 307) { handleUrlReTurn(conn, conn.getHeaderField("Location")); } else { - fail(new TaskException(TAG, + fail(new AriaM3U8Exception(TAG, String.format("连接错误,http错误码:%s,url:%s", code, getThreadConfig().url)), false); } @@ -151,7 +150,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter { 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); + fail(new AriaM3U8Exception(TAG, "下载失败,重定向url为空"), false); return; } @@ -161,14 +160,14 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter { } if (!CheckUtil.checkUrl(newUrl)) { - fail(new AriaIOException(TAG, "下载失败,重定向url错误"), false); + fail(new AriaM3U8Exception(TAG, "下载失败,重定向url错误"), false); return; } String cookies = conn.getHeaderField("Set-Cookie"); conn.disconnect(); // 关闭上一个连接 URL url = ConnectionHelp.handleUrl(newUrl, mHttpTaskOption); conn = ConnectionHelp.handleConnection(url, mHttpTaskOption); - if (!TextUtils.isEmpty(cookies)){ + if (!TextUtils.isEmpty(cookies)) { conn.setRequestProperty("Cookie", cookies); } if (mHttpTaskOption.isChunked()) { @@ -199,7 +198,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter { } handleComplete(); } catch (IOException e) { - fail(new AriaIOException(TAG, + fail(new AriaM3U8Exception(TAG, String.format("文件下载失败,savePath: %s, url: %s", getThreadConfig().tempFile.getPath(), getThreadConfig().url), e), true); } finally { @@ -242,7 +241,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter { } handleComplete(); } catch (IOException e) { - fail(new AriaIOException(TAG, + fail(new AriaM3U8Exception(TAG, String.format("文件下载失败,savePath: %s, url: %s", getThreadConfig().tempFile.getPath(), getThreadConfig().url), e), true); } finally { diff --git a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/live/M3U8LiveLoader.java b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/live/M3U8LiveLoader.java index 4768faca..51ad32d9 100644 --- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/live/M3U8LiveLoader.java +++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/live/M3U8LiveLoader.java @@ -32,9 +32,8 @@ import com.arialyy.aria.core.processor.ILiveTsUrlConverter; import com.arialyy.aria.core.processor.ITsMergeHandler; import com.arialyy.aria.core.task.ThreadTask; import com.arialyy.aria.core.wrapper.ITaskWrapper; -import com.arialyy.aria.exception.BaseException; -import com.arialyy.aria.exception.M3U8Exception; -import com.arialyy.aria.exception.TaskException; +import com.arialyy.aria.exception.AriaM3U8Exception; +import com.arialyy.aria.exception.AriaException; import com.arialyy.aria.m3u8.BaseM3U8Loader; import com.arialyy.aria.m3u8.IdGenerator; import com.arialyy.aria.m3u8.M3U8InfoTask; @@ -255,7 +254,7 @@ final class M3U8LiveLoader extends BaseM3U8Loader { ALog.d(TAG, "更新直播的m3u8文件"); } - @Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) { + @Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) { } }); @@ -275,7 +274,7 @@ final class M3U8LiveLoader extends BaseM3U8Loader { } } if (TextUtils.isEmpty(url) || !url.startsWith("http")) { - fail(new M3U8Exception(TAG, String.format("ts地址错误,url:%s", url)), false); + fail(new AriaM3U8Exception(TAG, String.format("ts地址错误,url:%s", url)), false); return; } offerPeer(new M3U8LiveLoader.ExtInfo(url, extInf)); @@ -283,7 +282,7 @@ final class M3U8LiveLoader extends BaseM3U8Loader { }); } - private void fail(BaseException e, boolean needRetry) { + private void fail(AriaM3U8Exception e, boolean needRetry) { getListener().onFail(needRetry, e); handleComplete(); } @@ -296,13 +295,13 @@ final class M3U8LiveLoader extends BaseM3U8Loader { if (generateIndexFile(true)) { getListener().onComplete(); } else { - getListener().onFail(false, new TaskException(TAG, "创建索引文件失败")); + getListener().onFail(false, new AriaM3U8Exception(TAG, "创建索引文件失败")); } } else if (mM3U8Option.isMergeFile()) { if (mergeFile()) { getListener().onComplete(); } else { - getListener().onFail(false, new M3U8Exception(TAG, "合并文件失败")); + getListener().onFail(false, new AriaM3U8Exception(TAG, "合并文件失败")); } } else { getListener().onComplete(); diff --git a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java index 832ecb53..fa3fb634 100644 --- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java +++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java @@ -35,8 +35,8 @@ import com.arialyy.aria.core.manager.ThreadTaskManager; import com.arialyy.aria.core.processor.IVodTsUrlConverter; import com.arialyy.aria.core.task.ThreadTask; import com.arialyy.aria.core.wrapper.ITaskWrapper; -import com.arialyy.aria.exception.BaseException; -import com.arialyy.aria.exception.M3U8Exception; +import com.arialyy.aria.exception.AriaException; +import com.arialyy.aria.exception.AriaM3U8Exception; import com.arialyy.aria.m3u8.BaseM3U8Loader; import com.arialyy.aria.m3u8.M3U8Listener; import com.arialyy.aria.m3u8.M3U8TaskOption; @@ -517,10 +517,10 @@ final class M3U8VodLoader extends BaseM3U8Loader { urls.addAll((Collection) info.obj); } if (urls.isEmpty()) { - fail(new M3U8Exception(TAG, "获取地址失败"), false); + fail(new AriaM3U8Exception(TAG, "获取地址失败"), false); return; } else if (!urls.get(0).startsWith("http")) { - fail(new M3U8Exception(TAG, "地址错误,请使用IVodTsUrlConverter处理你的url信息"), false); + fail(new AriaM3U8Exception(TAG, "地址错误,请使用IVodTsUrlConverter处理你的url信息"), false); return; } mM3U8Option.setUrls(urls); @@ -534,13 +534,13 @@ final class M3U8VodLoader extends BaseM3U8Loader { } } - @Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) { + @Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) { fail(e, needRetry); } }); } - protected void fail(BaseException e, boolean needRetry) { + protected void fail(AriaException e, boolean needRetry) { if (isBreak()) { return; } diff --git a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/VodStateManager.java b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/VodStateManager.java index 425ba1a7..ec65abdb 100644 --- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/VodStateManager.java +++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/VodStateManager.java @@ -29,8 +29,8 @@ import com.arialyy.aria.core.loader.ILoaderVisitor; import com.arialyy.aria.core.manager.ThreadTaskManager; import com.arialyy.aria.core.processor.ITsMergeHandler; import com.arialyy.aria.core.task.ThreadTask; -import com.arialyy.aria.exception.BaseException; -import com.arialyy.aria.exception.TaskException; +import com.arialyy.aria.exception.AriaM3U8Exception; +import com.arialyy.aria.exception.AriaException; import com.arialyy.aria.m3u8.BaseM3U8Loader; import com.arialyy.aria.m3u8.M3U8Listener; import com.arialyy.aria.m3u8.M3U8TaskOption; @@ -113,7 +113,7 @@ public final class VodStateManager implements IThreadStateManager { ALog.d(TAG, String.format("vod任务【%s】失败", loader.getTempFile().getName())); Bundle b = msg.getData(); listener.onFail(b.getBoolean(DATA_RETRY, true), - (BaseException) b.getSerializable(DATA_ERROR_INFO)); + (AriaException) b.getSerializable(DATA_ERROR_INFO)); quitLooper(); } break; @@ -148,7 +148,7 @@ public final class VodStateManager implements IThreadStateManager { if (loader.generateIndexFile(false)) { listener.onComplete(); } else { - listener.onFail(false, new TaskException(TAG, "创建索引文件失败")); + listener.onFail(false, new AriaM3U8Exception(TAG, "创建索引文件失败")); } } else if (m3U8Option.isMergeFile()) { if (mergeFile()) { 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 84895214..2a0232bd 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,7 +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.exception.AriaException; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.CommonUtil; import java.io.File; @@ -321,7 +321,7 @@ public abstract class AbsGroupLoader implements ILoaderVisitor, ILoader { } } - protected void fail(BaseException e, boolean needRetry){ + protected void fail(AriaException e, boolean needRetry){ closeTimer(); getListener().onFail(needRetry, e); } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/group/SimpleSchedulers.java b/PublicComponent/src/main/java/com/arialyy/aria/core/group/SimpleSchedulers.java index d7192d6f..a84d59f6 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/group/SimpleSchedulers.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/group/SimpleSchedulers.java @@ -24,7 +24,7 @@ import com.arialyy.aria.core.config.Configuration; import com.arialyy.aria.core.inf.IThreadStateManager; import com.arialyy.aria.core.loader.IRecordHandler; import com.arialyy.aria.core.manager.ThreadTaskManager; -import com.arialyy.aria.exception.TaskException; +import com.arialyy.aria.exception.AriaException; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.NetUtils; @@ -113,7 +113,7 @@ final class SimpleSchedulers implements Handler.Callback { || loaderUtil.getLoader() == null // 如果获取不到文件信息,loader为空 || loaderUtil.getEntity().getFailNum() > num) { mQueue.removeTaskFromExecQ(loaderUtil); - mGState.listener.onSubFail(loaderUtil.getEntity(), new TaskException(TAG, + mGState.listener.onSubFail(loaderUtil.getEntity(), new AriaException(TAG, String.format("任务组子任务【%s】下载失败,下载地址【%s】", loaderUtil.getEntity().getFileName(), loaderUtil.getEntity().getUrl()))); mGState.countFailNum(loaderUtil.getKey()); @@ -122,7 +122,7 @@ final class SimpleSchedulers implements Handler.Callback { == mGState.getSubSize()) { mQueue.clear(); mGState.isRunning = false; - mGState.listener.onFail(false, new TaskException(TAG, + mGState.listener.onFail(false, new AriaException(TAG, String.format("任务组【%s】下载失败", mGState.getGroupHash()))); } else { startNext(); diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/listener/BaseListener.java b/PublicComponent/src/main/java/com/arialyy/aria/core/listener/BaseListener.java index 8a6833e3..07f0b085 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/listener/BaseListener.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/listener/BaseListener.java @@ -16,13 +16,14 @@ package com.arialyy.aria.core.listener; import android.os.Handler; +import android.util.Log; import com.arialyy.aria.core.common.AbsEntity; import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.inf.TaskSchedulerType; import com.arialyy.aria.core.task.AbsTask; import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.core.wrapper.ITaskWrapper; -import com.arialyy.aria.exception.BaseException; +import com.arialyy.aria.exception.AriaException; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.ErrorHelp; @@ -114,7 +115,7 @@ public abstract class BaseListener extends AbsNormalLoader { startThreadTask(); } - @Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) { + @Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) { getListener().onFail(needRetry, e); } }); diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/loader/NormalThreadStateManager.java b/PublicComponent/src/main/java/com/arialyy/aria/core/loader/NormalThreadStateManager.java index 9ca449d9..22af4255 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/loader/NormalThreadStateManager.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/loader/NormalThreadStateManager.java @@ -22,7 +22,7 @@ import android.os.Message; import com.arialyy.aria.core.TaskRecord; import com.arialyy.aria.core.inf.IThreadStateManager; import com.arialyy.aria.core.listener.IEventListener; -import com.arialyy.aria.exception.BaseException; +import com.arialyy.aria.exception.AriaException; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.FileUtil; import java.io.File; @@ -91,7 +91,7 @@ public class NormalThreadStateManager implements IThreadStateManager { if (isFail()) { Bundle b = msg.getData(); mListener.onFail(b.getBoolean(DATA_RETRY, false), - (BaseException) b.getSerializable(DATA_ERROR_INFO)); + (AriaException) b.getSerializable(DATA_ERROR_INFO)); quitLooper(); } break; diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/loader/SubLoader.java b/PublicComponent/src/main/java/com/arialyy/aria/core/loader/SubLoader.java index f227b2e7..e98e3157 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/loader/SubLoader.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/loader/SubLoader.java @@ -27,7 +27,7 @@ import com.arialyy.aria.core.manager.ThreadTaskManager; import com.arialyy.aria.core.task.IThreadTask; import com.arialyy.aria.core.task.ThreadTask; import com.arialyy.aria.core.wrapper.AbsTaskWrapper; -import com.arialyy.aria.exception.BaseException; +import com.arialyy.aria.exception.AriaException; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.CommonUtil; import java.io.File; @@ -207,7 +207,7 @@ public final class SubLoader implements ILoader, ILoaderVisitor { handlerTask(); } - @Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) { + @Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) { sendFailState(needRetry); } }); diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/manager/ThreadTaskManager.java b/PublicComponent/src/main/java/com/arialyy/aria/core/manager/ThreadTaskManager.java index b985dca8..1c2bc973 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/manager/ThreadTaskManager.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/manager/ThreadTaskManager.java @@ -255,7 +255,7 @@ public class ThreadTaskManager { return; } } catch (Exception e) { - ALog.e(TAG, e); + ALog.e(TAG, "", e); return; } mExePool.submit(task); diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/task/AbsThreadTaskAdapter.java b/PublicComponent/src/main/java/com/arialyy/aria/core/task/AbsThreadTaskAdapter.java index 32593444..b72dc15c 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/task/AbsThreadTaskAdapter.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/task/AbsThreadTaskAdapter.java @@ -19,7 +19,7 @@ import com.arialyy.aria.core.ThreadRecord; import com.arialyy.aria.core.common.SubThreadConfig; import com.arialyy.aria.core.config.BaseTaskConfig; import com.arialyy.aria.core.wrapper.AbsTaskWrapper; -import com.arialyy.aria.exception.BaseException; +import com.arialyy.aria.exception.AriaException; import com.arialyy.aria.util.BandwidthLimiter; import com.arialyy.aria.util.CommonUtil; @@ -110,7 +110,7 @@ public abstract class AbsThreadTaskAdapter implements IThreadTaskAdapter { } } - protected void fail(BaseException ex, boolean needRetry) { + protected void fail(AriaException ex, boolean needRetry) { if (mObserver != null) { mObserver.updateFailState(ex, needRetry); } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/task/IThreadTaskObserver.java b/PublicComponent/src/main/java/com/arialyy/aria/core/task/IThreadTaskObserver.java index 3716b1e9..9460ff7f 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/task/IThreadTaskObserver.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/task/IThreadTaskObserver.java @@ -17,7 +17,7 @@ package com.arialyy.aria.core.task; import android.os.Bundle; import com.arialyy.aria.core.inf.IThreadStateManager; -import com.arialyy.aria.exception.BaseException; +import com.arialyy.aria.exception.AriaException; /** * 线程任务观察者 @@ -44,7 +44,7 @@ public interface IThreadTaskObserver { * * @param needRetry 是否需要重试,一般是网络错误才需要重试 */ - void updateFailState(BaseException e, boolean needRetry); + void updateFailState(AriaException e, boolean needRetry); /** * 更新进度 diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java b/PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java index d84aa596..c44323a1 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java @@ -29,7 +29,7 @@ import com.arialyy.aria.core.listener.ISchedulers; import com.arialyy.aria.core.manager.ThreadTaskManager; import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.core.wrapper.ITaskWrapper; -import com.arialyy.aria.exception.BaseException; +import com.arialyy.aria.exception.AriaException; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.BufferedRandomAccessFile; import com.arialyy.aria.util.CommonUtil; @@ -323,7 +323,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver { * * @param needRetry 是否需要重试,一般是网络错误才需要重试 */ - @Override public synchronized void updateFailState(BaseException e, boolean needRetry) { + @Override public synchronized void updateFailState(AriaException e, boolean needRetry) { fail(mRangeProgress, e, needRetry); } @@ -396,7 +396,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver { * * @param subCurrentLocation 当前子线程进度 */ - protected void fail(final long subCurrentLocation, BaseException ex, boolean needRetry) { + protected void fail(final long subCurrentLocation, AriaException ex, boolean needRetry) { if (ex != null) { ex.printStackTrace(); } @@ -505,7 +505,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver { /** * 发送失败信息 */ - private void sendFailMsg(BaseException e, boolean needRetry) { + private void sendFailMsg(AriaException e, boolean needRetry) { Bundle b = new Bundle(); b.putBoolean(IThreadStateManager.DATA_RETRY, needRetry); if (e != null) { diff --git a/PublicComponent/src/main/java/com/arialyy/aria/exception/AriaException.java b/PublicComponent/src/main/java/com/arialyy/aria/exception/AriaException.java index a860a97c..909315eb 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/exception/AriaException.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/exception/AriaException.java @@ -15,14 +15,22 @@ */ package com.arialyy.aria.exception; -public class AriaException extends BaseException { - private static final String ARIA_NET_EXCEPTION = "Aria Exception:"; +public class AriaException extends Exception { + + private String tag; public AriaException(String tag, String message) { - super(tag, String.format("%s%s", ARIA_NET_EXCEPTION, message)); + super(message); + this.tag = tag; } public AriaException(String tag, String message, Exception e) { - super(tag, message, e); + super(String.format("%s, %s\n%s", tag, message == null ? "" : message, + e == null ? "" : e.getMessage())); + this.tag = tag; + } + + public String getTag() { + return tag; } } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/exception/M3U8Exception.java b/PublicComponent/src/main/java/com/arialyy/aria/exception/AriaFTPException.java similarity index 69% rename from PublicComponent/src/main/java/com/arialyy/aria/exception/M3U8Exception.java rename to PublicComponent/src/main/java/com/arialyy/aria/exception/AriaFTPException.java index 132841e5..fffabf3b 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/exception/M3U8Exception.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/exception/AriaFTPException.java @@ -15,14 +15,14 @@ */ package com.arialyy.aria.exception; -public class M3U8Exception extends BaseException{ - private static final String M3U8_EXCEPTION = "M3U8 Exception:"; +public class AriaFTPException extends AriaException { + private static final String FTP_EXCEPTION = "Aria SFTP Exception:"; - public M3U8Exception(String tag, String message) { - super(tag, String.format("%s%s", M3U8_EXCEPTION, message)); + public AriaFTPException(String tag, String message) { + super(tag, String.format("%s\n%s", FTP_EXCEPTION, message)); } - public M3U8Exception(String tag, String message, Exception e){ + public AriaFTPException(String tag, String message, Exception e) { super(tag, message, e); } } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/exception/AriaLoginException.java b/PublicComponent/src/main/java/com/arialyy/aria/exception/AriaHTTPException.java similarity index 68% rename from PublicComponent/src/main/java/com/arialyy/aria/exception/AriaLoginException.java rename to PublicComponent/src/main/java/com/arialyy/aria/exception/AriaHTTPException.java index a79269d3..ab04a2ca 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/exception/AriaLoginException.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/exception/AriaHTTPException.java @@ -15,14 +15,14 @@ */ package com.arialyy.aria.exception; -public class AriaLoginException extends BaseException{ - private static final String ARIA_NET_EXCEPTION = "Aria Login Exception:"; +public class AriaHTTPException extends AriaException { + private static final String HTTP_EXCEPTION = "Aria HTTP Exception:"; - public AriaLoginException(String tag, String message) { - super(tag, String.format("%s%s", ARIA_NET_EXCEPTION, message)); + public AriaHTTPException(String tag, String message) { + super(tag, String.format("%s\n%s", HTTP_EXCEPTION, message)); } - public AriaLoginException(String tag, String message, Exception e){ + public AriaHTTPException(String tag, String message, Exception e) { super(tag, message, e); } } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/exception/AriaIOException.java b/PublicComponent/src/main/java/com/arialyy/aria/exception/AriaM3U8Exception.java similarity index 68% rename from PublicComponent/src/main/java/com/arialyy/aria/exception/AriaIOException.java rename to PublicComponent/src/main/java/com/arialyy/aria/exception/AriaM3U8Exception.java index db0ffc7a..b9f643de 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/exception/AriaIOException.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/exception/AriaM3U8Exception.java @@ -15,14 +15,14 @@ */ package com.arialyy.aria.exception; -public class AriaIOException extends BaseException{ - private static final String ARIA_NET_EXCEPTION = "Aria Net Exception:"; +public class AriaM3U8Exception extends AriaException { + private static final String M3U8_EXCEPTION = "Aria M3U8 Exception:"; - public AriaIOException(String tag, String message) { - super(tag, String.format("%s%s", ARIA_NET_EXCEPTION, message)); + public AriaM3U8Exception(String tag, String message) { + super(tag, String.format("%s\n%s", M3U8_EXCEPTION, message)); } - public AriaIOException(String tag, String message, Exception e){ + public AriaM3U8Exception(String tag, String message, Exception e){ super(tag, message, e); } } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/exception/TaskException.java b/PublicComponent/src/main/java/com/arialyy/aria/exception/AriaSFTPException.java similarity index 66% rename from PublicComponent/src/main/java/com/arialyy/aria/exception/TaskException.java rename to PublicComponent/src/main/java/com/arialyy/aria/exception/AriaSFTPException.java index e8f7b765..e0000fac 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/exception/TaskException.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/exception/AriaSFTPException.java @@ -15,17 +15,14 @@ */ package com.arialyy.aria.exception; -/** - * 任务异常 - */ -public class TaskException extends BaseException { - private static final String ARIA_TASK_EXCEPTION = "Aria Task Exception:"; +public class AriaSFTPException extends AriaException { + private static final String SFTP_EXCEPTION = "Aria SFTP Exception:"; - public TaskException(String tag, String detailMessage) { - super(tag, String.format("%s, %s", ARIA_TASK_EXCEPTION, detailMessage)); + public AriaSFTPException(String tag, String message) { + super(tag, String.format("%s\n%s", SFTP_EXCEPTION, message)); } - public TaskException(String tag, String message, Exception e){ + public AriaSFTPException(String tag, String message, Exception e) { super(tag, message, e); } } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/exception/BaseException.java b/PublicComponent/src/main/java/com/arialyy/aria/exception/BaseException.java deleted file mode 100644 index 98073c31..00000000 --- a/PublicComponent/src/main/java/com/arialyy/aria/exception/BaseException.java +++ /dev/null @@ -1,35 +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.exception; - -public abstract class BaseException extends Exception { - - private String tag; - - public BaseException(String tag, String message) { - super(message); - this.tag = tag; - } - - public BaseException(String tag, String message, Exception e) { - super(String.format("%s\n%s", message == null ? "" : message, e == null ? "" : e.getMessage())); - this.tag = tag; - } - - public String getTag() { - return tag; - } -} diff --git a/PublicComponent/src/main/java/com/arialyy/aria/exception/FileException.java b/PublicComponent/src/main/java/com/arialyy/aria/exception/FileException.java deleted file mode 100644 index 0c4ffed5..00000000 --- a/PublicComponent/src/main/java/com/arialyy/aria/exception/FileException.java +++ /dev/null @@ -1,32 +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.exception; - -/** - * Created by lyy on 2017/1/18. - * Aria 文件异常 - */ -public class FileException extends BaseException { - private static final String ARIA_FILE_EXCEPTION = "Aria File Exception:"; - - public FileException(String tag, String detailMessage) { - super(tag, String.format("%s%s", ARIA_FILE_EXCEPTION, detailMessage)); - } - - public FileException(String tag, String message, Exception e){ - super(tag, message, e); - } -} diff --git a/PublicComponent/src/main/java/com/arialyy/aria/exception/FileNotFoundException.java b/PublicComponent/src/main/java/com/arialyy/aria/exception/FileNotFoundException.java deleted file mode 100644 index 12378266..00000000 --- a/PublicComponent/src/main/java/com/arialyy/aria/exception/FileNotFoundException.java +++ /dev/null @@ -1,32 +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.exception; - -/** - * Created by lyy on 2017/1/18. - * Aria 文件异常 - */ -public class FileNotFoundException extends BaseException { - private static final String ARIA_FILE_EXCEPTION = "Aria File not found Exception:"; - - public FileNotFoundException(String tag, String detailMessage) { - super(tag, String.format("%s%s", ARIA_FILE_EXCEPTION, detailMessage)); - } - - public FileNotFoundException(String tag, String message, Exception e) { - super(tag, message, e); - } -} diff --git a/PublicComponent/src/main/java/com/arialyy/aria/exception/ParamException.java b/PublicComponent/src/main/java/com/arialyy/aria/exception/ParamException.java deleted file mode 100644 index b2299c2f..00000000 --- a/PublicComponent/src/main/java/com/arialyy/aria/exception/ParamException.java +++ /dev/null @@ -1,24 +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.exception; - -public class ParamException extends RuntimeException { - private static final String ARIA_NET_EXCEPTION = "Aria Params Exception:"; - - public ParamException(String message) { - super(String.format("%s%s", ARIA_NET_EXCEPTION, message)); - } -} diff --git a/PublicComponent/src/main/java/com/arialyy/aria/util/ALog.java b/PublicComponent/src/main/java/com/arialyy/aria/util/ALog.java index 5e5d4b7e..84a9a819 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/util/ALog.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/util/ALog.java @@ -63,10 +63,8 @@ public class ALog { return println(Log.ERROR, tag, msg); } - public static int e(String tag, Throwable e) { - String msg = getExceptionString(e); - ErrorHelp.saveError(tag, "", msg); - return println(Log.ERROR, tag, msg); + public static void e(String tag, String msg, Throwable e) { + Log.e(tag, msg, e); } /** diff --git a/PublicComponent/src/main/java/com/arialyy/aria/util/CommonUtil.java b/PublicComponent/src/main/java/com/arialyy/aria/util/CommonUtil.java index a1efdab4..d3800a8f 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/util/CommonUtil.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/util/CommonUtil.java @@ -534,7 +534,7 @@ public class CommonUtil { try { is = new FileInputStream(updateFile); } catch (FileNotFoundException e) { - ALog.e(TAG, e); + e.printStackTrace(); return null; } @@ -549,7 +549,7 @@ public class CommonUtil { try { digest = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { - ALog.e(TAG, e); + e.printStackTrace(); return null; } @@ -571,7 +571,7 @@ public class CommonUtil { try { is.close(); } catch (IOException e) { - ALog.e(TAG, e); + e.printStackTrace(); } } } diff --git a/SFtpComponent/src/main/java/com/arialyy/aria/sftp/AbsSFtpInfoTask.java b/SFtpComponent/src/main/java/com/arialyy/aria/sftp/AbsSFtpInfoTask.java index ada8224a..c5c6145d 100644 --- a/SFtpComponent/src/main/java/com/arialyy/aria/sftp/AbsSFtpInfoTask.java +++ b/SFtpComponent/src/main/java/com/arialyy/aria/sftp/AbsSFtpInfoTask.java @@ -19,7 +19,8 @@ import com.arialyy.aria.core.FtpUrlEntity; import com.arialyy.aria.core.loader.IInfoTask; import com.arialyy.aria.core.loader.ILoaderVisitor; import com.arialyy.aria.core.wrapper.AbsTaskWrapper; -import com.arialyy.aria.exception.BaseException; +import com.arialyy.aria.exception.AriaException; +import com.arialyy.aria.exception.AriaSFTPException; import com.arialyy.aria.util.CommonUtil; import com.jcraft.jsch.JSchException; import com.jcraft.jsch.Session; @@ -53,14 +54,11 @@ public abstract class AbsSFtpInfoTask implements IInf } getFileInfo(session); } catch (JSchException e) { - e.printStackTrace(); - fail(false, null); + fail(new AriaSFTPException(TAG, "jsch错误", e), false); } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - fail(false, null); + fail(new AriaSFTPException(TAG, "字符编码错误", e), false); } catch (SftpException e) { - e.printStackTrace(); - fail(false, null); + fail(new AriaSFTPException(TAG, "sftp错误,错误类型:" + e.id, e), false); } } @@ -72,7 +70,7 @@ public abstract class AbsSFtpInfoTask implements IInf return wrapper; } - protected void fail(boolean needRetry, BaseException e) { + protected void fail(AriaException e, boolean needRetry) { callback.onFail(getWrapper().getEntity(), e, needRetry); } diff --git a/SFtpComponent/src/main/java/com/arialyy/aria/sftp/download/SFtpDInfoTask.java b/SFtpComponent/src/main/java/com/arialyy/aria/sftp/download/SFtpDInfoTask.java index f01578d6..dddfac55 100644 --- a/SFtpComponent/src/main/java/com/arialyy/aria/sftp/download/SFtpDInfoTask.java +++ b/SFtpComponent/src/main/java/com/arialyy/aria/sftp/download/SFtpDInfoTask.java @@ -17,7 +17,7 @@ package com.arialyy.aria.sftp.download; import com.arialyy.aria.core.common.CompleteInfo; import com.arialyy.aria.core.download.DTaskWrapper; -import com.arialyy.aria.exception.AriaException; +import com.arialyy.aria.exception.AriaSFTPException; import com.arialyy.aria.sftp.AbsSFtpInfoTask; import com.arialyy.aria.sftp.SFtpTaskOption; import com.arialyy.aria.util.ALog; @@ -63,7 +63,7 @@ final class SFtpDInfoTask extends AbsSFtpInfoTask { callback.onSucceed(getWrapper().getKey(), info); } else { callback.onFail(getWrapper().getEntity(), - new AriaException(TAG, String.format("文件不存在,remotePath:%s", remotePath)), false); + new AriaSFTPException(TAG, String.format("文件不存在,remotePath:%s", remotePath)), false); } channel.disconnect(); } diff --git a/SFtpComponent/src/main/java/com/arialyy/aria/sftp/download/SFtpDLoader.java b/SFtpComponent/src/main/java/com/arialyy/aria/sftp/download/SFtpDLoader.java index f6d214d3..2a3b68a3 100644 --- a/SFtpComponent/src/main/java/com/arialyy/aria/sftp/download/SFtpDLoader.java +++ b/SFtpComponent/src/main/java/com/arialyy/aria/sftp/download/SFtpDLoader.java @@ -31,7 +31,7 @@ import com.arialyy.aria.core.loader.IRecordHandler; import com.arialyy.aria.core.loader.IThreadTaskBuilder; import com.arialyy.aria.core.manager.ThreadTaskManager; import com.arialyy.aria.core.task.IThreadTask; -import com.arialyy.aria.exception.BaseException; +import com.arialyy.aria.exception.AriaException; import com.arialyy.aria.util.FileUtil; import java.io.File; @@ -140,7 +140,7 @@ final class SFtpDLoader extends AbsNormalLoader { startThreadTask(); } - @Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) { + @Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) { getListener().onFail(needRetry, e); } }); diff --git a/SFtpComponent/src/main/java/com/arialyy/aria/sftp/download/SFtpDThreadTaskAdapter.java b/SFtpComponent/src/main/java/com/arialyy/aria/sftp/download/SFtpDThreadTaskAdapter.java index a8bdcdd0..a139fec3 100644 --- a/SFtpComponent/src/main/java/com/arialyy/aria/sftp/download/SFtpDThreadTaskAdapter.java +++ b/SFtpComponent/src/main/java/com/arialyy/aria/sftp/download/SFtpDThreadTaskAdapter.java @@ -17,7 +17,7 @@ package com.arialyy.aria.sftp.download; import com.arialyy.aria.core.common.SubThreadConfig; import com.arialyy.aria.core.task.AbsThreadTaskAdapter; -import com.arialyy.aria.exception.AriaException; +import com.arialyy.aria.exception.AriaSFTPException; import com.arialyy.aria.sftp.SFtpTaskOption; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.CommonUtil; @@ -53,7 +53,7 @@ final class SFtpDThreadTaskAdapter extends AbsThreadTaskAdapter { @Override protected void handlerThreadTask() { if (session == null) { - fail(new AriaException(TAG, "session 为空"), false); + fail(new AriaSFTPException(TAG, "session 为空"), false); return; } try { @@ -74,18 +74,13 @@ final class SFtpDThreadTaskAdapter extends AbsThreadTaskAdapter { CommonUtil.convertSFtpChar(charSet, option.getUrlEntity().remotePath); download(remotePath); } catch (SftpException e) { - e.printStackTrace(); - ALog.e(TAG, "错误类型:" + e.id); - fail(null, false); + fail(new AriaSFTPException(TAG, "sftp错误,错误类型:" + e.id, e), false); } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - fail(null, false); + fail(new AriaSFTPException(TAG, "字符编码错误", e), false); } catch (IOException e) { - e.printStackTrace(); - fail(null, true); + fail(new AriaSFTPException(TAG, "", e), true); } catch (JSchException e) { - e.printStackTrace(); - fail(null, false); + fail(new AriaSFTPException(TAG, "jsch 错误", e), false); } finally { channelSftp.disconnect(); } diff --git a/SFtpComponent/src/main/java/com/arialyy/aria/sftp/upload/SFtpULoader.java b/SFtpComponent/src/main/java/com/arialyy/aria/sftp/upload/SFtpULoader.java index ae7cdaf4..34cda951 100644 --- a/SFtpComponent/src/main/java/com/arialyy/aria/sftp/upload/SFtpULoader.java +++ b/SFtpComponent/src/main/java/com/arialyy/aria/sftp/upload/SFtpULoader.java @@ -31,7 +31,7 @@ import com.arialyy.aria.core.manager.ThreadTaskManager; import com.arialyy.aria.core.task.IThreadTask; import com.arialyy.aria.core.upload.UTaskWrapper; import com.arialyy.aria.core.upload.UploadEntity; -import com.arialyy.aria.exception.BaseException; +import com.arialyy.aria.exception.AriaException; import com.arialyy.aria.util.FileUtil; import com.jcraft.jsch.SftpATTRS; import java.io.File; @@ -139,7 +139,7 @@ final class SFtpULoader extends AbsNormalLoader { } } - @Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) { + @Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) { getListener().onFail(needRetry, e); } }); diff --git a/SFtpComponent/src/main/java/com/arialyy/aria/sftp/upload/SFtpUThreadTaskAdapter.java b/SFtpComponent/src/main/java/com/arialyy/aria/sftp/upload/SFtpUThreadTaskAdapter.java index dd6ce4ed..1edcfbf1 100644 --- a/SFtpComponent/src/main/java/com/arialyy/aria/sftp/upload/SFtpUThreadTaskAdapter.java +++ b/SFtpComponent/src/main/java/com/arialyy/aria/sftp/upload/SFtpUThreadTaskAdapter.java @@ -18,7 +18,7 @@ package com.arialyy.aria.sftp.upload; import com.arialyy.aria.core.common.SubThreadConfig; import com.arialyy.aria.core.task.AbsThreadTaskAdapter; import com.arialyy.aria.core.upload.UploadEntity; -import com.arialyy.aria.exception.AriaException; +import com.arialyy.aria.exception.AriaSFTPException; import com.arialyy.aria.sftp.SFtpTaskOption; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.BufferedRandomAccessFile; @@ -50,7 +50,7 @@ final class SFtpUThreadTaskAdapter extends AbsThreadTaskAdapter { @Override protected void handlerThreadTask() { if (session == null) { - fail(new AriaException(TAG, "session 为空"), false); + fail(new AriaSFTPException(TAG, "session 为空"), false); return; } try { @@ -74,19 +74,14 @@ final class SFtpUThreadTaskAdapter extends AbsThreadTaskAdapter { } channelSftp.cd(remotePath); upload(remotePath); - } catch (JSchException e) { - e.printStackTrace(); - fail(null, false); + } catch (SftpException e) { + fail(new AriaSFTPException(TAG, "sftp错误,错误类型:" + e.id, e), false); } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - fail(null, false); + fail(new AriaSFTPException(TAG, "字符编码错误", e), false); } catch (IOException e) { - e.printStackTrace(); - fail(null, true); - } catch (SftpException e) { - e.printStackTrace(); - fail(null, false); - ALog.d(TAG, "错误类型:" + e.id); + fail(new AriaSFTPException(TAG, "", e), true); + } catch (JSchException e) { + fail(new AriaSFTPException(TAG, "jsch 错误", e), false); } finally { channelSftp.disconnect(); } diff --git a/app/src/main/java/com/arialyy/simple/core/download/group/DownloadGroupActivity.java b/app/src/main/java/com/arialyy/simple/core/download/group/DownloadGroupActivity.java index 4a0cc8ad..193080d2 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/group/DownloadGroupActivity.java +++ b/app/src/main/java/com/arialyy/simple/core/download/group/DownloadGroupActivity.java @@ -17,22 +17,21 @@ package com.arialyy.simple.core.download.group; import android.os.Bundle; import android.os.Environment; -import android.util.Log; import android.view.View; import com.arialyy.annotations.DownloadGroup; import com.arialyy.aria.core.Aria; +import com.arialyy.aria.core.common.AbsEntity; import com.arialyy.aria.core.common.HttpOption; -import com.arialyy.aria.core.processor.IHttpFileLenAdapter; import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadGroupEntity; -import com.arialyy.aria.core.inf.IEntity; +import com.arialyy.aria.core.processor.IHttpFileLenAdapter; import com.arialyy.aria.core.task.DownloadGroupTask; import com.arialyy.aria.util.ALog; -import com.arialyy.frame.util.show.L; import com.arialyy.frame.util.show.T; import com.arialyy.simple.R; import com.arialyy.simple.base.BaseActivity; import com.arialyy.simple.databinding.ActivityDownloadGroupBinding; +import com.arialyy.simple.widget.ProgressLayout; import com.arialyy.simple.widget.SubStateLinearLayout; import java.util.List; import java.util.Map; @@ -57,26 +56,47 @@ public class DownloadGroupActivity extends BaseActivity> headers) { List sLength = headers.get("Content-Length"); diff --git a/app/src/main/java/com/arialyy/simple/core/download/group/FTPDirDownloadActivity.java b/app/src/main/java/com/arialyy/simple/core/download/group/FTPDirDownloadActivity.java index e13632d2..cb8fb31b 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/group/FTPDirDownloadActivity.java +++ b/app/src/main/java/com/arialyy/simple/core/download/group/FTPDirDownloadActivity.java @@ -20,18 +20,17 @@ import android.os.Environment; import android.view.View; import com.arialyy.annotations.DownloadGroup; import com.arialyy.aria.core.Aria; +import com.arialyy.aria.core.common.AbsEntity; import com.arialyy.aria.core.common.FtpOption; import com.arialyy.aria.core.download.DownloadGroupEntity; -import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.task.DownloadGroupTask; import com.arialyy.aria.util.ALog; -import com.arialyy.frame.util.show.L; import com.arialyy.frame.util.show.T; import com.arialyy.simple.R; import com.arialyy.simple.base.BaseActivity; import com.arialyy.simple.databinding.ActivityDownloadGroupBinding; +import com.arialyy.simple.widget.ProgressLayout; import com.arialyy.simple.widget.SubStateLinearLayout; -import java.security.AlgorithmConstraints; /** * Created by lyy on 2017/7/6. @@ -52,56 +51,40 @@ public class FTPDirDownloadActivity extends BaseActivity - - - - - - - - - + - + - diff --git a/app/src/main/res/layout/layout_progress_content.xml b/app/src/main/res/layout/layout_progress_content.xml index 11815793..2fecc8a5 100644 --- a/app/src/main/res/layout/layout_progress_content.xml +++ b/app/src/main/res/layout/layout_progress_content.xml @@ -53,6 +53,7 @@ android:layout_alignTop="@+id/speed_or_state" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" + android:text="-/-" android:textSize="@dimen/text_size_smallest" tools:ignore="RelativeOverlap" />