Skip to content

Commit

Permalink
Add strict mode for debug builds
Browse files Browse the repository at this point in the history
Tested on a few emulators - no crashes so far.
  • Loading branch information
Sergey-Makarov committed Dec 9, 2024
1 parent 2273a12 commit 76e3c21
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion app/src/main/java/com/fingerprintjs/android/playground/App.kt
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -10,10 +11,26 @@ class App : Application() {
private set

override fun onCreate() {
setupStrictMode()
super.onCreate()
appComponent = DaggerAppComponent
.builder()
.app(this)
.build()
}
}

private fun setupStrictMode() {
if (BuildConfig.DEBUG) {
StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.penaltyDeath()
.build())
StrictMode.setVmPolicy(StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog()
.penaltyDeath()
.build())
}
}
}

0 comments on commit 76e3c21

Please sign in to comment.