mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Build a simple ANR detector.
This commit is contained in:
@@ -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}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,6 +97,7 @@ public class SubmitDebugLogRepository {
|
||||
add(new LogSectionSenderKey());
|
||||
}
|
||||
add(new LogSectionRemappedRecords());
|
||||
add(new LogSectionAnr());
|
||||
add(new LogSectionLogcat());
|
||||
add(new LogSectionLoggerHeader());
|
||||
}};
|
||||
|
||||
Reference in New Issue
Block a user