mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-27 13:29:40 +00:00
Update AsyncTasks to prevent memory leak
This commit is contained in:
@@ -8,6 +8,7 @@ import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -116,7 +117,7 @@ public class Shell {
|
||||
}
|
||||
}
|
||||
|
||||
public void sh(List<String> output, String... commands) {
|
||||
public void sh(Collection<String> output, String... commands) {
|
||||
if (!isValid) return;
|
||||
try {
|
||||
shellProcess.exitValue();
|
||||
@@ -144,8 +145,24 @@ public class Shell {
|
||||
sh_raw(commands);
|
||||
}
|
||||
|
||||
public void su(List<String> output, String... commands) {
|
||||
public void su(Collection<String> output, String... commands) {
|
||||
if (!rootAccess()) return;
|
||||
sh(output, commands);
|
||||
}
|
||||
|
||||
public static abstract class AbstractList<E> extends java.util.AbstractList<E> {
|
||||
|
||||
@Override
|
||||
public abstract boolean add(E e);
|
||||
|
||||
@Override
|
||||
public E get(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Modified by topjohnwu, based on Chainfire's libsuperuser
|
||||
@@ -15,8 +15,7 @@ import java.util.List;
|
||||
public class StreamGobbler extends Thread {
|
||||
|
||||
private BufferedReader reader = null;
|
||||
private List<String> writer = null;
|
||||
private boolean isRoot = false;
|
||||
private Collection<String> writer = null;
|
||||
|
||||
/**
|
||||
* <p>StreamGobbler constructor</p>
|
||||
@@ -28,7 +27,7 @@ public class StreamGobbler extends Thread {
|
||||
* @param inputStream InputStream to read from
|
||||
* @param outputList {@literal List<String>} to write to, or null
|
||||
*/
|
||||
public StreamGobbler(InputStream inputStream, List<String> outputList) {
|
||||
public StreamGobbler(InputStream inputStream, Collection<String> outputList) {
|
||||
try {
|
||||
while (inputStream.available() != 0) {
|
||||
inputStream.skip(inputStream.available());
|
||||
|
||||
@@ -108,23 +108,6 @@ public class Utils {
|
||||
.replace("#", "").replace("@", "").replace("*", "");
|
||||
}
|
||||
|
||||
public static String detectBootImage(Shell shell) {
|
||||
String[] commands = {
|
||||
"for PARTITION in kern-a KERN-A android_boot ANDROID_BOOT kernel KERNEL boot BOOT lnx LNX; do",
|
||||
"BOOTIMAGE=`readlink /dev/block/by-name/$PARTITION || " +
|
||||
"readlink /dev/block/platform/*/by-name/$PARTITION || " +
|
||||
"readlink /dev/block/platform/*/*/by-name/$PARTITION`",
|
||||
"if [ ! -z \"$BOOTIMAGE\" ]; then break; fi",
|
||||
"done",
|
||||
"echo \"$BOOTIMAGE\""
|
||||
};
|
||||
List<String> ret = shell.su(commands);
|
||||
if (isValidShellResponse(ret)) {
|
||||
return ret.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean lowercaseContains(CharSequence string, CharSequence nonNullLowercaseSearch) {
|
||||
return !TextUtils.isEmpty(string) && string.toString().toLowerCase().contains(nonNullLowercaseSearch);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user