mirror of
https://github.com/kalarina-bit/Sparkledns.git
synced 2026-11-22 15:46:09 +00:00
Enable StrictMode in debug builds
This commit is contained in:
@@ -4,6 +4,7 @@ import android.app.Application
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
|
import android.os.StrictMode
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.PrintWriter
|
import java.io.PrintWriter
|
||||||
import java.io.StringWriter
|
import java.io.StringWriter
|
||||||
@@ -11,6 +12,7 @@ import java.io.StringWriter
|
|||||||
class SparkleApp : Application() {
|
class SparkleApp : Application() {
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
if (BuildConfig.DEBUG) enableStrictMode()
|
||||||
CrashLog.install(this)
|
CrashLog.install(this)
|
||||||
Thread({
|
Thread({
|
||||||
// Reads what the first screen needs before it asks, so its first frame does not wait on storage
|
// Reads what the first screen needs before it asks, so its first frame does not wait on storage
|
||||||
@@ -21,6 +23,12 @@ class SparkleApp : Application() {
|
|||||||
runCatching { Blocklist.reload(this) }
|
runCatching { Blocklist.reload(this) }
|
||||||
}, "startup-load").start()
|
}, "startup-load").start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Debug builds only: logs disk and network access on the main thread, leaked closeables and the like
|
||||||
|
private fun enableStrictMode() {
|
||||||
|
StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build())
|
||||||
|
StrictMode.setVmPolicy(StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Saves the last crash so it can be shown and copied on the next launch
|
// Saves the last crash so it can be shown and copied on the next launch
|
||||||
|
|||||||
Reference in New Issue
Block a user