No issue: Enable Strict Mode in Debug Builds (#4014)
parent
7cea2ed048
commit
2feddc9bd6
|
@ -26,7 +26,6 @@ import java.io.File
|
|||
class DebugFenixApplication : FenixApplication() {
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
SoLoader.init(this, false)
|
||||
|
||||
if (FlipperUtils.shouldEnableFlipper(this)) {
|
||||
|
@ -39,6 +38,8 @@ class DebugFenixApplication : FenixApplication() {
|
|||
start()
|
||||
}
|
||||
}
|
||||
|
||||
super.onCreate()
|
||||
}
|
||||
|
||||
private var heapDumper: ToggleableHeapDumper? = null
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.annotation.SuppressLint
|
|||
import android.app.Application
|
||||
import android.os.Build
|
||||
import android.os.Build.VERSION.SDK_INT
|
||||
import android.os.StrictMode
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import io.reactivex.plugins.RxJavaPlugins
|
||||
import kotlinx.coroutines.Deferred
|
||||
|
@ -55,6 +56,7 @@ open class FenixApplication : Application() {
|
|||
setupLogging(megazordEnabled)
|
||||
registerRxExceptionHandling()
|
||||
setupCrashReporting()
|
||||
enableStrictMode()
|
||||
|
||||
if (!isMainProcess()) {
|
||||
// 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