|
|
|
@ -4,12 +4,11 @@ import android.annotation.SuppressLint |
|
|
|
|
import android.content.Context |
|
|
|
|
import android.content.pm.PackageManager |
|
|
|
|
import android.os.Build |
|
|
|
|
import android.os.Handler |
|
|
|
|
import android.os.Looper |
|
|
|
|
import android.util.Log |
|
|
|
|
import android.widget.Toast |
|
|
|
|
import io.legado.app.service.help.ReadAloud |
|
|
|
|
import io.legado.app.utils.FileUtils |
|
|
|
|
import io.legado.app.utils.msg |
|
|
|
|
import io.legado.app.utils.share |
|
|
|
|
import java.io.PrintWriter |
|
|
|
|
import java.io.StringWriter |
|
|
|
|
import java.text.SimpleDateFormat |
|
|
|
@ -64,18 +63,12 @@ class CrashHandler(val context: Context) : Thread.UncaughtExceptionHandler { |
|
|
|
|
//添加自定义信息 |
|
|
|
|
addCustomInfo() |
|
|
|
|
kotlin.runCatching { |
|
|
|
|
//使用Toast来显示异常信息 |
|
|
|
|
Handler(Looper.getMainLooper()).post { |
|
|
|
|
Toast.makeText( |
|
|
|
|
context, |
|
|
|
|
ex.message, |
|
|
|
|
Toast.LENGTH_LONG |
|
|
|
|
).show() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//分享崩溃日志 |
|
|
|
|
context.share(ex.msg, "崩溃日志") |
|
|
|
|
//保存日志文件 |
|
|
|
|
saveCrashInfo2File(ex) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 收集设备参数信息 |
|
|
|
@ -116,7 +109,6 @@ class CrashHandler(val context: Context) : Thread.UncaughtExceptionHandler { |
|
|
|
|
* 保存错误信息到文件中 |
|
|
|
|
*/ |
|
|
|
|
private fun saveCrashInfo2File(ex: Throwable) { |
|
|
|
|
kotlin.runCatching { |
|
|
|
|
val sb = StringBuilder() |
|
|
|
|
for ((key, value) in paramsMap) { |
|
|
|
|
sb.append(key).append("=").append(value).append("\n") |
|
|
|
@ -146,6 +138,5 @@ class CrashHandler(val context: Context) : Thread.UncaughtExceptionHandler { |
|
|
|
|
.writeText(sb.toString()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|