Skip to content

Commit

Permalink
Prevent upgrading database before upgrading to v17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Sep 1, 2018
1 parent 298d5e1 commit ff3dad2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/src/full/java/com/topjohnwu/magisk/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public static final class MAGISK_VER {
public static final int REMOVE_LEGACY_LINK = 1630;
public static final int SEPOL_REFACTOR = 1640;
public static final int FIX_ENV = 1650;
public static final int DBVER_SIX = 17000;
}

public static class ID {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
public class MagiskDatabaseHelper {

private static final int DATABASE_VER = 6;
private static final int OLD_DATABASE_VER = 5;
private static final String POLICY_TABLE = "policies";
private static final String LOG_TABLE = "logs";
private static final String SETTINGS_TABLE = "settings";
Expand All @@ -57,13 +58,15 @@ private MagiskDatabaseHelper(MagiskManager context) {
pm = mm.getPackageManager();
db = openDatabase(mm);
db.disableWriteAheadLogging();
int version = db.getVersion();
if (version < DATABASE_VER) {
onUpgrade(db, version);
} else if (version > DATABASE_VER) {
int version = Data.magiskVersionCode >= Const.MAGISK_VER.DBVER_SIX ? DATABASE_VER : OLD_DATABASE_VER;
int curVersion = db.getVersion();
if (curVersion < version) {
onUpgrade(db, curVersion);
} else if (curVersion > DATABASE_VER) {
/* Higher than we can possibly support */
onDowngrade(db);
}
db.setVersion(DATABASE_VER);
db.setVersion(version);
clearOutdated();
}

Expand Down
3 changes: 3 additions & 0 deletions app/src/full/res/raw/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 5.9.1
- Prevent upgrading database before upgrading to v17.0

### v5.9.0
- No more on boot notifications
- Support new mechanism for installing to inactive slot for OTAs on A/B devices
Expand Down

0 comments on commit ff3dad2

Please sign in to comment.