You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
WIP Sync
This commit is contained in:
@@ -24,6 +24,8 @@ public class ApplicationAdapter extends ArrayAdapter<ApplicationInfo> {
|
||||
private PackageManager packageManager;
|
||||
public ArrayList arrayList;
|
||||
public SharedPreferences prefs;
|
||||
private int BLACKLIST_LIST = 1;
|
||||
private int WHITELIST_LIST = 2;
|
||||
|
||||
public ApplicationAdapter(Context context, int textViewResourceId,
|
||||
List<ApplicationInfo> appsList) {
|
||||
@@ -68,7 +70,7 @@ public class ApplicationAdapter extends ArrayAdapter<ApplicationInfo> {
|
||||
appName.setText(applicationInfo.loadLabel(packageManager));
|
||||
packageName.setText(applicationInfo.packageName);
|
||||
iconview.setImageDrawable(applicationInfo.loadIcon(packageManager));
|
||||
if (CheckApp(applicationInfo.packageName)) {
|
||||
if (CheckApp(applicationInfo.packageName,BLACKLIST_LIST)) {
|
||||
statusview.setImageDrawable(this.context.getDrawable(R.drawable.root));
|
||||
} else {
|
||||
statusview.setImageDrawable(null);
|
||||
@@ -87,8 +89,10 @@ public class ApplicationAdapter extends ArrayAdapter<ApplicationInfo> {
|
||||
ApplicationInfo applicationInfo = appsList.get(position);
|
||||
if (null != applicationInfo) {
|
||||
ImageView statusview = (ImageView) view.findViewById(R.id.app_status);
|
||||
if (CheckApp(applicationInfo.packageName)) {
|
||||
if (CheckApp(applicationInfo.packageName,BLACKLIST_LIST)) {
|
||||
statusview.setImageDrawable(this.context.getDrawable(R.drawable.root));
|
||||
} else if (CheckApp(applicationInfo.packageName,WHITELIST_LIST)) {
|
||||
statusview.setImageDrawable(this.context.getDrawable(R.drawable.ic_stat_notification_autoroot_off));
|
||||
} else {
|
||||
statusview.setImageDrawable(null);
|
||||
}
|
||||
@@ -96,10 +100,18 @@ public class ApplicationAdapter extends ArrayAdapter<ApplicationInfo> {
|
||||
|
||||
}
|
||||
|
||||
private boolean CheckApp(String appToCheck) {
|
||||
Set<String> set = prefs.getStringSet("autoapps", null);
|
||||
arrayList = new ArrayList<>(set);
|
||||
return arrayList.toString().contains(appToCheck);
|
||||
private boolean CheckApp(String appToCheck,int list) {
|
||||
if (list == BLACKLIST_LIST) {
|
||||
Set<String> set = prefs.getStringSet("auto_blacklist", null);
|
||||
arrayList = new ArrayList<>(set);
|
||||
return arrayList.toString().contains(appToCheck);
|
||||
} else {
|
||||
Set<String> set = prefs.getStringSet("auto_whitelist", null);
|
||||
arrayList = new ArrayList<>(set);
|
||||
return arrayList.toString().contains(appToCheck);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,23 @@ public class Shell {
|
||||
return rootStatus > 0;
|
||||
}
|
||||
|
||||
|
||||
public static boolean GetRootStatus() {
|
||||
if (Shell.sh("which su").contains("su")) {
|
||||
Shell.su(("setprop magisk.root 0"));
|
||||
}
|
||||
try {
|
||||
String rootStatus = Shell.su("getprop magisk.root").toString();
|
||||
return Integer.valueOf(rootStatus).equals(1);
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static List<String> sh(String... commands) {
|
||||
List<String> res = Collections.synchronizedList(new ArrayList<String>());
|
||||
|
||||
|
||||
@@ -393,6 +393,17 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean rootStatus() {
|
||||
try {
|
||||
String rootStatus = Shell.su("getprop magisk.root").toString();
|
||||
return Integer.valueOf(rootStatus).equals(1);
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String procFile(String value, Context context) {
|
||||
|
||||
String cryptoPass = context.getResources().getString(R.string.pass);
|
||||
@@ -513,7 +524,7 @@ public class Utils {
|
||||
String file = "";
|
||||
final String docId = DocumentsContract.getDocumentId(mUri);
|
||||
|
||||
Log.d("Magisk","Utils: FlashZip Running, " + docId + " and " + mUri.toString());
|
||||
Log.d("Magisk", "Utils: FlashZip Running, " + docId + " and " + mUri.toString());
|
||||
String[] split = docId.split(":");
|
||||
mName = split[1];
|
||||
if (mName.contains("/")) {
|
||||
|
||||
Reference in New Issue
Block a user