Fix StrictMode config (#7837)

Remove `penaltyDialog()` as it makes the app unusable even in debug builds
This commit is contained in:
Jorge Martin Espinosa
2026-10-02 10:05:08 +02:00
committed by GitHub
parent 5ed880d539
commit 558c4541cd
@@ -40,19 +40,7 @@ class ElementXApplication : Application(), DependencyInjectionGraphOwner, Config
override fun onCreate() {
super.onCreate()
// Workaround to avoid NetworkOnMainThreadException when using the network on the main thread.
// This is a temporary solution to rustls doing the certificate verification using blocking network requests.
// It should be removed once the underlying issue is fixed.
// Also, we only want to enable it on nightly and release builds so we can debug the issue on debug builds.
if (!BuildConfig.DEBUG) {
StrictMode.setThreadPolicy(
StrictMode.ThreadPolicy.Builder()
.detectNetwork()
.penaltyLog()
.penaltyDialog()
.build()
)
}
enableStrictMode()
AppInitializer.getInstance(this).apply {
initializeComponent(CrashInitializer::class.java)
@@ -67,4 +55,16 @@ class ElementXApplication : Application(), DependencyInjectionGraphOwner, Config
// Remove once https://issuetracker.google.com/issues/477038695 is fixed.
isAnchoredDraggableComponentsStrictOffsetCheckEnabled = false
}
private fun enableStrictMode() {
// Workaround to avoid NetworkOnMainThreadException when using the network on the main thread.
// This is a temporary solution to rustls doing the certificate verification using blocking network requests.
// It should be removed once the underlying issue is fixed.
StrictMode.setThreadPolicy(
StrictMode.ThreadPolicy.Builder()
.detectNetwork()
.penaltyLog()
.build()
)
}
}