Only allow device owner to hide/restore Magisk Manager

This commit is contained in:
topjohnwu 2018-10-28 00:58:22 -04:00
parent 75ab1fa570
commit f8ea43466c
2 changed files with 3 additions and 3 deletions

View File

@ -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 {

View File

@ -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());