Small tweak in setting up magisk DB

This commit is contained in:
topjohnwu 2018-06-12 00:04:36 +08:00
parent 79c71509f6
commit c231e88a5d
3 changed files with 4 additions and 12 deletions

View File

@ -78,7 +78,7 @@ public class MagiskDatabaseHelper {
if (mm.magiskVersionCode < Const.MAGISK_VER.FBE_AWARE) {
// Super old legacy mode
return mm.openOrCreateDatabase("su.db", Context.MODE_PRIVATE, null);
} else if (mm.magiskVersionCode < Const.MAGISK_VER.LEGACY_GLOBAL_DB) {
} else if (mm.magiskVersionCode < Const.MAGISK_VER.HIDDEN_PATH) {
// Legacy mode with FBE aware
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
de.moveDatabaseFrom(mm, "su.db");
@ -89,13 +89,6 @@ public class MagiskDatabaseHelper {
final SuFile GLOBAL_DB = new SuFile("/data/adb/magisk.db", true);
mm.deleteDatabase("su.db");
de.deleteDatabase("su.db");
if (mm.magiskVersionCode < Const.MAGISK_VER.HIDDEN_PATH) {
// Link to new path
File oldDB = new File(de.getFilesDir().getParentFile().getParentFile(),
"magisk.db");
Shell.Sync.su(Utils.fmt("mv -f %s %s; ln -s %s %s",
oldDB, GLOBAL_DB, GLOBAL_DB, oldDB));
}
if (mm.magiskVersionCode < Const.MAGISK_VER.SEPOL_REFACTOR) {
// We need some additional policies on old versions
Shell.Sync.su("db_sepatch");
@ -105,8 +98,8 @@ public class MagiskDatabaseHelper {
SQLiteDatabase.openOrCreateDatabase(GLOBAL_DB, null).close();
Shell.Sync.su("db_restore");
}
Shell.Sync.su("db_setup " + Process.myUid());
}
Shell.Sync.su("db_setup " + Process.myUid());
}
// Not using legacy mode, open the mounted global DB
return SQLiteDatabase.openOrCreateDatabase(DB_FILE, null);

View File

@ -13,14 +13,14 @@ db_clean() {
}
db_init() {
ADB_CONTEXT=`/system/bin/ls -dZ /data/adb | awk '{print $1}'`
# Temporary let the folder rw by anyone
chcon u:object_r:magisk_file:s0 /data/adb
chmod 777 /data/adb
}
db_restore() {
chcon $ADB_CONTEXT /data/adb
chmod 700 /data/adb
magisk --restorecon
}
db_setup() {

View File

@ -57,7 +57,6 @@ public class Const {
public static final int RESETPROP_PERSIST = 1436;
public static final int MANAGER_HIDE = 1440;
public static final int DTBO_SUPPORT = 1446;
public static final int LEGACY_GLOBAL_DB = 1450;
public static final int HIDDEN_PATH = 1460;
public static final int REMOVE_LEGACY_LINK = 1630;
public static final int SEPOL_REFACTOR = 1640;