diff --git a/app/src/full/java/com/topjohnwu/magisk/asyncs/PatchAPK.java b/app/src/full/java/com/topjohnwu/magisk/asyncs/PatchAPK.java index 9ad2dab7a..a3b3c818c 100644 --- a/app/src/full/java/com/topjohnwu/magisk/asyncs/PatchAPK.java +++ b/app/src/full/java/com/topjohnwu/magisk/asyncs/PatchAPK.java @@ -111,6 +111,7 @@ public class PatchAPK { repack.delete(); mm.mDB.setStrings(Const.Key.SU_MANAGER, pkg); + mm.mDB.flush(); Data.exportPrefs(); RootUtils.uninstallPkg(Const.ORIG_PKG_NAME); diff --git a/app/src/full/java/com/topjohnwu/magisk/database/MagiskDatabaseHelper.java b/app/src/full/java/com/topjohnwu/magisk/database/MagiskDatabaseHelper.java index b30559c19..bbac8a94c 100644 --- a/app/src/full/java/com/topjohnwu/magisk/database/MagiskDatabaseHelper.java +++ b/app/src/full/java/com/topjohnwu/magisk/database/MagiskDatabaseHelper.java @@ -57,6 +57,10 @@ public class MagiskDatabaseHelper { private MagiskDatabaseHelper() { pm = Data.MM().getPackageManager(); + init(); + } + + private void init() { db = openDatabase(); db.disableWriteAheadLogging(); int version = Data.magiskVersionCode >= Const.MAGISK_VER.DBVER_SIX ? DATABASE_VER : OLD_DATABASE_VER; @@ -171,6 +175,11 @@ public class MagiskDatabaseHelper { "(key TEXT, value INT, PRIMARY KEY(key))"); } + public void flush() { + db.close(); + init(); + } + public void clearOutdated() { // Clear outdated policies db.delete(POLICY_TABLE, Utils.fmt("until > 0 AND until < %d", System.currentTimeMillis() / 1000), null);