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