Save boot kmsg (#1688)

This commit is contained in:
南宫雪珊 2022-02-14 18:36:00 +08:00 committed by GitHub
parent a72f59d07a
commit a32d4fc0ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -226,11 +226,16 @@ public class ConfigFileManager {
return logDirPath.resolve(getNewLogFileName("modules")).toFile();
}
static File getpropsLogPath() throws IOException {
static File getPropsPath() throws IOException {
createLogDirPath();
return logDirPath.resolve("props.txt").toFile();
}
static File getKmsgPath() throws IOException {
createLogDirPath();
return logDirPath.resolve("kmsg.log").toFile();
}
static void getLogs(ParcelFileDescriptor zipFd) throws RemoteException {
try (var os = new ZipOutputStream(new FileOutputStream(zipFd.getFileDescriptor()))) {
var comment = String.format(Locale.ROOT, "LSPosed %s %s (%d)",

View File

@ -37,6 +37,7 @@ public class LogcatService implements Runnable {
}
getprop();
dmesg();
}
private static void getprop() {
@ -46,7 +47,7 @@ public class LogcatService implements Runnable {
try {
SELinux.setFSCreateContext("u:object_r:app_data_file:s0");
new ProcessBuilder("sh", "-c", cmd)
.redirectOutput(ConfigFileManager.getpropsLogPath())
.redirectOutput(ConfigFileManager.getPropsPath())
.start();
} catch (IOException e) {
Log.e(TAG, "getprop: ", e);
@ -55,6 +56,16 @@ public class LogcatService implements Runnable {
}
}
private static void dmesg() {
try {
new ProcessBuilder("dmesg")
.redirectOutput(ConfigFileManager.getKmsgPath())
.start();
} catch (IOException e) {
Log.e(TAG, "dmesg: ", e);
}
}
private native void runLogcat();
@Override