diff --git a/DEV_LOG.md b/DEV_LOG.md index a74fea82..8e5eb6c4 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -8,6 +8,7 @@ - 修复组任务中,其中一个子任务是30x地址,导致调度器无法出现该子任务状态的问题 - 增加组任务groupHash冲突检查 https://github.com/AriaLyy/Aria/issues/635 - 修复task.cancel(false)还是把本地文件删除的问题 https://github.com/AriaLyy/Aria/issues/646 + - fix bug https://github.com/AriaLyy/Aria/issues/670 + v_3.8.6 (2020/2/17) - fix bug https://github.com/AriaLyy/Aria/issues/608 - fix bug https://github.com/AriaLyy/Aria/issues/579#issuecomment-586665035 diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/group/SubRecordHandler.java b/PublicComponent/src/main/java/com/arialyy/aria/core/group/SubRecordHandler.java index 4b64115e..5d4021d0 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/group/SubRecordHandler.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/group/SubRecordHandler.java @@ -25,7 +25,6 @@ import com.arialyy.aria.core.loader.IRecordHandler; import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.core.wrapper.ITaskWrapper; import com.arialyy.aria.util.RecordUtil; - import java.util.ArrayList; /** @@ -97,13 +96,13 @@ public class SubRecordHandler extends RecordHandler { @Override public int initTaskThreadNum() { int requestTpe = getWrapper().getRequestType(); if (requestTpe == ITaskWrapper.U_HTTP - || (requestTpe == ITaskWrapper.D_HTTP && (!getWrapper().isSupportBP()) + || (requestTpe == ITaskWrapper.D_HTTP && (!getWrapper().isSupportBP()) )) { return 1; } int threadNum = Configuration.getInstance().downloadCfg.getThreadNum(); return getFileSize() <= IRecordHandler.SUB_LEN - ? 1 - : threadNum; + ? 1 + : threadNum; } } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/loader/NormalLoader.java b/PublicComponent/src/main/java/com/arialyy/aria/core/loader/NormalLoader.java index ff1d8f18..a3d4db2e 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/loader/NormalLoader.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/loader/NormalLoader.java @@ -132,8 +132,6 @@ public class NormalLoader extends AbsNormalLoader { ThreadTaskManager.getInstance().startThread(mTaskWrapper.getKey(), threadTask); } - List list = getTaskList(); - // 启动定时器 startTimer(); } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/loader/SubLoader.java b/PublicComponent/src/main/java/com/arialyy/aria/core/loader/SubLoader.java index 8d737056..b9144d5a 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/loader/SubLoader.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/loader/SubLoader.java @@ -22,7 +22,6 @@ import android.os.Message; import android.text.TextUtils; import com.arialyy.aria.core.TaskRecord; import com.arialyy.aria.core.common.AbsEntity; -import com.arialyy.aria.core.common.AbsNormalEntity; import com.arialyy.aria.core.common.CompleteInfo; import com.arialyy.aria.core.inf.IThreadStateManager; import com.arialyy.aria.core.manager.ThreadTaskManager; @@ -97,26 +96,27 @@ public final class SubLoader implements ILoader, ILoaderVisitor { } private void handlerTask() { - if (isBreak()){ + if (isBreak()) { return; } - Looper looper=Looper.myLooper(); - if(looper==null) { + Looper looper = Looper.myLooper(); + if (looper == null) { Looper.prepare(); - looper=Looper.myLooper(); + looper = Looper.myLooper(); } record = recordHandler.getRecord(wrapper.getEntity().getFileSize()); if (record.threadRecords != null - && !TextUtils.isEmpty(record.filePath) - && new File(record.filePath).exists() - && !record.threadRecords.isEmpty() - && record.threadRecords.get(0).isComplete) { + && !TextUtils.isEmpty(record.filePath) + && new File(record.filePath).exists() + && !record.threadRecords.isEmpty() + && record.threadRecords.get(0).isComplete) { ALog.d(TAG, "子任务已完成,key:" + wrapper.getKey()); sendNormalState(IThreadStateManager.STATE_COMPLETE); return; } - List task = ttBuild.buildThreadTask(record, new Handler(looper, mStateManager.getHandlerCallback())); + List task = + ttBuild.buildThreadTask(record, new Handler(looper, mStateManager.getHandlerCallback())); mStateManager.setLooper(record, looper); if (task == null || task.isEmpty()) { ALog.e(TAG, "创建子任务的线程任务失败,key:" + wrapper.getKey()); @@ -129,9 +129,8 @@ public final class SubLoader implements ILoader, ILoaderVisitor { return; } - sendNormalState(IThreadStateManager.STATE_PRE); - mTask .addAll( task); + mTask.addAll(task); try { for (IThreadTask iThreadTask : mTask) { ThreadTaskManager.getInstance().startThread(parentKey, iThreadTask); @@ -146,7 +145,7 @@ public final class SubLoader implements ILoader, ILoaderVisitor { Looper.loop(); } - public TaskRecord getRecord(){ + public TaskRecord getRecord() { return record; } @@ -160,7 +159,7 @@ public final class SubLoader implements ILoader, ILoaderVisitor { public void retryTask() { try { - if (!mTask.isEmpty() ) { + if (!mTask.isEmpty()) { for (IThreadTask iThreadTask : mTask) { iThreadTask.call(); } @@ -181,14 +180,14 @@ public final class SubLoader implements ILoader, ILoaderVisitor { for (IThreadTask iThreadTask : mTask) { iThreadTask.stop(); } - } @Override public boolean isRunning() { - if(mTask.isEmpty()) + if (mTask.isEmpty()) { return false; + } for (IThreadTask iThreadTask : mTask) { - if(!iThreadTask.isBreak()) return true; + if (!iThreadTask.isBreak()) return true; } return false; } @@ -223,7 +222,8 @@ public final class SubLoader implements ILoader, ILoaderVisitor { } @Override public long getCurrentProgress() { - return isRunning() ? mStateManager.getCurrentProgress() : getWrapper().getEntity().getCurrentProgress(); + return isRunning() ? mStateManager.getCurrentProgress() + : getWrapper().getEntity().getCurrentProgress(); } @Override public void addComponent(IRecordHandler recordHandler) { diff --git a/PublicComponent/src/main/java/com/arialyy/aria/orm/DelegateFind.java b/PublicComponent/src/main/java/com/arialyy/aria/orm/DelegateFind.java index dc1f0b45..7209315f 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/orm/DelegateFind.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/orm/DelegateFind.java @@ -139,8 +139,8 @@ class DelegateFind extends AbsDelegate { Class parentClazz = Class.forName(one.getType().getName()); Class childClazz = Class.forName(CommonUtil.getListParamType(many).getName()); // 检查表 - SqlUtil.checkTable(db, parentClazz); - SqlUtil.checkTable(db, childClazz); + SqlUtil.checkOrCreateTable(db, parentClazz); + SqlUtil.checkOrCreateTable(db, childClazz); final String pTableName = parentClazz.getSimpleName(); final String cTableName = childClazz.getSimpleName(); List pColumn = SqlUtil.getAllNotIgnoreField(parentClazz); @@ -460,7 +460,7 @@ class DelegateFind extends AbsDelegate { */ private List exeNormalDataSql(SQLiteDatabase db, Class clazz, String sql, String[] selectionArgs) { - SqlUtil.checkTable(db, clazz); + SqlUtil.checkOrCreateTable(db, clazz); Cursor cursor; if (selectionArgs != null) { diff --git a/PublicComponent/src/main/java/com/arialyy/aria/orm/DelegateUpdate.java b/PublicComponent/src/main/java/com/arialyy/aria/orm/DelegateUpdate.java index 4ee99afe..2c6bb876 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/orm/DelegateUpdate.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/orm/DelegateUpdate.java @@ -38,7 +38,7 @@ class DelegateUpdate extends AbsDelegate { */ synchronized void delData(SQLiteDatabase db, Class clazz, String... expression) { - SqlUtil.checkTable(db, clazz); + SqlUtil.checkOrCreateTable(db, clazz); db = checkDb(db); if (!CommonUtil.checkSqlExpression(expression)) { return; @@ -58,7 +58,7 @@ class DelegateUpdate extends AbsDelegate { * 修改某行数据 */ synchronized void updateData(SQLiteDatabase db, DbEntity dbEntity) { - SqlUtil.checkTable(db, dbEntity.getClass()); + SqlUtil.checkOrCreateTable(db, dbEntity.getClass()); db = checkDb(db); ContentValues values = createValues(dbEntity); if (values != null) { @@ -111,7 +111,7 @@ class DelegateUpdate extends AbsDelegate { if (oldClazz == null || oldClazz != entity.getClass() || table == null) { oldClazz = entity.getClass(); table = CommonUtil.getClassName(oldClazz); - SqlUtil.checkTable(db, oldClazz); + SqlUtil.checkOrCreateTable(db, oldClazz); } ContentValues value = createValues(entity); @@ -133,7 +133,7 @@ class DelegateUpdate extends AbsDelegate { * 插入数据 */ synchronized void insertData(SQLiteDatabase db, DbEntity dbEntity) { - SqlUtil.checkTable(db, dbEntity.getClass()); + SqlUtil.checkOrCreateTable(db, dbEntity.getClass()); db = checkDb(db); ContentValues values = createValues(dbEntity); if (values != null) { diff --git a/PublicComponent/src/main/java/com/arialyy/aria/orm/SqlHelper.java b/PublicComponent/src/main/java/com/arialyy/aria/orm/SqlHelper.java index 0e8caafb..7f5d2c62 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/orm/SqlHelper.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/orm/SqlHelper.java @@ -22,7 +22,11 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.os.Build; import android.text.TextUtils; +import com.arialyy.aria.core.TaskRecord; +import com.arialyy.aria.core.ThreadRecord; +import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.M3U8Entity; +import com.arialyy.aria.core.upload.UploadEntity; import com.arialyy.aria.core.wrapper.ITaskWrapper; import com.arialyy.aria.util.ALog; import java.io.File; @@ -308,6 +312,11 @@ final class SqlHelper extends SQLiteOpenHelper { */ private void addTaskRecordType(SQLiteDatabase db) { try { + SqlUtil.checkOrCreateTable(db, ThreadRecord.class); + SqlUtil.checkOrCreateTable(db, TaskRecord.class); + SqlUtil.checkOrCreateTable(db, UploadEntity.class); + SqlUtil.checkOrCreateTable(db, DownloadEntity.class); + db.beginTransaction(); /* * 增加下载实体的类型 @@ -380,6 +389,7 @@ final class SqlHelper extends SQLiteOpenHelper { * 删除重复的repeat数据 */ private void delRepeatThreadRecord(SQLiteDatabase db) { + SqlUtil.checkOrCreateTable(db, ThreadRecord.class); 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)"; @@ -406,6 +416,7 @@ final class SqlHelper extends SQLiteOpenHelper { * 处理365版本以下的升级 */ private void handle365Update(SQLiteDatabase db) { + SqlUtil.checkOrCreateTable(db, ThreadRecord.class); db.execSQL("UPDATE ThreadRecord SET threadId=0 WHERE threadId=-1"); Map> modifyMap = new HashMap<>(); diff --git a/PublicComponent/src/main/java/com/arialyy/aria/orm/SqlUtil.java b/PublicComponent/src/main/java/com/arialyy/aria/orm/SqlUtil.java index ff173eb2..80f236a5 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/orm/SqlUtil.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/orm/SqlUtil.java @@ -49,7 +49,7 @@ final class SqlUtil { /** * 检查表是否存在,不存在则创建表 */ - static void checkTable(SQLiteDatabase db, Class clazz) { + static void checkOrCreateTable(SQLiteDatabase db, Class clazz) { if (!tableExists(db, clazz)) { createTable(db, clazz); } diff --git a/build.gradle b/build.gradle index abdbe3bc..5ae534e9 100644 --- a/build.gradle +++ b/build.gradle @@ -45,7 +45,7 @@ task clean(type: Delete) { ext { versionCode = 387 - versionName = '3.8.7-beta-11' + versionName = '3.8.7-beta-12' userOrg = 'arialyy' groupId = 'com.arialyy.aria' publishVersion = versionName