From 4df35a483e031d74eaa1a728dceac844d537209e Mon Sep 17 00:00:00 2001 From: laoyuyu <511455842@qq.com> Date: Thu, 20 Dec 2018 19:10:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BD=91=E7=BB=9C=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E5=BC=80=E5=85=B3=20https://github.com/AriaLyy/Aria/i?= =?UTF-8?q?ssues/339?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Aria/build.gradle | 4 ++-- .../com/arialyy/aria/core/ConfigHelper.java | 11 ++++++++++ .../core/command/normal/AbsNormalCmd.java | 5 ++--- .../aria/core/scheduler/ISchedulers.java | 16 +++++++------- .../java/com/arialyy/aria/util/NetUtils.java | 4 ++++ app/src/main/AndroidManifest.xml | 2 +- app/src/main/assets/aria_config.xml | 2 ++ .../arialyy/simple/base/BaseApplication.java | 9 +++++++- .../simple/upload/FtpUploadActivity.java | 3 +-- .../com/arialyy/aria/core/Configuration.java | 22 ++++++++++++++----- build.gradle | 2 +- 11 files changed, 56 insertions(+), 24 deletions(-) diff --git a/Aria/build.gradle b/Aria/build.gradle index 2b00cf71..247d08ee 100644 --- a/Aria/build.gradle +++ b/Aria/build.gradle @@ -26,8 +26,8 @@ dependencies { testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile project(':AriaAnnotations') -// compile 'com.arialyy.aria:aria-ftp-plug:1.0.4' + compile 'com.arialyy.aria:aria-ftp-plug:1.0.4' - compile project(':AriaFtpPlug') +// compile project(':AriaFtpPlug') } apply from: 'bintray-release.gradle' diff --git a/Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java b/Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java index 89414399..e5feef66 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java +++ b/Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java @@ -113,10 +113,21 @@ class ConfigHelper extends DefaultHandler { case "logLevel": loadLogLevel(value); break; + case "netCheck": + loadNetCheck(value); + break; } } } + private void loadNetCheck(String value) { + boolean b = checkBoolean(value), temp = false; + if (b) { + temp = Boolean.valueOf(value); + } + mAppConfig.netCheck = temp; + } + private void loadUseBroadcast(String value) { boolean b = checkBoolean(value), temp = false; diff --git a/Aria/src/main/java/com/arialyy/aria/core/command/normal/AbsNormalCmd.java b/Aria/src/main/java/com/arialyy/aria/core/command/normal/AbsNormalCmd.java index 256fb3d3..80024b6d 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/command/normal/AbsNormalCmd.java +++ b/Aria/src/main/java/com/arialyy/aria/core/command/normal/AbsNormalCmd.java @@ -34,8 +34,7 @@ import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.CommonUtil; /** - * Created by lyy on 2016/8/22. - * 下载命令 + * Created by lyy on 2016/8/22. 下载命令 */ public abstract class AbsNormalCmd extends AbsCmd { /** @@ -84,7 +83,7 @@ public abstract class AbsNormalCmd extends AbsCmd { */ void sendWaitState() { if (tempTask != null) { - sendWaitState(tempTask); + sendWaitState(tempTask); } } diff --git a/Aria/src/main/java/com/arialyy/aria/core/scheduler/ISchedulers.java b/Aria/src/main/java/com/arialyy/aria/core/scheduler/ISchedulers.java index caa11261..491364bd 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/scheduler/ISchedulers.java +++ b/Aria/src/main/java/com/arialyy/aria/core/scheduler/ISchedulers.java @@ -36,14 +36,14 @@ public interface ISchedulers extends Handler.Callback { String TASK_TYPE = "ARIA_TASK_TYPE"; /** - * 广播接收器中通过TASK_STATE字段获取任务状态 普通任务的有: - *
- * {@link #NO_SUPPORT_BREAK_POINT}、{@link #PRE}、{@link #POST_PRE}、{@link #START}、{@link - * #STOP}、{@link #FAIL}、{@link #CANCEL}、{@link #COMPLETE}、{@link #RUNNING}、{@link #RESUME}、{@link - * #WAIT} - *
- * 子任务的有:{@link #SUB_PRE}、{@link #SUB_START}、{@link #SUB_STOP}、{@link #SUB_CANCEL}、{@link - * #SUB_FAIL}、{@link #SUB_RUNNING}、{@link #SUB_COMPLETE} + * 广播接收器中通过TASK_STATE字段获取任务状态 + * + * 普通任务的有: {@link #NO_SUPPORT_BREAK_POINT}、{@link #PRE}、{@link + * #POST_PRE}、{@link #START}、{@link #STOP}、{@link #FAIL}、{@link #CANCEL}、{@link #COMPLETE}、{@link + * #RUNNING}、{@link #RESUME}、{@link #WAIT} + * + * 子任务的有:{@link #SUB_PRE}、{@link #SUB_START}、{@link + * #SUB_STOP}、{@link #SUB_CANCEL}、{@link #SUB_FAIL}、{@link #SUB_RUNNING}、{@link #SUB_COMPLETE} */ String TASK_STATE = "ARIA_TASK_STATE"; diff --git a/Aria/src/main/java/com/arialyy/aria/util/NetUtils.java b/Aria/src/main/java/com/arialyy/aria/util/NetUtils.java index bf398135..44f63c52 100644 --- a/Aria/src/main/java/com/arialyy/aria/util/NetUtils.java +++ b/Aria/src/main/java/com/arialyy/aria/util/NetUtils.java @@ -22,6 +22,7 @@ import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.telephony.TelephonyManager; import android.text.TextUtils; +import com.arialyy.aria.core.Aria; /** * 跟网络相关的工具类 @@ -54,6 +55,9 @@ public class NetUtils { * @return {@code true} 网络已连接、{@code false}网络未连接 */ public static boolean isConnected(Context context) { + if (!Aria.get(context).getAppConfig().isNetCheck()){ + return true; + } ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6bfc4bfb..31d410bf 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -20,7 +20,7 @@ diff --git a/app/src/main/assets/aria_config.xml b/app/src/main/assets/aria_config.xml index f866fb80..d54e9f61 100644 --- a/app/src/main/assets/aria_config.xml +++ b/app/src/main/assets/aria_config.xml @@ -6,6 +6,8 @@ + + diff --git a/app/src/main/java/com/arialyy/simple/base/BaseApplication.java b/app/src/main/java/com/arialyy/simple/base/BaseApplication.java index d2a23288..b06e0e04 100644 --- a/app/src/main/java/com/arialyy/simple/base/BaseApplication.java +++ b/app/src/main/java/com/arialyy/simple/base/BaseApplication.java @@ -41,7 +41,14 @@ public class BaseApplication extends Application { if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { StrictMode.setThreadPolicy( new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build()); - StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build()); + StrictMode.VmPolicy policy = new StrictMode.VmPolicy.Builder() + //.detectLeakedSqlLiteObjects() + //.detectLeakedClosableObjects() + .detectAll() + .penaltyDeath() + .penaltyLog() + .build(); + StrictMode.setVmPolicy(policy); } registerReceiver(new ConnectionChangeReceiver(), diff --git a/app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java b/app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java index afe2291a..ff55fdf4 100644 --- a/app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java +++ b/app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java @@ -32,8 +32,7 @@ import com.arialyy.simple.databinding.ActivityFtpUploadBinding; import java.io.File; /** - * Created by lyy on 2017/7/28. - * Ftp 文件上传demo + * Created by lyy on 2017/7/28. Ftp 文件上传demo */ public class FtpUploadActivity extends BaseActivity { private final String FILE_PATH = "/mnt/sdcard/AriaPrj.rar"; diff --git a/aria/src/main/java/com/arialyy/aria/core/Configuration.java b/aria/src/main/java/com/arialyy/aria/core/Configuration.java index d7267345..3c90f7a3 100644 --- a/aria/src/main/java/com/arialyy/aria/core/Configuration.java +++ b/aria/src/main/java/com/arialyy/aria/core/Configuration.java @@ -27,9 +27,9 @@ import java.io.File; import java.io.Serializable; /** - * Created by lyy on 2016/12/8. 信息配置 + * Created by lyy on 2016/12/8. 信息配置 kotlin 方式有bug,不能将public去掉 */ -final class Configuration { +public final class Configuration { private static final String TAG = "Configuration"; private static final String DOWNLOAD_CONFIG_FILE = "/Aria/AriaDownload.cfg"; private static final String UPLOAD_CONFIG_FILE = "/Aria/AriaUpload.cfg"; @@ -207,9 +207,7 @@ final class Configuration { int maxSpeed = 0; /** - * 是否使用广播 - * 除非无法使用注解,否则不建议使用广播来接受任务 - * {@code true} 使用广播,{@code false} 不适用广播 + * 是否使用广播 除非无法使用注解,否则不建议使用广播来接受任务 {@code true} 使用广播,{@code false} 不适用广播 */ boolean useBroadcast = false; @@ -479,7 +477,19 @@ final class Configuration { */ int logLevel; - private AppConfig() { + /** + * 是否检查网络,{@code true}检查网络 + */ + boolean netCheck = true; + + public boolean isNetCheck() { + return netCheck; + } + + public AppConfig setNetCheck(boolean netCheck) { + this.netCheck = netCheck; + save(); + return this; } public AppConfig setLogLevel(int level) { diff --git a/build.gradle b/build.gradle index 5e852501..c5463e8e 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ task clean(type: Delete) { ext { userOrg = 'arialyy' groupId = 'com.arialyy.aria' - publishVersion = '3.5.2' + publishVersion = '3.5.3_dev_1' // publishVersion = '1.0.4' //FTP插件 repoName='maven' desc = 'android 下载框架'