|
|
@ -8,20 +8,31 @@ import android.os.StrictMode
|
|
|
|
import androidx.preference.PreferenceManager
|
|
|
|
import androidx.preference.PreferenceManager
|
|
|
|
import leakcanary.AppWatcher
|
|
|
|
import leakcanary.AppWatcher
|
|
|
|
import leakcanary.LeakCanary
|
|
|
|
import leakcanary.LeakCanary
|
|
|
|
|
|
|
|
import org.mozilla.fenix.ext.application
|
|
|
|
import org.mozilla.fenix.ext.getPreferenceKey
|
|
|
|
import org.mozilla.fenix.ext.getPreferenceKey
|
|
|
|
|
|
|
|
|
|
|
|
class DebugFenixApplication : FenixApplication() {
|
|
|
|
class DebugFenixApplication : FenixApplication() {
|
|
|
|
|
|
|
|
|
|
|
|
override fun setupLeakCanary() {
|
|
|
|
override fun setupLeakCanary() {
|
|
|
|
|
|
|
|
if (!AppWatcher.isInstalled) {
|
|
|
|
|
|
|
|
AppWatcher.manualInstall(
|
|
|
|
|
|
|
|
application = application,
|
|
|
|
|
|
|
|
watchersToInstall = AppWatcher.appDefaultWatchers(application)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val isEnabled = components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) {
|
|
|
|
val isEnabled = components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) {
|
|
|
|
PreferenceManager.getDefaultSharedPreferences(this)
|
|
|
|
PreferenceManager.getDefaultSharedPreferences(this)
|
|
|
|
.getBoolean(getPreferenceKey(R.string.pref_key_leakcanary), true)
|
|
|
|
.getBoolean(getPreferenceKey(R.string.pref_key_leakcanary), true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateLeakCanaryState(isEnabled)
|
|
|
|
updateLeakCanaryState(isEnabled)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun updateLeakCanaryState(isEnabled: Boolean) {
|
|
|
|
override fun updateLeakCanaryState(isEnabled: Boolean) {
|
|
|
|
AppWatcher.config = AppWatcher.config.copy(enabled = isEnabled)
|
|
|
|
LeakCanary.showLeakDisplayActivityLauncherIcon(isEnabled)
|
|
|
|
|
|
|
|
components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) {
|
|
|
|
LeakCanary.config = LeakCanary.config.copy(dumpHeap = isEnabled)
|
|
|
|
LeakCanary.config = LeakCanary.config.copy(dumpHeap = isEnabled)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|