From 1fb9f13dae38a202f853497e41e8e517c75f6eaf Mon Sep 17 00:00:00 2001 From: laoyuyu <511455842@qq.com> Date: Fri, 26 Jul 2019 21:37:49 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E8=AE=B0=E5=BD=95=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/arialyy/aria/orm/DBConfig.java | 2 +- .../main/java/com/arialyy/aria/orm/SqlHelper.java | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java b/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java index e50113e7..6bdddbd4 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java @@ -38,7 +38,7 @@ class DBConfig { static boolean DEBUG = false; static Map mapping = new LinkedHashMap<>(); static String DB_NAME; - static int VERSION = 52; + static int VERSION = 53; /** * 是否将数据库保存在Sd卡,{@code true} 是 diff --git a/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java b/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java index 1795cb79..4b2683db 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java @@ -100,7 +100,7 @@ final class SqlHelper extends SQLiteOpenHelper { handle360AriaUpdate(db); } else if (oldVersion < 51) { handle365Update(db); - } else if (oldVersion < 52) { + } else if (oldVersion < 53) { handle366Update(db); } else { handleDbUpdate(db, null, null); @@ -240,12 +240,9 @@ final class SqlHelper extends SQLiteOpenHelper { * 删除重复的repeat数据 */ private void delRepeatThreadRecord(SQLiteDatabase db) { - String repeatSql = - "DELETE FROM ThreadRecord WHERE (taskKey, threadId, endLocation) " - + "IN (SELECT taskKey, threadId, endLocation FROM ThreadRecord GROUP BY taskKey, threadId, endLocation " - + "HAVING COUNT(*) > 1) AND rowid " - + "NOT IN (SELECT MIN(rowid) FROM ThreadRecord GROUP BY taskKey, threadId, endLocation " - + "HAVING COUNT(*)> 1)"; + String repeatSql = "DELETE FROM ThreadRecord WHERE (rowid) " + + "IN (SELECT rowid FROM ThreadRecord GROUP BY taskKey, threadId, endLocation HAVING COUNT(*) > 1) " + + "AND rowid NOT IN (SELECT MIN(rowid) FROM ThreadRecord GROUP BY taskKey, threadId, endLocation HAVING COUNT(*)> 1)"; ALog.d(TAG, repeatSql); db.execSQL(repeatSql); } @@ -262,6 +259,7 @@ final class SqlHelper extends SQLiteOpenHelper { // 执行升级操作 handleDbUpdate(db, modifyMap, null); + delRepeatThreadRecord(db); } /** From 558c9e1223bc5ed2b0d8d2c6fe9a6207b2c30eaa Mon Sep 17 00:00:00 2001 From: laoyuyu <511455842@qq.com> Date: Mon, 5 Aug 2019 19:29:32 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=99=AE=E9=80=9A?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E4=BB=BB=E5=8A=A1=E3=80=81=E7=BB=84=E5=90=88?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=85=B1=E4=BA=AB=E6=89=A7=E8=A1=8C=E9=98=9F?= =?UTF-8?q?=E5=88=97=E3=80=81=E7=BC=93=E5=AD=98=E6=B1=A0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20=E4=BF=AE=E5=A4=8D=E7=BB=84=E5=90=88=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=90=AF=E5=8A=A8=E5=A4=B1=E8=B4=A5=E6=97=B6=EF=BC=8C?= =?UTF-8?q?`DownloadGroupEntity`=E7=9A=84=E7=8A=B6=E6=80=81=E5=8F=98?= =?UTF-8?q?=E4=B8=BA=E6=89=A7=E8=A1=8C=E4=B8=AD=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20fix=20bug=20https://github.com/AriaLyy/Aria/issues/441?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aria/core/common/AbsThreadTask.java | 6 ++- .../aria/core/common/ThreadStateManager.java | 6 ++- .../core/download/group/AbsGroupUtil.java | 13 ++++-- .../aria/core/download/group/DGroupUtil.java | 6 ++- .../download/group/FtpDirDownloadUtil.java | 4 +- .../arialyy/aria/core/queue/AbsTaskQueue.java | 10 +++-- .../core/queue/pool/DGLoadExecutePool.java | 31 ++++++++++++++ ...oadSharePool.java => DGLoadSharePool.java} | 16 ++++---- ...ExecutePool.java => DLoadExecutePool.java} | 4 +- .../aria/core/queue/pool/DLoadSharePool.java | 41 +++++++++++++++++++ .../com/arialyy/aria/orm/DelegateCommon.java | 4 +- .../com/arialyy/aria/orm/DelegateFind.java | 15 ++++--- .../com/arialyy/aria/orm/DelegateUpdate.java | 12 +++--- .../java/com/arialyy/aria/util/CheckUtil.java | 21 +++++++--- app/src/main/assets/aria_config.xml | 4 +- .../multi_download/MultiDownloadActivity.java | 8 ++-- app/src/main/res/values/strings.xml | 21 ++++------ build.gradle | 2 +- 18 files changed, 164 insertions(+), 60 deletions(-) create mode 100644 Aria/src/main/java/com/arialyy/aria/core/queue/pool/DGLoadExecutePool.java rename Aria/src/main/java/com/arialyy/aria/core/queue/pool/{DownloadSharePool.java => DGLoadSharePool.java} (72%) rename Aria/src/main/java/com/arialyy/aria/core/queue/pool/{DownloadExecutePool.java => DLoadExecutePool.java} (95%) create mode 100644 Aria/src/main/java/com/arialyy/aria/core/queue/pool/DLoadSharePool.java diff --git a/Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java b/Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java index b9138926..c606be66 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java @@ -201,10 +201,12 @@ public abstract class AbsThreadTask 1) { startDownload(); } else { @@ -57,6 +56,7 @@ public class FtpDirDownloadUtil extends AbsGroupUtil { }); new Thread(infoThread).start(); } + return true; } private void startDownload() { diff --git a/Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java b/Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java index 98ab974f..062fa37c 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java +++ b/Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java @@ -26,7 +26,8 @@ import com.arialyy.aria.core.manager.TaskWrapperManager; import com.arialyy.aria.core.manager.ThreadTaskManager; import com.arialyy.aria.core.queue.pool.BaseCachePool; import com.arialyy.aria.core.queue.pool.BaseExecutePool; -import com.arialyy.aria.core.queue.pool.DownloadSharePool; +import com.arialyy.aria.core.queue.pool.DGLoadSharePool; +import com.arialyy.aria.core.queue.pool.DLoadSharePool; import com.arialyy.aria.core.queue.pool.UploadSharePool; import com.arialyy.aria.core.upload.UploadTask; import com.arialyy.aria.util.ALog; @@ -47,9 +48,12 @@ public abstract class AbsTaskQueue extends DLoadExecutePool { + private final String TAG = "DGLoadExecutePool"; + + @Override protected int getMaxSize() { + return AriaManager.getInstance(AriaManager.APP).getDGroupConfig().getMaxTaskNum(); + } +} diff --git a/Aria/src/main/java/com/arialyy/aria/core/queue/pool/DownloadSharePool.java b/Aria/src/main/java/com/arialyy/aria/core/queue/pool/DGLoadSharePool.java similarity index 72% rename from Aria/src/main/java/com/arialyy/aria/core/queue/pool/DownloadSharePool.java rename to Aria/src/main/java/com/arialyy/aria/core/queue/pool/DGLoadSharePool.java index 4c07a16e..869612dc 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/queue/pool/DownloadSharePool.java +++ b/Aria/src/main/java/com/arialyy/aria/core/queue/pool/DGLoadSharePool.java @@ -19,21 +19,21 @@ package com.arialyy.aria.core.queue.pool; * Created by Aria.Lao on 2017/7/17. * 下载任务池,该池子为简单任务和任务组共用 */ -public class DownloadSharePool { - private static volatile DownloadSharePool INSTANCE; +public class DGLoadSharePool { + private static volatile DGLoadSharePool INSTANCE; - public DownloadExecutePool executePool; + public DGLoadExecutePool executePool; public BaseCachePool cachePool; - private DownloadSharePool() { - executePool = new DownloadExecutePool<>(); + private DGLoadSharePool() { + executePool = new DGLoadExecutePool<>(); cachePool = new BaseCachePool<>(); } - public static DownloadSharePool getInstance() { + public static DGLoadSharePool getInstance() { if (INSTANCE == null) { - synchronized (DownloadSharePool.class) { - INSTANCE = new DownloadSharePool(); + synchronized (DGLoadSharePool.class) { + INSTANCE = new DGLoadSharePool(); } } return INSTANCE; diff --git a/Aria/src/main/java/com/arialyy/aria/core/queue/pool/DownloadExecutePool.java b/Aria/src/main/java/com/arialyy/aria/core/queue/pool/DLoadExecutePool.java similarity index 95% rename from Aria/src/main/java/com/arialyy/aria/core/queue/pool/DownloadExecutePool.java rename to Aria/src/main/java/com/arialyy/aria/core/queue/pool/DLoadExecutePool.java index 25fcbcb0..81e5f340 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/queue/pool/DownloadExecutePool.java +++ b/Aria/src/main/java/com/arialyy/aria/core/queue/pool/DLoadExecutePool.java @@ -26,7 +26,7 @@ import java.util.concurrent.TimeUnit; * Created by AriaL on 2017/6/29. * 单个下载任务的执行池 */ -class DownloadExecutePool extends BaseExecutePool { +class DLoadExecutePool extends BaseExecutePool { private final String TAG = "DownloadExecutePool"; @Override protected int getMaxSize() { @@ -34,7 +34,7 @@ class DownloadExecutePool extends BaseExecutePool { } @Override public boolean putTask(TASK task) { - synchronized (DownloadExecutePool.class) { + synchronized (DLoadExecutePool.class) { if (task == null) { ALog.e(TAG, "任务不能为空!!"); return false; diff --git a/Aria/src/main/java/com/arialyy/aria/core/queue/pool/DLoadSharePool.java b/Aria/src/main/java/com/arialyy/aria/core/queue/pool/DLoadSharePool.java new file mode 100644 index 00000000..2ab96c9d --- /dev/null +++ b/Aria/src/main/java/com/arialyy/aria/core/queue/pool/DLoadSharePool.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.arialyy.aria.core.queue.pool; + +/** + * Created by Aria.Lao on 2017/7/17. + * 下载任务池,该池子为简单任务和任务组共用 + */ +public class DLoadSharePool { + private static volatile DLoadSharePool INSTANCE; + + public DLoadExecutePool executePool; + public BaseCachePool cachePool; + + private DLoadSharePool() { + executePool = new DLoadExecutePool<>(); + cachePool = new BaseCachePool<>(); + } + + public static DLoadSharePool getInstance() { + if (INSTANCE == null) { + synchronized (DLoadSharePool.class) { + INSTANCE = new DLoadSharePool(); + } + } + return INSTANCE; + } +} diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DelegateCommon.java b/Aria/src/main/java/com/arialyy/aria/orm/DelegateCommon.java index b1e8c319..3408a8af 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/DelegateCommon.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/DelegateCommon.java @@ -106,7 +106,9 @@ class DelegateCommon extends AbsDelegate { */ boolean checkDataExist(SQLiteDatabase db, Class clazz, String... expression) { db = checkDb(db); - CheckUtil.checkSqlExpression(expression); + if (!CheckUtil.checkSqlExpression(expression)) { + return false; + } String sql = String.format("SELECT rowid, * FROM %s WHERE %s ", CommonUtil.getClassName(clazz), expression[0]); sql = sql.replace("?", "%s"); diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DelegateFind.java b/Aria/src/main/java/com/arialyy/aria/orm/DelegateFind.java index ae8e01ad..0bb8dff0 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/DelegateFind.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/DelegateFind.java @@ -15,7 +15,6 @@ */ package com.arialyy.aria.orm; -import android.annotation.SuppressLint; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.text.TextUtils; @@ -30,10 +29,8 @@ import java.lang.reflect.Field; import java.net.URLDecoder; import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; /** * Created by laoyuyu on 2018/3/22. @@ -201,7 +198,9 @@ class DelegateFind extends AbsDelegate { .append(cTableName.concat(".").concat(m.entityColumn())); String sql; if (expression != null && expression.length > 0) { - CheckUtil.checkSqlExpression(expression); + if (!CheckUtil.checkSqlExpression(expression)) { + return null; + } sb.append(" WHERE ").append(expression[0]).append(" "); sql = sb.toString(); sql = sql.replace("?", "%s"); @@ -321,7 +320,9 @@ class DelegateFind extends AbsDelegate { */ List findData(SQLiteDatabase db, Class clazz, String... expression) { db = checkDb(db); - CheckUtil.checkSqlExpression(expression); + if (!CheckUtil.checkSqlExpression(expression)) { + return null; + } String sql = String.format("SELECT rowid, * FROM %s WHERE %s", CommonUtil.getClassName(clazz), expression[0]); String[] params = new String[expression.length - 1]; @@ -339,7 +340,9 @@ class DelegateFind extends AbsDelegate { return null; } db = checkDb(db); - CheckUtil.checkSqlExpression(expression); + if (!CheckUtil.checkSqlExpression(expression)) { + return null; + } String sql = String.format("SELECT rowid, * FROM %s WHERE %s LIMIT %s,%s", CommonUtil.getClassName(clazz), expression[0], (page - 1) * num, num); diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DelegateUpdate.java b/Aria/src/main/java/com/arialyy/aria/orm/DelegateUpdate.java index ba1085a6..669e0280 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/DelegateUpdate.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/DelegateUpdate.java @@ -34,13 +34,15 @@ class DelegateUpdate extends AbsDelegate { private DelegateUpdate() { } - /** + /** * 删除某条数据 */ synchronized void delData(SQLiteDatabase db, Class clazz, String... expression) { db = checkDb(db); - CheckUtil.checkSqlExpression(expression); + if (!CheckUtil.checkSqlExpression(expression)) { + return; + } String sql = "DELETE FROM " + CommonUtil.getClassName(clazz) + " WHERE " + expression[0] + " "; sql = sql.replace("?", "%s"); @@ -60,7 +62,7 @@ class DelegateUpdate extends AbsDelegate { ContentValues values = createValues(dbEntity); if (values != null) { db.update(CommonUtil.getClassName(dbEntity), values, "rowid=?", - new String[] {String.valueOf(dbEntity.rowID)}); + new String[] { String.valueOf(dbEntity.rowID) }); } else { ALog.e(TAG, "更新记录失败,记录没有属性字段"); } @@ -69,7 +71,7 @@ class DelegateUpdate extends AbsDelegate { /** * 更新多条记录 */ - synchronized void updateManyData(SQLiteDatabase db, List dbEntities) { + synchronized void updateManyData(SQLiteDatabase db, List dbEntities) { db = checkDb(db); db.beginTransaction(); try { @@ -84,7 +86,7 @@ class DelegateUpdate extends AbsDelegate { if (value == null) { ALog.e(TAG, "更新记录失败,记录没有属性字段"); } else { - db.update(table, value, "rowid=?", new String[] {String.valueOf(entity.rowID)}); + db.update(table, value, "rowid=?", new String[] { String.valueOf(entity.rowID) }); } } db.setTransactionSuccessful(); diff --git a/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java b/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java index 8891a0a5..bc453e3a 100644 --- a/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java +++ b/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java @@ -24,6 +24,7 @@ import com.arialyy.aria.core.upload.UTaskWrapper; import com.arialyy.aria.core.upload.UploadEntity; import com.arialyy.aria.exception.ParamException; import java.io.File; +import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -68,17 +69,22 @@ public class CheckUtil { /** * 检查sql的expression是否合法 + * + * @return false 不合法 */ - public static void checkSqlExpression(String... expression) { + public static boolean checkSqlExpression(String... expression) { if (expression.length == 0) { - throw new IllegalArgumentException("sql语句表达式不能为null"); + ALog.e(TAG, "sql语句表达式不能为null"); + return false; } if (expression.length == 1) { - throw new IllegalArgumentException("表达式需要写入参数"); + ALog.e(TAG, String.format("表达式需要写入参数,参数信息:%s", Arrays.toString(expression))); + return false; } String where = expression[0]; if (!where.contains("?")) { - throw new IllegalArgumentException("请在where语句的'='后编写?"); + ALog.e(TAG, String.format("请在where语句的'='后编写?,参数信息:%s", Arrays.toString(expression))); + return false; } Pattern pattern = Pattern.compile("\\?"); Matcher matcher = pattern.matcher(where); @@ -87,11 +93,14 @@ public class CheckUtil { count++; } if (count < expression.length - 1) { - throw new IllegalArgumentException("条件语句的?个数不能小于参数个数"); + ALog.e(TAG, String.format("条件语句的?个数不能小于参数个数,参数信息:%s", Arrays.toString(expression))); + return false; } if (count > expression.length - 1) { - throw new IllegalArgumentException("条件语句的?个数不能大于参数个数"); + ALog.e(TAG, String.format("条件语句的?个数不能大于参数个数, 参数信息:%s", Arrays.toString(expression))); + return false; } + return true; } /** diff --git a/app/src/main/assets/aria_config.xml b/app/src/main/assets/aria_config.xml index 1fb5c1ec..52688d22 100644 --- a/app/src/main/assets/aria_config.xml +++ b/app/src/main/assets/aria_config.xml @@ -113,7 +113,7 @@ - + @@ -131,7 +131,7 @@ - + diff --git a/app/src/main/java/com/arialyy/simple/core/download/multi_download/MultiDownloadActivity.java b/app/src/main/java/com/arialyy/simple/core/download/multi_download/MultiDownloadActivity.java index 65e4953c..b31d4cd4 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/multi_download/MultiDownloadActivity.java +++ b/app/src/main/java/com/arialyy/simple/core/download/multi_download/MultiDownloadActivity.java @@ -76,7 +76,7 @@ public class MultiDownloadActivity extends BaseActivity - - - - http://static.gaoshouyou.com/d/12/0d/7f120f50c80d2e7b8c4ba24ece4f9cdd.apk - + https://downs.muzhiwan.com/2019/06/19/com.and.games505.TerrariaPaid5d0a074e451c0.gpk + https://downs.muzhiwan.com/2017/03/28/com.xyzstudio_58da07426e959.apk http://hzdown.muzhiwan.com/2017/05/08/nl.noio.kingdom_59104935e56f0.apk - https://atom-installer.github.com/v1.13.0/AtomSetup.exe1 + http://hzdown.muzhiwan.com/2017/09/05/com.mir.iphone.empire83jie.mzw_59ae6d5a3638d.apk @@ -125,8 +122,8 @@ - http://apk500.bce.baidu-mgame.com/game/883000/883227/20170828102306_oem_5502845.apk?r=1 - http://static.gaoshouyou.com/d/92/12/5592a647b8126755647abbe8074fde39.apk + https://downs.muzhiwan.com/2019/07/23/com.amazid.me_5d36bade614d9.apk + https://downs.muzhiwan.com/2019/07/30/com.counter.terrorist.attack.fps.sniper.fight_5d3fe8f0a7edf.apk @@ -135,8 +132,8 @@ - 王者荣耀.apk - 战斗吧剑灵.apk + 泰拉瑞亚.apk + 疯狂屁股.apk @@ -151,8 +148,8 @@ - 部落冲突.apk - 城堡争霸.apk + 神奇的绳索英雄.apk + 自由火力反击.apk diff --git a/build.gradle b/build.gradle index 05b0c05b..b0fe1385 100644 --- a/build.gradle +++ b/build.gradle @@ -43,7 +43,7 @@ task clean(type: Delete) { ext { userOrg = 'arialyy' groupId = 'com.arialyy.aria' - publishVersion = '3.6.6_beta_1' + publishVersion = '3.6.6_beta_3' // publishVersion = '1.0.4' //FTP插件 repoName='maven' desc = 'android 下载框架'