Try to flush database before uninstalling

This commit is contained in:
topjohnwu 2018-10-20 15:31:41 -04:00
parent e7e580e177
commit 6557070ae1
2 changed files with 10 additions and 0 deletions

View File

@ -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);

View File

@ -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);