Colota - Android GPS Location tracker
fix: add process cleanup in getNativeLogs and non-null bound to TimedCache
Max Dietrich4d192f15f6d1
diff --git a/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.kt b/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.ktindex bb94568f..8aaafc93 100644--- a/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.kt+++ b/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.kt@@ -908,10 +908,14 @@ class LocationServiceModule(reactContext: ReactApplicationContext) :fun getNativeLogs(promise: Promise) = executeAsync(promise) {val pid = android.os.Process.myPid()val process = Runtime.getRuntime().exec(arrayOf("logcat", "-d", "-v", "threadtime", "--pid=$pid"))- val lines = process.inputStream.bufferedReader().readLines()- process.waitFor(10, java.util.concurrent.TimeUnit.SECONDS)- Arguments.createArray().apply {- lines.filter { "Colota." in it }.forEach { pushString(it) }+ try {+ val lines = process.inputStream.bufferedReader().readLines()+ process.waitFor(10, java.util.concurrent.TimeUnit.SECONDS)+ Arguments.createArray().apply {+ lines.filter { "Colota." in it }.forEach { pushString(it) }+ }+ } finally {+ process.destroy()}}}diff --git a/apps/mobile/android/app/src/main/java/com/colota/util/TimedCache.kt b/apps/mobile/android/app/src/main/java/com/colota/util/TimedCache.ktindex 4d6946e3..4228ead2 100644--- a/apps/mobile/android/app/src/main/java/com/colota/util/TimedCache.kt+++ b/apps/mobile/android/app/src/main/java/com/colota/util/TimedCache.kt@@ -11,7 +11,7 @@ package com.Colota.util* @param ttlMs Time-to-live in milliseconds before the cached value is refreshed* @param loader Function that produces a fresh value when the cache is stale*/-class TimedCache<T>(+class TimedCache<T : Any>(private val ttlMs: Long,private val loader: () -> T) {