aboutsummaryrefslogtreecommitdiff
path: root/app/src/nonFree/java
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2023-11-26 21:36:59 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2023-11-26 21:36:59 +0530
commit8fa7b0b60f9718209f8827767fa71b277faf8cec (patch)
tree4d485ecc72e003c7d52f233fb8a6faf818f7db57 /app/src/nonFree/java
parentdd01fc78a07fff23ac22fa45f3317fdf1c02dbb1 (diff)
feat: remove Leak Canary
This mostly ends up spamming about Autofill leaks in the framework
Diffstat (limited to 'app/src/nonFree/java')
-rw-r--r--app/src/nonFree/java/app/passwordstore/util/leaks/SentryLeakUploader.kt67
1 files changed, 0 insertions, 67 deletions
diff --git a/app/src/nonFree/java/app/passwordstore/util/leaks/SentryLeakUploader.kt b/app/src/nonFree/java/app/passwordstore/util/leaks/SentryLeakUploader.kt
deleted file mode 100644
index d8889350..00000000
--- a/app/src/nonFree/java/app/passwordstore/util/leaks/SentryLeakUploader.kt
+++ /dev/null
@@ -1,67 +0,0 @@
-package app.passwordstore.util.leaks
-
-import io.sentry.Sentry
-import io.sentry.SentryEvent
-import leakcanary.EventListener
-import leakcanary.EventListener.Event
-import shark.HeapAnalysisSuccess
-import shark.Leak
-import shark.LeakTrace
-import shark.LibraryLeak
-
-object SentryLeakUploader : EventListener {
-
- override fun onEvent(event: Event) {
- when (event) {
- is Event.HeapAnalysisDone<*> -> {
- if (event.heapAnalysis !is HeapAnalysisSuccess) return
- val heapAnalysis = event.heapAnalysis as HeapAnalysisSuccess
- val allLeakTraces =
- heapAnalysis.allLeaks.toList().flatMap { leak ->
- leak.leakTraces.map { leakTrace -> leak to leakTrace }
- }
-
- allLeakTraces.forEach { (leak, leakTrace) ->
- val exception = FakeReportingException(leak.shortDescription)
- val sentryEvent =
- SentryEvent(exception).apply {
- val leakContexts = mutableMapOf<String, Any>()
- addHeapAnalysis(heapAnalysis, leakContexts)
- addLeak(leak, leakContexts)
- addLeakTrace(leakTrace, leakContexts)
- contexts["Leak"] = leakContexts
- // grouping leaks
- fingerprints = listOf(leak.signature)
- }
- Sentry.captureEvent(sentryEvent)
- }
- }
- else -> {}
- }
- }
-
- private fun addHeapAnalysis(
- heapAnalysis: HeapAnalysisSuccess,
- leakContexts: MutableMap<String, Any>
- ) {
- leakContexts["heapDumpPath"] = heapAnalysis.heapDumpFile.absolutePath
- heapAnalysis.metadata.forEach { (key, value) -> leakContexts[key] = value }
- leakContexts["analysisDurationMs"] = heapAnalysis.analysisDurationMillis
- }
-
- private fun addLeak(leak: Leak, leakContexts: MutableMap<String, Any>) {
- leakContexts["libraryLeak"] = leak is LibraryLeak
- if (leak is LibraryLeak) {
- leakContexts["libraryLeakPattern"] = leak.pattern.toString()
- leakContexts["libraryLeakDescription"] = leak.description
- }
- }
-
- private fun addLeakTrace(leakTrace: LeakTrace, leakContexts: MutableMap<String, Any>) {
- leakTrace.retainedHeapByteSize?.let { leakContexts["retainedHeapByteSize"] = it }
- leakContexts["signature"] = leakTrace.signature
- leakContexts["leakTrace"] = leakTrace.toString()
- }
-
- class FakeReportingException(message: String) : RuntimeException(message)
-}