From 8ccd05070ca97efabe242917b5e450a2ca671817 Mon Sep 17 00:00:00 2001 From: Horis <8674809+821938089@users.noreply.github.com> Date: Fri, 27 Dec 2024 14:37:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/service/AudioPlayService.kt | 2 ++ .../app/service/BaseReadAloudService.kt | 2 ++ .../io/legado/app/ui/about/AboutFragment.kt | 23 +++++++++++++++---- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/AudioPlayService.kt b/app/src/main/java/io/legado/app/service/AudioPlayService.kt index cad78badf..2e5c75a6b 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/app/src/main/java/io/legado/app/service/AudioPlayService.kt @@ -404,6 +404,8 @@ class AudioPlayService : BaseService(), } if (timeMinute == 0) { AudioPlay.stop() + postEvent(EventBus.AUDIO_DS, timeMinute) + break } } postEvent(EventBus.AUDIO_DS, timeMinute) diff --git a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt index ca3286656..09a9332c5 100644 --- a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt @@ -396,6 +396,8 @@ abstract class BaseReadAloudService : BaseService(), } if (timeMinute == 0) { ReadAloud.stop(this@BaseReadAloudService) + postEvent(EventBus.READ_ALOUD_DS, timeMinute) + break } } postEvent(EventBus.READ_ALOUD_DS, timeMinute) diff --git a/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt b/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt index d0a191794..4df449d80 100644 --- a/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt +++ b/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt @@ -164,11 +164,15 @@ class AboutFragment : PreferenceFragmentCompat() { } private fun copyLogs(doc: FileDoc) { - val logFiles = File(appCtx.externalCacheDir, "logs") - val crashFiles = File(appCtx.externalCacheDir, "crash") + val cacheDir = appCtx.externalCacheDir + val logFiles = File(cacheDir, "logs") + val crashFiles = File(cacheDir, "crash") + val logcatFile = File(cacheDir, "logcat.txt") - val zipFile = File(appCtx.externalCacheDir, "logs.zip") - ZipUtils.zipFiles(arrayListOf(logFiles, crashFiles), zipFile) + dumpLogcat(logcatFile) + + val zipFile = File(cacheDir, "logs.zip") + ZipUtils.zipFiles(arrayListOf(logFiles, crashFiles, logcatFile), zipFile) doc.find("logs.zip")?.delete() @@ -195,4 +199,15 @@ class AboutFragment : PreferenceFragmentCompat() { return true } + private fun dumpLogcat(file: File) { + try { + val process = Runtime.getRuntime().exec("logcat -d") + file.outputStream().use { + process.inputStream.copyTo(it) + } + } catch (e: Exception) { + AppLog.put("保存Logcat失败\n$e", e) + } + } + } \ No newline at end of file