No issue: Enable Strict Mode in Debug Builds (#4014)
parent
7cea2ed048
commit
2feddc9bd6
|
@ -26,7 +26,6 @@ import java.io.File
|
||||||
class DebugFenixApplication : FenixApplication() {
|
class DebugFenixApplication : FenixApplication() {
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
|
||||||
SoLoader.init(this, false)
|
SoLoader.init(this, false)
|
||||||
|
|
||||||
if (FlipperUtils.shouldEnableFlipper(this)) {
|
if (FlipperUtils.shouldEnableFlipper(this)) {
|
||||||
|
@ -39,6 +38,8 @@ class DebugFenixApplication : FenixApplication() {
|
||||||
start()
|
start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super.onCreate()
|
||||||
}
|
}
|
||||||
|
|
||||||
private var heapDumper: ToggleableHeapDumper? = null
|
private var heapDumper: ToggleableHeapDumper? = null
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.annotation.SuppressLint
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Build.VERSION.SDK_INT
|
import android.os.Build.VERSION.SDK_INT
|
||||||
|
import android.os.StrictMode
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import io.reactivex.plugins.RxJavaPlugins
|
import io.reactivex.plugins.RxJavaPlugins
|
||||||
import kotlinx.coroutines.Deferred
|
import kotlinx.coroutines.Deferred
|
||||||
|
@ -55,6 +56,7 @@ open class FenixApplication : Application() {
|
||||||
setupLogging(megazordEnabled)
|
setupLogging(megazordEnabled)
|
||||||
registerRxExceptionHandling()
|
registerRxExceptionHandling()
|
||||||
setupCrashReporting()
|
setupCrashReporting()
|
||||||
|
enableStrictMode()
|
||||||
|
|
||||||
if (!isMainProcess()) {
|
if (!isMainProcess()) {
|
||||||
// If this is not the main process then do not continue with the initialization here. Everything that
|
// If this is not the main process then do not continue with the initialization here. Everything that
|
||||||
|
@ -237,4 +239,25 @@ open class FenixApplication : Application() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun enableStrictMode() {
|
||||||
|
if (BuildConfig.DEBUG) {
|
||||||
|
StrictMode.setThreadPolicy(
|
||||||
|
StrictMode.ThreadPolicy.Builder()
|
||||||
|
.detectAll()
|
||||||
|
.penaltyLog()
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
var builder = StrictMode.VmPolicy.Builder()
|
||||||
|
.detectLeakedSqlLiteObjects()
|
||||||
|
.detectLeakedClosableObjects()
|
||||||
|
.detectLeakedRegistrationObjects()
|
||||||
|
.detectActivityLeaks()
|
||||||
|
.detectFileUriExposure()
|
||||||
|
.penaltyLog()
|
||||||
|
if (SDK_INT >= Build.VERSION_CODES.O) builder = builder.detectContentUriWithoutPermission()
|
||||||
|
if (SDK_INT >= Build.VERSION_CODES.P) builder = builder.detectNonSdkApiUsage()
|
||||||
|
StrictMode.setVmPolicy(builder.build())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue