From c231e88a5dec5ec7e0662327fce1cd78a4e03047 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 12 Jun 2018 00:04:36 +0800 Subject: [PATCH] Small tweak in setting up magisk DB --- .../magisk/database/MagiskDatabaseHelper.java | 11 ++--------- src/full/res/raw/utils.sh | 4 ++-- src/main/java/com/topjohnwu/magisk/utils/Const.java | 1 - 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/full/java/com/topjohnwu/magisk/database/MagiskDatabaseHelper.java b/src/full/java/com/topjohnwu/magisk/database/MagiskDatabaseHelper.java index ccb318ba5..c8b35aa44 100644 --- a/src/full/java/com/topjohnwu/magisk/database/MagiskDatabaseHelper.java +++ b/src/full/java/com/topjohnwu/magisk/database/MagiskDatabaseHelper.java @@ -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); diff --git a/src/full/res/raw/utils.sh b/src/full/res/raw/utils.sh index 9209274a4..15c5e103f 100644 --- a/src/full/res/raw/utils.sh +++ b/src/full/res/raw/utils.sh @@ -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() { diff --git a/src/main/java/com/topjohnwu/magisk/utils/Const.java b/src/main/java/com/topjohnwu/magisk/utils/Const.java index 9360ffa85..4bfbf266f 100644 --- a/src/main/java/com/topjohnwu/magisk/utils/Const.java +++ b/src/main/java/com/topjohnwu/magisk/utils/Const.java @@ -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;