Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
821938089 committed Dec 27, 2024
1 parent 7825050 commit 8ccd050
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/io/legado/app/service/AudioPlayService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@ class AudioPlayService : BaseService(),
}
if (timeMinute == 0) {
AudioPlay.stop()
postEvent(EventBus.AUDIO_DS, timeMinute)
break
}
}
postEvent(EventBus.AUDIO_DS, timeMinute)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 19 additions & 4 deletions app/src/main/java/io/legado/app/ui/about/AboutFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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)
}
}

}

0 comments on commit 8ccd050

Please sign in to comment.