Build a simple ANR detector.

This commit is contained in:
Greyson Parrelli
2023-10-31 13:53:32 -07:00
parent 776a4c5dce
commit 5a005fb809
7 changed files with 308 additions and 2 deletions

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2023 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.thoughtcrime.securesms.logsubmit
import android.content.Context
import org.thoughtcrime.securesms.database.LogDatabase
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
class LogSectionAnr : LogSection {
companion object {
private val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz", Locale.US)
}
override fun getTitle(): String = "ANR"
override fun getContent(context: Context): CharSequence {
val anrs = LogDatabase.getInstance(ApplicationDependencies.getApplication()).anrs.getAll()
return if (anrs.isEmpty()) {
"None"
} else {
"\n" + anrs.joinToString(separator = "\n\n") {
val date = dateFormat.format(Date(it.createdAt))
"------------- $date -------------\n${it.threadDump}"
}
}
}
}

View File

@@ -97,6 +97,7 @@ public class SubmitDebugLogRepository {
add(new LogSectionSenderKey());
}
add(new LogSectionRemappedRecords());
add(new LogSectionAnr());
add(new LogSectionLogcat());
add(new LogSectionLoggerHeader());
}};