You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
More refactoring
Cleanups, move classes to sane locations, etc.
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
package com.topjohnwu.magisk.data.database
|
||||
|
||||
import androidx.room.*
|
||||
import com.topjohnwu.magisk.model.entity.MagiskLog
|
||||
import com.topjohnwu.magisk.core.model.su.SuLog
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.util.*
|
||||
|
||||
@Database(version = 1, entities = [MagiskLog::class], exportSchema = false)
|
||||
@Database(version = 1, entities = [SuLog::class], exportSchema = false)
|
||||
abstract class SuLogDatabase : RoomDatabase() {
|
||||
|
||||
abstract fun suLogDao(): SuLogDao
|
||||
@@ -20,18 +20,18 @@ abstract class SuLogDao(private val db: SuLogDatabase) {
|
||||
|
||||
suspend fun deleteAll() = withContext(Dispatchers.IO) { db.clearAllTables() }
|
||||
|
||||
suspend fun fetchAll(): MutableList<MagiskLog> {
|
||||
suspend fun fetchAll(): MutableList<SuLog> {
|
||||
deleteOutdated()
|
||||
return fetch()
|
||||
}
|
||||
|
||||
@Query("SELECT * FROM logs ORDER BY time DESC")
|
||||
protected abstract suspend fun fetch(): MutableList<MagiskLog>
|
||||
protected abstract suspend fun fetch(): MutableList<SuLog>
|
||||
|
||||
@Query("DELETE FROM logs WHERE time < :timeout")
|
||||
protected abstract suspend fun deleteOutdated(timeout: Long = twoWeeksAgo)
|
||||
|
||||
@Insert
|
||||
abstract suspend fun insert(log: MagiskLog)
|
||||
abstract suspend fun insert(log: SuLog)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user