From 97bf3884716b985df01dd8b854eb4ed55dadab40 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 17 Nov 2017 23:34:38 +0800 Subject: [PATCH] Support new module specification --- .../magisk/container/BaseModule.java | 13 ++++----- .../com/topjohnwu/magisk/container/Repo.java | 3 ++- .../magisk/database/RepoDatabaseHelper.java | 27 ++++++++++--------- .../magisk/database/SuDatabaseHelper.java | 9 ++++--- .../com/topjohnwu/magisk/utils/Const.java | 3 +-- 5 files changed, 30 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/container/BaseModule.java b/app/src/main/java/com/topjohnwu/magisk/container/BaseModule.java index c161a7d74..c22feafd6 100644 --- a/app/src/main/java/com/topjohnwu/magisk/container/BaseModule.java +++ b/app/src/main/java/com/topjohnwu/magisk/container/BaseModule.java @@ -10,7 +10,7 @@ import java.util.List; public abstract class BaseModule implements Comparable { private String mId = null, mName, mVersion, mAuthor, mDescription; - private int mVersionCode = -1, templateVersion = -1; + private int mVersionCode = -1, minMagiskVersion = -1; protected BaseModule() {} @@ -21,7 +21,7 @@ public abstract class BaseModule implements Comparable { mVersionCode = c.getInt(c.getColumnIndex("versionCode")); mAuthor = c.getString(c.getColumnIndex("author")); mDescription = c.getString(c.getColumnIndex("description")); - templateVersion = c.getInt(c.getColumnIndex("template")); + minMagiskVersion = c.getInt(c.getColumnIndex("minMagisk")); } public ContentValues getContentValues() { @@ -32,7 +32,7 @@ public abstract class BaseModule implements Comparable { values.put("versionCode", mVersionCode); values.put("author", mAuthor); values.put("description", mDescription); - values.put("template", templateVersion); + values.put("minMagisk", minMagiskVersion); return values; } @@ -67,8 +67,9 @@ public abstract class BaseModule implements Comparable { case "description": mDescription = prop[1]; break; + case "minMagisk": case "template": - templateVersion = Integer.parseInt(prop[1]); + minMagiskVersion = Integer.parseInt(prop[1]); break; default: break; @@ -108,8 +109,8 @@ public abstract class BaseModule implements Comparable { return mVersionCode; } - public int getTemplateVersion() { - return templateVersion; + public int getMinMagiskVersion() { + return minMagiskVersion; } @Override diff --git a/app/src/main/java/com/topjohnwu/magisk/container/Repo.java b/app/src/main/java/com/topjohnwu/magisk/container/Repo.java index 25a18fe02..7a57e75f7 100644 --- a/app/src/main/java/com/topjohnwu/magisk/container/Repo.java +++ b/app/src/main/java/com/topjohnwu/magisk/container/Repo.java @@ -40,7 +40,7 @@ public class Repo extends BaseModule { if (getVersionCode() < 0) { throw new IllegalRepoException("Repo [" + repoName + "] does not contain versionCode"); } - if (getTemplateVersion() < Const.Value.MIN_TEMPLATE_VER) { + if (getMinMagiskVersion() < Const.Value.MIN_MODULE_VER) { throw new IllegalRepoException("Repo [" + repoName + "] is outdated"); } } @@ -54,6 +54,7 @@ public class Repo extends BaseModule { return false; } + @Override public ContentValues getContentValues() { ContentValues values = super.getContentValues(); values.put("repo_name", repoName); diff --git a/app/src/main/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java b/app/src/main/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java index a28f598ff..e342a6994 100644 --- a/app/src/main/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java +++ b/app/src/main/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java @@ -15,7 +15,7 @@ import java.util.List; public class RepoDatabaseHelper extends SQLiteOpenHelper { - private static final int DATABASE_VER = 2; + private static final int DATABASE_VER = 3; private static final String TABLE_NAME = "repos"; private SQLiteDatabase mDb; @@ -23,12 +23,12 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper { public RepoDatabaseHelper(Context context) { super(context, "repo.db", null, DATABASE_VER); - mDb = getWritableDatabase(); mm = Utils.getMagiskManager(context); + mDb = getWritableDatabase(); // Clear bad repos - mDb.delete(TABLE_NAME, "template