Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit ddd958a

Browse files
committed
fix(app): control LeakCanary lifecycle more explicitly
1 parent 538f98b commit ddd958a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

app/src/main/java/app/passwordstore/Application.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,19 @@ class Application : android.app.Application(), SharedPreferences.OnSharedPrefere
4646
override fun onCreate() {
4747
super.onCreate()
4848
instance = this
49-
LeakCanary.config =
50-
LeakCanary.config.copy(eventListeners = LeakCanary.config.eventListeners + SentryLeakUploader)
49+
val eventListeners = LeakCanary.config.eventListeners + SentryLeakUploader
5150
if (
5251
BuildConfig.ENABLE_DEBUG_FEATURES ||
5352
prefs.getBoolean(PreferenceKeys.ENABLE_DEBUG_LOGGING, false)
5453
) {
5554
LogcatLogger.install(AndroidLogcatLogger(DEBUG))
56-
AppWatcher.manualInstall(this)
5755
setVmPolicy()
56+
LeakCanary.config.copy(dumpHeap = true, eventListeners = eventListeners)
57+
LeakCanary.showLeakDisplayActivityLauncherIcon(true)
58+
AppWatcher.manualInstall(this)
59+
} else {
60+
LeakCanary.config.copy(dumpHeap = false, eventListeners = eventListeners)
61+
LeakCanary.showLeakDisplayActivityLauncherIcon(false)
5862
}
5963
prefs.registerOnSharedPreferenceChangeListener(this)
6064
setNightMode()

app/src/main/res/values/bools.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55

66
<resources>
77
<bool name="leak_canary_allow_in_non_debuggable_build">true</bool>
8+
<bool name="leak_canary_watcher_auto_install">false</bool>
89
<bool name="light_status_bar">true</bool>
910
</resources>

0 commit comments

Comments
 (0)