chore: format code

This commit is contained in:
fiatcode 2026-05-04 08:28:05 +07:00
parent 31180f9921
commit 1b3440e2fe
No known key found for this signature in database
7 changed files with 516 additions and 2 deletions

View file

@ -93,6 +93,9 @@ class BridgeModule : FlutterPlugin, MethodChannel.MethodCallHandler {
"isBatteryOptimizationDisabled" -> {
result.success(isBatteryOptimizationDisabled())
}
"clearLogs" -> {
clearLogs(result)
}
else -> result.notImplemented()
}
}
@ -191,6 +194,7 @@ class BridgeModule : FlutterPlugin, MethodChannel.MethodCallHandler {
}
mainHandler.post { result.success(logs) }
} catch (e: Exception) {
Log.e(TAG, "fetchLogs failed", e)
mainHandler.post { result.success(emptyList<Map<String, Any>>()) }
}
}.start()
@ -228,4 +232,23 @@ class BridgeModule : FlutterPlugin, MethodChannel.MethodCallHandler {
false
}
}
private fun clearLogs(result: MethodChannel.Result) {
Thread {
try {
val deleted = runBlocking(Dispatchers.IO) {
val db = context?.let { AppDatabase.getInstance(it) }
if (db != null) {
db.eventLogDao().deleteAll()
} else {
0
}
}
mainHandler.post { result.success(deleted) }
} catch (e: Exception) {
Log.e(TAG, "clearLogs failed", e)
mainHandler.post { result.success(-1) }
}
}.start()
}
}

View file

@ -42,7 +42,7 @@ import android.util.Log
class LocationTrackingService : Service() {
private val binder = LocalBinder()
private val serviceScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
private val serviceScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
private val TAG = "LocationTrackingService"
private lateinit var fusedLocationProvider: FusedLocationProvider

View file

@ -18,4 +18,7 @@ interface EventLogDao {
@Query("DELETE FROM event_log WHERE timestamp < :beforeTimestamp")
suspend fun deleteOlderThan(beforeTimestamp: Long)
@Query("DELETE FROM event_log")
suspend fun deleteAll()
}