diff options
Diffstat (limited to 'app')
4 files changed, 1 insertions, 86 deletions
diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 9a469213..2bef7d22 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -85,7 +85,7 @@ dependencies { implementation(libs.thirdparty.kotlinResult) implementation(libs.thirdparty.logcat) implementation(libs.thirdparty.modernAndroidPrefs) - implementation(libs.thirdparty.plumber) + implementation(libs.thirdparty.leakcanary.plumber) implementation(libs.thirdparty.sshj) implementation(libs.thirdparty.bouncycastle.bcprov) @@ -99,7 +99,6 @@ dependencies { because("SSHJ now uses SLF4J 2.0 which we don't want") } - implementation(libs.thirdparty.leakcanary.core) nonFreeImplementation(libs.thirdparty.nonfree.googlePlayAuthApiPhone) nonFreeImplementation(libs.thirdparty.nonfree.sentry) freeImplementation(projects.sentryStub) 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) -} |