diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/LogcatActivity.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/LogcatActivity.kt index bd35637e..5ae0f357 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/LogcatActivity.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/LogcatActivity.kt @@ -1,8 +1,8 @@ package com.v2ray.ang.ui +import android.os.Bundle import android.os.Handler import android.os.Looper -import android.os.Bundle import android.text.method.ScrollingMovementMethod import android.view.Menu import android.view.MenuItem @@ -14,11 +14,9 @@ import com.v2ray.ang.databinding.ActivityLogcatBinding import com.v2ray.ang.extension.toast import com.v2ray.ang.util.Utils import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch - +import kotlinx.coroutines.withContext import java.io.IOException -import java.util.LinkedHashSet class LogcatActivity : BaseActivity() { private val binding by lazy { @@ -44,8 +42,10 @@ class LogcatActivity : BaseActivity() { val lst = LinkedHashSet() lst.add("logcat") lst.add("-c") - val process = Runtime.getRuntime().exec(lst.toTypedArray()) - process.waitFor() + withContext(Dispatchers.IO) { + val process = Runtime.getRuntime().exec(lst.toTypedArray()) + process.waitFor() + } } val lst = LinkedHashSet() lst.add("logcat") @@ -54,7 +54,9 @@ class LogcatActivity : BaseActivity() { lst.add("time") lst.add("-s") lst.add("GoLog,tun2socks,${ANG_PACKAGE},AndroidRuntime,System.err") - val process = Runtime.getRuntime().exec(lst.toTypedArray()) + val process = withContext(Dispatchers.IO) { + Runtime.getRuntime().exec(lst.toTypedArray()) + } // val bufferedReader = BufferedReader( // InputStreamReader(process.inputStream)) // val allText = bufferedReader.use(BufferedReader::readText)