Prevent outdated modules to be shown

This commit is contained in:
topjohnwu 2018-04-08 01:05:01 +08:00
parent 684c5d225a
commit ce2e6b7d35
5 changed files with 11 additions and 7 deletions

View File

@ -106,9 +106,9 @@ public class MagiskManager extends Shell.ContainerApp {
@Override
public void onRootShellInit(@NonNull Shell shell) {
try (InputStream utils = getAssets().open(Const.UTIL_FUNCTIONS);
InputStream sudb = getResources().openRawResource(R.raw.magiskdb)) {
InputStream magiskDB = getResources().openRawResource(R.raw.magiskdb)) {
shell.loadInputStream(null, null, utils);
shell.loadInputStream(null, null, sudb);
shell.loadInputStream(null, null, magiskDB);
} catch (IOException e) {
e.printStackTrace();
}
@ -140,7 +140,6 @@ public class MagiskManager extends Shell.ContainerApp {
mDB = MagiskDatabaseHelper.getInstance(this);
}
repoDB = new RepoDatabaseHelper(this);
defaultLocale = Locale.getDefault();
setLocale();
loadConfig();

View File

@ -11,6 +11,7 @@ import com.topjohnwu.magisk.asyncs.LoadModules;
import com.topjohnwu.magisk.asyncs.ParallelTask;
import com.topjohnwu.magisk.asyncs.UpdateRepos;
import com.topjohnwu.magisk.components.Activity;
import com.topjohnwu.magisk.database.RepoDatabaseHelper;
import com.topjohnwu.magisk.receivers.ShortcutReceiver;
import com.topjohnwu.magisk.utils.Const;
import com.topjohnwu.magisk.utils.Utils;
@ -24,6 +25,7 @@ public class SplashActivity extends Activity {
MagiskManager mm = getMagiskManager();
mm.repoDB = new RepoDatabaseHelper(this);
mm.loadMagiskInfo();
mm.getDefaultInstallFlags();
Utils.loadPrefs();

View File

@ -42,7 +42,7 @@ public class Repo extends BaseModule {
if (getVersionCode() < 0) {
throw new IllegalRepoException("Repo [" + repoName + "] does not contain versionCode");
}
if (getMinMagiskVersion() < Const.MIN_MODULE_VER) {
if (getMinMagiskVersion() < Const.MIN_MODULE_VER()) {
throw new IllegalRepoException("Repo [" + repoName + "] is outdated");
}
}

View File

@ -26,9 +26,9 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
mm = Utils.getMagiskManager(context);
mDb = getWritableDatabase();
// Clear bad repos
// Remove outdated repos
mDb.delete(TABLE_NAME, "minMagisk<?",
new String[] { String.valueOf(Const.MIN_MODULE_VER) });
new String[] { String.valueOf(Const.MIN_MODULE_VER()) });
}
@Override

View File

@ -36,7 +36,10 @@ public class Const {
// Versions
public static final int UPDATE_SERVICE_VER = 1;
public static final int SNET_VER = 7;
public static final int MIN_MODULE_VER = 1400;
public static int MIN_MODULE_VER() {
return MagiskManager.get().magiskVersionCode >= 1630 ? 1500 : 1400;
}
public synchronized static SuFile MAGISK_PATH() {
SuFile file;