chore: format code
This commit is contained in:
parent
31180f9921
commit
1b3440e2fe
7 changed files with 516 additions and 2 deletions
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue