mirror of https://github.com/M66B/NetGuard.git
Merge branch 'master' of https://github.com/M66B/NetGuard
This commit is contained in:
commit
a237ce9194
|
@ -219,9 +219,11 @@ public class SinkholeService extends VpnService {
|
|||
thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FileInputStream in = null;
|
||||
FileOutputStream out = null;
|
||||
try {
|
||||
FileInputStream in = new FileInputStream(pfd.getFileDescriptor());
|
||||
FileOutputStream out = new FileOutputStream(pfd.getFileDescriptor());
|
||||
in = new FileInputStream(pfd.getFileDescriptor());
|
||||
out = new FileOutputStream(pfd.getFileDescriptor());
|
||||
|
||||
ByteBuffer buffer = ByteBuffer.allocate(32767);
|
||||
buffer.order(ByteOrder.BIG_ENDIAN);
|
||||
|
@ -264,6 +266,17 @@ public class SinkholeService extends VpnService {
|
|||
Log.i(TAG, "End receiving");
|
||||
} catch (Throwable ex) {
|
||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||
} finally {
|
||||
try {
|
||||
if (in != null)
|
||||
in.close();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
try {
|
||||
if (out != null)
|
||||
out.close();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -214,18 +214,25 @@ public class Util {
|
|||
private static StringBuilder getLogcat(String tag) {
|
||||
String pid = Integer.toString(android.os.Process.myPid());
|
||||
StringBuilder builder = new StringBuilder();
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
String[] command = new String[]{"logcat", "-d", "-v", "threadtime"};
|
||||
Process process = Runtime.getRuntime().exec(command);
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
br = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null)
|
||||
while ((line = br.readLine()) != null)
|
||||
if (line.contains(pid)) {
|
||||
builder.append(line);
|
||||
builder.append("\r\n");
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Log.e(tag, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||
} finally {
|
||||
if (br != null)
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue