mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-06 07:20:47 -05:00
Centralize configuration management
This commit is contained in:
@@ -5,7 +5,7 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.topjohnwu.core.App;
|
||||
import com.topjohnwu.core.Config;
|
||||
import com.topjohnwu.core.Const;
|
||||
import com.topjohnwu.core.utils.Utils;
|
||||
import com.topjohnwu.magisk.ClassMap;
|
||||
@@ -23,7 +23,7 @@ import androidx.work.WorkManager;
|
||||
public class AppUtils {
|
||||
|
||||
public static void scheduleUpdateCheck() {
|
||||
if (App.self.prefs.getBoolean(Const.Key.CHECK_UPDATES, true)) {
|
||||
if (Config.get(Config.Key.CHECK_UPDATES)) {
|
||||
Constraints constraints = new Constraints.Builder()
|
||||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||
.build();
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.topjohnwu.magisk.utils;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import com.topjohnwu.core.App;
|
||||
import com.topjohnwu.core.Data;
|
||||
import com.topjohnwu.core.Config;
|
||||
import com.topjohnwu.core.utils.RootUtils;
|
||||
import com.topjohnwu.core.utils.Utils;
|
||||
import com.topjohnwu.magisk.BuildConfig;
|
||||
@@ -25,7 +25,7 @@ public class DownloadApp {
|
||||
|
||||
public static void restore() {
|
||||
String name = Utils.fmt("MagiskManager v%s(%d)",
|
||||
Data.remoteManagerVersionString, Data.remoteManagerVersionCode);
|
||||
Config.remoteManagerVersionString, Config.remoteManagerVersionCode);
|
||||
dlInstall(name, new RestoreManager());
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class DownloadApp {
|
||||
File apk = new File(App.self.getCacheDir(), "manager.apk");
|
||||
ProgressNotification progress = new ProgressNotification(name);
|
||||
listener.progress = progress;
|
||||
Networking.get(Data.managerLink)
|
||||
Networking.get(Config.managerLink)
|
||||
.setExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
|
||||
.setDownloadProgressListener(progress)
|
||||
.setErrorHandler((conn, e) -> progress.dlFail())
|
||||
@@ -85,7 +85,7 @@ public class DownloadApp {
|
||||
.setContentTitle(app.getString(R.string.restore_img_msg))
|
||||
.setContentText("");
|
||||
progress.update();
|
||||
Data.exportPrefs();
|
||||
Config.export();
|
||||
// Make it world readable
|
||||
apk.setReadable(true, false);
|
||||
if (ShellUtils.fastCmdResult("pm install " + apk))
|
||||
|
||||
@@ -17,6 +17,7 @@ import android.view.Gravity;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.topjohnwu.core.App;
|
||||
import com.topjohnwu.core.Config;
|
||||
import com.topjohnwu.core.Const;
|
||||
import com.topjohnwu.core.utils.Utils;
|
||||
import com.topjohnwu.magisk.R;
|
||||
@@ -36,9 +37,9 @@ public abstract class FingerprintHelper {
|
||||
private CancellationSignal cancel;
|
||||
|
||||
public static boolean useFingerPrint() {
|
||||
boolean fp = App.self.mDB.getSettings(Const.Key.SU_FINGERPRINT, 0) != 0;
|
||||
boolean fp = Config.get(Config.Key.SU_FINGERPRINT);
|
||||
if (fp && !canUseFingerprint()) {
|
||||
App.self.mDB.setSettings(Const.Key.SU_FINGERPRINT, 0);
|
||||
Config.set(Config.Key.SU_FINGERPRINT, false);
|
||||
fp = false;
|
||||
}
|
||||
return fp;
|
||||
|
||||
@@ -4,8 +4,8 @@ import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.topjohnwu.core.App;
|
||||
import com.topjohnwu.core.Config;
|
||||
import com.topjohnwu.core.Const;
|
||||
import com.topjohnwu.core.Data;
|
||||
import com.topjohnwu.core.utils.RootUtils;
|
||||
import com.topjohnwu.core.utils.Utils;
|
||||
import com.topjohnwu.magisk.BuildConfig;
|
||||
@@ -110,8 +110,8 @@ public class PatchAPK {
|
||||
if (!ShellUtils.fastCmdResult("pm install " + repack))
|
||||
return false;
|
||||
|
||||
app.mDB.setStrings(Const.Key.SU_MANAGER, pkg);
|
||||
Data.exportPrefs();
|
||||
Config.set(Config.Key.SU_MANAGER, pkg);
|
||||
Config.export();
|
||||
RootUtils.rmAndLaunch(BuildConfig.APPLICATION_ID, pkg);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -10,8 +10,7 @@ import android.text.TextUtils;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.topjohnwu.core.App;
|
||||
import com.topjohnwu.core.Const;
|
||||
import com.topjohnwu.core.Data;
|
||||
import com.topjohnwu.core.Config;
|
||||
import com.topjohnwu.core.container.Policy;
|
||||
import com.topjohnwu.core.container.SuLogEntry;
|
||||
import com.topjohnwu.core.utils.Utils;
|
||||
@@ -123,7 +122,8 @@ public abstract class SuConnector {
|
||||
private static void handleNotify(Policy policy) {
|
||||
String message = App.self.getString(policy.policy == Policy.ALLOW ?
|
||||
R.string.su_allow_toast : R.string.su_deny_toast, policy.appName);
|
||||
if (policy.notification && Data.suNotificationType == Const.Value.NOTIFICATION_TOAST)
|
||||
if (policy.notification &&
|
||||
(int) Config.get(Config.Key.SU_NOTIFICATION) == Config.Value.NOTIFICATION_TOAST)
|
||||
Utils.toast(message, Toast.LENGTH_SHORT);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user