From 6a8743828d9e9fc32169505ddb51b0ccce3d1c5f Mon Sep 17 00:00:00 2001 From: Goooler Date: Fri, 26 Aug 2022 15:43:51 +0800 Subject: [PATCH 1/2] enableStrictMode --- .../goooler/demoapp/common/CommonApplication.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/common/src/main/kotlin/io/goooler/demoapp/common/CommonApplication.kt b/common/src/main/kotlin/io/goooler/demoapp/common/CommonApplication.kt index 4a9285aa5..d83d0a6b4 100644 --- a/common/src/main/kotlin/io/goooler/demoapp/common/CommonApplication.kt +++ b/common/src/main/kotlin/io/goooler/demoapp/common/CommonApplication.kt @@ -1,5 +1,6 @@ package io.goooler.demoapp.common +import android.os.StrictMode import com.scwang.smart.refresh.footer.ClassicsFooter import com.scwang.smart.refresh.header.ClassicsHeader import com.scwang.smart.refresh.layout.SmartRefreshLayout @@ -17,6 +18,7 @@ abstract class CommonApplication : BaseApplication() { CrashHandler.init() ImageLoader.init(this) initSmartRefresh() + enableStrictMode() } private fun initSmartRefresh() { @@ -31,6 +33,21 @@ abstract class CommonApplication : BaseApplication() { } } + private fun enableStrictMode() { + if (BuildConfig.DEBUG) { + val threadPolicy = StrictMode.ThreadPolicy.Builder() + .detectAll() + .penaltyDeath() + .build() + val vmPolicy = StrictMode.VmPolicy.Builder() + .detectAll() + .penaltyDeath() + .build() + StrictMode.setThreadPolicy(threadPolicy) + StrictMode.setVmPolicy(vmPolicy) + } + } + companion object { lateinit var app: CommonApplication private set From c6cae56edbd19a3ddbdf274e419aab527a5d67c4 Mon Sep 17 00:00:00 2001 From: Goooler Date: Fri, 26 Aug 2022 16:13:31 +0800 Subject: [PATCH 2/2] Disable rules --- .../kotlin/io/goooler/demoapp/common/CommonApplication.kt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/common/src/main/kotlin/io/goooler/demoapp/common/CommonApplication.kt b/common/src/main/kotlin/io/goooler/demoapp/common/CommonApplication.kt index d83d0a6b4..fea30c71a 100644 --- a/common/src/main/kotlin/io/goooler/demoapp/common/CommonApplication.kt +++ b/common/src/main/kotlin/io/goooler/demoapp/common/CommonApplication.kt @@ -37,14 +37,9 @@ abstract class CommonApplication : BaseApplication() { if (BuildConfig.DEBUG) { val threadPolicy = StrictMode.ThreadPolicy.Builder() .detectAll() - .penaltyDeath() - .build() - val vmPolicy = StrictMode.VmPolicy.Builder() - .detectAll() - .penaltyDeath() + .penaltyLog() .build() StrictMode.setThreadPolicy(threadPolicy) - StrictMode.setVmPolicy(vmPolicy) } }