添加日志级别

pull/330/head
AriaLyy 7 years ago
parent 3a3667f214
commit 3fa49f11dd
  1. 23
      Aria/src/main/java/com/arialyy/aria/core/AriaManager.java
  2. 6
      Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java
  3. 17
      Aria/src/main/java/com/arialyy/aria/core/FtpUrlEntity.java
  4. 8
      Aria/src/main/java/com/arialyy/aria/core/SubTaskManager.java
  5. 4
      Aria/src/main/java/com/arialyy/aria/core/TaskManager.java
  6. 6
      Aria/src/main/java/com/arialyy/aria/core/WidgetLiftManager.java
  7. 4
      Aria/src/main/java/com/arialyy/aria/core/command/group/AbsGroupCmd.java
  8. 13
      Aria/src/main/java/com/arialyy/aria/core/command/normal/AbsNormalCmd.java
  9. 4
      Aria/src/main/java/com/arialyy/aria/core/command/normal/AddCmd.java
  10. 5
      Aria/src/main/java/com/arialyy/aria/core/command/normal/HighestPriorityCmd.java
  11. 4
      Aria/src/main/java/com/arialyy/aria/core/command/normal/ResumeAllCmd.java
  12. 4
      Aria/src/main/java/com/arialyy/aria/core/command/normal/StartCmd.java
  13. 4
      Aria/src/main/java/com/arialyy/aria/core/command/normal/StopCmd.java
  14. 6
      Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java
  15. 22
      Aria/src/main/java/com/arialyy/aria/core/common/AbsFtpInfoThread.java
  16. 26
      Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java
  17. 4
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java
  18. 4
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTask.java
  19. 4
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java
  20. 6
      Aria/src/main/java/com/arialyy/aria/core/download/FtpDirDownloadTarget.java
  21. 5
      Aria/src/main/java/com/arialyy/aria/core/download/FtpDownloadTarget.java
  22. 18
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/AbsGroupUtil.java
  23. 4
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/Downloader.java
  24. 5
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpDirInfoThread.java
  25. 6
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpThreadTask.java
  26. 6
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java
  27. 11
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpThreadTask.java
  28. 4
      Aria/src/main/java/com/arialyy/aria/core/inf/AbsDownloadTarget.java
  29. 4
      Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java
  30. 2
      Aria/src/main/java/com/arialyy/aria/core/inf/AbsTaskEntity.java
  31. 18
      Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java
  32. 5
      Aria/src/main/java/com/arialyy/aria/core/queue/DownloadGroupTaskQueue.java
  33. 7
      Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java
  34. 5
      Aria/src/main/java/com/arialyy/aria/core/queue/UploadTaskQueue.java
  35. 16
      Aria/src/main/java/com/arialyy/aria/core/queue/pool/BaseCachePool.java
  36. 16
      Aria/src/main/java/com/arialyy/aria/core/queue/pool/BaseExecutePool.java
  37. 8
      Aria/src/main/java/com/arialyy/aria/core/queue/pool/DownloadExecutePool.java
  38. 16
      Aria/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulers.java
  39. 6
      Aria/src/main/java/com/arialyy/aria/core/upload/FtpUploadTarget.java
  40. 6
      Aria/src/main/java/com/arialyy/aria/core/upload/uploader/FtpThreadTask.java
  41. 8
      Aria/src/main/java/com/arialyy/aria/core/upload/uploader/HttpThreadTask.java
  42. 6
      Aria/src/main/java/com/arialyy/aria/orm/DbUtil.java
  43. 12
      Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java
  44. 90
      Aria/src/main/java/com/arialyy/aria/util/ALog.java
  45. 11
      Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java
  46. 31
      Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java
  47. 8
      app/src/main/java/com/arialyy/simple/download/FtpDownloadActivity.java
  48. 2
      app/src/main/java/com/arialyy/simple/download/group/FTPDirDownloadActivity.java
  49. 5
      aria/src/main/java/com/arialyy/aria/core/upload/UploadTask.java

