mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-16 08:51:24 +00:00
Cleanup prefs
This commit is contained in:
parent
1cd2c5e653
commit
f3c3b5a649
@ -8,7 +8,7 @@ android {
|
|||||||
applicationId "com.topjohnwu.magisk"
|
applicationId "com.topjohnwu.magisk"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 27
|
targetSdkVersion 27
|
||||||
versionCode 68
|
versionCode 69
|
||||||
versionName "5.4.3"
|
versionName "5.4.3"
|
||||||
ndk {
|
ndk {
|
||||||
moduleName 'zipadjust'
|
moduleName 'zipadjust'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
### v5.4.3 (68)
|
### v5.4.3 (69)
|
||||||
- Fix dynamic resource loading, should prevent crashing when chacking SafetyNet
|
- Fix dynamic resource loading, should prevent crashing when checking SafetyNet
|
||||||
- Update SignAPK to use very little RAM, should expand old device support
|
- Update SignAPK to use very little RAM, should expand old device support
|
||||||
- Support settings migration after hiding Magisk Manager
|
- Support settings migration after hiding Magisk Manager
|
||||||
- Add changelog in app
|
- Add reboot menu in modules section
|
||||||
|
- Add changelog in app
|
||||||
|
@ -91,7 +91,7 @@ public class MagiskFragment extends Fragment
|
|||||||
new CheckSafetyNet(getActivity()).exec();
|
new CheckSafetyNet(getActivity()).exec();
|
||||||
collapse();
|
collapse();
|
||||||
};
|
};
|
||||||
if (mm.snet_version < 0) {
|
if (mm.snetVersion < 0) {
|
||||||
// Show dialog
|
// Show dialog
|
||||||
new AlertDialogBuilder(getActivity())
|
new AlertDialogBuilder(getActivity())
|
||||||
.setTitle(R.string.proprietary_title)
|
.setTitle(R.string.proprietary_title)
|
||||||
|
@ -50,9 +50,7 @@ public class MagiskManager extends Application {
|
|||||||
public int remoteManagerVersionCode = -1;
|
public int remoteManagerVersionCode = -1;
|
||||||
public String managerLink;
|
public String managerLink;
|
||||||
public String bootBlock = null;
|
public String bootBlock = null;
|
||||||
public int snet_version;
|
public int snetVersion;
|
||||||
public int updateServiceVersion;
|
|
||||||
public int appVersion;
|
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
public Map<String, Module> moduleMap;
|
public Map<String, Module> moduleMap;
|
||||||
@ -66,7 +64,6 @@ public class MagiskManager extends Application {
|
|||||||
public boolean isDarkTheme;
|
public boolean isDarkTheme;
|
||||||
public boolean updateNotification;
|
public boolean updateNotification;
|
||||||
public boolean suReauth;
|
public boolean suReauth;
|
||||||
public boolean coreOnly;
|
|
||||||
public int suRequestTimeout;
|
public int suRequestTimeout;
|
||||||
public int suLogTimeout = 14;
|
public int suLogTimeout = 14;
|
||||||
public int suAccessState;
|
public int suAccessState;
|
||||||
@ -146,8 +143,6 @@ public class MagiskManager extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadConfig() {
|
public void loadConfig() {
|
||||||
isDarkTheme = prefs.getBoolean(Const.Key.DARK_THEME, false);
|
|
||||||
|
|
||||||
// su
|
// su
|
||||||
suRequestTimeout = Utils.getPrefsInt(prefs, Const.Key.SU_REQUEST_TIMEOUT, Const.Value.timeoutList[2]);
|
suRequestTimeout = Utils.getPrefsInt(prefs, Const.Key.SU_REQUEST_TIMEOUT, Const.Value.timeoutList[2]);
|
||||||
suResponseType = Utils.getPrefsInt(prefs, Const.Key.SU_AUTO_RESPONSE, Const.Value.SU_PROMPT);
|
suResponseType = Utils.getPrefsInt(prefs, Const.Key.SU_AUTO_RESPONSE, Const.Value.SU_PROMPT);
|
||||||
@ -157,14 +152,13 @@ public class MagiskManager extends Application {
|
|||||||
multiuserMode = suDB.getSettings(Const.Key.SU_MULTIUSER_MODE, Const.Value.MULTIUSER_MODE_OWNER_ONLY);
|
multiuserMode = suDB.getSettings(Const.Key.SU_MULTIUSER_MODE, Const.Value.MULTIUSER_MODE_OWNER_ONLY);
|
||||||
suNamespaceMode = suDB.getSettings(Const.Key.SU_MNT_NS, Const.Value.NAMESPACE_MODE_REQUESTER);
|
suNamespaceMode = suDB.getSettings(Const.Key.SU_MNT_NS, Const.Value.NAMESPACE_MODE_REQUESTER);
|
||||||
|
|
||||||
coreOnly = prefs.getBoolean(Const.Key.DISABLE, false);
|
// config
|
||||||
|
isDarkTheme = prefs.getBoolean(Const.Key.DARK_THEME, false);
|
||||||
updateNotification = prefs.getBoolean(Const.Key.UPDATE_NOTIFICATION, true);
|
updateNotification = prefs.getBoolean(Const.Key.UPDATE_NOTIFICATION, true);
|
||||||
updateChannel = Utils.getPrefsInt(prefs, Const.Key.UPDATE_CHANNEL, Const.Value.STABLE_CHANNEL);
|
updateChannel = Utils.getPrefsInt(prefs, Const.Key.UPDATE_CHANNEL, Const.Value.STABLE_CHANNEL);
|
||||||
bootFormat = prefs.getString(Const.Key.BOOT_FORMAT, ".img");
|
bootFormat = prefs.getString(Const.Key.BOOT_FORMAT, ".img");
|
||||||
snet_version = prefs.getInt(Const.Key.SNET_VER, -1);
|
snetVersion = prefs.getInt(Const.Key.SNET_VER, -1);
|
||||||
updateServiceVersion = prefs.getInt(Const.Key.UPDATE_SERVICE_VER, -1);
|
|
||||||
customChannelUrl = prefs.getString(Const.Key.CUSTOM_CHANNEL, "");
|
customChannelUrl = prefs.getString(Const.Key.CUSTOM_CHANNEL, "");
|
||||||
appVersion = prefs.getInt(Const.Key.APP_VER, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toast(String msg, int duration) {
|
public static void toast(String msg, int duration) {
|
||||||
|
@ -92,9 +92,8 @@ public class MainActivity extends Activity
|
|||||||
|
|
||||||
navigationView.setNavigationItemSelectedListener(this);
|
navigationView.setNavigationItemSelectedListener(this);
|
||||||
|
|
||||||
if (mm.appVersion < BuildConfig.VERSION_CODE) {
|
if (mm.prefs.getInt(Const.Key.APP_VER, -1) < BuildConfig.VERSION_CODE) {
|
||||||
prefs.edit().putInt(Const.Key.APP_VER, BuildConfig.VERSION_CODE).apply();
|
prefs.edit().putInt(Const.Key.APP_VER, BuildConfig.VERSION_CODE).apply();
|
||||||
mm.appVersion = BuildConfig.VERSION_CODE;
|
|
||||||
try {
|
try {
|
||||||
InputStream is = getAssets().open("changelog.md");
|
InputStream is = getAssets().open("changelog.md");
|
||||||
new MarkDownWindow(this, getString(R.string.app_changelog), is).exec();
|
new MarkDownWindow(this, getString(R.string.app_changelog), is).exec();
|
||||||
@ -149,7 +148,7 @@ public class MainActivity extends Activity
|
|||||||
Shell.rootAccess() && mm.magiskVersionCode >= 0);
|
Shell.rootAccess() && mm.magiskVersionCode >= 0);
|
||||||
menu.findItem(R.id.downloads).setVisible(Utils.checkNetworkStatus() &&
|
menu.findItem(R.id.downloads).setVisible(Utils.checkNetworkStatus() &&
|
||||||
Shell.rootAccess() && mm.magiskVersionCode >= 0);
|
Shell.rootAccess() && mm.magiskVersionCode >= 0);
|
||||||
menu.setGroupVisible(R.id.second_group, !mm.coreOnly);
|
menu.setGroupVisible(R.id.second_group, !mm.prefs.getBoolean(Const.Key.COREONLY, false));
|
||||||
menu.findItem(R.id.log).setVisible(Shell.rootAccess());
|
menu.findItem(R.id.log).setVisible(Shell.rootAccess());
|
||||||
menu.findItem(R.id.superuser).setVisible(Shell.rootAccess());
|
menu.findItem(R.id.superuser).setVisible(Shell.rootAccess());
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,8 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
|||||||
|
|
||||||
// Remove re-authentication option on Android O, it will not work
|
// Remove re-authentication option on Android O, it will not work
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
suCategory.removePreference(reauth);
|
reauth.setEnabled(false);
|
||||||
|
reauth.setSummary(R.string.android_o_not_support);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mm.getPackageName().equals(Const.ORIG_PKG_NAME) && mm.magiskVersionCode >= 1440) {
|
if (mm.getPackageName().equals(Const.ORIG_PKG_NAME) && mm.magiskVersionCode >= 1440) {
|
||||||
@ -204,18 +205,14 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
||||||
boolean enabled;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case Const.Key.DARK_THEME:
|
case Const.Key.DARK_THEME:
|
||||||
enabled = prefs.getBoolean(Const.Key.DARK_THEME, false);
|
mm.isDarkTheme = prefs.getBoolean(key, false);
|
||||||
if (mm.isDarkTheme != enabled) {
|
mm.reloadActivity.publish(false);
|
||||||
mm.reloadActivity.publish(false);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case Const.Key.DISABLE:
|
case Const.Key.COREONLY:
|
||||||
enabled = prefs.getBoolean(Const.Key.DISABLE, false);
|
if (prefs.getBoolean(key, false)) {
|
||||||
if (enabled) {
|
|
||||||
Utils.createFile(Const.MAGISK_DISABLE_FILE);
|
Utils.createFile(Const.MAGISK_DISABLE_FILE);
|
||||||
} else {
|
} else {
|
||||||
Utils.removeItem(Const.MAGISK_DISABLE_FILE);
|
Utils.removeItem(Const.MAGISK_DISABLE_FILE);
|
||||||
@ -223,16 +220,14 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
|||||||
Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show();
|
Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show();
|
||||||
break;
|
break;
|
||||||
case Const.Key.MAGISKHIDE:
|
case Const.Key.MAGISKHIDE:
|
||||||
enabled = prefs.getBoolean(Const.Key.MAGISKHIDE, false);
|
if (prefs.getBoolean(key, false)) {
|
||||||
if (enabled) {
|
|
||||||
Shell.su_raw("magiskhide --enable");
|
Shell.su_raw("magiskhide --enable");
|
||||||
} else {
|
} else {
|
||||||
Shell.su_raw("magiskhide --disable");
|
Shell.su_raw("magiskhide --disable");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Const.Key.HOSTS:
|
case Const.Key.HOSTS:
|
||||||
enabled = prefs.getBoolean(Const.Key.HOSTS, false);
|
if (prefs.getBoolean(key, false)) {
|
||||||
if (enabled) {
|
|
||||||
Shell.su_raw(
|
Shell.su_raw(
|
||||||
"cp -af /system/etc/hosts " + Const.MAGISK_HOST_FILE(),
|
"cp -af /system/etc/hosts " + Const.MAGISK_HOST_FILE(),
|
||||||
"mount -o bind " + Const.MAGISK_HOST_FILE() + " /system/etc/hosts");
|
"mount -o bind " + Const.MAGISK_HOST_FILE() + " /system/etc/hosts");
|
||||||
@ -243,13 +238,9 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Const.Key.ROOT_ACCESS:
|
case Const.Key.ROOT_ACCESS:
|
||||||
mm.suDB.setSettings(Const.Key.ROOT_ACCESS, Utils.getPrefsInt(prefs, Const.Key.ROOT_ACCESS));
|
|
||||||
break;
|
|
||||||
case Const.Key.SU_MULTIUSER_MODE:
|
case Const.Key.SU_MULTIUSER_MODE:
|
||||||
mm.suDB.setSettings(Const.Key.SU_MULTIUSER_MODE, Utils.getPrefsInt(prefs, Const.Key.SU_MULTIUSER_MODE));
|
|
||||||
break;
|
|
||||||
case Const.Key.SU_MNT_NS:
|
case Const.Key.SU_MNT_NS:
|
||||||
mm.suDB.setSettings(Const.Key.SU_MNT_NS, Utils.getPrefsInt(prefs, Const.Key.SU_MNT_NS));
|
mm.suDB.setSettings(key, Utils.getPrefsInt(prefs, key));
|
||||||
break;
|
break;
|
||||||
case Const.Key.LOCALE:
|
case Const.Key.LOCALE:
|
||||||
mm.setLocale();
|
mm.setLocale();
|
||||||
|
@ -69,7 +69,7 @@ public class SplashActivity extends Activity {
|
|||||||
SuDatabaseHelper.setupSuDB();
|
SuDatabaseHelper.setupSuDB();
|
||||||
|
|
||||||
// Add update checking service
|
// Add update checking service
|
||||||
if (Const.Value.UPDATE_SERVICE_VER > mm.updateServiceVersion) {
|
if (Const.Value.UPDATE_SERVICE_VER > mm.prefs.getInt(Const.Key.UPDATE_SERVICE_VER, -1)) {
|
||||||
ComponentName service = new ComponentName(this, UpdateCheckService.class);
|
ComponentName service = new ComponentName(this, UpdateCheckService.class);
|
||||||
JobInfo info = new JobInfo.Builder(Const.ID.UPDATE_SERVICE_ID, service)
|
JobInfo info = new JobInfo.Builder(Const.ID.UPDATE_SERVICE_ID, service)
|
||||||
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
|
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
|
||||||
@ -77,7 +77,6 @@ public class SplashActivity extends Activity {
|
|||||||
.setPeriodic(8 * 60 * 60 * 1000)
|
.setPeriodic(8 * 60 * 60 * 1000)
|
||||||
.build();
|
.build();
|
||||||
((JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE)).schedule(info);
|
((JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE)).schedule(info);
|
||||||
mm.updateServiceVersion = Const.Value.UPDATE_SERVICE_VER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fire asynctasks
|
// Fire asynctasks
|
||||||
@ -93,7 +92,7 @@ public class SplashActivity extends Activity {
|
|||||||
.putBoolean(Const.Key.MAGISKHIDE, mm.magiskHide)
|
.putBoolean(Const.Key.MAGISKHIDE, mm.magiskHide)
|
||||||
.putBoolean(Const.Key.UPDATE_NOTIFICATION, mm.updateNotification)
|
.putBoolean(Const.Key.UPDATE_NOTIFICATION, mm.updateNotification)
|
||||||
.putBoolean(Const.Key.HOSTS, Utils.itemExist(Const.MAGISK_HOST_FILE()))
|
.putBoolean(Const.Key.HOSTS, Utils.itemExist(Const.MAGISK_HOST_FILE()))
|
||||||
.putBoolean(Const.Key.DISABLE, Utils.itemExist(Const.MAGISK_DISABLE_FILE))
|
.putBoolean(Const.Key.COREONLY, Utils.itemExist(Const.MAGISK_DISABLE_FILE))
|
||||||
.putBoolean(Const.Key.SU_REAUTH, mm.suReauth)
|
.putBoolean(Const.Key.SU_REAUTH, mm.suReauth)
|
||||||
.putString(Const.Key.SU_REQUEST_TIMEOUT, String.valueOf(mm.suRequestTimeout))
|
.putString(Const.Key.SU_REQUEST_TIMEOUT, String.valueOf(mm.suRequestTimeout))
|
||||||
.putString(Const.Key.SU_AUTO_RESPONSE, String.valueOf(mm.suResponseType))
|
.putString(Const.Key.SU_AUTO_RESPONSE, String.valueOf(mm.suResponseType))
|
||||||
@ -104,7 +103,7 @@ public class SplashActivity extends Activity {
|
|||||||
.putString(Const.Key.UPDATE_CHANNEL, String.valueOf(mm.updateChannel))
|
.putString(Const.Key.UPDATE_CHANNEL, String.valueOf(mm.updateChannel))
|
||||||
.putString(Const.Key.LOCALE, mm.localeConfig)
|
.putString(Const.Key.LOCALE, mm.localeConfig)
|
||||||
.putString(Const.Key.BOOT_FORMAT, mm.bootFormat)
|
.putString(Const.Key.BOOT_FORMAT, mm.bootFormat)
|
||||||
.putInt(Const.Key.UPDATE_SERVICE_VER, mm.updateServiceVersion)
|
.putInt(Const.Key.UPDATE_SERVICE_VER, Const.Value.UPDATE_SERVICE_VER)
|
||||||
.apply();
|
.apply();
|
||||||
|
|
||||||
mm.hasInit = true;
|
mm.hasInit = true;
|
||||||
|
@ -32,10 +32,10 @@ public class CheckSafetyNet extends ParallelTask<Void, Void, Exception> {
|
|||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
MagiskManager mm = MagiskManager.get();
|
MagiskManager mm = MagiskManager.get();
|
||||||
if (mm.snet_version != Const.Value.SNET_VER) {
|
if (mm.snetVersion != Const.Value.SNET_VER) {
|
||||||
Shell.sh("rm -rf " + dexPath.getParent());
|
Shell.sh("rm -rf " + dexPath.getParent());
|
||||||
}
|
}
|
||||||
mm.snet_version = Const.Value.SNET_VER;
|
mm.snetVersion = Const.Value.SNET_VER;
|
||||||
mm.prefs.edit().putInt(Const.Key.SNET_VER, Const.Value.SNET_VER).apply();
|
mm.prefs.edit().putInt(Const.Key.SNET_VER, Const.Value.SNET_VER).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ public class Const {
|
|||||||
public static final String APP_VER = "app_version";
|
public static final String APP_VER = "app_version";
|
||||||
public static final String MAGISKHIDE = "magiskhide";
|
public static final String MAGISKHIDE = "magiskhide";
|
||||||
public static final String HOSTS = "hosts";
|
public static final String HOSTS = "hosts";
|
||||||
public static final String DISABLE = "disable";
|
public static final String COREONLY = "disable";
|
||||||
public static final String LOCALE = "locale";
|
public static final String LOCALE = "locale";
|
||||||
public static final String DARK_THEME = "dark_theme";
|
public static final String DARK_THEME = "dark_theme";
|
||||||
public static final String ETAG_KEY = "ETag";
|
public static final String ETAG_KEY = "ETag";
|
||||||
|
@ -210,5 +210,6 @@
|
|||||||
<string name="reboot_recovery">重啟到 Recovery</string>
|
<string name="reboot_recovery">重啟到 Recovery</string>
|
||||||
<string name="reboot_bootloader">重啟到 Bootloader</string>
|
<string name="reboot_bootloader">重啟到 Bootloader</string>
|
||||||
<string name="reboot_download">重啟到 Download</string>
|
<string name="reboot_download">重啟到 Download</string>
|
||||||
|
<string name="android_o_not_support">不支援 Android 8.0+</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -180,6 +180,7 @@
|
|||||||
<string name="global_summary">All root sessions use the global mount namespace</string>
|
<string name="global_summary">All root sessions use the global mount namespace</string>
|
||||||
<string name="requester_summary">Root sessions will inherit its requester\'s namespace</string>
|
<string name="requester_summary">Root sessions will inherit its requester\'s namespace</string>
|
||||||
<string name="isolate_summary">Each root session will have its own isolated namespace</string>
|
<string name="isolate_summary">Each root session will have its own isolated namespace</string>
|
||||||
|
<string name="android_o_not_support">Does not support on Android 8.0+</string>
|
||||||
|
|
||||||
<!--Superuser-->
|
<!--Superuser-->
|
||||||
<string name="su_request_title">Superuser Request</string>
|
<string name="su_request_title">Superuser Request</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user