From f8ea43466c294401d99968aff8fcb27238e62f97 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sun, 28 Oct 2018 00:58:22 -0400 Subject: [PATCH] Only allow device owner to hide/restore Magisk Manager --- app/src/full/java/com/topjohnwu/magisk/Data.java | 4 ++-- .../java/com/topjohnwu/magisk/fragments/SettingsFragment.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/full/java/com/topjohnwu/magisk/Data.java b/app/src/full/java/com/topjohnwu/magisk/Data.java index 24cf8eb60..25d1cb3c9 100644 --- a/app/src/full/java/com/topjohnwu/magisk/Data.java +++ b/app/src/full/java/com/topjohnwu/magisk/Data.java @@ -106,12 +106,12 @@ public class Data { mm.prefs.edit().commit(); File xml = new File(mm.getFilesDir().getParent() + "/shared_prefs", mm.getPackageName() + "_preferences.xml"); - Shell.su(Utils.fmt("for usr in /data/user/*; do cat %s > ${usr}/%s; done", xml, Const.MANAGER_CONFIGS)).exec(); + Shell.su(Utils.fmt("cat %s > /data/user/0/%s", xml, Const.MANAGER_CONFIGS)).exec(); } public static void importPrefs() { MagiskManager mm = MM(); - SuFile config = new SuFile(Utils.fmt("/data/user/%d/%s", Const.USER_ID, Const.MANAGER_CONFIGS)); + SuFile config = new SuFile("/data/user/0/" + Const.MANAGER_CONFIGS); if (config.exists()) { SharedPreferences.Editor editor = mm.prefs.edit(); try { diff --git a/app/src/full/java/com/topjohnwu/magisk/fragments/SettingsFragment.java b/app/src/full/java/com/topjohnwu/magisk/fragments/SettingsFragment.java index f5d414178..b950a6e65 100644 --- a/app/src/full/java/com/topjohnwu/magisk/fragments/SettingsFragment.java +++ b/app/src/full/java/com/topjohnwu/magisk/fragments/SettingsFragment.java @@ -140,7 +140,7 @@ public class SettingsFragment extends PreferenceFragmentCompat fingerprint.setSummary(R.string.disable_fingerprint); } - if (Shell.rootAccess()) { + if (Shell.rootAccess() && Const.USER_ID == 0) { if (mm.getPackageName().equals(Const.ORIG_PKG_NAME)) { hideManager.setOnPreferenceClickListener((pref) -> { PatchAPK.hideManager(requireActivity());