diff options
Diffstat (limited to 'app/src')
3 files changed, 0 insertions, 84 deletions
diff --git a/app/src/free/java/app/passwordstore/util/leaks/SentryLeakUploader.kt b/app/src/free/java/app/passwordstore/util/leaks/SentryLeakUploader.kt deleted file mode 100644 index 4b59b9f7..00000000 --- a/app/src/free/java/app/passwordstore/util/leaks/SentryLeakUploader.kt +++ /dev/null @@ -1,8 +0,0 @@ -package app.passwordstore.util.leaks - -import leakcanary.EventListener - -object SentryLeakUploader : EventListener { - - override fun onEvent(event: EventListener.Event) {} -} diff --git a/app/src/main/java/app/passwordstore/Application.kt b/app/src/main/java/app/passwordstore/Application.kt index 279c6af0..b685ebb7 100644 --- a/app/src/main/java/app/passwordstore/Application.kt +++ b/app/src/main/java/app/passwordstore/Application.kt @@ -14,7 +14,6 @@ import app.passwordstore.util.extensions.getString import app.passwordstore.util.features.Feature import app.passwordstore.util.features.Features import app.passwordstore.util.git.sshj.setUpBouncyCastleForSshj -import app.passwordstore.util.leaks.SentryLeakUploader import app.passwordstore.util.proxy.ProxyUtils import app.passwordstore.util.settings.GitSettings import app.passwordstore.util.settings.PreferenceKeys @@ -25,8 +24,6 @@ import io.sentry.Sentry import io.sentry.protocol.User import java.util.concurrent.Executors import javax.inject.Inject -import leakcanary.AppWatcher -import leakcanary.LeakCanary import logcat.AndroidLogcatLogger import logcat.LogPriority.DEBUG import logcat.LogPriority.VERBOSE @@ -46,18 +43,12 @@ class Application : android.app.Application(), SharedPreferences.OnSharedPrefere override fun onCreate() { super.onCreate() instance = this - val eventListeners = LeakCanary.config.eventListeners + SentryLeakUploader if ( BuildConfig.ENABLE_DEBUG_FEATURES || prefs.getBoolean(PreferenceKeys.ENABLE_DEBUG_LOGGING, false) ) { LogcatLogger.install(AndroidLogcatLogger(DEBUG)) setVmPolicy() - AppWatcher.manualInstall(this) - LeakCanary.config = LeakCanary.config.copy(dumpHeap = true, eventListeners = eventListeners) - LeakCanary.showLeakDisplayActivityLauncherIcon(true) - } else { - LeakCanary.config = LeakCanary.config.copy(dumpHeap = false, eventListeners = eventListeners) } prefs.registerOnSharedPreferenceChangeListener(this) setNightMode() 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) -} |