Ensure that logcat command exits properly

This commit is contained in:
MM20 2021-09-26 20:34:44 +02:00
parent ac9a9de69a
commit f1546d3d3e
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389

View File

@ -17,15 +17,14 @@ class DebugInformationDumper {
"kvaesitso-log-${df.format(Date(System.currentTimeMillis()))}"
)
withContext(Dispatchers.IO) {
val timeout = System.currentTimeMillis() + 5000
val fos = file.outputStream().writer()
fos.write("Device: ${Build.DEVICE}\n")
fos.write("SDK version: ${Build.VERSION.SDK_INT}\n")
fos.write("====================================\n")
val input =
Runtime.getRuntime().exec("/system/bin/sh -c logcat").inputStream.bufferedReader()
Runtime.getRuntime().exec("/system/bin/logcat -d").inputStream.bufferedReader()
var line = input.readLine()
while (line != null && System.currentTimeMillis() < timeout) {
while (line != null) {
line = input.readLine()
fos.write("$line\n")
}