From 76e3c21a2c48d45772b19f8e72a9c80d79173dcd Mon Sep 17 00:00:00 2001 From: Sergey Makarov Date: Fri, 6 Dec 2024 16:34:31 +0300 Subject: [PATCH] Add strict mode for debug builds Tested on a few emulators - no crashes so far. --- .../fingerprintjs/android/playground/App.kt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/fingerprintjs/android/playground/App.kt b/app/src/main/java/com/fingerprintjs/android/playground/App.kt index b8769035..4dfd95e8 100644 --- a/app/src/main/java/com/fingerprintjs/android/playground/App.kt +++ b/app/src/main/java/com/fingerprintjs/android/playground/App.kt @@ -1,6 +1,7 @@ package com.fingerprintjs.android.playground import android.app.Application +import android.os.StrictMode import com.fingerprintjs.android.playground.di.AppComponent import com.fingerprintjs.android.playground.di.DaggerAppComponent @@ -10,10 +11,26 @@ class App : Application() { private set override fun onCreate() { + setupStrictMode() super.onCreate() appComponent = DaggerAppComponent .builder() .app(this) .build() } -} \ No newline at end of file + + private fun setupStrictMode() { + if (BuildConfig.DEBUG) { + StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder() + .detectAll() + .penaltyLog() + .penaltyDeath() + .build()) + StrictMode.setVmPolicy(StrictMode.VmPolicy.Builder() + .detectAll() + .penaltyLog() + .penaltyDeath() + .build()) + } + } +}