aboutsummaryrefslogtreecommitdiff
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
parentdd01fc78a07fff23ac22fa45f3317fdf1c02dbb1 (diff)
feat: remove Leak Canary
This mostly ends up spamming about Autofill leaks in the framework
-rw-r--r--app/build.gradle.kts3
-rw-r--r--app/src/free/java/app/passwordstore/util/leaks/SentryLeakUploader.kt8
-rw-r--r--app/src/main/java/app/passwordstore/Application.kt9
-rw-r--r--app/src/nonFree/java/app/passwordstore/util/leaks/SentryLeakUploader.kt67
-rw-r--r--gradle/libs.versions.toml4
5 files changed, 2 insertions, 89 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)
-}
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 8a434511..bec1a8e4 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -10,7 +10,6 @@ flowbinding = "1.2.0"
hilt = "2.48.1"
kotlin = "1.9.20"
kotlinResult = "1.1.18"
-leakcanary = "2.12"
lifecycle = "2.6.2"
[libraries]
@@ -84,13 +83,12 @@ thirdparty-flowbinding-android = { module = "io.github.reactivecircus.flowbindin
thirdparty-jgit = "org.eclipse.jgit:org.eclipse.jgit:3.7.1.201504261725-r"
thirdparty-kotlinResult = { module = "com.michael-bull.kotlin-result:kotlin-result", version.ref = "kotlinResult" }
thirdparty-kotlinResult-coroutines = { module = "com.michael-bull.kotlin-result:kotlin-result-coroutines", version.ref = "kotlinResult" }
-thirdparty-leakcanary-core = { module = "com.squareup.leakcanary:leakcanary-android-core", version.ref = "leakcanary" }
+thirdparty-leakcanary-plumber = "com.squareup.leakcanary:plumber-android-startup:2.12"
thirdparty-logcat = "com.squareup.logcat:logcat:0.1"
thirdparty-modernAndroidPrefs = "de.maxr1998:modernandroidpreferences:2.3.2"
thirdparty-nonfree-googlePlayAuthApiPhone = "com.google.android.gms:play-services-auth-api-phone:18.0.1"
thirdparty-nonfree-sentry = "io.sentry:sentry-android:6.34.0"
thirdparty-pgpainless = "org.pgpainless:pgpainless-core:1.6.3"
-thirdparty-plumber = { module = "com.squareup.leakcanary:plumber-android-startup", version.ref = "leakcanary" }
thirdparty-slack-lints = "com.slack.lint:slack-lint-checks:0.7.0"
thirdparty-slf4j-api = { module = "org.slf4j:slf4j-api", version = { strictly = "[1.7, 1.8[", prefer = "1.7.36" } }
thirdparty-sshj = "com.hierynomus:sshj:0.37.0"