@ -27,7 +27,6 @@ import android.os.Bundle;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.widget.PopupWindow; import android.widget.PopupWindow;
import com.arialyy.aria.core.command.ICmd; import com.arialyy.aria.core.command.ICmd;
import com.arialyy.aria.core.common.QueueMod; import com.arialyy.aria.core.common.QueueMod;
@ -42,6 +41,7 @@ import com.arialyy.aria.core.upload.UploadReceiver;
import com.arialyy.aria.core.upload.UploadTaskEntity; import com.arialyy.aria.core.upload.UploadTaskEntity;
import com.arialyy.aria.orm.DbEntity; import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.orm.DbUtil; import com.arialyy.aria.orm.DbUtil;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -67,6 +67,16 @@ import org.xml.sax.SAXException;
public static final Object LOCK = new Object(); public static final Object LOCK = new Object();
public static final String DOWNLOAD_TEMP_DIR = "/Aria/temp/download/"; public static final String DOWNLOAD_TEMP_DIR = "/Aria/temp/download/";
public static final String UPLOAD_TEMP_DIR = "/Aria/temp/upload/"; public static final String UPLOAD_TEMP_DIR = "/Aria/temp/upload/";
public static final int LOG_LEVEL_VERBOSE = 2;
public static final int LOG_LEVEL_DEBUG = 3;
public static final int LOG_LEVEL_INFO = 4;
public static final int LOG_LEVEL_WARN = 5;
public static final int LOG_LEVEL_ERROR = 6;
public static final int LOG_LEVEL_ASSERT = 7;
public static final int LOG_CLOSE = 8;
public static final int LOG_DEFAULT = LOG_LEVEL_DEBUG;
@SuppressLint("StaticFieldLeak") private static volatile AriaManager INSTANCE = null; @SuppressLint("StaticFieldLeak") private static volatile AriaManager INSTANCE = null;
private Map<String, IReceiver> mReceivers = new ConcurrentHashMap<>(); private Map<String, IReceiver> mReceivers = new ConcurrentHashMap<>();
public static Context APP; public static Context APP;
@ -94,6 +104,15 @@ import org.xml.sax.SAXException;
return mReceivers; return mReceivers;
} }
/**
* 设置Aria 日志级别
*
* @param level {@link #LOG_LEVEL_VERBOSE}
*/
public void setLogLevel(int level) {
ALog.LOG_LEVEL = level;
}
/** /**
* 设置上传任务的执行队列类型 * 设置上传任务的执行队列类型
* *
@ -356,7 +375,7 @@ import org.xml.sax.SAXException;
CommonUtil.createFileFormInputStream(APP.getAssets().open("aria_config.xml"), CommonUtil.createFileFormInputStream(APP.getAssets().open("aria_config.xml"),
APP.getFilesDir().getPath() + Configuration.XML_FILE); APP.getFilesDir().getPath() + Configuration.XML_FILE);
} catch (ParserConfigurationException | IOException | SAXException e) { } catch (ParserConfigurationException | IOException | SAXException e) {
Log.e(TAG, e.toString()); ALog.e(TAG, e.toString());
} }
} }

@ -16,7 +16,7 @@
package com.arialyy.aria.core; package com.arialyy.aria.core;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import com.arialyy.aria.util.ALog;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.DefaultHandler;
@ -210,7 +210,7 @@ class ConfigHelper extends DefaultHandler {
num = Integer.parseInt(value); num = Integer.parseInt(value);
} }
if (num < 1) { if (num < 1) {
Log.e(TAG, "任务队列数不能小于 1"); ALog.w(TAG, "任务队列数不能小于 1");
num = 2; num = 2;
} }
if (isDownloadConfig) { if (isDownloadConfig) {
@ -227,7 +227,7 @@ class ConfigHelper extends DefaultHandler {
num = Integer.parseInt(value); num = Integer.parseInt(value);
} }
if (num < 1) { if (num < 1) {
Log.e(TAG, "下载线程数不能小于 1"); ALog.e(TAG, "下载线程数不能小于 1");
num = 1; num = 1;
} }
if (isDownloadConfig) { if (isDownloadConfig) {

@ -1,3 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core; package com.arialyy.aria.core;
import java.net.InetAddress; import java.net.InetAddress;

@ -16,9 +16,9 @@
package com.arialyy.aria.core; package com.arialyy.aria.core;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.command.group.GroupCmdFactory; import com.arialyy.aria.core.command.group.GroupCmdFactory;
import com.arialyy.aria.core.inf.AbsGroupTaskEntity; import com.arialyy.aria.core.inf.AbsGroupTaskEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.util.List; import java.util.List;
@ -86,16 +86,16 @@ public class SubTaskManager {
*/ */
private boolean checkUrl(String url) { private boolean checkUrl(String url) {
if (TextUtils.isEmpty(url)) { if (TextUtils.isEmpty(url)) {
Log.e(TAG, "子任务地址不能为null"); ALog.e(TAG, "子任务地址不能为null");
return false; return false;
} }
List<String> urls = mEntity.getEntity().getUrls(); List<String> urls = mEntity.getEntity().getUrls();
if (urls == null || urls.isEmpty()) { if (urls == null || urls.isEmpty()) {
Log.e(TAG, "任务组任务链接为null"); ALog.e(TAG, "任务组任务链接为null");
return false; return false;
} }
if (!urls.contains(url)) { if (!urls.contains(url)) {
Log.e(TAG, "任务组中没有改Url【+ " + url + "】"); ALog.e(TAG, "任务组中没有改Url【+ " + url + "】");
return false; return false;
} }
return true; return true;

@ -15,8 +15,8 @@
*/ */
package com.arialyy.aria.core; package com.arialyy.aria.core;
import android.util.Log;
import com.arialyy.aria.core.inf.AbsTask; import com.arialyy.aria.core.inf.AbsTask;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
@ -54,7 +54,7 @@ public class TaskManager {
public boolean addTask(String key, AbsTask task) { public boolean addTask(String key, AbsTask task) {
String hash = CommonUtil.keyToHashKey(key); String hash = CommonUtil.keyToHashKey(key);
if (map.keySet().contains(hash)) { if (map.keySet().contains(hash)) {
Log.e(TAG, "任务【" + key + "】已存在"); ALog.e(TAG, "任务【" + key + "】已存在");
return false; return false;
} }
map.put(CommonUtil.keyToHashKey(key), task); map.put(CommonUtil.keyToHashKey(key), task);

@ -21,8 +21,8 @@ import android.content.DialogInterface;
import android.os.Build; import android.os.Build;
import android.os.Message; import android.os.Message;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.util.Log;
import android.widget.PopupWindow; import android.widget.PopupWindow;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -62,7 +62,7 @@ final class WidgetLiftManager {
PopupWindow.OnDismissListener listener = PopupWindow.OnDismissListener listener =
(PopupWindow.OnDismissListener) dismissField.get(popupWindow); (PopupWindow.OnDismissListener) dismissField.get(popupWindow);
if (listener != null) { if (listener != null) {
Log.e(TAG, "你已经对PopupWindow设置了Dismiss事件。为了防止内存泄露," ALog.e(TAG, "你已经对PopupWindow设置了Dismiss事件。为了防止内存泄露,"
+ "请在dismiss方法中调用Aria.download(this).unRegister();来注销事件"); + "请在dismiss方法中调用Aria.download(this).unRegister();来注销事件");
return true; return true;
} else { } else {
@ -97,7 +97,7 @@ final class WidgetLiftManager {
Field cancelField = CommonUtil.getField(dialog.getClass(), "mCancelMessage"); Field cancelField = CommonUtil.getField(dialog.getClass(), "mCancelMessage");
Message cancelMsg = (Message) cancelField.get(dialog); Message cancelMsg = (Message) cancelField.get(dialog);
if (cancelMsg != null) { if (cancelMsg != null) {
Log.e(TAG, "你已经对Dialog设置了Dismiss和cancel事件。" ALog.e(TAG, "你已经对Dialog设置了Dismiss和cancel事件。"
+ "为了防止内存泄露,请在dismiss方法中调用Aria.download(this).unRegister();来注销事件\n" + "为了防止内存泄露,请在dismiss方法中调用Aria.download(this).unRegister();来注销事件\n"
+ "如果你使用的是DialogFragment,那么你需要在onDestroy()中进行销毁Aria事件操作"); + "如果你使用的是DialogFragment,那么你需要在onDestroy()中进行销毁Aria事件操作");
return true; return true;

@ -15,13 +15,13 @@
*/ */
package com.arialyy.aria.core.command.group; package com.arialyy.aria.core.command.group;
import android.util.Log;
import com.arialyy.aria.core.command.AbsCmd; import com.arialyy.aria.core.command.AbsCmd;
import com.arialyy.aria.core.download.DownloadGroupTaskEntity; import com.arialyy.aria.core.download.DownloadGroupTaskEntity;
import com.arialyy.aria.core.inf.AbsGroupTask; import com.arialyy.aria.core.inf.AbsGroupTask;
import com.arialyy.aria.core.inf.AbsGroupTaskEntity; import com.arialyy.aria.core.inf.AbsGroupTaskEntity;
import com.arialyy.aria.core.inf.AbsTask; import com.arialyy.aria.core.inf.AbsTask;
import com.arialyy.aria.core.queue.DownloadGroupTaskQueue; import com.arialyy.aria.core.queue.DownloadGroupTaskQueue;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
/** /**
@ -64,7 +64,7 @@ public abstract class AbsGroupCmd<T extends AbsGroupTaskEntity> extends AbsCmd<T
if (tempTask == null) { if (tempTask == null) {
createTask(); createTask();
if (tempTask.isComplete()) { if (tempTask.isComplete()) {
Log.w(TAG, "任务已完成"); ALog.i(TAG, "任务已完成");
return false; return false;
} }
} }

@ -16,7 +16,6 @@
package com.arialyy.aria.core.command.normal; package com.arialyy.aria.core.command.normal;
import android.util.Log;
import com.arialyy.aria.core.command.AbsCmd; import com.arialyy.aria.core.command.AbsCmd;
import com.arialyy.aria.core.command.ICmd; import com.arialyy.aria.core.command.ICmd;
import com.arialyy.aria.core.download.DownloadGroupTaskEntity; import com.arialyy.aria.core.download.DownloadGroupTaskEntity;
@ -28,6 +27,7 @@ import com.arialyy.aria.core.queue.DownloadGroupTaskQueue;
import com.arialyy.aria.core.queue.DownloadTaskQueue; import com.arialyy.aria.core.queue.DownloadTaskQueue;
import com.arialyy.aria.core.queue.UploadTaskQueue; import com.arialyy.aria.core.queue.UploadTaskQueue;
import com.arialyy.aria.core.upload.UploadTaskEntity; import com.arialyy.aria.core.upload.UploadTaskEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
/** /**
@ -55,30 +55,29 @@ public abstract class AbsNormalCmd<T extends AbsTaskEntity> extends AbsCmd<T> {
TAG = CommonUtil.getClassName(this); TAG = CommonUtil.getClassName(this);
if (taskType == ICmd.TASK_TYPE_DOWNLOAD) { if (taskType == ICmd.TASK_TYPE_DOWNLOAD) {
if (!(entity instanceof DownloadTaskEntity)) { if (!(entity instanceof DownloadTaskEntity)) {
Log.w(TAG, "任务类型错误,任务类型应该为ICM.TASK_TYPE_DOWNLOAD"); ALog.e(TAG, "任务类型错误,任务类型应该为ICM.TASK_TYPE_DOWNLOAD");
return; return;
} }
mQueue = DownloadTaskQueue.getInstance(); mQueue = DownloadTaskQueue.getInstance();
} else if (taskType == ICmd.TASK_TYPE_DOWNLOAD_GROUP) { } else if (taskType == ICmd.TASK_TYPE_DOWNLOAD_GROUP) {
if (!(entity instanceof DownloadGroupTaskEntity)) { if (!(entity instanceof DownloadGroupTaskEntity)) {
Log.w(TAG, "任务类型错误,任务类型应该为ICM.TASK_TYPE_DOWNLOAD_GROUP"); ALog.e(TAG, "任务类型错误,任务类型应该为ICM.TASK_TYPE_DOWNLOAD_GROUP");
return; return;
} }
mQueue = DownloadGroupTaskQueue.getInstance(); mQueue = DownloadGroupTaskQueue.getInstance();
} else if (taskType == ICmd.TASK_TYPE_UPLOAD) { } else if (taskType == ICmd.TASK_TYPE_UPLOAD) {
if (!(entity instanceof UploadTaskEntity)) { if (!(entity instanceof UploadTaskEntity)) {
Log.w(TAG, "任务类型错误,任务类型应该为ICM.TASK_TYPE_UPLOAD"); ALog.e(TAG, "任务类型错误,任务类型应该为ICM.TASK_TYPE_UPLOAD");
return; return;
} }
mQueue = UploadTaskQueue.getInstance(); mQueue = UploadTaskQueue.getInstance();
} else { } else {
Log.w(TAG, "任务类型错误,任务类型应该为ICM.TASK_TYPE_DOWNLOAD、TASK_TYPE_DOWNLOAD_GROUP、TASK_TYPE_UPLOAD"); ALog.e(TAG, "任务类型错误,任务类型应该为ICM.TASK_TYPE_DOWNLOAD、TASK_TYPE_DOWNLOAD_GROUP、TASK_TYPE_UPLOAD");
return;
} }
isDownloadCmd = taskType < ICmd.TASK_TYPE_UPLOAD; isDownloadCmd = taskType < ICmd.TASK_TYPE_UPLOAD;
} }
/** /**
* 删除所有任务 * 删除所有任务
*/ */

@ -16,10 +16,10 @@
package com.arialyy.aria.core.command.normal; package com.arialyy.aria.core.command.normal;
import android.util.Log;
import com.arialyy.aria.core.inf.AbsTask; import com.arialyy.aria.core.inf.AbsTask;
import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.util.ALog;
/** /**
* Created by lyy on 2016/8/22. * Created by lyy on 2016/8/22.
@ -38,7 +38,7 @@ class AddCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
mTaskEntity.getEntity().setState(IEntity.STATE_WAIT); mTaskEntity.getEntity().setState(IEntity.STATE_WAIT);
createTask(); createTask();
} else { } else {
Log.w(TAG, "添加命令执行失败,【该任务已经存在】"); ALog.w(TAG, "添加命令执行失败,【该任务已经存在】");
} }
} }
} }

@ -16,12 +16,11 @@
package com.arialyy.aria.core.command.normal; package com.arialyy.aria.core.command.normal;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.download.DownloadTask; import com.arialyy.aria.core.download.DownloadTask;
import com.arialyy.aria.core.inf.AbsNormalTask;
import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.core.queue.DownloadTaskQueue; import com.arialyy.aria.core.queue.DownloadTaskQueue;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.NetUtils; import com.arialyy.aria.util.NetUtils;
/** /**
@ -47,7 +46,7 @@ final class HighestPriorityCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T>
@Override public void executeCmd() { @Override public void executeCmd() {
if (!canExeCmd) return; if (!canExeCmd) return;
if (!NetUtils.isConnected(AriaManager.APP)){ if (!NetUtils.isConnected(AriaManager.APP)){
Log.w(TAG, "启动任务失败,网络未连接"); ALog.e(TAG, "启动任务失败,网络未连接");
return; return;
} }
DownloadTask task = (DownloadTask) getTask(); DownloadTask task = (DownloadTask) getTask();

@ -1,6 +1,5 @@
package com.arialyy.aria.core.command.normal; package com.arialyy.aria.core.command.normal;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.download.DownloadGroupTaskEntity; import com.arialyy.aria.core.download.DownloadGroupTaskEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity; import com.arialyy.aria.core.download.DownloadTaskEntity;
@ -11,6 +10,7 @@ import com.arialyy.aria.core.queue.DownloadTaskQueue;
import com.arialyy.aria.core.queue.UploadTaskQueue; import com.arialyy.aria.core.queue.UploadTaskQueue;
import com.arialyy.aria.core.upload.UploadTaskEntity; import com.arialyy.aria.core.upload.UploadTaskEntity;
import com.arialyy.aria.orm.DbEntity; import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.NetUtils; import com.arialyy.aria.util.NetUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -34,7 +34,7 @@ final class ResumeAllCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
@Override public void executeCmd() { @Override public void executeCmd() {
if (!NetUtils.isConnected(AriaManager.APP)) { if (!NetUtils.isConnected(AriaManager.APP)) {
Log.w(TAG, "恢复任务失败,网络未连接"); ALog.w(TAG, "恢复任务失败,网络未连接");
return; return;
} }
if (isDownloadCmd) { if (isDownloadCmd) {

@ -17,7 +17,6 @@
package com.arialyy.aria.core.command.normal; package com.arialyy.aria.core.command.normal;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.common.QueueMod; import com.arialyy.aria.core.common.QueueMod;
import com.arialyy.aria.core.download.DownloadGroupTaskEntity; import com.arialyy.aria.core.download.DownloadGroupTaskEntity;
@ -30,6 +29,7 @@ import com.arialyy.aria.core.queue.DownloadTaskQueue;
import com.arialyy.aria.core.queue.UploadTaskQueue; import com.arialyy.aria.core.queue.UploadTaskQueue;
import com.arialyy.aria.core.upload.UploadTaskEntity; import com.arialyy.aria.core.upload.UploadTaskEntity;
import com.arialyy.aria.orm.DbEntity; import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.NetUtils; import com.arialyy.aria.util.NetUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -48,7 +48,7 @@ class StartCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
@Override public void executeCmd() { @Override public void executeCmd() {
if (!canExeCmd) return; if (!canExeCmd) return;
if (!NetUtils.isConnected(AriaManager.APP)) { if (!NetUtils.isConnected(AriaManager.APP)) {
Log.w(TAG, "启动任务失败,网络未连接"); ALog.e(TAG, "启动任务失败,网络未连接");
return; return;
} }
String mod; String mod;

@ -17,10 +17,10 @@
package com.arialyy.aria.core.command.normal; package com.arialyy.aria.core.command.normal;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.inf.AbsTask; import com.arialyy.aria.core.inf.AbsTask;
import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.util.ALog;
/** /**
* Created by lyy on 2016/9/20. * Created by lyy on 2016/9/20.
@ -39,7 +39,7 @@ class StopCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
if (mTaskEntity.getEntity().getState() == IEntity.STATE_RUNNING) { if (mTaskEntity.getEntity().getState() == IEntity.STATE_RUNNING) {
stopTask(); stopTask();
} else { } else {
Log.w(TAG, "停止命令执行失败,【调度器中没有该任务】"); ALog.w(TAG, "停止命令执行失败,【调度器中没有该任务】");
} }
} else { } else {
if (!TextUtils.isEmpty(mTargetName)) { if (!TextUtils.isEmpty(mTargetName)) {

@ -16,7 +16,6 @@
package com.arialyy.aria.core.common; package com.arialyy.aria.core.common;
import android.content.Context; import android.content.Context;
import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.download.DownloadTaskEntity; import com.arialyy.aria.core.download.DownloadTaskEntity;
@ -25,6 +24,7 @@ import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.core.inf.IDownloadListener; import com.arialyy.aria.core.inf.IDownloadListener;
import com.arialyy.aria.core.inf.IEventListener; import com.arialyy.aria.core.inf.IEventListener;
import com.arialyy.aria.core.upload.UploadTaskEntity; import com.arialyy.aria.core.upload.UploadTaskEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.io.File; import java.io.File;
import java.util.Properties; import java.util.Properties;
@ -264,7 +264,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
*/ */
private boolean resumeRecordLocation(int i, long startL, long endL) { private boolean resumeRecordLocation(int i, long startL, long endL) {
mConstance.CURRENT_LOCATION += endL - startL; mConstance.CURRENT_LOCATION += endL - startL;
Log.d(TAG, "++++++++++ 线程_" + i + "_已经下载完成 ++++++++++"); ALog.d(TAG, "++++++++++ 线程_" + i + "_已经下载完成 ++++++++++");
mConstance.COMPLETE_THREAD_NUM++; mConstance.COMPLETE_THREAD_NUM++;
mConstance.STOP_NUM++; mConstance.STOP_NUM++;
mConstance.CANCEL_NUM++; mConstance.CANCEL_NUM++;
@ -332,7 +332,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
mConstance.CURRENT_LOCATION += r - startL; mConstance.CURRENT_LOCATION += r - startL;
startL = r; startL = r;
} }
Log.d(TAG, "任务【" + mEntity.getFileName() + "】线程__" + i + "__恢复下载"); ALog.d(TAG, "任务【" + mEntity.getFileName() + "】线程__" + i + "__恢复下载");
recordL[rl] = i; recordL[rl] = i;
rl++; rl++;
} else { } else {

@ -16,12 +16,12 @@
package com.arialyy.aria.core.common; package com.arialyy.aria.core.common;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.FtpUrlEntity; import com.arialyy.aria.core.FtpUrlEntity;
import com.arialyy.aria.core.inf.AbsEntity; import com.arialyy.aria.core.inf.AbsEntity;
import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.core.upload.UploadEntity; import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.Regular; import com.arialyy.aria.util.Regular;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
@ -73,11 +73,6 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
if (client == null) return; if (client == null) return;
String remotePath = String remotePath =
new String(setRemotePath().getBytes(charSet), AbsFtpThreadTask.SERVER_CHARSET); new String(setRemotePath().getBytes(charSet), AbsFtpThreadTask.SERVER_CHARSET);
FTPFile[] files_1 = client.listFiles();
for (FTPFile tf : files_1) {
Log.d(TAG, tf.getName());
}
FTPFile[] files = client.listFiles(remotePath); FTPFile[] files = client.listFiles(remotePath);
boolean isExist = files.length != 0; boolean isExist = files.length != 0;
if (!isExist && !isUpload) { if (!isExist && !isUpload) {
@ -186,7 +181,7 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
charSet = "UTF-8"; charSet = "UTF-8";
if (!TextUtils.isEmpty(mTaskEntity.charSet) || !FTPReply.isPositiveCompletion( if (!TextUtils.isEmpty(mTaskEntity.charSet) || !FTPReply.isPositiveCompletion(
client.sendCommand("OPTS UTF8", "ON"))) { client.sendCommand("OPTS UTF8", "ON"))) {
Log.d(TAG, "FTP 服务器不支持开启UTF8编码,尝试使用Aria手动设置的编码"); ALog.i(TAG, "FTP 服务器不支持开启UTF8编码,尝试使用Aria手动设置的编码");
charSet = mTaskEntity.charSet; charSet = mTaskEntity.charSet;
} }
client.setControlEncoding(charSet); client.setControlEncoding(charSet);
@ -210,8 +205,15 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
return client; return client;
} catch (IOException e) { } catch (IOException e) {
//e.printStackTrace(); //e.printStackTrace();
try {
if (client.isConnected()) {
client.disconnect();
}
} catch (IOException e1) {
e1.printStackTrace();
}
if (index + 1 >= ips.length) { if (index + 1 >= ips.length) {
Log.e(TAG, "遇到[ECONNREFUSED-连接被服务器拒绝]错误,已没有其他地址,链接失败"); ALog.w(TAG, "遇到[ECONNREFUSED-连接被服务器拒绝]错误,已没有其他地址,链接失败");
return null; return null;
} }
try { try {
@ -219,7 +221,7 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
} catch (InterruptedException e1) { } catch (InterruptedException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
Log.e(TAG, "遇到[ECONNREFUSED-连接被服务器拒绝]错误,正在尝试下一个地址"); ALog.w(TAG, "遇到[ECONNREFUSED-连接被服务器拒绝]错误,正在尝试下一个地址");
return connect(new FTPClient(), ips, index + 1, port); return connect(new FTPClient(), ips, index + 1, port);
} }
} }
@ -255,7 +257,7 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
} }
private void failDownload(String errorMsg, boolean needRetry) { private void failDownload(String errorMsg, boolean needRetry) {
Log.e(TAG, errorMsg); ALog.e(TAG, errorMsg);
if (mCallback != null) { if (mCallback != null) {
mCallback.onFail(mEntity.getKey(), errorMsg, needRetry); mCallback.onFail(mEntity.getKey(), errorMsg, needRetry);
} }

@ -17,12 +17,12 @@ package com.arialyy.aria.core.common;
import android.os.Build; import android.os.Build;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.inf.AbsNormalEntity; import com.arialyy.aria.core.inf.AbsNormalEntity;
import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.core.inf.IEventListener; import com.arialyy.aria.core.inf.IEventListener;
import com.arialyy.aria.core.upload.UploadEntity; import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.util.ErrorHelp; import com.arialyy.aria.util.ErrorHelp;
import com.arialyy.aria.util.NetUtils; import com.arialyy.aria.util.NetUtils;
@ -103,7 +103,7 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
if (mConfig.SUPPORT_BP) { if (mConfig.SUPPORT_BP) {
final long currentTemp = mChildCurrentLocation; final long currentTemp = mChildCurrentLocation;
STATE.STOP_NUM++; STATE.STOP_NUM++;
Log.d(TAG, "任务【" ALog.d(TAG, "任务【"
+ mConfig.TEMP_FILE.getName() + mConfig.TEMP_FILE.getName()
+ "】thread__" + "】thread__"
+ mConfig.THREAD_ID + mConfig.THREAD_ID
@ -111,12 +111,12 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
+ currentTemp); + currentTemp);
writeConfig(false, currentTemp); writeConfig(false, currentTemp);
if (STATE.isStop()) { if (STATE.isStop()) {
Log.d(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】已停止"); ALog.i(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】已停止");
STATE.isRunning = false; STATE.isRunning = false;
mListener.onStop(STATE.CURRENT_LOCATION); mListener.onStop(STATE.CURRENT_LOCATION);
} }
} else { } else {
Log.d(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】已停止"); ALog.i(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】已停止");
STATE.isRunning = false; STATE.isRunning = false;
mListener.onStop(STATE.CURRENT_LOCATION); mListener.onStop(STATE.CURRENT_LOCATION);
} }
@ -157,7 +157,7 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
synchronized (AriaManager.LOCK) { synchronized (AriaManager.LOCK) {
if (mConfig.SUPPORT_BP) { if (mConfig.SUPPORT_BP) {
STATE.CANCEL_NUM++; STATE.CANCEL_NUM++;
Log.d(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】thread__" + mConfig.THREAD_ID + "__取消"); ALog.d(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】thread__" + mConfig.THREAD_ID + "__取消");
if (STATE.isCancel()) { if (STATE.isCancel()) {
File configFile = new File(mConfigFPath); File configFile = new File(mConfigFPath);
if (configFile.exists()) { if (configFile.exists()) {
@ -166,12 +166,12 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
if (mConfig.TEMP_FILE.exists() && !(mEntity instanceof UploadEntity)) { if (mConfig.TEMP_FILE.exists() && !(mEntity instanceof UploadEntity)) {
mConfig.TEMP_FILE.delete(); mConfig.TEMP_FILE.delete();
} }
Log.d(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】已取消"); ALog.d(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】已取消");
STATE.isRunning = false; STATE.isRunning = false;
mListener.onCancel(); mListener.onCancel();
} }
} else { } else {
Log.d(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】已取消"); ALog.d(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】已取消");
STATE.isRunning = false; STATE.isRunning = false;
mListener.onCancel(); mListener.onCancel();
} }
@ -185,15 +185,15 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
synchronized (AriaManager.LOCK) { synchronized (AriaManager.LOCK) {
try { try {
if (ex != null) { if (ex != null) {
Log.e(TAG, msg + "\n" + CommonUtil.getPrintException(ex)); ALog.e(TAG, msg + "\n" + CommonUtil.getPrintException(ex));
} else { } else {
Log.e(TAG, msg); ALog.e(TAG, msg);
} }
if (mConfig.SUPPORT_BP) { if (mConfig.SUPPORT_BP) {
writeConfig(false, currentLocation); writeConfig(false, currentLocation);
retryThis(STATE.THREAD_NUM != 1); retryThis(STATE.THREAD_NUM != 1);
} else { } else {
Log.e(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】执行失败"); ALog.e(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】执行失败");
mListener.onFail(true); mListener.onFail(true);
ErrorHelp.saveError(mTaskType, mEntity, "", CommonUtil.getPrintException(ex)); ErrorHelp.saveError(mTaskType, mEntity, "", CommonUtil.getPrintException(ex));
} }
@ -210,7 +210,7 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
*/ */
private void retryThis(boolean needRetry) { private void retryThis(boolean needRetry) {
if (!NetUtils.isConnected(AriaManager.APP)) { if (!NetUtils.isConnected(AriaManager.APP)) {
Log.w(TAG, ALog.w(TAG,
"任务【" + mConfig.TEMP_FILE.getName() + "】thread__" + mConfig.THREAD_ID + "__重试失败,网络未连接"); "任务【" + mConfig.TEMP_FILE.getName() + "】thread__" + mConfig.THREAD_ID + "__重试失败,网络未连接");
} }
if (mFailNum < RETRY_NUM && needRetry && NetUtils.isConnected(AriaManager.APP)) { if (mFailNum < RETRY_NUM && needRetry && NetUtils.isConnected(AriaManager.APP)) {
@ -222,7 +222,7 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
mFailTimer.schedule(new TimerTask() { mFailTimer.schedule(new TimerTask() {
@Override public void run() { @Override public void run() {
mFailNum++; mFailNum++;
Log.w(TAG, ALog.w(TAG,
"任务【" + mConfig.TEMP_FILE.getName() + "】thread__" + mConfig.THREAD_ID + "__正在重试"); "任务【" + mConfig.TEMP_FILE.getName() + "】thread__" + mConfig.THREAD_ID + "__正在重试");
final long retryLocation = final long retryLocation =
mChildCurrentLocation == 0 ? mConfig.START_LOCATION : mChildCurrentLocation; mChildCurrentLocation == 0 ? mConfig.START_LOCATION : mChildCurrentLocation;
@ -235,7 +235,7 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
if (STATE.isFail()) { if (STATE.isFail()) {
STATE.isRunning = false; STATE.isRunning = false;
STATE.isStop = true; STATE.isStop = true;
Log.e(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】执行失败"); ALog.e(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】执行失败");
mListener.onFail(true); mListener.onFail(true);
} }
} }

@ -16,8 +16,8 @@
package com.arialyy.aria.core.download; package com.arialyy.aria.core.download;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.orm.DbEntity; import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CheckUtil; import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.util.List; import java.util.List;
@ -67,7 +67,7 @@ public class DownloadGroupTarget
*/ */
public DownloadGroupTarget setFileSize(long fileSize) { public DownloadGroupTarget setFileSize(long fileSize) {
if (fileSize <= 0) { if (fileSize <= 0) {
Log.w(TAG, "文件大小不能小于 0"); ALog.e(TAG, "文件大小不能小于 0");
return this; return this;
} }
if (mEntity.getFileSize() <= 1 || mEntity.getFileSize() != fileSize) { if (mEntity.getFileSize() <= 1 || mEntity.getFileSize() != fileSize) {

@ -24,6 +24,7 @@ import com.arialyy.aria.core.download.downloader.FtpDirDownloadUtil;
import com.arialyy.aria.core.inf.AbsGroupTask; import com.arialyy.aria.core.inf.AbsGroupTask;
import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.core.scheduler.ISchedulers; import com.arialyy.aria.core.scheduler.ISchedulers;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CheckUtil; import com.arialyy.aria.util.CheckUtil;
/** /**
@ -47,6 +48,7 @@ public class DownloadGroupTask extends AbsGroupTask<DownloadGroupTaskEntity> {
mUtil = new FtpDirDownloadUtil(mListener, mTaskEntity); mUtil = new FtpDirDownloadUtil(mListener, mTaskEntity);
break; break;
} }
Log.d(TAG, "FTP_TASK_MD5:" + mTaskEntity.hashCode());
} }
@Override public boolean isRunning() { @Override public boolean isRunning() {
@ -59,7 +61,7 @@ public class DownloadGroupTask extends AbsGroupTask<DownloadGroupTaskEntity> {
@Override public void start() { @Override public void start() {
if (mUtil.isRunning()) { if (mUtil.isRunning()) {
Log.d(TAG, "任务正在下载"); ALog.d(TAG, "任务正在下载");
} else { } else {
mUtil.start(); mUtil.start();
} }

@ -18,12 +18,12 @@ package com.arialyy.aria.core.download;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.common.IUtil; import com.arialyy.aria.core.common.IUtil;
import com.arialyy.aria.core.download.downloader.SimpleDownloadUtil; import com.arialyy.aria.core.download.downloader.SimpleDownloadUtil;
import com.arialyy.aria.core.inf.AbsNormalTask; import com.arialyy.aria.core.inf.AbsNormalTask;
import com.arialyy.aria.core.scheduler.ISchedulers; import com.arialyy.aria.core.scheduler.ISchedulers;
import com.arialyy.aria.util.ALog;
import java.io.File; import java.io.File;
/** /**
@ -115,7 +115,7 @@ public class DownloadTask extends AbsNormalTask<DownloadTaskEntity> {
@Override public void start() { @Override public void start() {
mListener.isWait = false; mListener.isWait = false;
if (mUtil.isRunning()) { if (mUtil.isRunning()) {
Log.d(TAG, "任务正在下载"); ALog.d(TAG, "任务正在下载");
} else { } else {
mUtil.start(); mUtil.start();
} }

@ -19,6 +19,7 @@ import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.orm.DbEntity; import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
/** /**
@ -34,6 +35,7 @@ public class FtpDirDownloadTarget
mTargetName = targetName; mTargetName = targetName;
mTaskEntity.urlEntity = CommonUtil.getFtpUrlInfo(url); mTaskEntity.urlEntity = CommonUtil.getFtpUrlInfo(url);
mTaskEntity.requestType = AbsTaskEntity.FTP_DIR; mTaskEntity.requestType = AbsTaskEntity.FTP_DIR;
Log.d(TAG, "FTP_TARGET_MD5:" + mTaskEntity.hashCode());
} }
private void init(String key) { private void init(String key) {
@ -77,10 +79,10 @@ public class FtpDirDownloadTarget
*/ */
public FtpDirDownloadTarget login(String userName, String password, String account) { public FtpDirDownloadTarget login(String userName, String password, String account) {
if (TextUtils.isEmpty(userName)) { if (TextUtils.isEmpty(userName)) {
Log.e(TAG, "用户名不能为null"); ALog.e(TAG, "用户名不能为null");
return this; return this;
} else if (TextUtils.isEmpty(password)) { } else if (TextUtils.isEmpty(password)) {
Log.e(TAG, "密码不能为null"); ALog.e(TAG, "密码不能为null");
return this; return this;
} }
mTaskEntity.urlEntity.needLogin = true; mTaskEntity.urlEntity.needLogin = true;

@ -19,6 +19,7 @@ import android.support.annotation.NonNull;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.io.File; import java.io.File;
@ -100,10 +101,10 @@ public class FtpDownloadTarget extends DownloadTarget {
*/ */
public FtpDownloadTarget login(String userName, String password, String account) { public FtpDownloadTarget login(String userName, String password, String account) {
if (TextUtils.isEmpty(userName)) { if (TextUtils.isEmpty(userName)) {
Log.e(TAG, "用户名不能为null"); ALog.e(TAG, "用户名不能为null");
return this; return this;
} else if (TextUtils.isEmpty(password)) { } else if (TextUtils.isEmpty(password)) {
Log.e(TAG, "密码不能为null"); ALog.e(TAG, "密码不能为null");
return this; return this;
} }
mTaskEntity.urlEntity.needLogin = true; mTaskEntity.urlEntity.needLogin = true;

@ -15,8 +15,8 @@
*/ */
package com.arialyy.aria.core.download.downloader; package com.arialyy.aria.core.download.downloader;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.FtpUrlEntity;
import com.arialyy.aria.core.common.IUtil; import com.arialyy.aria.core.common.IUtil;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadGroupTaskEntity; import com.arialyy.aria.core.download.DownloadGroupTaskEntity;
@ -24,6 +24,7 @@ import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.inf.IDownloadListener; import com.arialyy.aria.core.inf.IDownloadListener;
import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.orm.DbEntity; import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.util.NetUtils; import com.arialyy.aria.util.NetUtils;
import java.io.File; import java.io.File;
@ -201,11 +202,11 @@ public abstract class AbsGroupUtil implements IUtil {
DownloadTaskEntity entity = mTasksMap.get(url); DownloadTaskEntity entity = mTasksMap.get(url);
if (entity != null) { if (entity != null) {
if (entity.getState() == IEntity.STATE_COMPLETE) { if (entity.getState() == IEntity.STATE_COMPLETE) {
Log.w(TAG, "任务【" + url + "】已完成," + type + "失败"); ALog.w(TAG, "任务【" + url + "】已完成," + type + "失败");
return false; return false;
} }
} else { } else {
Log.w(TAG, "任务组中没有该任务【" + url + "】," + type + "失败"); ALog.w(TAG, "任务组中没有该任务【" + url + "】," + type + "失败");
return false; return false;
} }
return true; return true;
@ -387,7 +388,7 @@ public abstract class AbsGroupUtil implements IUtil {
if (taskEntity != null) { if (taskEntity != null) {
taskEntity.entity = entity; taskEntity.entity = entity;
//ftp登录的 //ftp登录的
taskEntity.urlEntity = mTaskEntity.urlEntity; taskEntity.urlEntity = createFtpUrlEntity(entity);
mTasksMap.put(entity.getUrl(), taskEntity); mTasksMap.put(entity.getUrl(), taskEntity);
return taskEntity; return taskEntity;
} }
@ -401,13 +402,18 @@ public abstract class AbsGroupUtil implements IUtil {
taskEntity.isGroupTask = true; taskEntity.isGroupTask = true;
taskEntity.requestType = mTaskEntity.requestType; taskEntity.requestType = mTaskEntity.requestType;
//ftp登录的 //ftp登录的
taskEntity.urlEntity = mTaskEntity.urlEntity; taskEntity.urlEntity = createFtpUrlEntity(entity);
taskEntity.key = entity.getDownloadPath();
taskEntity.save(); taskEntity.save();
mTasksMap.put(entity.getUrl(), taskEntity); mTasksMap.put(entity.getUrl(), taskEntity);
return taskEntity; return taskEntity;
} }
private FtpUrlEntity createFtpUrlEntity(DownloadEntity entity) {
FtpUrlEntity urlEntity = CommonUtil.getFtpUrlInfo(entity.getUrl());
urlEntity.validAddr = mTaskEntity.urlEntity.validAddr;
return urlEntity;
}
/** /**
* 子任务事件监听 * 子任务事件监听
*/ */

@ -15,7 +15,6 @@
*/ */
package com.arialyy.aria.core.download.downloader; package com.arialyy.aria.core.download.downloader;
import android.util.Log;
import com.arialyy.aria.core.common.AbsFileer; import com.arialyy.aria.core.common.AbsFileer;
import com.arialyy.aria.core.common.AbsThreadTask; import com.arialyy.aria.core.common.AbsThreadTask;
import com.arialyy.aria.core.common.SubThreadConfig; import com.arialyy.aria.core.common.SubThreadConfig;
@ -24,6 +23,7 @@ import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.core.inf.IDownloadListener; import com.arialyy.aria.core.inf.IDownloadListener;
import com.arialyy.aria.orm.DbEntity; import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.BufferedRandomAccessFile; import com.arialyy.aria.util.BufferedRandomAccessFile;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.util.ErrorHelp; import com.arialyy.aria.util.ErrorHelp;
@ -102,7 +102,7 @@ class Downloader extends AbsFileer<DownloadEntity, DownloadTaskEntity> {
private void failDownload(String errorMsg) { private void failDownload(String errorMsg) {
closeTimer(); closeTimer();
Log.e(TAG, errorMsg); ALog.e(TAG, errorMsg);
mConstance.isRunning = false; mConstance.isRunning = false;
mListener.onFail(false); mListener.onFail(false);
ErrorHelp.saveError("", mEntity, "", errorMsg); ErrorHelp.saveError("", mEntity, "", errorMsg);

@ -15,6 +15,7 @@
*/ */
package com.arialyy.aria.core.download.downloader; package com.arialyy.aria.core.download.downloader;
import com.arialyy.aria.core.FtpUrlEntity;
import com.arialyy.aria.core.common.AbsFtpInfoThread; import com.arialyy.aria.core.common.AbsFtpInfoThread;
import com.arialyy.aria.core.common.OnFileInfoCallback; import com.arialyy.aria.core.common.OnFileInfoCallback;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
@ -52,8 +53,10 @@ class FtpDirInfoThread extends AbsFtpInfoThread<DownloadGroupEntity, DownloadGro
} }
private void addEntity(String remotePath, FTPFile ftpFile) { private void addEntity(String remotePath, FTPFile ftpFile) {
final FtpUrlEntity urlEntity = mTaskEntity.urlEntity;
DownloadEntity entity = new DownloadEntity(); DownloadEntity entity = new DownloadEntity();
entity.setUrl(mTaskEntity.urlEntity.url); entity.setUrl(
urlEntity.protocol + "://" + urlEntity.hostName + ":" + urlEntity.port + remotePath);
entity.setDownloadPath(mEntity.getDirPath() + "/" + remotePath); entity.setDownloadPath(mEntity.getDirPath() + "/" + remotePath);
int lastIndex = remotePath.lastIndexOf("/"); int lastIndex = remotePath.lastIndexOf("/");
String fileName = lastIndex < 0 ? CommonUtil.keyToHashKey(remotePath) String fileName = lastIndex < 0 ? CommonUtil.keyToHashKey(remotePath)

@ -15,13 +15,13 @@
*/ */
package com.arialyy.aria.core.download.downloader; package com.arialyy.aria.core.download.downloader;
import android.util.Log;
import com.arialyy.aria.core.common.AbsFtpThreadTask; import com.arialyy.aria.core.common.AbsFtpThreadTask;
import com.arialyy.aria.core.common.StateConstance; import com.arialyy.aria.core.common.StateConstance;
import com.arialyy.aria.core.common.SubThreadConfig; import com.arialyy.aria.core.common.SubThreadConfig;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity; import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.inf.IDownloadListener; import com.arialyy.aria.core.inf.IDownloadListener;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.BufferedRandomAccessFile; import com.arialyy.aria.util.BufferedRandomAccessFile;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -48,7 +48,7 @@ class FtpThreadTask extends AbsFtpThreadTask<DownloadEntity, DownloadTaskEntity>
InputStream is = null; InputStream is = null;
BufferedRandomAccessFile file = null; BufferedRandomAccessFile file = null;
try { try {
Log.d(TAG, "任务【" ALog.d(TAG, "任务【"
+ mConfig.TEMP_FILE.getName() + mConfig.TEMP_FILE.getName()
+ "】线程__" + "】线程__"
+ mConfig.THREAD_ID + mConfig.THREAD_ID
@ -90,7 +90,7 @@ class FtpThreadTask extends AbsFtpThreadTask<DownloadEntity, DownloadTaskEntity>
} }
} }
if (STATE.isCancel || STATE.isStop) return; if (STATE.isCancel || STATE.isStop) return;
Log.i(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】线程__" + mConfig.THREAD_ID + "__下载完毕"); ALog.i(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】线程__" + mConfig.THREAD_ID + "__下载完毕");
writeConfig(true, 1); writeConfig(true, 1);
STATE.COMPLETE_THREAD_NUM++; STATE.COMPLETE_THREAD_NUM++;
if (STATE.isComplete()) { if (STATE.isComplete()) {

@ -16,11 +16,11 @@
package com.arialyy.aria.core.download.downloader; package com.arialyy.aria.core.download.downloader;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.common.OnFileInfoCallback; import com.arialyy.aria.core.common.OnFileInfoCallback;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity; import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.io.IOException; import java.io.IOException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
@ -127,7 +127,7 @@ class HttpFileInfoThread implements Runnable {
*/ */
private void handle302Turn(HttpURLConnection conn) throws IOException { private void handle302Turn(HttpURLConnection conn) throws IOException {
String newUrl = conn.getHeaderField(mTaskEntity.redirectUrlKey); String newUrl = conn.getHeaderField(mTaskEntity.redirectUrlKey);
Log.d(TAG, "30x跳转,location【 " + mTaskEntity.redirectUrlKey + "】" + "新url为【" + newUrl + "】"); ALog.d(TAG, "30x跳转,location【 " + mTaskEntity.redirectUrlKey + "】" + "新url为【" + newUrl + "】");
if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) { if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) {
if (onFileInfoListener != null) { if (onFileInfoListener != null) {
onFileInfoListener.onFail(mEntity.getUrl(), "获取重定向链接失败", false); onFileInfoListener.onFail(mEntity.getUrl(), "获取重定向链接失败", false);
@ -163,7 +163,7 @@ class HttpFileInfoThread implements Runnable {
} }
private void failDownload(String errorMsg, boolean needRetry) { private void failDownload(String errorMsg, boolean needRetry) {
Log.e(TAG, errorMsg); ALog.e(TAG, errorMsg);
if (onFileInfoListener != null) { if (onFileInfoListener != null) {
onFileInfoListener.onFail(mEntity.getUrl(), errorMsg, needRetry); onFileInfoListener.onFail(mEntity.getUrl(), errorMsg, needRetry);
} }

@ -15,19 +15,18 @@
*/ */
package com.arialyy.aria.core.download.downloader; package com.arialyy.aria.core.download.downloader;
import android.util.Log;
import com.arialyy.aria.core.common.AbsThreadTask; import com.arialyy.aria.core.common.AbsThreadTask;
import com.arialyy.aria.core.common.StateConstance; import com.arialyy.aria.core.common.StateConstance;
import com.arialyy.aria.core.common.SubThreadConfig; import com.arialyy.aria.core.common.SubThreadConfig;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity; import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.inf.IDownloadListener; import com.arialyy.aria.core.inf.IDownloadListener;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.BufferedRandomAccessFile; import com.arialyy.aria.util.BufferedRandomAccessFile;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
@ -54,7 +53,7 @@ final class HttpThreadTask extends AbsThreadTask<DownloadEntity, DownloadTaskEnt
URL url = new URL(CommonUtil.convertUrl(mConfig.URL)); URL url = new URL(CommonUtil.convertUrl(mConfig.URL));
conn = ConnectionHelp.handleConnection(url); conn = ConnectionHelp.handleConnection(url);
if (mConfig.SUPPORT_BP) { if (mConfig.SUPPORT_BP) {
Log.d(TAG, "任务【" ALog.d(TAG, "任务【"
+ mConfig.TEMP_FILE.getName() + mConfig.TEMP_FILE.getName()
+ "】线程__" + "】线程__"
+ mConfig.THREAD_ID + mConfig.THREAD_ID
@ -67,7 +66,7 @@ final class HttpThreadTask extends AbsThreadTask<DownloadEntity, DownloadTaskEnt
conn.setRequestProperty("Range", conn.setRequestProperty("Range",
"bytes=" + mConfig.START_LOCATION + "-" + (mConfig.END_LOCATION - 1)); "bytes=" + mConfig.START_LOCATION + "-" + (mConfig.END_LOCATION - 1));
} else { } else {
Log.w(TAG, "该下载不支持断点"); ALog.w(TAG, "该下载不支持断点");
} }
conn = ConnectionHelp.setConnectParam(mConfig.TASK_ENTITY, conn); conn = ConnectionHelp.setConnectParam(mConfig.TASK_ENTITY, conn);
conn.setConnectTimeout(STATE.CONNECT_TIME_OUT); conn.setConnectTimeout(STATE.CONNECT_TIME_OUT);
@ -90,7 +89,7 @@ final class HttpThreadTask extends AbsThreadTask<DownloadEntity, DownloadTaskEnt
if (STATE.isCancel || STATE.isStop) return; if (STATE.isCancel || STATE.isStop) return;
//支持断点的处理 //支持断点的处理
if (mConfig.SUPPORT_BP) { if (mConfig.SUPPORT_BP) {
Log.i(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】线程__" + mConfig.THREAD_ID + "__下载完毕"); ALog.i(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】线程__" + mConfig.THREAD_ID + "__下载完毕");
writeConfig(true, 1); writeConfig(true, 1);
STATE.COMPLETE_THREAD_NUM++; STATE.COMPLETE_THREAD_NUM++;
if (STATE.isComplete()) { if (STATE.isComplete()) {
@ -102,7 +101,7 @@ final class HttpThreadTask extends AbsThreadTask<DownloadEntity, DownloadTaskEnt
mListener.onComplete(); mListener.onComplete();
} }
} else { } else {
Log.i(TAG, "下载任务完成"); ALog.i(TAG, "下载任务完成");
STATE.isRunning = false; STATE.isRunning = false;
mListener.onComplete(); mListener.onComplete();
} }

@ -16,10 +16,10 @@
package com.arialyy.aria.core.inf; package com.arialyy.aria.core.inf;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.command.normal.NormalCmdFactory; import com.arialyy.aria.core.command.normal.NormalCmdFactory;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
/** /**
@ -107,7 +107,7 @@ public abstract class AbsDownloadTarget<TARGET extends AbsTarget, ENTITY extends
*/ */
public void setRedirectUrlKey(String redirectUrlKey) { public void setRedirectUrlKey(String redirectUrlKey) {
if (TextUtils.isEmpty(redirectUrlKey)) { if (TextUtils.isEmpty(redirectUrlKey)) {
Log.w("AbsDownloadTarget", "重定向后,新url的key不能为null"); ALog.e("AbsDownloadTarget", "重定向后,新url的key不能为null");
return; return;
} }
mTaskEntity.redirectUrlKey = redirectUrlKey; mTaskEntity.redirectUrlKey = redirectUrlKey;

@ -17,7 +17,6 @@ package com.arialyy.aria.core.inf;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.command.ICmd; import com.arialyy.aria.core.command.ICmd;
import com.arialyy.aria.core.command.normal.CancelCmd; import com.arialyy.aria.core.command.normal.CancelCmd;
@ -26,6 +25,7 @@ import com.arialyy.aria.core.common.RequestEnum;
import com.arialyy.aria.core.download.DownloadGroupTaskEntity; import com.arialyy.aria.core.download.DownloadGroupTaskEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity; import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.upload.UploadTaskEntity; import com.arialyy.aria.core.upload.UploadTaskEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -120,7 +120,7 @@ public abstract class AbsTarget<TARGET extends AbsTarget, ENTITY extends AbsEnti
*/ */
@Override public int getPercent() { @Override public int getPercent() {
if (mEntity == null) { if (mEntity == null) {
Log.e("AbsTarget", "下载管理器中没有该任务"); ALog.e("AbsTarget", "下载管理器中没有该任务");
return 0; return 0;
} }
if (mEntity.getFileSize() != 0) { if (mEntity.getFileSize() != 0) {

@ -50,8 +50,6 @@ public abstract class AbsTaskEntity<ENTITY extends AbsEntity> extends DbEntity {
* 账号和密码 * 账号和密码
*/ */
@Ignore public FtpUrlEntity urlEntity; @Ignore public FtpUrlEntity urlEntity;
//@Ignore public String userName, userPw, account, serverIp;
//@Ignore public int port;
/** /**
* 刷新信息 {@code true} 重新刷新下载信息 * 刷新信息 {@code true} 重新刷新下载信息

@ -16,13 +16,13 @@
package com.arialyy.aria.core.queue; package com.arialyy.aria.core.queue;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.inf.AbsTask; import com.arialyy.aria.core.inf.AbsTask;
import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.queue.pool.BaseCachePool; import com.arialyy.aria.core.queue.pool.BaseCachePool;
import com.arialyy.aria.core.queue.pool.BaseExecutePool; import com.arialyy.aria.core.queue.pool.BaseExecutePool;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.NetUtils; import com.arialyy.aria.util.NetUtils;
/** /**
@ -114,7 +114,7 @@ abstract class AbsTaskQueue<TASK extends AbsTask, TASK_ENTITY extends AbsTaskEnt
int oldMaxSize = getConfigMaxNum(); int oldMaxSize = getConfigMaxNum();
int diff = downloadNum - oldMaxSize; int diff = downloadNum - oldMaxSize;
if (oldMaxSize == downloadNum) { if (oldMaxSize == downloadNum) {
Log.d(TAG, "设置的下载任务数和配置文件的下载任务数一直,跳过"); ALog.e(TAG, "设置的下载任务数和配置文件的下载任务数一直,跳过");
return; return;
} }
//设置的任务数小于配置任务数 //设置的任务数小于配置任务数
@ -154,39 +154,39 @@ abstract class AbsTaskQueue<TASK extends AbsTask, TASK_ENTITY extends AbsTaskEnt
} }
@Override public void stopTask(TASK task) { @Override public void stopTask(TASK task) {
if (!task.isRunning()) Log.w(TAG, "停止任务失败,【任务已经停止】"); if (!task.isRunning()) ALog.w(TAG, "停止任务失败,【任务已经停止】");
if (mExecutePool.removeTask(task)) { if (mExecutePool.removeTask(task)) {
task.stop(); task.stop();
} else { } else {
task.stop(); task.stop();
Log.w(TAG, "删除任务失败,【执行队列中没有该任务】"); ALog.w(TAG, "删除任务失败,【执行队列中没有该任务】");
} }
} }
@Override public void removeTaskFormQueue(String key) { @Override public void removeTaskFormQueue(String key) {
TASK task = mExecutePool.getTask(key); TASK task = mExecutePool.getTask(key);
if (task != null) { if (task != null) {
Log.d(TAG, "从执行池删除任务,删除" + (mExecutePool.removeTask(task) ? "成功" : "失败")); ALog.d(TAG, "从执行池删除任务,删除" + (mExecutePool.removeTask(task) ? "成功" : "失败"));
} }
task = mCachePool.getTask(key); task = mCachePool.getTask(key);
if (task != null) { if (task != null) {
Log.d(TAG, "从缓存池删除任务,删除" + (mCachePool.removeTask(task) ? "成功" : "失败")); ALog.d(TAG, "从缓存池删除任务,删除" + (mCachePool.removeTask(task) ? "成功" : "失败"));
} }
} }
@Override public void reTryStart(TASK task) { @Override public void reTryStart(TASK task) {
if (task == null) { if (task == null) {
Log.w(TAG, "重试失败,task 为null"); ALog.e(TAG, "重试失败,task 为null");
return; return;
} }
if (!NetUtils.isConnected(AriaManager.APP)) { if (!NetUtils.isConnected(AriaManager.APP)) {
Log.w(TAG, "重试失败,网络未连接"); ALog.e(TAG, "重试失败,网络未连接");
return; return;
} }
if (!task.isRunning()) { if (!task.isRunning()) {
task.start(); task.start();
} else { } else {
Log.w(TAG, "任务没有完全停止,重试下载失败"); ALog.e(TAG, "任务没有完全停止,重试下载失败");
} }
} }

@ -17,15 +17,14 @@
package com.arialyy.aria.core.queue; package com.arialyy.aria.core.queue;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.download.DownloadGroupEntity;
import com.arialyy.aria.core.download.DownloadGroupTask; import com.arialyy.aria.core.download.DownloadGroupTask;
import com.arialyy.aria.core.download.DownloadGroupTaskEntity; import com.arialyy.aria.core.download.DownloadGroupTaskEntity;
import com.arialyy.aria.core.queue.pool.BaseCachePool; import com.arialyy.aria.core.queue.pool.BaseCachePool;
import com.arialyy.aria.core.queue.pool.BaseExecutePool; import com.arialyy.aria.core.queue.pool.BaseExecutePool;
import com.arialyy.aria.core.queue.pool.DownloadSharePool; import com.arialyy.aria.core.queue.pool.DownloadSharePool;
import com.arialyy.aria.core.scheduler.DownloadGroupSchedulers; import com.arialyy.aria.core.scheduler.DownloadGroupSchedulers;
import com.arialyy.aria.util.ALog;
/** /**
* Created by AriaL on 2017/6/29. * Created by AriaL on 2017/6/29.
@ -65,7 +64,7 @@ public class DownloadGroupTaskQueue
entity.key = entity.getEntity().getGroupName(); entity.key = entity.getEntity().getGroupName();
mCachePool.putTask(task); mCachePool.putTask(task);
} else { } else {
Log.e(TAG, "target name 为 null!!"); ALog.e(TAG, "target name 为 null!!");
} }
return task; return task;
} }

@ -17,15 +17,14 @@
package com.arialyy.aria.core.queue; package com.arialyy.aria.core.queue;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTask; import com.arialyy.aria.core.download.DownloadTask;
import com.arialyy.aria.core.download.DownloadTaskEntity; import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.queue.pool.BaseCachePool; import com.arialyy.aria.core.queue.pool.BaseCachePool;
import com.arialyy.aria.core.queue.pool.BaseExecutePool; import com.arialyy.aria.core.queue.pool.BaseExecutePool;
import com.arialyy.aria.core.queue.pool.DownloadSharePool; import com.arialyy.aria.core.queue.pool.DownloadSharePool;
import com.arialyy.aria.core.scheduler.DownloadSchedulers; import com.arialyy.aria.core.scheduler.DownloadSchedulers;
import com.arialyy.aria.util.ALog;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -75,7 +74,7 @@ public class DownloadTaskQueue
DownloadTask temp = exeTasks.get(key); DownloadTask temp = exeTasks.get(key);
if (temp != null && temp.isRunning() && temp.isHighestPriorityTask() && !temp.getKey() if (temp != null && temp.isRunning() && temp.isHighestPriorityTask() && !temp.getKey()
.equals(task.getKey())) { .equals(task.getKey())) {
Log.e(TAG, "设置最高优先级任务失败,失败原因【任务中已经有最高优先级任务,请等待上一个最高优先级任务完成,或手动暂停该任务】"); ALog.e(TAG, "设置最高优先级任务失败,失败原因【任务中已经有最高优先级任务,请等待上一个最高优先级任务完成,或手动暂停该任务】");
task.setHighestPriority(false); task.setHighestPriority(false);
return; return;
} }
@ -126,7 +125,7 @@ public class DownloadTaskQueue
entity.key = entity.getEntity().getDownloadPath(); entity.key = entity.getEntity().getDownloadPath();
mCachePool.putTask(task); mCachePool.putTask(task);
} else { } else {
Log.e(TAG, "target name 为 null!!"); ALog.e(TAG, "target name 为 null!!");
} }
return task; return task;

@ -17,15 +17,14 @@
package com.arialyy.aria.core.queue; package com.arialyy.aria.core.queue;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.queue.pool.BaseCachePool; import com.arialyy.aria.core.queue.pool.BaseCachePool;
import com.arialyy.aria.core.queue.pool.BaseExecutePool; import com.arialyy.aria.core.queue.pool.BaseExecutePool;
import com.arialyy.aria.core.queue.pool.UploadSharePool; import com.arialyy.aria.core.queue.pool.UploadSharePool;
import com.arialyy.aria.core.scheduler.UploadSchedulers; import com.arialyy.aria.core.scheduler.UploadSchedulers;
import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.core.upload.UploadTask; import com.arialyy.aria.core.upload.UploadTask;
import com.arialyy.aria.core.upload.UploadTaskEntity; import com.arialyy.aria.core.upload.UploadTaskEntity;
import com.arialyy.aria.util.ALog;
/** /**
* Created by lyy on 2017/2/27. * Created by lyy on 2017/2/27.
@ -67,7 +66,7 @@ public class UploadTaskQueue extends AbsTaskQueue<UploadTask, UploadTaskEntity>
entity.key = entity.getEntity().getFilePath(); entity.key = entity.getEntity().getFilePath();
mCachePool.putTask(task); mCachePool.putTask(task);
} else { } else {
Log.e(TAG, "target name 为 null是!!"); ALog.e(TAG, "target name 为 null是!!");
} }
return task; return task;
} }

@ -17,12 +17,10 @@
package com.arialyy.aria.core.queue.pool; package com.arialyy.aria.core.queue.pool;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.inf.AbsTask; import com.arialyy.aria.core.inf.AbsTask;
import com.arialyy.aria.core.inf.ITask; import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.util.HashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -87,16 +85,16 @@ public class BaseCachePool<TASK extends AbsTask> implements IPool<TASK> {
@Override public boolean putTask(TASK task) { @Override public boolean putTask(TASK task) {
synchronized (AriaManager.LOCK) { synchronized (AriaManager.LOCK) {
if (task == null) { if (task == null) {
Log.e(TAG, "下载任务不能为空!!"); ALog.e(TAG, "下载任务不能为空!!");
return false; return false;
} }
String url = task.getKey(); String url = task.getKey();
if (mCacheQueue.contains(task)) { if (mCacheQueue.contains(task)) {
Log.w(TAG, "队列中已经包含了该任务,任务下载链接【" + url + "】"); ALog.w(TAG, "队列中已经包含了该任务,任务下载链接【" + url + "】");
return false; return false;
} else { } else {
boolean s = mCacheQueue.offer(task); boolean s = mCacheQueue.offer(task);
Log.d(TAG, "任务添加" + (s ? "成功" : "失败,【" + url + "】")); ALog.d(TAG, "任务添加" + (s ? "成功" : "失败,【" + url + "】"));
if (s) { if (s) {
mCacheMap.put(CommonUtil.keyToHashKey(url), task); mCacheMap.put(CommonUtil.keyToHashKey(url), task);
} }
@ -125,7 +123,7 @@ public class BaseCachePool<TASK extends AbsTask> implements IPool<TASK> {
@Override public TASK getTask(String downloadUrl) { @Override public TASK getTask(String downloadUrl) {
synchronized (AriaManager.LOCK) { synchronized (AriaManager.LOCK) {
if (TextUtils.isEmpty(downloadUrl)) { if (TextUtils.isEmpty(downloadUrl)) {
Log.e(TAG, "请传入有效的下载链接"); ALog.e(TAG, "请传入有效的下载链接");
return null; return null;
} }
String key = CommonUtil.keyToHashKey(downloadUrl); String key = CommonUtil.keyToHashKey(downloadUrl);
@ -136,7 +134,7 @@ public class BaseCachePool<TASK extends AbsTask> implements IPool<TASK> {
@Override public boolean removeTask(TASK task) { @Override public boolean removeTask(TASK task) {
synchronized (AriaManager.LOCK) { synchronized (AriaManager.LOCK) {
if (task == null) { if (task == null) {
Log.e(TAG, "任务不能为空"); ALog.e(TAG, "任务不能为空");
return false; return false;
} else { } else {
String key = CommonUtil.keyToHashKey(task.getKey()); String key = CommonUtil.keyToHashKey(task.getKey());
@ -149,7 +147,7 @@ public class BaseCachePool<TASK extends AbsTask> implements IPool<TASK> {
@Override public boolean removeTask(String downloadUrl) { @Override public boolean removeTask(String downloadUrl) {
synchronized (AriaManager.LOCK) { synchronized (AriaManager.LOCK) {
if (TextUtils.isEmpty(downloadUrl)) { if (TextUtils.isEmpty(downloadUrl)) {
Log.e(TAG, "请传入有效的下载链接"); ALog.e(TAG, "请传入有效的下载链接");
return false; return false;
} }
String key = CommonUtil.keyToHashKey(downloadUrl); String key = CommonUtil.keyToHashKey(downloadUrl);

@ -17,9 +17,9 @@
package com.arialyy.aria.core.queue.pool; package com.arialyy.aria.core.queue.pool;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.inf.AbsTask; import com.arialyy.aria.core.inf.AbsTask;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ArrayBlockingQueue;
@ -62,12 +62,12 @@ public class BaseExecutePool<TASK extends AbsTask> implements IPool<TASK> {
@Override public boolean putTask(TASK task) { @Override public boolean putTask(TASK task) {
synchronized (AriaManager.LOCK) { synchronized (AriaManager.LOCK) {
if (task == null) { if (task == null) {
Log.e(TAG, "任务不能为空!!"); ALog.e(TAG, "任务不能为空!!");
return false; return false;
} }
String url = task.getKey(); String url = task.getKey();
if (mExecuteQueue.contains(task)) { if (mExecuteQueue.contains(task)) {
Log.e(TAG, "队列中已经包含了该任务,任务key【" + url + "】"); ALog.e(TAG, "队列中已经包含了该任务,任务key【" + url + "】");
return false; return false;
} else { } else {
if (mExecuteQueue.size() >= mSize) { if (mExecuteQueue.size() >= mSize) {
@ -112,7 +112,7 @@ public class BaseExecutePool<TASK extends AbsTask> implements IPool<TASK> {
synchronized (AriaManager.LOCK) { synchronized (AriaManager.LOCK) {
String url = newTask.getKey(); String url = newTask.getKey();
boolean s = mExecuteQueue.offer(newTask); boolean s = mExecuteQueue.offer(newTask);
Log.w(TAG, "任务添加" + (s ? "成功" : "失败,【" + url + "】")); ALog.d(TAG, "任务添加" + (s ? "成功" : "失败,【" + url + "】"));
if (s) { if (s) {
mExecuteMap.put(CommonUtil.keyToHashKey(url), newTask); mExecuteMap.put(CommonUtil.keyToHashKey(url), newTask);
} }
@ -128,7 +128,7 @@ public class BaseExecutePool<TASK extends AbsTask> implements IPool<TASK> {
try { try {
TASK oldTask = mExecuteQueue.poll(TIME_OUT, TimeUnit.MICROSECONDS); TASK oldTask = mExecuteQueue.poll(TIME_OUT, TimeUnit.MICROSECONDS);
if (oldTask == null) { if (oldTask == null) {
Log.e(TAG, "移除任务失败"); ALog.w(TAG, "移除任务失败");
return false; return false;
} }
oldTask.stop(); oldTask.stop();
@ -162,7 +162,7 @@ public class BaseExecutePool<TASK extends AbsTask> implements IPool<TASK> {
@Override public TASK getTask(String key) { @Override public TASK getTask(String key) {
synchronized (AriaManager.LOCK) { synchronized (AriaManager.LOCK) {
if (TextUtils.isEmpty(key)) { if (TextUtils.isEmpty(key)) {
Log.e(TAG, "请传入有效的任务key"); ALog.e(TAG, "请传入有效的任务key");
return null; return null;
} }
return mExecuteMap.get(CommonUtil.keyToHashKey(key)); return mExecuteMap.get(CommonUtil.keyToHashKey(key));
@ -172,7 +172,7 @@ public class BaseExecutePool<TASK extends AbsTask> implements IPool<TASK> {
@Override public boolean removeTask(TASK task) { @Override public boolean removeTask(TASK task) {
synchronized (AriaManager.LOCK) { synchronized (AriaManager.LOCK) {
if (task == null) { if (task == null) {
Log.e(TAG, "任务不能为空"); ALog.e(TAG, "任务不能为空");
return false; return false;
} else { } else {
return removeTask(task.getKey()); return removeTask(task.getKey());
@ -183,7 +183,7 @@ public class BaseExecutePool<TASK extends AbsTask> implements IPool<TASK> {
@Override public boolean removeTask(String key) { @Override public boolean removeTask(String key) {
synchronized (AriaManager.LOCK) { synchronized (AriaManager.LOCK) {
if (TextUtils.isEmpty(key)) { if (TextUtils.isEmpty(key)) {
Log.e(TAG, "请传入有效的任务key"); ALog.e(TAG, "请传入有效的任务key");
return false; return false;
} }
String convertKey = CommonUtil.keyToHashKey(key); String convertKey = CommonUtil.keyToHashKey(key);

@ -15,9 +15,9 @@
*/ */
package com.arialyy.aria.core.queue.pool; package com.arialyy.aria.core.queue.pool;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.inf.AbsTask; import com.arialyy.aria.core.inf.AbsTask;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -36,13 +36,13 @@ class DownloadExecutePool<TASK extends AbsTask> extends BaseExecutePool<TASK> {
@Override public boolean putTask(TASK task) { @Override public boolean putTask(TASK task) {
synchronized (AriaManager.LOCK) { synchronized (AriaManager.LOCK) {
if (task == null) { if (task == null) {
Log.e(TAG, "任务不能为空!!"); ALog.e(TAG, "任务不能为空!!");
return false; return false;
} }
String url = task.getKey(); String url = task.getKey();
if (mExecuteQueue.contains(task)) { if (mExecuteQueue.contains(task)) {
if (!task.isRunning()) return true; if (!task.isRunning()) return true;
Log.e(TAG, "队列中已经包含了该任务,任务key【" + url + "】"); ALog.e(TAG, "队列中已经包含了该任务,任务key【" + url + "】");
return false; return false;
} else { } else {
if (mExecuteQueue.size() >= mSize) { if (mExecuteQueue.size() >= mSize) {
@ -65,7 +65,7 @@ class DownloadExecutePool<TASK extends AbsTask> extends BaseExecutePool<TASK> {
try { try {
TASK oldTask = mExecuteQueue.poll(TIME_OUT, TimeUnit.MICROSECONDS); TASK oldTask = mExecuteQueue.poll(TIME_OUT, TimeUnit.MICROSECONDS);
if (oldTask == null) { if (oldTask == null) {
Log.e(TAG, "移除任务失败"); ALog.e(TAG, "移除任务失败");
return false; return false;
} }
if (oldTask.isHighestPriorityTask()) { if (oldTask.isHighestPriorityTask()) {

@ -17,7 +17,6 @@ package com.arialyy.aria.core.scheduler;
import android.os.CountDownTimer; import android.os.CountDownTimer;
import android.os.Message; import android.os.Message;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.download.DownloadTask; import com.arialyy.aria.core.download.DownloadTask;
import com.arialyy.aria.core.inf.AbsEntity; import com.arialyy.aria.core.inf.AbsEntity;
@ -28,6 +27,7 @@ import com.arialyy.aria.core.inf.GroupSendParams;
import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.queue.ITaskQueue; import com.arialyy.aria.core.queue.ITaskQueue;
import com.arialyy.aria.core.upload.UploadTask; import com.arialyy.aria.core.upload.UploadTask;
import com.arialyy.aria.util.ALog;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -60,7 +60,7 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, TASK extends Abs
listener.setListener(obj); listener.setListener(obj);
mObservers.put(targetName, listener); mObservers.put(targetName, listener);
} else { } else {
Log.e(TAG, "注册错误,没有【" + targetName + "】观察者"); ALog.e(TAG, "注册错误,没有【" + targetName + "】观察者");
} }
} }
} }
@ -84,11 +84,11 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, TASK extends Abs
Class clazz = Class.forName(targetName + getProxySuffix()); Class clazz = Class.forName(targetName + getProxySuffix());
listener = (AbsSchedulerListener<TASK, AbsNormalEntity>) clazz.newInstance(); listener = (AbsSchedulerListener<TASK, AbsNormalEntity>) clazz.newInstance();
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
Log.e(TAG, targetName + ",没有Aria的Download或Upload注解方法"); ALog.e(TAG, targetName + ",没有Aria的Download或Upload注解方法");
} catch (InstantiationException e) { } catch (InstantiationException e) {
Log.e(TAG, e.getMessage()); ALog.e(TAG, e.getMessage());
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
Log.e(TAG, e.getMessage()); ALog.e(TAG, e.getMessage());
} }
return listener; return listener;
} }
@ -100,7 +100,7 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, TASK extends Abs
TASK task = (TASK) msg.obj; TASK task = (TASK) msg.obj;
if (task == null) { if (task == null) {
Log.e(TAG, "请传入下载任务"); ALog.e(TAG, "请传入下载任务");
return true; return true;
} }
handleNormalEvent(task, msg.what); handleNormalEvent(task, msg.what);
@ -190,7 +190,7 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, TASK extends Abs
AbsSchedulerListener<TASK, AbsNormalEntity> listener) { AbsSchedulerListener<TASK, AbsNormalEntity> listener) {
if (listener != null) { if (listener != null) {
if (task == null) { if (task == null) {
Log.e(TAG, "TASK 为null,回调失败"); ALog.e(TAG, "TASK 为null,回调失败");
return; return;
} }
switch (state) { switch (state) {
@ -275,7 +275,7 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, TASK extends Abs
private void startNextTask() { private void startNextTask() {
TASK newTask = mQueue.getNextTask(); TASK newTask = mQueue.getNextTask();
if (newTask == null) { if (newTask == null) {
Log.w(TAG, "没有下一任务"); ALog.d(TAG, "没有下一任务");
return; return;
} }
if (newTask.getState() == IEntity.STATE_WAIT) { if (newTask.getState() == IEntity.STATE_WAIT) {

@ -17,11 +17,11 @@ package com.arialyy.aria.core.upload;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.FtpUrlEntity; import com.arialyy.aria.core.FtpUrlEntity;
import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.core.inf.AbsUploadTarget; import com.arialyy.aria.core.inf.AbsUploadTarget;
import com.arialyy.aria.orm.DbEntity; import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CheckUtil; import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.io.File; import java.io.File;
@ -87,10 +87,10 @@ public class FtpUploadTarget
*/ */
public FtpUploadTarget login(String userName, String password, String account) { public FtpUploadTarget login(String userName, String password, String account) {
if (TextUtils.isEmpty(userName)) { if (TextUtils.isEmpty(userName)) {
Log.e(TAG, "用户名不能为null"); ALog.e(TAG, "用户名不能为null");
return this; return this;
} else if (TextUtils.isEmpty(password)) { } else if (TextUtils.isEmpty(password)) {
Log.e(TAG, "密码不能为null"); ALog.e(TAG, "密码不能为null");
return this; return this;
} }
mTaskEntity.urlEntity.needLogin = true; mTaskEntity.urlEntity.needLogin = true;

@ -15,13 +15,13 @@
*/ */
package com.arialyy.aria.core.upload.uploader; package com.arialyy.aria.core.upload.uploader;
import android.util.Log;
import com.arialyy.aria.core.common.AbsFtpThreadTask; import com.arialyy.aria.core.common.AbsFtpThreadTask;
import com.arialyy.aria.core.common.StateConstance; import com.arialyy.aria.core.common.StateConstance;
import com.arialyy.aria.core.common.SubThreadConfig; import com.arialyy.aria.core.common.SubThreadConfig;
import com.arialyy.aria.core.inf.IEventListener; import com.arialyy.aria.core.inf.IEventListener;
import com.arialyy.aria.core.upload.UploadEntity; import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.core.upload.UploadTaskEntity; import com.arialyy.aria.core.upload.UploadTaskEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.BufferedRandomAccessFile; import com.arialyy.aria.util.BufferedRandomAccessFile;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -49,7 +49,7 @@ class FtpThreadTask extends AbsFtpThreadTask<UploadEntity, UploadTaskEntity> {
FTPClient client = null; FTPClient client = null;
BufferedRandomAccessFile file = null; BufferedRandomAccessFile file = null;
try { try {
Log.d(TAG, "任务【" ALog.d(TAG, "任务【"
+ mConfig.TEMP_FILE.getName() + mConfig.TEMP_FILE.getName()
+ "】线程__" + "】线程__"
+ mConfig.THREAD_ID + mConfig.THREAD_ID
@ -71,7 +71,7 @@ class FtpThreadTask extends AbsFtpThreadTask<UploadEntity, UploadTaskEntity> {
} }
upload(client, file); upload(client, file);
if (STATE.isCancel || STATE.isStop) return; if (STATE.isCancel || STATE.isStop) return;
Log.i(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】线程__" + mConfig.THREAD_ID + "__上传完毕"); ALog.i(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】线程__" + mConfig.THREAD_ID + "__上传完毕");
writeConfig(true, 1); writeConfig(true, 1);
STATE.COMPLETE_THREAD_NUM++; STATE.COMPLETE_THREAD_NUM++;
if (STATE.isComplete()) { if (STATE.isComplete()) {

@ -15,13 +15,13 @@
*/ */
package com.arialyy.aria.core.upload.uploader; package com.arialyy.aria.core.upload.uploader;
import android.util.Log;
import com.arialyy.aria.core.common.AbsThreadTask; import com.arialyy.aria.core.common.AbsThreadTask;
import com.arialyy.aria.core.common.StateConstance; import com.arialyy.aria.core.common.StateConstance;
import com.arialyy.aria.core.common.SubThreadConfig; import com.arialyy.aria.core.common.SubThreadConfig;
import com.arialyy.aria.core.inf.IUploadListener; import com.arialyy.aria.core.inf.IUploadListener;
import com.arialyy.aria.core.upload.UploadEntity; import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.core.upload.UploadTaskEntity; import com.arialyy.aria.core.upload.UploadTaskEntity;
import com.arialyy.aria.util.ALog;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -56,7 +56,7 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> {
@Override public void run() { @Override public void run() {
File uploadFile = new File(mEntity.getFilePath()); File uploadFile = new File(mEntity.getFilePath());
if (!uploadFile.exists()) { if (!uploadFile.exists()) {
Log.e(TAG, "【" + mEntity.getFilePath() + "】,文件不存在。"); ALog.e(TAG, "【" + mEntity.getFilePath() + "】,文件不存在。");
fail(); fail();
return; return;
} }
@ -89,7 +89,7 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> {
addFormField(writer, key, mTaskEntity.formFields.get(key)); addFormField(writer, key, mTaskEntity.formFields.get(key));
} }
uploadFile(writer, mTaskEntity.attachment, uploadFile); uploadFile(writer, mTaskEntity.attachment, uploadFile);
Log.d(TAG, finish(writer) + ""); finish(writer);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
fail(); fail();
@ -193,7 +193,7 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> {
reader.close(); reader.close();
mHttpConn.disconnect(); mHttpConn.disconnect();
} else { } else {
Log.w(TAG, "state_code = " + status); ALog.w(TAG, "state_code = " + status);
fail(); fail();
} }

@ -21,8 +21,8 @@ import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CheckUtil; import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.util.List; import java.util.List;
@ -203,10 +203,10 @@ public class DbUtil {
synchronized int getRowId(Class clazz, Object[] wheres, Object[] values) { synchronized int getRowId(Class clazz, Object[] wheres, Object[] values) {
checkDb(); checkDb();
if (wheres.length <= 0 || values.length <= 0) { if (wheres.length <= 0 || values.length <= 0) {
Log.e(TAG, "请输入删除条件"); ALog.e(TAG, "请输入删除条件");
return -1; return -1;
} else if (wheres.length != values.length) { } else if (wheres.length != values.length) {
Log.e(TAG, "groupName 和 vaule 长度不相等"); ALog.e(TAG, "groupName 和 vaule 长度不相等");
return -1; return -1;
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

@ -22,8 +22,8 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CheckUtil; import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -96,10 +96,10 @@ final class SqlHelper extends SQLiteOpenHelper {
*/ */
private void handleDbUpdate(SQLiteDatabase db) { private void handleDbUpdate(SQLiteDatabase db) {
if (db == null) { if (db == null) {
Log.d("SqlHelper", "db 为 null"); ALog.e("SqlHelper", "db 为 null");
return; return;
} else if (!db.isOpen()) { } else if (!db.isOpen()) {
Log.d("SqlHelper", "db已关闭"); ALog.e("SqlHelper", "db已关闭");
return; return;
} }
Set<String> tables = DBConfig.mapping.keySet(); Set<String> tables = DBConfig.mapping.keySet();
@ -206,10 +206,10 @@ final class SqlHelper extends SQLiteOpenHelper {
Class<T> clazz, @NonNull String[] wheres, @NonNull String[] values) { Class<T> clazz, @NonNull String[] wheres, @NonNull String[] values) {
db = checkDb(db); db = checkDb(db);
if (wheres.length <= 0 || values.length <= 0) { if (wheres.length <= 0 || values.length <= 0) {
Log.e(TAG, "请输入查询条件"); ALog.e(TAG, "请输入查询条件");
return null; return null;
} else if (wheres.length != values.length) { } else if (wheres.length != values.length) {
Log.e(TAG, "groupName 和 vaule 长度不相等"); ALog.e(TAG, "groupName 和 vaule 长度不相等");
return null; return null;
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -517,7 +517,7 @@ final class SqlHelper extends SQLiteOpenHelper {
str = "遍历整个数据库 >>>> "; str = "遍历整个数据库 >>>> ";
break; break;
} }
Log.v(TAG, str + sql); ALog.v(TAG, str + sql);
} }
/** /**

@ -0,0 +1,90 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.util;
import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.AriaManager;
/**
* Created by Aria.Lao on 2017/10/25.
* Aria日志工具
*/
public class ALog {
public static int LOG_LEVEL = AriaManager.LOG_DEFAULT;
public static int v(String tag, String msg) {
return println(Log.VERBOSE, tag, msg);
}
public static int d(String tag, String msg) {
return println(Log.DEBUG, tag, msg);
}
public static int i(String tag, String msg) {
return println(Log.INFO, tag, msg);
}
public static int w(String tag, String msg) {
return println(Log.WARN, tag, msg);
}
public static int e(String tag, String msg) {
return println(Log.ERROR, tag, msg);
}
public static int e(String tag, Throwable e) {
return println(Log.ERROR, tag, getExceptionString(e));
}
/**
* 将异常信息转换为字符串
*/
public static String getExceptionString(Throwable ex) {
StringBuilder err = new StringBuilder();
err.append("ExceptionDetailed:\n");
err.append("====================Exception Info====================\n");
err.append(ex.toString());
err.append("\n");
StackTraceElement[] stack = ex.getStackTrace();
for (StackTraceElement stackTraceElement : stack) {
err.append(stackTraceElement.toString()).append("\n");
}
Throwable cause = ex.getCause();
if (cause != null) {
err.append("【Caused by】: ");
err.append(cause.toString());
err.append("\n");
StackTraceElement[] stackTrace = cause.getStackTrace();
for (StackTraceElement stackTraceElement : stackTrace) {
err.append(stackTraceElement.toString()).append("\n");
}
}
err.append("===================================================");
return err.toString();
}
private static int println(int level, String tag, String msg) {
if (LOG_LEVEL <= level) {
return Log.println(level, tag, TextUtils.isEmpty(msg) ? "null" : msg);
} else {
return -1;
}
}
}

@ -17,7 +17,6 @@
package com.arialyy.aria.util; package com.arialyy.aria.util;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity; import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.inf.AbsTaskEntity;
@ -135,20 +134,20 @@ public class CheckUtil {
if (entity instanceof DownloadTaskEntity) { if (entity instanceof DownloadTaskEntity) {
DownloadEntity entity1 = ((DownloadTaskEntity) entity).getEntity(); DownloadEntity entity1 = ((DownloadTaskEntity) entity).getEntity();
if (entity1 == null) { if (entity1 == null) {
Log.e(TAG, "下载实体不能为空"); ALog.e(TAG, "下载实体不能为空");
} else if (checkType && TextUtils.isEmpty(entity1.getUrl())) { } else if (checkType && TextUtils.isEmpty(entity1.getUrl())) {
Log.e(TAG, "下载链接不能为空"); ALog.e(TAG, "下载链接不能为空");
} else if (checkType && TextUtils.isEmpty(entity1.getDownloadPath())) { } else if (checkType && TextUtils.isEmpty(entity1.getDownloadPath())) {
Log.e(TAG, "保存路径不能为空"); ALog.e(TAG, "保存路径不能为空");
} else { } else {
b = true; b = true;
} }
} else if (entity instanceof UploadTaskEntity) { } else if (entity instanceof UploadTaskEntity) {
UploadEntity entity1 = ((UploadTaskEntity) entity).getEntity(); UploadEntity entity1 = ((UploadTaskEntity) entity).getEntity();
if (entity1 == null) { if (entity1 == null) {
Log.e(TAG, "上传实体不能为空"); ALog.e(TAG, "上传实体不能为空");
} else if (TextUtils.isEmpty(entity1.getFilePath())) { } else if (TextUtils.isEmpty(entity1.getFilePath())) {
Log.e(TAG, "上传文件路径不能为空"); ALog.e(TAG, "上传文件路径不能为空");
} else { } else {
b = true; b = true;
} }

@ -22,7 +22,6 @@ import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Base64; import android.util.Base64;
import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.FtpUrlEntity; import com.arialyy.aria.core.FtpUrlEntity;
import com.arialyy.aria.core.command.ICmd; import com.arialyy.aria.core.command.ICmd;
@ -251,7 +250,7 @@ public class CommonUtil {
md.update(sb.toString().getBytes()); md.update(sb.toString().getBytes());
md5 = new BigInteger(1, md.digest()).toString(16); md5 = new BigInteger(1, md.digest()).toString(16);
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
Log.e(TAG, e.getMessage()); ALog.e(TAG, e.getMessage());
} }
return md5; return md5;
} }
@ -356,12 +355,12 @@ public class CommonUtil {
File dir = new File("/sys/devices/system/cpu/"); File dir = new File("/sys/devices/system/cpu/");
//Filter to only list the devices we care about //Filter to only list the devices we care about
File[] files = dir.listFiles(new CpuFilter()); File[] files = dir.listFiles(new CpuFilter());
Log.d(TAG, "CPU Count: " + files.length); ALog.d(TAG, "CPU Count: " + files.length);
//Return the number of cores (virtual CPU devices) //Return the number of cores (virtual CPU devices)
return files.length; return files.length;
} catch (Exception e) { } catch (Exception e) {
//Print exception //Print exception
Log.d(TAG, "CPU Count: Failed."); ALog.d(TAG, "CPU Count: Failed.");
e.printStackTrace(); e.printStackTrace();
//Default to return 1 core //Default to return 1 core
return 1; return 1;
@ -391,13 +390,13 @@ public class CommonUtil {
*/ */
public static boolean checkMD5(String md5, File updateFile) { public static boolean checkMD5(String md5, File updateFile) {
if (TextUtils.isEmpty(md5) || updateFile == null) { if (TextUtils.isEmpty(md5) || updateFile == null) {
Log.e(TAG, "MD5 string empty or updateFile null"); ALog.e(TAG, "MD5 string empty or updateFile null");
return false; return false;
} }
String calculatedDigest = getFileMD5(updateFile); String calculatedDigest = getFileMD5(updateFile);
if (calculatedDigest == null) { if (calculatedDigest == null) {
Log.e(TAG, "calculatedDigest null"); ALog.e(TAG, "calculatedDigest null");
return false; return false;
} }
return calculatedDigest.equalsIgnoreCase(md5); return calculatedDigest.equalsIgnoreCase(md5);
@ -408,13 +407,13 @@ public class CommonUtil {
*/ */
public static boolean checkMD5(String md5, InputStream is) { public static boolean checkMD5(String md5, InputStream is) {
if (TextUtils.isEmpty(md5) || is == null) { if (TextUtils.isEmpty(md5) || is == null) {
Log.e(TAG, "MD5 string empty or updateFile null"); ALog.e(TAG, "MD5 string empty or updateFile null");
return false; return false;
} }
String calculatedDigest = getFileMD5(is); String calculatedDigest = getFileMD5(is);
if (calculatedDigest == null) { if (calculatedDigest == null) {
Log.e(TAG, "calculatedDigest null"); ALog.e(TAG, "calculatedDigest null");
return false; return false;
} }
return calculatedDigest.equalsIgnoreCase(md5); return calculatedDigest.equalsIgnoreCase(md5);
@ -428,7 +427,7 @@ public class CommonUtil {
try { try {
is = new FileInputStream(updateFile); is = new FileInputStream(updateFile);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
Log.e(TAG, "Exception while getting FileInputStream", e); ALog.e(TAG, e);
return null; return null;
} }
@ -443,7 +442,7 @@ public class CommonUtil {
try { try {
digest = MessageDigest.getInstance("MD5"); digest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
Log.e(TAG, "Exception while getting digest", e); ALog.e(TAG, e);
return null; return null;
} }
@ -465,7 +464,7 @@ public class CommonUtil {
try { try {
is.close(); is.close();
} catch (IOException e) { } catch (IOException e) {
Log.e(TAG, "Exception on closing MD5 input stream", e); ALog.e(TAG, e);
} }
} }
} }
@ -699,7 +698,7 @@ public class CommonUtil {
File file = new File(path); File file = new File(path);
if (!file.exists()) { if (!file.exists()) {
if (!file.mkdirs()) { if (!file.mkdirs()) {
Log.d(TAG, "创建失败,请检查路径和是否配置文件权限!"); ALog.d(TAG, "创建失败,请检查路径和是否配置文件权限!");
return false; return false;
} }
return true; return true;
@ -714,14 +713,14 @@ public class CommonUtil {
*/ */
public static void createFile(String path) { public static void createFile(String path) {
if (TextUtils.isEmpty(path)) { if (TextUtils.isEmpty(path)) {
Log.e(TAG, "文件路径不能为null"); ALog.e(TAG, "文件路径不能为null");
return; return;
} }
File file = new File(path); File file = new File(path);
if (!file.getParentFile().exists()) { if (!file.getParentFile().exists()) {
Log.d(TAG, "目标文件所在路径不存在,准备创建……"); ALog.d(TAG, "目标文件所在路径不存在,准备创建……");
if (!createDir(file.getParent())) { if (!createDir(file.getParent())) {
Log.d(TAG, "创建目录文件所在的目录失败!文件路径【" + path + "】"); ALog.d(TAG, "创建目录文件所在的目录失败!文件路径【" + path + "】");
} }
} }
// 创建目标文件 // 创建目标文件
@ -732,7 +731,7 @@ public class CommonUtil {
} }
try { try {
if (file.createNewFile()) { if (file.createNewFile()) {
Log.d(TAG, "创建文件成功:" + file.getAbsolutePath()); ALog.d(TAG, "创建文件成功:" + file.getAbsolutePath());
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();

@ -36,7 +36,9 @@ import java.io.File;
*/ */
public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding> { public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding> {
//private final String URL = "ftp://192.168.1.9:21/下载/AriaPrj.zip"; //private final String URL = "ftp://192.168.1.9:21/下载/AriaPrj.zip";
private final String URL = "ftp://192.168.1.9:21/下载/[电影天堂www.dy2018.com]赛车总动员3BD中英双字.mp4"; //private final String URL = "ftp://192.168.1.9:21/下载/[电影天堂www.dy2018.com]赛车总动员3BD中英双字.mp4";
//private final String URL = "ftp://d:d@dygodj8.com:12311/[电影天堂www.dy2018.com]光辉岁月BD韩语中字.rmvb";
private final String URL = "ftp://172.18.104.64:21/upload/成都.mp3";
@Override protected void init(Bundle savedInstanceState) { @Override protected void init(Bundle savedInstanceState) {
super.init(savedInstanceState); super.init(savedInstanceState);
@ -58,8 +60,8 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
switch (view.getId()) { switch (view.getId()) {
case R.id.start: case R.id.start:
Aria.download(this).loadFtp(URL, true) Aria.download(this).loadFtp(URL, true)
.charSet("GBK") //.charSet("GBK")
//.login("lao", "123456") .login("lao", "123456")
.setDownloadPath("/mnt/sdcard/").start(); .setDownloadPath("/mnt/sdcard/").start();
break; break;
case R.id.stop: case R.id.stop:

@ -35,7 +35,7 @@ import com.arialyy.simple.widget.SubStateLinearLayout;
* Created by Aria.Lao on 2017/7/6. * Created by Aria.Lao on 2017/7/6.
*/ */
public class FTPDirDownloadActivity extends BaseActivity<ActivityDownloadGroupBinding> { public class FTPDirDownloadActivity extends BaseActivity<ActivityDownloadGroupBinding> {
private static final String dir = "ftp://172.18.104.49:21/haha/"; private static final String dir = "ftp://172.18.104.64:21/haha/";
@Bind(R.id.child_list) SubStateLinearLayout mChildList; @Bind(R.id.child_list) SubStateLinearLayout mChildList;

@ -17,11 +17,10 @@ package com.arialyy.aria.core.upload;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.util.Log;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.inf.AbsNormalTask; import com.arialyy.aria.core.inf.AbsNormalTask;
import com.arialyy.aria.core.scheduler.ISchedulers; import com.arialyy.aria.core.scheduler.ISchedulers;
import com.arialyy.aria.core.upload.uploader.SimpleUploadUtil; import com.arialyy.aria.core.upload.uploader.SimpleUploadUtil;
import com.arialyy.aria.util.ALog;
/** /**
* Created by lyy on 2017/2/23. * Created by lyy on 2017/2/23.
@ -54,7 +53,7 @@ public class UploadTask extends AbsNormalTask<UploadTaskEntity> {
@Override public void start() { @Override public void start() {
if (mUtil.isRunning()) { if (mUtil.isRunning()) {
Log.d(TAG, "任务正在下载"); ALog.d(TAG, "任务正在下载");
} else { } else {
mUtil.start(); mUtil.start();
} }

Loading…
Cancel
Save