diff --git a/app/build.gradle b/app/build.gradle index 78e5b5fb..4a30ef05 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -214,9 +214,6 @@ dependencies { implementation 'com.zzhoujay.richtext:richtext:3.0.8' implementation 'com.squareup.retrofit2:retrofit:2.9.0' - //ANR异常捕获 - implementation 'com.github.anrwatchdog:anrwatchdog:1.4.0' - //美团多渠道打包 implementation 'com.meituan.android.walle:library:1.1.6' diff --git a/app/src/main/java/com/idormy/sms/forwarder/App.kt b/app/src/main/java/com/idormy/sms/forwarder/App.kt index 8564c545..1a3b68ec 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/App.kt +++ b/app/src/main/java/com/idormy/sms/forwarder/App.kt @@ -27,7 +27,6 @@ import com.idormy.sms.forwarder.service.BatteryService import com.idormy.sms.forwarder.service.ForegroundService import com.idormy.sms.forwarder.service.HttpService import com.idormy.sms.forwarder.utils.* -import com.idormy.sms.forwarder.utils.sdkinit.ANRWatchDogInit import com.idormy.sms.forwarder.utils.sdkinit.UMengInit import com.idormy.sms.forwarder.utils.sdkinit.XBasicLibInit import com.idormy.sms.forwarder.utils.sdkinit.XUpdateInit @@ -223,8 +222,6 @@ class App : Application(), CactusCallback, Configuration.Provider by Core { XUpdateInit.init(this) // 运营统计数据 UMengInit.init(this) - // ANR监控 - ANRWatchDogInit.init() } @SuppressLint("CheckResult") diff --git a/app/src/main/java/com/idormy/sms/forwarder/utils/sdkinit/ANRWatchDogInit.kt b/app/src/main/java/com/idormy/sms/forwarder/utils/sdkinit/ANRWatchDogInit.kt deleted file mode 100644 index 2ac9acb6..00000000 --- a/app/src/main/java/com/idormy/sms/forwarder/utils/sdkinit/ANRWatchDogInit.kt +++ /dev/null @@ -1,64 +0,0 @@ -@file:Suppress("MemberVisibilityCanBePrivate") - -package com.idormy.sms.forwarder.utils.sdkinit - -import com.github.anrwatchdog.ANRError -import com.github.anrwatchdog.ANRWatchDog -import com.github.anrwatchdog.ANRWatchDog.ANRListener -import com.xuexiang.xutil.common.logger.Logger - -/** - * ANR看门狗监听器初始化 - * - * @author xuexiang - * @since 2020-02-18 15:08 - */ -@Suppress("unused", "MemberVisibilityCanBePrivate") -class ANRWatchDogInit private constructor() { - companion object { - private const val TAG = "ANRWatchDog" - - /** - * ANR看门狗 - */ - var aNRWatchDog: ANRWatchDog? = null - private set - - /** - * ANR监听触发的时间 - */ - private const val ANR_DURATION = 4000 - - /** - * ANR静默处理【就是不处理,直接记录一下日志】 - */ - private val SILENT_LISTENER = ANRListener { error: ANRError? -> Logger.eTag(TAG, error) } - - /** - * ANR自定义处理【可以是记录日志用于上传】 - */ - private val CUSTOM_LISTENER = ANRListener { error: ANRError? -> - Logger.eTag(TAG, "Detected Application Not Responding!", error) - throw error!! - } - - fun init() { - //这里设置监听的间隔为2秒 - aNRWatchDog = ANRWatchDog(2000) - aNRWatchDog!!.setANRInterceptor { duration: Long -> - val ret = ANR_DURATION - duration - if (ret > 0) { - Logger.wTag( - TAG, - "Intercepted ANR that is too short ($duration ms), postponing for $ret ms." - ) - } - ret - }.setANRListener(SILENT_LISTENER).start() - } - } - - init { - throw UnsupportedOperationException("u can't instantiate me...") - } -} \ No newline at end of file