Commit f8ea4346 authored by topjohnwu's avatar topjohnwu

Only allow device owner to hide/restore Magisk Manager

parent 75ab1fa5
...@@ -106,12 +106,12 @@ public class Data { ...@@ -106,12 +106,12 @@ public class Data {
mm.prefs.edit().commit(); mm.prefs.edit().commit();
File xml = new File(mm.getFilesDir().getParent() + "/shared_prefs", File xml = new File(mm.getFilesDir().getParent() + "/shared_prefs",
mm.getPackageName() + "_preferences.xml"); 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() { public static void importPrefs() {
MagiskManager mm = MM(); 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()) { if (config.exists()) {
SharedPreferences.Editor editor = mm.prefs.edit(); SharedPreferences.Editor editor = mm.prefs.edit();
try { try {
......
...@@ -140,7 +140,7 @@ public class SettingsFragment extends PreferenceFragmentCompat ...@@ -140,7 +140,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
fingerprint.setSummary(R.string.disable_fingerprint); fingerprint.setSummary(R.string.disable_fingerprint);
} }
if (Shell.rootAccess()) { if (Shell.rootAccess() && Const.USER_ID == 0) {
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());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment