mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-25 19:47:31 +00:00
Log the threadId of a log.
This commit is contained in:

committed by
Alan Evans

parent
7b0de2d2a9
commit
3983d5aca4
@@ -0,0 +1,37 @@
|
||||
package org.thoughtcrime.securesms.logsubmit;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class LogSectionBlockedThreads implements LogSection {
|
||||
|
||||
@Override
|
||||
public @NonNull String getTitle() {
|
||||
return "BLOCKED THREADS";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull CharSequence getContent(@NonNull Context context) {
|
||||
Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces();
|
||||
StringBuilder out = new StringBuilder();
|
||||
|
||||
for (Map.Entry<Thread, StackTraceElement[]> entry : traces.entrySet()) {
|
||||
if (entry.getKey().getState() == Thread.State.BLOCKED) {
|
||||
Thread thread = entry.getKey();
|
||||
out.append("-- [").append(thread.getId()).append("] ")
|
||||
.append(thread.getName()).append(" (").append(thread.getState().toString()).append(")\n");
|
||||
|
||||
for (StackTraceElement element : entry.getValue()) {
|
||||
out.append(element.toString()).append("\n");
|
||||
}
|
||||
|
||||
out.append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
return out.length() == 0 ? "None" : out;
|
||||
}
|
||||
}
|
@@ -4,34 +4,29 @@ import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class LogSectionThreads implements LogSection {
|
||||
|
||||
@Override
|
||||
public @NonNull String getTitle() {
|
||||
return "BLOCKED THREADS";
|
||||
return "THREADS";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull CharSequence getContent(@NonNull Context context) {
|
||||
Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces();
|
||||
StringBuilder out = new StringBuilder();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
for (Map.Entry<Thread, StackTraceElement[]> entry : traces.entrySet()) {
|
||||
if (entry.getKey().getState() == Thread.State.BLOCKED) {
|
||||
Thread thread = entry.getKey();
|
||||
out.append("-- [").append(thread.getId()).append("] ")
|
||||
.append(thread.getName()).append(" (").append(thread.getState().toString()).append(")\n");
|
||||
List<Thread> threads = new ArrayList<>(Thread.getAllStackTraces().keySet());
|
||||
Collections.sort(threads, (lhs, rhs) -> Long.compare(lhs.getId(), rhs.getId()));
|
||||
|
||||
for (StackTraceElement element : entry.getValue()) {
|
||||
out.append(element.toString()).append("\n");
|
||||
}
|
||||
|
||||
out.append("\n");
|
||||
}
|
||||
for (Thread thread : threads) {
|
||||
builder.append("[").append(thread.getId()).append("] ").append(thread.getName()).append("\n");
|
||||
}
|
||||
|
||||
return out.length() == 0 ? "None" : out;
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,6 @@ import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.logsubmit.util.Scrubber;
|
||||
import org.thoughtcrime.securesms.net.StandardUserAgentInterceptor;
|
||||
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
||||
import org.thoughtcrime.securesms.tracing.Tracer;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -64,6 +63,7 @@ public class SubmitDebugLogRepository {
|
||||
add(new LogSectionPermissions());
|
||||
add(new LogSectionTrace());
|
||||
add(new LogSectionThreads());
|
||||
add(new LogSectionBlockedThreads());
|
||||
add(new LogSectionLogcat());
|
||||
add(new LogSectionLogger());
|
||||
}};
|
||||
|
Reference in New Issue
Block a user