From 5897711af545a4b2cee66ccc9e224d03b3035f2d Mon Sep 17 00:00:00 2001 From: adbenitez Date: Fri, 14 Jun 2024 15:58:26 +0200 Subject: [PATCH] only show debug entries if developer mode is enabled --- .../thoughtcrime/securesms/LogViewFragment.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/thoughtcrime/securesms/LogViewFragment.java b/src/main/java/org/thoughtcrime/securesms/LogViewFragment.java index d4f7f0eb8..4293353b4 100644 --- a/src/main/java/org/thoughtcrime/securesms/LogViewFragment.java +++ b/src/main/java/org/thoughtcrime/securesms/LogViewFragment.java @@ -127,21 +127,27 @@ public class LogViewFragment extends Fragment { return logFile; } - private static String grabLogcat() { + private static String grabLogcat(LogViewFragment fragment) { try { final Process process = Runtime.getRuntime().exec("logcat -v threadtime -d"); final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); final StringBuilder log = new StringBuilder(); final String separator = System.getProperty("line.separator"); + final boolean devMode = Prefs.isDeveloperModeEnabled(fragment.getActivity()); String line; while ((line = bufferedReader.readLine()) != null) { line = line.replaceFirst(" (\\d+) E ", " $1 \uD83D\uDD34 "); line = line.replaceFirst(" (\\d+) W ", " $1 \uD83D\uDFE0 "); line = line.replaceFirst(" (\\d+) I ", " $1 \uD83D\uDD35 "); - line = line.replaceFirst(" (\\d+) D ", " $1 \uD83D\uDFE2 "); - log.append(line); - log.append(separator); + String debugLine = line.replaceFirst(" (\\d+) D ", " $1 \uD83D\uDFE2 "); + if (debugLine.equals(line)) { // not a debug entry + log.append(line); + log.append(separator); + } else if (devMode) { + log.append(debugLine); + log.append(separator); + } } return log.toString(); } catch (Exception e) { @@ -162,7 +168,7 @@ public class LogViewFragment extends Fragment { if (fragment == null) return null; return "**This log may contain sensitive information. If you want to post it publicly you may examine and edit it beforehand.**\n\n" + - buildDescription(fragment) + "\n" + grabLogcat(); + buildDescription(fragment) + "\n" + grabLogcat(fragment); } @Override