fix: tile control and kernel sync (#320)

increase auto tunnel delay to 3 seconds

optimize stats job by killing it when app is backgrounded

fix tunnel launch from background

add restart of services and tunnels after update
This commit is contained in:
Zane Schepke
2024-08-17 21:29:31 -04:00
committed by GitHub
parent 3f4673b2a7
commit 30851a7d7b
22 changed files with 235 additions and 109 deletions
@@ -5,7 +5,7 @@ import kotlinx.coroutines.flow.Flow
import java.io.File
interface LocalLogCollector {
fun start(onLogMessage: ((message: LogMessage) -> Unit)? = null)
suspend fun start(onLogMessage: ((message: LogMessage) -> Unit)? = null)
fun stop()
@@ -69,7 +69,7 @@ object LogcatUtil {
internal object Logcat : LocalLogCollector {
private var logcatReader: LogcatReader? = null
override fun start(onLogMessage: ((message: LogMessage) -> Unit)?) {
override suspend fun start(onLogMessage: ((message: LogMessage) -> Unit)?) {
logcatReader ?: run {
logcatReader =
LogcatReader(
@@ -78,9 +78,7 @@ object LogcatUtil {
onLogMessage,
)
}
logcatReader?.let { logReader ->
if (!logReader.isAlive) logReader.start()
}
logcatReader?.run()
}
override fun stop() {
@@ -142,7 +140,7 @@ object LogcatUtil {
pID: String,
private val logcatPath: String,
private val callback: ((input: LogMessage) -> Unit)?,
) : Thread() {
) {
private var logcatProc: Process? = null
private var reader: BufferedReader? = null
private var mRunning = true
@@ -177,7 +175,7 @@ object LogcatUtil {
}.let { last -> findIpv4AddressRegex.replace(last, "<ipv4-address>") }
}
override fun run() {
fun run() {
if (outputStream == null) return
try {
clear()