You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
More fixes, more breaks...
This commit is contained in:
@@ -15,7 +15,6 @@ import android.widget.TextView;
|
||||
|
||||
import com.topjohnwu.magisk.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -23,7 +22,6 @@ public class ApplicationAdapter extends ArrayAdapter<ApplicationInfo> {
|
||||
private List<ApplicationInfo> appsList = null;
|
||||
private Context context;
|
||||
private PackageManager packageManager;
|
||||
public ArrayList arrayList;
|
||||
public SharedPreferences prefs;
|
||||
|
||||
public ApplicationAdapter(Context context, int textViewResourceId,
|
||||
@@ -99,15 +97,14 @@ public class ApplicationAdapter extends ArrayAdapter<ApplicationInfo> {
|
||||
|
||||
private boolean CheckApp(String appToCheck) {
|
||||
boolean starter = false;
|
||||
Set<String> set = prefs.getStringSet("auto_blacklist", null);
|
||||
if (set != null) {
|
||||
arrayList = new ArrayList<>(set);
|
||||
for (String string : set) {
|
||||
if (string.equals(appToCheck)) {
|
||||
starter = true;
|
||||
}
|
||||
Set<String> set = prefs.getStringSet("auto_blacklist", null);
|
||||
if (set != null) {
|
||||
for (String string : set) {
|
||||
if (string.equals(appToCheck)) {
|
||||
starter = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return starter;
|
||||
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
package com.topjohnwu.magisk.utils;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
|
||||
public class Logger {
|
||||
|
||||
private static final String LOG_TAG = "Magisk";
|
||||
private static final String LOG_TAG = "Magisk: DH";
|
||||
|
||||
public static void dh(String msg, Object... args) {
|
||||
if (PrefHelper.CheckBool("developer_logging")) {
|
||||
Context context = null;
|
||||
try {
|
||||
context = getApplicationUsingReflection();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (PrefHelper.CheckBool("developer_logging", context)) {
|
||||
if (args.length == 1 && args[0] instanceof Throwable) {
|
||||
Log.d(LOG_TAG, msg, (Throwable) args[0]);
|
||||
} else {
|
||||
@@ -17,4 +23,9 @@ public class Logger {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Application getApplicationUsingReflection() throws Exception {
|
||||
return (Application) Class.forName("android.app.AppGlobals")
|
||||
.getMethod("getInitialApplication").invoke(null, (Object[]) null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,19 +10,11 @@ public class PrefHelper {
|
||||
|
||||
}
|
||||
|
||||
public static boolean CheckBool(String key) {
|
||||
Context context = null;
|
||||
try {
|
||||
context = getApplicationUsingReflection();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
public static boolean CheckBool(String key, Context context) {
|
||||
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(key, false);
|
||||
}
|
||||
|
||||
private static Application getApplicationUsingReflection() throws Exception {
|
||||
return (Application) Class.forName("android.app.AppGlobals")
|
||||
.getMethod("getInitialApplication").invoke(null, (Object[]) null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ import com.topjohnwu.magisk.RootFragment;
|
||||
import com.topjohnwu.magisk.module.BaseModule;
|
||||
import com.topjohnwu.magisk.receivers.PrivateBroadcastReceiver;
|
||||
import com.topjohnwu.magisk.services.MonitorService;
|
||||
import com.topjohnwu.magisk.services.QuickSettingTileService;
|
||||
import com.topjohnwu.magisk.services.TileService;
|
||||
import com.topjohnwu.magisk.services.TileServiceNewApi;
|
||||
import com.topjohnwu.magisk.services.TileServiceCompat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -71,10 +71,10 @@ public class Utils {
|
||||
if (!Shell.rootAccess()) {
|
||||
Snackbar.make(((Activity) context).findViewById(android.R.id.content), R.string.no_root_access, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
if (PrefHelper.CheckBool("keep_root_off")) {
|
||||
if (PrefHelper.CheckBool("keep_root_off",context)) {
|
||||
Utils.toggleRoot(false);
|
||||
}
|
||||
if (PrefHelper.CheckBool("enable_quicktile")) {
|
||||
if (PrefHelper.CheckBool("enable_quicktile",context)) {
|
||||
Utils.SetupQuickSettingsTile(context);
|
||||
}
|
||||
}
|
||||
@@ -129,6 +129,7 @@ public class Utils {
|
||||
} else {
|
||||
Shell.su("rm -rf /magisk/.core/bin", "setprop magisk.root 0");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +213,7 @@ public class Utils {
|
||||
public static void SetupQuickSettingsTile(Context mContext) {
|
||||
Logger.dh("Utils: SetupQuickSettings called");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
Intent serviceIntent = new Intent(mContext, QuickSettingTileService.class);
|
||||
Intent serviceIntent = new Intent(mContext, TileServiceNewApi.class);
|
||||
mContext.startService(serviceIntent);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
|
||||
@@ -266,7 +267,7 @@ public class Utils {
|
||||
|
||||
public static void installTile(Context context) {
|
||||
|
||||
String qsTileId = "intent(" + TileService.TILE_ID + ")";
|
||||
String qsTileId = "intent(" + TileServiceCompat.TILE_ID + ")";
|
||||
List<String> lines = Shell.su("settings get secure sysui_qs_tiles");
|
||||
if (lines != null && lines.size() == 1) {
|
||||
List<String> tiles = new LinkedList<String>(Arrays.asList(lines.get(0).split(",")));
|
||||
@@ -289,7 +290,7 @@ public class Utils {
|
||||
|
||||
public static void uninstallTile(Context context) {
|
||||
|
||||
String qsTileId = "intent(" + TileService.TILE_ID + ")";
|
||||
String qsTileId = "intent(" + TileServiceCompat.TILE_ID + ")";
|
||||
List<String> lines = Shell.su("settings get secure sysui_qs_tiles");
|
||||
if (lines != null && lines.size() == 1) {
|
||||
List<String> tiles = new LinkedList<String>(Arrays.asList(lines.get(0).split(",")));
|
||||
@@ -318,7 +319,7 @@ public class Utils {
|
||||
|
||||
|
||||
private void refreshService(Context context) {
|
||||
context.startService(new Intent(context, TileService.class));
|
||||
context.startService(new Intent(context, TileServiceCompat.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -448,7 +449,7 @@ public class Utils {
|
||||
public static class ModuleComparator implements Comparator<BaseModule> {
|
||||
@Override
|
||||
public int compare(BaseModule o1, BaseModule o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
return o1.getName().compareToIgnoreCase(o2.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user