Remove support for Magisk lower than 1500
This commit is contained in:
parent
dd9ddd2019
commit
e7e580e177
@ -48,11 +48,6 @@ public class Const {
|
|||||||
public static final int USER_ID = Process.myUid() / 100000;
|
public static final int USER_ID = Process.myUid() / 100000;
|
||||||
|
|
||||||
public static final class MAGISK_VER {
|
public static final class MAGISK_VER {
|
||||||
public static final int UNIFIED = 1300;
|
|
||||||
public static final int FBE_AWARE = 1410;
|
|
||||||
public static final int RESETPROP_PERSIST = 1436;
|
|
||||||
public static final int MANAGER_HIDE = 1440;
|
|
||||||
public static final int HIDDEN_PATH = 1460;
|
|
||||||
public static final int REMOVE_LEGACY_LINK = 1630;
|
public static final int REMOVE_LEGACY_LINK = 1630;
|
||||||
public static final int SEPOL_REFACTOR = 1640;
|
public static final int SEPOL_REFACTOR = 1640;
|
||||||
public static final int FIX_ENV = 1650;
|
public static final int FIX_ENV = 1650;
|
||||||
|
@ -95,8 +95,7 @@ public class Data {
|
|||||||
try {
|
try {
|
||||||
magiskVersionString = ShellUtils.fastCmd("magisk -v").split(":")[0];
|
magiskVersionString = ShellUtils.fastCmd("magisk -v").split(":")[0];
|
||||||
magiskVersionCode = Integer.parseInt(ShellUtils.fastCmd("magisk -V"));
|
magiskVersionCode = Integer.parseInt(ShellUtils.fastCmd("magisk -V"));
|
||||||
String s = ShellUtils.fastCmd((magiskVersionCode >= Const.MAGISK_VER.RESETPROP_PERSIST ?
|
String s = ShellUtils.fastCmd(("resetprop -p ") + Const.MAGISKHIDE_PROP);
|
||||||
"resetprop -p " : "getprop ") + Const.MAGISKHIDE_PROP);
|
|
||||||
magiskHide = s.isEmpty() || Integer.parseInt(s) != 0;
|
magiskHide = s.isEmpty() || Integer.parseInt(s) != 0;
|
||||||
} catch (NumberFormatException ignored) {}
|
} catch (NumberFormatException ignored) {}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class MagiskManager extends ContainerApp {
|
|||||||
Shell.Config.setInitializer(RootUtils.class);
|
Shell.Config.setInitializer(RootUtils.class);
|
||||||
|
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
mDB = MagiskDatabaseHelper.getInstance(this);
|
mDB = MagiskDatabaseHelper.getInstance();
|
||||||
|
|
||||||
String pkg = mDB.getStrings(Const.Key.SU_MANAGER, null);
|
String pkg = mDB.getStrings(Const.Key.SU_MANAGER, null);
|
||||||
if (pkg != null && getPackageName().equals(Const.ORIG_PKG_NAME)) {
|
if (pkg != null && getPackageName().equals(Const.ORIG_PKG_NAME)) {
|
||||||
|
@ -119,7 +119,6 @@ public class MainActivity extends BaseActivity
|
|||||||
public void checkHideSection() {
|
public void checkHideSection() {
|
||||||
Menu menu = navigationView.getMenu();
|
Menu menu = navigationView.getMenu();
|
||||||
menu.findItem(R.id.magiskhide).setVisible(Shell.rootAccess() &&
|
menu.findItem(R.id.magiskhide).setVisible(Shell.rootAccess() &&
|
||||||
Data.magiskVersionCode >= Const.MAGISK_VER.UNIFIED &&
|
|
||||||
mm.prefs.getBoolean(Const.Key.MAGISKHIDE, false));
|
mm.prefs.getBoolean(Const.Key.MAGISKHIDE, false));
|
||||||
menu.findItem(R.id.modules).setVisible(Shell.rootAccess() && Data.magiskVersionCode >= 0);
|
menu.findItem(R.id.modules).setVisible(Shell.rootAccess() && Data.magiskVersionCode >= 0);
|
||||||
menu.findItem(R.id.downloads).setVisible(Download.checkNetworkStatus(this)
|
menu.findItem(R.id.downloads).setVisible(Download.checkNetworkStatus(this)
|
||||||
|
@ -38,26 +38,26 @@ public class MagiskDatabaseHelper {
|
|||||||
private static final String LOG_TABLE = "logs";
|
private static final String LOG_TABLE = "logs";
|
||||||
private static final String SETTINGS_TABLE = "settings";
|
private static final String SETTINGS_TABLE = "settings";
|
||||||
private static final String STRINGS_TABLE = "strings";
|
private static final String STRINGS_TABLE = "strings";
|
||||||
|
private static final File MANAGER_DB =
|
||||||
|
new File(Utils.fmt("/sbin/.core/db-%d/magisk.db", Const.USER_ID));
|
||||||
|
|
||||||
private PackageManager pm;
|
private PackageManager pm;
|
||||||
private SQLiteDatabase db;
|
private SQLiteDatabase db;
|
||||||
private MagiskManager mm;
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static MagiskDatabaseHelper getInstance(MagiskManager mm) {
|
public static MagiskDatabaseHelper getInstance() {
|
||||||
try {
|
try {
|
||||||
return new MagiskDatabaseHelper(mm);
|
return new MagiskDatabaseHelper();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Let's cleanup everything and try again
|
// Let's cleanup everything and try again
|
||||||
Shell.su("db_clean '*'").exec();
|
Shell.su("db_clean '*'").exec();
|
||||||
return new MagiskDatabaseHelper(mm);
|
return new MagiskDatabaseHelper();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private MagiskDatabaseHelper(MagiskManager context) {
|
private MagiskDatabaseHelper() {
|
||||||
mm = context;
|
pm = Data.MM().getPackageManager();
|
||||||
pm = mm.getPackageManager();
|
db = openDatabase();
|
||||||
db = openDatabase(mm);
|
|
||||||
db.disableWriteAheadLogging();
|
db.disableWriteAheadLogging();
|
||||||
int version = Data.magiskVersionCode >= Const.MAGISK_VER.DBVER_SIX ? DATABASE_VER : OLD_DATABASE_VER;
|
int version = Data.magiskVersionCode >= Const.MAGISK_VER.DBVER_SIX ? DATABASE_VER : OLD_DATABASE_VER;
|
||||||
int curVersion = db.getVersion();
|
int curVersion = db.getVersion();
|
||||||
@ -71,48 +71,37 @@ public class MagiskDatabaseHelper {
|
|||||||
clearOutdated();
|
clearOutdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
private SQLiteDatabase openDatabase(MagiskManager mm) {
|
private SQLiteDatabase openDatabase() {
|
||||||
final File DB_FILE = new File(Utils.fmt("/sbin/.core/db-%d/magisk.db", Const.USER_ID));
|
MagiskManager mm = Data.MM();
|
||||||
Context de = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
|
Context de = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
|
||||||
? mm.createDeviceProtectedStorageContext() : mm;
|
? mm.createDeviceProtectedStorageContext() : mm;
|
||||||
if (!DB_FILE.canWrite()) {
|
if (!MANAGER_DB.canWrite()) {
|
||||||
if (!Shell.rootAccess()) {
|
if (!Shell.rootAccess()) {
|
||||||
// We don't want the app to crash, create a db and return
|
// We don't want the app to crash, create a db and return
|
||||||
return mm.openOrCreateDatabase("su.db", Context.MODE_PRIVATE, null);
|
return mm.openOrCreateDatabase("su.db", Context.MODE_PRIVATE, null);
|
||||||
}
|
}
|
||||||
// Cleanup
|
// Cleanup
|
||||||
Shell.su("db_clean " + Const.USER_ID).exec();
|
Shell.su("db_clean " + Const.USER_ID).exec();
|
||||||
if (Data.magiskVersionCode < Const.MAGISK_VER.FBE_AWARE) {
|
// Global database
|
||||||
// Super old legacy mode
|
final SuFile GLOBAL_DB = new SuFile("/data/adb/magisk.db");
|
||||||
return mm.openOrCreateDatabase("su.db", Context.MODE_PRIVATE, null);
|
mm.deleteDatabase("su.db");
|
||||||
} else if (Data.magiskVersionCode < Const.MAGISK_VER.HIDDEN_PATH) {
|
de.deleteDatabase("su.db");
|
||||||
// Legacy mode with FBE aware
|
if (Data.magiskVersionCode < Const.MAGISK_VER.SEPOL_REFACTOR) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
// We need some additional policies on old versions
|
||||||
de.moveDatabaseFrom(mm, "su.db");
|
Shell.su("db_sepatch").exec();
|
||||||
}
|
}
|
||||||
return de.openOrCreateDatabase("su.db", Context.MODE_PRIVATE, null);
|
if (!GLOBAL_DB.exists()) {
|
||||||
} else {
|
Shell.su("db_init").exec();
|
||||||
// Global database
|
SQLiteDatabase.openOrCreateDatabase(GLOBAL_DB, null).close();
|
||||||
final SuFile GLOBAL_DB = new SuFile("/data/adb/magisk.db");
|
Shell.su("db_restore").exec();
|
||||||
mm.deleteDatabase("su.db");
|
|
||||||
de.deleteDatabase("su.db");
|
|
||||||
if (Data.magiskVersionCode < Const.MAGISK_VER.SEPOL_REFACTOR) {
|
|
||||||
// We need some additional policies on old versions
|
|
||||||
Shell.su("db_sepatch").exec();
|
|
||||||
}
|
|
||||||
if (!GLOBAL_DB.exists()) {
|
|
||||||
Shell.su("db_init").exec();
|
|
||||||
SQLiteDatabase.openOrCreateDatabase(GLOBAL_DB, null).close();
|
|
||||||
Shell.su("db_restore").exec();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Shell.su("db_setup " + Process.myUid()).exec();
|
Shell.su("db_setup " + Process.myUid()).exec();
|
||||||
}
|
}
|
||||||
// Not using legacy mode, open the mounted global DB
|
// Not using legacy mode, open the mounted global DB
|
||||||
return SQLiteDatabase.openOrCreateDatabase(DB_FILE, null);
|
return SQLiteDatabase.openOrCreateDatabase(MANAGER_DB, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion) {
|
private void onUpgrade(SQLiteDatabase db, int oldVersion) {
|
||||||
if (oldVersion == 0) {
|
if (oldVersion == 0) {
|
||||||
createTables(db);
|
createTables(db);
|
||||||
oldVersion = 3;
|
oldVersion = 3;
|
||||||
@ -147,13 +136,13 @@ public class MagiskDatabaseHelper {
|
|||||||
}
|
}
|
||||||
if (oldVersion == 5) {
|
if (oldVersion == 5) {
|
||||||
setSettings(Const.Key.SU_FINGERPRINT,
|
setSettings(Const.Key.SU_FINGERPRINT,
|
||||||
mm.prefs.getBoolean(Const.Key.SU_FINGERPRINT, false) ? 1 : 0);
|
Data.MM().prefs.getBoolean(Const.Key.SU_FINGERPRINT, false) ? 1 : 0);
|
||||||
++oldVersion;
|
++oldVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove everything, we do not support downgrade
|
// Remove everything, we do not support downgrade
|
||||||
public void onDowngrade(SQLiteDatabase db) {
|
private void onDowngrade(SQLiteDatabase db) {
|
||||||
Utils.toast(R.string.su_db_corrupt, Toast.LENGTH_LONG);
|
Utils.toast(R.string.su_db_corrupt, Toast.LENGTH_LONG);
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + POLICY_TABLE);
|
db.execSQL("DROP TABLE IF EXISTS " + POLICY_TABLE);
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + LOG_TABLE);
|
db.execSQL("DROP TABLE IF EXISTS " + LOG_TABLE);
|
||||||
|
@ -214,11 +214,10 @@ public class MagiskFragment extends BaseFragment
|
|||||||
|
|
||||||
boolean hasNetwork = Download.checkNetworkStatus(mm);
|
boolean hasNetwork = Download.checkNetworkStatus(mm);
|
||||||
boolean hasRoot = Shell.rootAccess();
|
boolean hasRoot = Shell.rootAccess();
|
||||||
boolean isUpToDate = Data.magiskVersionCode > Const.MAGISK_VER.UNIFIED;
|
|
||||||
|
|
||||||
magiskUpdate.setVisibility(hasNetwork ? View.VISIBLE : View.GONE);
|
magiskUpdate.setVisibility(hasNetwork ? View.VISIBLE : View.GONE);
|
||||||
installOptionCard.setVisibility(hasNetwork ? View.VISIBLE : View.GONE);
|
installOptionCard.setVisibility(hasNetwork ? View.VISIBLE : View.GONE);
|
||||||
uninstallButton.setVisibility(isUpToDate && hasRoot ? View.VISIBLE : View.GONE);
|
uninstallButton.setVisibility(hasRoot ? View.VISIBLE : View.GONE);
|
||||||
coreOnlyNotice.setVisibility(mm.prefs.getBoolean(Const.Key.COREONLY, false) ? View.VISIBLE : View.GONE);
|
coreOnlyNotice.setVisibility(mm.prefs.getBoolean(Const.Key.COREONLY, false) ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
int image, color;
|
int image, color;
|
||||||
|
@ -124,7 +124,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
|||||||
fingerprint.setSummary(R.string.disable_fingerprint);
|
fingerprint.setSummary(R.string.disable_fingerprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Data.magiskVersionCode >= Const.MAGISK_VER.MANAGER_HIDE) {
|
if (Shell.rootAccess()) {
|
||||||
if (mm.getPackageName().equals(Const.ORIG_PKG_NAME)) {
|
if (mm.getPackageName().equals(Const.ORIG_PKG_NAME)) {
|
||||||
hideManager.setOnPreferenceClickListener((pref) -> {
|
hideManager.setOnPreferenceClickListener((pref) -> {
|
||||||
PatchAPK.hideManager(requireActivity());
|
PatchAPK.hideManager(requireActivity());
|
||||||
@ -171,8 +171,6 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
|||||||
if (!Shell.rootAccess()) {
|
if (!Shell.rootAccess()) {
|
||||||
prefScreen.removePreference(magiskCategory);
|
prefScreen.removePreference(magiskCategory);
|
||||||
generalCatagory.removePreference(hideManager);
|
generalCatagory.removePreference(hideManager);
|
||||||
} else if (Data.magiskVersionCode < Const.MAGISK_VER.UNIFIED) {
|
|
||||||
prefScreen.removePreference(magiskCategory);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +45,7 @@ public class ShortcutReceiver extends BroadcastReceiver {
|
|||||||
.setRank(0)
|
.setRank(0)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
if (root && Data.magiskVersionCode >= Const.MAGISK_VER.UNIFIED
|
if (root && mm.prefs.getBoolean(Const.Key.MAGISKHIDE, false)) {
|
||||||
&& mm.prefs.getBoolean(Const.Key.MAGISKHIDE, false)) {
|
|
||||||
shortCuts.add(new ShortcutInfo.Builder(mm, "magiskhide")
|
shortCuts.add(new ShortcutInfo.Builder(mm, "magiskhide")
|
||||||
.setShortLabel(mm.getString(R.string.magiskhide))
|
.setShortLabel(mm.getString(R.string.magiskhide))
|
||||||
.setIntent(new Intent(mm, Data.classMap.get(SplashActivity.class))
|
.setIntent(new Intent(mm, Data.classMap.get(SplashActivity.class))
|
||||||
|
Loading…
Reference in New Issue
Block a user