Collect modules in log and close fds (#1610)
This commit is contained in:
parent
253fc2e0d1
commit
b81caac913
|
|
@ -226,26 +226,54 @@ public class ConfigFileManager {
|
||||||
Log.w(TAG, name, e);
|
Log.w(TAG, name, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var name = "full.log";
|
{
|
||||||
try (var is = new ProcessBuilder("logcat", "-d").start().getInputStream()) {
|
var name = "full.log";
|
||||||
os.putNextEntry(new ZipEntry(name));
|
try (var is = new ProcessBuilder("logcat", "-d").start().getInputStream()) {
|
||||||
transfer(is, os);
|
os.putNextEntry(new ZipEntry(name));
|
||||||
os.closeEntry();
|
transfer(is, os);
|
||||||
} catch (IOException e) {
|
os.closeEntry();
|
||||||
Log.w(TAG, name, e);
|
} catch (IOException e) {
|
||||||
|
Log.w(TAG, name, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
name = "dmesg.log";
|
{
|
||||||
try (var is = new ProcessBuilder("dmesg").start().getInputStream()) {
|
var name = "dmesg.log";
|
||||||
os.putNextEntry(new ZipEntry(name));
|
try (var is = new ProcessBuilder("dmesg").start().getInputStream()) {
|
||||||
transfer(is, os);
|
os.putNextEntry(new ZipEntry(name));
|
||||||
os.closeEntry();
|
transfer(is, os);
|
||||||
} catch (IOException e) {
|
os.closeEntry();
|
||||||
Log.w(TAG, name, e);
|
} catch (IOException e) {
|
||||||
|
Log.w(TAG, name, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
var magiskDataDir = Paths.get("/data/adb");
|
||||||
|
Files.list(magiskDataDir.resolve("modules")).forEach(p -> {
|
||||||
|
if (!Files.exists(p.resolve("disable"))) {
|
||||||
|
var prop = p.resolve("module.prop");
|
||||||
|
if (Files.exists(prop)) {
|
||||||
|
var name = magiskDataDir.relativize(prop).toString();
|
||||||
|
try (var is = new FileInputStream(prop.toFile())) {
|
||||||
|
os.putNextEntry(new ZipEntry(name));
|
||||||
|
transfer(is, os);
|
||||||
|
os.closeEntry();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.w(TAG, name, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ConfigManager.getInstance().exportScopes(os);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Log.w(TAG, "get log", e);
|
Log.w(TAG, "get log", e);
|
||||||
throw new RemoteException(Log.getStackTraceString(e));
|
throw new RemoteException(Log.getStackTraceString(e));
|
||||||
}
|
}
|
||||||
|
logs.forEach((name, fd) -> {
|
||||||
|
try {
|
||||||
|
fd.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.w(TAG, name, e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void putFds(Map<String, ParcelFileDescriptor> map, Path path) throws IOException {
|
private static void putFds(Map<String, ParcelFileDescriptor> map, Path path) throws IOException {
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.FileVisitResult;
|
import java.nio.file.FileVisitResult;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
@ -75,7 +76,9 @@ import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
private static ConfigManager instance = null;
|
private static ConfigManager instance = null;
|
||||||
|
|
@ -1015,4 +1018,25 @@ public class ConfigManager {
|
||||||
public String getApi() {
|
public String getApi() {
|
||||||
return api;
|
return api;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void exportScopes(ZipOutputStream os) throws IOException {
|
||||||
|
os.putNextEntry(new ZipEntry("scopes.txt"));
|
||||||
|
cachedScope.forEach((scope, modules) -> {
|
||||||
|
try {
|
||||||
|
os.write((scope.processName + "/" + scope.uid + "\n").getBytes(StandardCharsets.UTF_8));
|
||||||
|
for (var module : modules) {
|
||||||
|
os.write(("\t" + module.packageName + "\n").getBytes(StandardCharsets.UTF_8));
|
||||||
|
for (var cn : module.file.moduleClassNames) {
|
||||||
|
os.write(("\t\t" + cn + "\n").getBytes(StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
for (var ln : module.file.moduleLibraryNames) {
|
||||||
|
os.write(("\t\t" + ln + "\n").getBytes(StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.w(TAG, scope.processName, e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
os.closeEntry();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue