mirror of https://github.com/M66B/NetGuard.git
Close input stream logcat exec
This commit is contained in:
parent
aee85ebc8a
commit
b43af7d7ce
|
@ -214,18 +214,25 @@ public class Util {
|
||||||
private static StringBuilder getLogcat(String tag) {
|
private static StringBuilder getLogcat(String tag) {
|
||||||
String pid = Integer.toString(android.os.Process.myPid());
|
String pid = Integer.toString(android.os.Process.myPid());
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
BufferedReader br = null;
|
||||||
try {
|
try {
|
||||||
String[] command = new String[]{"logcat", "-d", "-v", "threadtime"};
|
String[] command = new String[]{"logcat", "-d", "-v", "threadtime"};
|
||||||
Process process = Runtime.getRuntime().exec(command);
|
Process process = Runtime.getRuntime().exec(command);
|
||||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
br = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
String line;
|
String line;
|
||||||
while ((line = bufferedReader.readLine()) != null)
|
while ((line = br.readLine()) != null)
|
||||||
if (line.contains(pid)) {
|
if (line.contains(pid)) {
|
||||||
builder.append(line);
|
builder.append(line);
|
||||||
builder.append("\r\n");
|
builder.append("\r\n");
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Log.e(tag, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
Log.e(tag, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||||
|
} finally {
|
||||||
|
if (br != null)
|
||||||
|
try {
|
||||||
|
br.close();
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue