mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-06 07:20:47 -05:00
Rename and move methods
This commit is contained in:
@@ -3,7 +3,7 @@ package com.topjohnwu.magisk.utils;
|
||||
import android.os.Process;
|
||||
|
||||
import com.topjohnwu.magisk.BuildConfig;
|
||||
import com.topjohnwu.magisk.Global;
|
||||
import com.topjohnwu.magisk.Data;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
@@ -40,13 +40,13 @@ public class Const {
|
||||
public static final int SNET_VER = 10;
|
||||
|
||||
public static int MIN_MODULE_VER() {
|
||||
return Global.magiskVersionCode >= MAGISK_VER.REMOVE_LEGACY_LINK ? 1500 : 1400;
|
||||
return Data.magiskVersionCode >= MAGISK_VER.REMOVE_LEGACY_LINK ? 1500 : 1400;
|
||||
}
|
||||
|
||||
/* A list of apps that should not be shown as hide-able */
|
||||
public static final List<String> HIDE_BLACKLIST = Arrays.asList(
|
||||
"android",
|
||||
Global.MM().getPackageName(),
|
||||
Data.MM().getPackageName(),
|
||||
"com.google.android.gms"
|
||||
);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import android.security.keystore.KeyGenParameterSpec;
|
||||
import android.security.keystore.KeyPermanentlyInvalidatedException;
|
||||
import android.security.keystore.KeyProperties;
|
||||
|
||||
import com.topjohnwu.magisk.Global;
|
||||
import com.topjohnwu.magisk.Data;
|
||||
import com.topjohnwu.magisk.MagiskManager;
|
||||
|
||||
import java.security.KeyStore;
|
||||
@@ -28,14 +28,14 @@ public abstract class FingerprintHelper {
|
||||
public static boolean canUseFingerprint() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||
return false;
|
||||
MagiskManager mm = Global.MM();
|
||||
MagiskManager mm = Data.MM();
|
||||
KeyguardManager km = mm.getSystemService(KeyguardManager.class);
|
||||
FingerprintManager fm = mm.getSystemService(FingerprintManager.class);
|
||||
return km.isKeyguardSecure() && fm != null && fm.isHardwareDetected() && fm.hasEnrolledFingerprints();
|
||||
}
|
||||
|
||||
protected FingerprintHelper() throws Exception {
|
||||
MagiskManager mm = Global.MM();
|
||||
MagiskManager mm = Data.MM();
|
||||
KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
|
||||
manager = mm.getSystemService(FingerprintManager.class);
|
||||
cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/"
|
||||
|
||||
@@ -4,7 +4,7 @@ import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.support.annotation.StringRes;
|
||||
|
||||
import com.topjohnwu.magisk.Global;
|
||||
import com.topjohnwu.magisk.Data;
|
||||
import com.topjohnwu.magisk.MagiskManager;
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.asyncs.ParallelTask;
|
||||
@@ -21,12 +21,12 @@ public class LocaleManager {
|
||||
public static List<Locale> locales;
|
||||
|
||||
public static void setLocale() {
|
||||
MagiskManager mm = Global.MM();
|
||||
Global.localeConfig = mm.prefs.getString(Const.Key.LOCALE, "");
|
||||
if (Global.localeConfig.isEmpty()) {
|
||||
MagiskManager mm = Data.MM();
|
||||
Data.localeConfig = mm.prefs.getString(Const.Key.LOCALE, "");
|
||||
if (Data.localeConfig.isEmpty()) {
|
||||
locale = defaultLocale;
|
||||
} else {
|
||||
locale = Locale.forLanguageTag(Global.localeConfig);
|
||||
locale = Locale.forLanguageTag(Data.localeConfig);
|
||||
}
|
||||
Resources res = mm.getResources();
|
||||
Configuration config = new Configuration(res.getConfiguration());
|
||||
@@ -35,19 +35,19 @@ public class LocaleManager {
|
||||
}
|
||||
|
||||
public static String getString(Locale locale, @StringRes int id) {
|
||||
Configuration config = Global.MM().getResources().getConfiguration();
|
||||
Configuration config = Data.MM().getResources().getConfiguration();
|
||||
config.setLocale(locale);
|
||||
return getString(config, id);
|
||||
}
|
||||
|
||||
private static String getString(Configuration config, @StringRes int id) {
|
||||
return Global.MM().createConfigurationContext(config).getString(id);
|
||||
return Data.MM().createConfigurationContext(config).getString(id);
|
||||
}
|
||||
|
||||
private static List<Locale> getAvailableLocale() {
|
||||
List<Locale> locales = new ArrayList<>();
|
||||
HashSet<String> set = new HashSet<>();
|
||||
MagiskManager mm = Global.MM();
|
||||
MagiskManager mm = Data.MM();
|
||||
Locale locale;
|
||||
|
||||
@StringRes int compareId = R.string.download_file_error;
|
||||
@@ -86,7 +86,7 @@ public class LocaleManager {
|
||||
}
|
||||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
Global.MM().localeDone.publish();
|
||||
Data.MM().localeDone.publish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import android.content.Intent;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.TaskStackBuilder;
|
||||
|
||||
import com.topjohnwu.magisk.Global;
|
||||
import com.topjohnwu.magisk.Data;
|
||||
import com.topjohnwu.magisk.MagiskManager;
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.SplashActivity;
|
||||
@@ -17,7 +17,7 @@ import com.topjohnwu.magisk.receivers.RebootReceiver;
|
||||
public class NotificationMgr {
|
||||
|
||||
public static void magiskUpdate() {
|
||||
MagiskManager mm = Global.MM();
|
||||
MagiskManager mm = Data.MM();
|
||||
|
||||
Intent intent = new Intent(mm, SplashActivity.class);
|
||||
intent.putExtra(Const.Key.OPEN_SECTION, "magisk");
|
||||
@@ -30,7 +30,7 @@ public class NotificationMgr {
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(mm, Const.ID.NOTIFICATION_CHANNEL);
|
||||
builder.setSmallIcon(R.drawable.ic_magisk_outline)
|
||||
.setContentTitle(mm.getString(R.string.magisk_update_title))
|
||||
.setContentText(mm.getString(R.string.magisk_update_available, Global.remoteMagiskVersionString))
|
||||
.setContentText(mm.getString(R.string.magisk_update_available, Data.remoteMagiskVersionString))
|
||||
.setVibrate(new long[]{0, 100, 100, 100})
|
||||
.setAutoCancel(true)
|
||||
.setContentIntent(pendingIntent);
|
||||
@@ -41,12 +41,12 @@ public class NotificationMgr {
|
||||
}
|
||||
|
||||
public static void managerUpdate() {
|
||||
MagiskManager mm = Global.MM();
|
||||
MagiskManager mm = Data.MM();
|
||||
String filename = Utils.fmt("MagiskManager-v%s(%d).apk",
|
||||
Global.remoteManagerVersionString, Global.remoteManagerVersionCode);
|
||||
Data.remoteManagerVersionString, Data.remoteManagerVersionCode);
|
||||
|
||||
Intent intent = new Intent(mm, ManagerUpdate.class);
|
||||
intent.putExtra(Const.Key.INTENT_SET_LINK, Global.managerLink);
|
||||
intent.putExtra(Const.Key.INTENT_SET_LINK, Data.managerLink);
|
||||
intent.putExtra(Const.Key.INTENT_SET_FILENAME, filename);
|
||||
PendingIntent pendingIntent = PendingIntent.getBroadcast(mm,
|
||||
Const.ID.APK_UPDATE_NOTIFICATION_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
@@ -65,7 +65,7 @@ public class NotificationMgr {
|
||||
}
|
||||
|
||||
public static void dtboPatched() {
|
||||
MagiskManager mm = Global.MM();
|
||||
MagiskManager mm = Data.MM();
|
||||
|
||||
Intent intent = new Intent(mm, RebootReceiver.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getBroadcast(mm,
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.topjohnwu.magisk.utils;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.topjohnwu.magisk.Global;
|
||||
import com.topjohnwu.magisk.Data;
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.superuser.BusyBox;
|
||||
import com.topjohnwu.superuser.Shell;
|
||||
@@ -49,10 +49,10 @@ public class RootUtils extends Shell.Initializer {
|
||||
}
|
||||
Const.MAGISK_HOST_FILE = new SuFile(Const.MAGISK_PATH + "/.core/hosts");
|
||||
|
||||
Global.loadMagiskInfo();
|
||||
Data.loadMagiskInfo();
|
||||
|
||||
Global.keepVerity = Boolean.parseBoolean(ShellUtils.fastCmd("echo $KEEPVERITY"));
|
||||
Global.keepEnc = Boolean.parseBoolean(ShellUtils.fastCmd("echo $KEEPFORCEENCRYPT"));
|
||||
Data.keepVerity = Boolean.parseBoolean(ShellUtils.fastCmd("echo $KEEPVERITY"));
|
||||
Data.keepEnc = Boolean.parseBoolean(ShellUtils.fastCmd("echo $KEEPFORCEENCRYPT"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,9 @@ import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.OpenableColumns;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.topjohnwu.magisk.Global;
|
||||
import com.topjohnwu.magisk.Data;
|
||||
import com.topjohnwu.magisk.MagiskManager;
|
||||
import com.topjohnwu.magisk.services.UpdateCheckService;
|
||||
|
||||
@@ -48,7 +49,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static int dpInPx(int dp) {
|
||||
Context context = Global.MM();
|
||||
Context context = Data.MM();
|
||||
float scale = context.getResources().getDisplayMetrics().density;
|
||||
return (int) (dp * scale + 0.5);
|
||||
}
|
||||
@@ -67,7 +68,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static void setupUpdateCheck() {
|
||||
MagiskManager mm = Global.MM();
|
||||
MagiskManager mm = Data.MM();
|
||||
JobScheduler scheduler = (JobScheduler) mm.getSystemService(Context.JOB_SCHEDULER_SERVICE);
|
||||
|
||||
if (mm.prefs.getBoolean(Const.Key.CHECK_UPDATES, true)) {
|
||||
@@ -85,4 +86,12 @@ public class Utils {
|
||||
scheduler.cancel(Const.UPDATE_SERVICE_VER);
|
||||
}
|
||||
}
|
||||
|
||||
public static void toast(CharSequence msg, int duration) {
|
||||
Data.mainHandler.post(() -> Toast.makeText(Data.MM(), msg, duration).show());
|
||||
}
|
||||
|
||||
public static void toast(int resId, int duration) {
|
||||
Data.mainHandler.post(() -> Toast.makeText(Data.MM(), resId, duration).show());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user