Lessen the use of GlobalScope launchIO (#7916)

* Lessen the use of GlobalScope `launchIO`

* Wrap some calls with `NonCancellable` context
This commit is contained in:
AntsyLich
2022-09-02 21:50:44 +06:00
committed by GitHub
parent 774a87a42a
commit da95ecb686
9 changed files with 59 additions and 67 deletions
@@ -7,7 +7,6 @@ import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
import eu.kanade.tachiyomi.data.notification.Notifications
import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.lang.withUIContext
import eu.kanade.tachiyomi.util.storage.getUriCompat
import eu.kanade.tachiyomi.util.system.createFileInCacheDir
@@ -21,17 +20,15 @@ class CrashLogUtil(private val context: Context) {
setSmallIcon(R.drawable.ic_tachi)
}
fun dumpLogs() {
launchIO {
try {
val file = context.createFileInCacheDir("tachiyomi_crash_logs.txt")
Runtime.getRuntime().exec("logcat *:E -d -f ${file.absolutePath}").waitFor()
file.appendText(getDebugInfo())
suspend fun dumpLogs() {
try {
val file = context.createFileInCacheDir("tachiyomi_crash_logs.txt")
Runtime.getRuntime().exec("logcat *:E -d -f ${file.absolutePath}").waitFor()
file.appendText(getDebugInfo())
showNotification(file.getUriCompat(context))
} catch (e: Throwable) {
withUIContext { context.toast("Failed to get logs") }
}
showNotification(file.getUriCompat(context))
} catch (e: Throwable) {
withUIContext { context.toast("Failed to get logs") }
}
}