From 63f51df94a08c9ee7493d4c51bd68a5413acdd40 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 13 Oct 2024 14:47:34 +0200 Subject: [PATCH] Some devices do not have logcat --- .../java/eu/faircode/email/DebugHelper.java | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DebugHelper.java b/app/src/main/java/eu/faircode/email/DebugHelper.java index d54b2f0fdf..ae8439ada9 100644 --- a/app/src/main/java/eu/faircode/email/DebugHelper.java +++ b/app/src/main/java/eu/faircode/email/DebugHelper.java @@ -1367,27 +1367,32 @@ public class DebugHelper { File logcat = new File(context.getFilesDir(), "logcat.txt"); - // https://cheatsheetseries.owasp.org/cheatsheets/OS_Command_Injection_Defense_Cheat_Sheet.html#java - ProcessBuilder pb = new ProcessBuilder("logcat", // CASA "/system/bin/logcat", - "-d", - "-v", "threadtime", - //"-t", "1000", - "fairemail" + ":I"); - Map env = pb.environment(); - env.clear(); - pb.directory(context.getFilesDir()); + try { - Process proc = null; - try (OutputStream os = new BufferedOutputStream(new FileOutputStream(logcat))) { - proc = pb.start(); - Helper.copy(proc.getInputStream(), os); - } finally { - if (proc != null) - proc.destroy(); + // https://cheatsheetseries.owasp.org/cheatsheets/OS_Command_Injection_Defense_Cheat_Sheet.html#java + ProcessBuilder pb = new ProcessBuilder("logcat", // CASA "/system/bin/logcat", + "-d", + "-v", "threadtime", + //"-t", "1000", + "fairemail" + ":I"); + Map env = pb.environment(); + env.clear(); + pb.directory(context.getFilesDir()); + + Process proc = null; + try (OutputStream os = new BufferedOutputStream(new FileOutputStream(logcat))) { + proc = pb.start(); + Helper.copy(proc.getInputStream(), os); + } finally { + if (proc != null) + proc.destroy(); + } + + files.add(logcat); + } catch (Throwable ex) { + Log.e(ex); } - files.add(logcat); - attachment.zip(context, files.toArray(new File[0])); Helper.secureDelete(logcat);