LogViewerActivity: destroy process when coroutine scope is cancelled

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2020-09-16 15:20:32 +02:00
parent bd1679b7e0
commit 44c2afbfba

View File

@ -193,7 +193,9 @@ class LogViewerActivity : AppCompatActivity() {
private suspend fun streamingLog() = withContext(Dispatchers.IO) { private suspend fun streamingLog() = withContext(Dispatchers.IO) {
val builder = ProcessBuilder().command("logcat", "-b", "all", "-v", "threadtime", "*:V") val builder = ProcessBuilder().command("logcat", "-b", "all", "-v", "threadtime", "*:V")
builder.environment()["LC_ALL"] = "C" builder.environment()["LC_ALL"] = "C"
val process = try { var process: Process? = null
try {
process = try {
builder.start() builder.start()
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printStackTrace()
@ -237,6 +239,9 @@ class LogViewerActivity : AppCompatActivity() {
} }
} }
} }
} finally {
process?.destroy()
}
} }
private fun parseTime(timeStr: String): Date? { private fun parseTime(timeStr: String): Date? {