From 576efbdc1b99e68384348d0be25c2c289e9e1963 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 14 Nov 2019 00:01:06 -0500 Subject: [PATCH] Move su logs out of magiskdb --- app/build.gradle | 1 + app/src/main/java/com/topjohnwu/magisk/App.kt | 3 ++ .../topjohnwu/magisk/data/database/LogDao.kt | 33 --------------- .../magisk/data/database/SuLogDao.kt | 36 ++++++++++++++++ .../magisk/data/repository/LogRepository.kt | 23 +++++----- .../com/topjohnwu/magisk/di/DatabaseModule.kt | 13 ++++-- .../magisk/model/entity/MagiskLog.kt | 42 +++++-------------- .../magisk/model/entity/recycler/LogRvItem.kt | 10 +---- .../topjohnwu/magisk/ui/log/LogViewModel.kt | 4 +- .../com/topjohnwu/magisk/utils/SuHandler.kt | 6 +-- native/jni/core/db.cpp | 15 ++++--- 11 files changed, 81 insertions(+), 105 deletions(-) delete mode 100644 app/src/main/java/com/topjohnwu/magisk/data/database/LogDao.kt create mode 100644 app/src/main/java/com/topjohnwu/magisk/data/database/SuLogDao.kt diff --git a/app/build.gradle b/app/build.gradle index 62adeb267..6cd88a0d6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -113,6 +113,7 @@ dependencies { } def vRoom = '2.2.1' implementation "com.github.topjohnwu:room-runtime:${vRoom}" + implementation "androidx.room:room-rxjava2:${vRoom}" kapt "androidx.room:room-compiler:${vRoom}" def vNav = '2.1.0' diff --git a/app/src/main/java/com/topjohnwu/magisk/App.kt b/app/src/main/java/com/topjohnwu/magisk/App.kt index c5d4ed0dc..3603a01ea 100644 --- a/app/src/main/java/com/topjohnwu/magisk/App.kt +++ b/app/src/main/java/com/topjohnwu/magisk/App.kt @@ -11,6 +11,8 @@ import androidx.work.impl.WorkDatabase import androidx.work.impl.WorkDatabase_Impl import com.topjohnwu.magisk.data.database.RepoDatabase import com.topjohnwu.magisk.data.database.RepoDatabase_Impl +import com.topjohnwu.magisk.data.database.SuLogDatabase +import com.topjohnwu.magisk.data.database.SuLogDatabase_Impl import com.topjohnwu.magisk.di.ActivityTracker import com.topjohnwu.magisk.di.koinModules import com.topjohnwu.magisk.extensions.get @@ -40,6 +42,7 @@ open class App() : Application() { when (it) { WorkDatabase::class.java -> WorkDatabase_Impl() RepoDatabase::class.java -> RepoDatabase_Impl() + SuLogDatabase::class.java -> SuLogDatabase_Impl() else -> null } } diff --git a/app/src/main/java/com/topjohnwu/magisk/data/database/LogDao.kt b/app/src/main/java/com/topjohnwu/magisk/data/database/LogDao.kt deleted file mode 100644 index ae7e5d6b9..000000000 --- a/app/src/main/java/com/topjohnwu/magisk/data/database/LogDao.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.topjohnwu.magisk.data.database - -import com.topjohnwu.magisk.data.database.magiskdb.* -import com.topjohnwu.magisk.model.entity.MagiskLog -import com.topjohnwu.magisk.model.entity.toLog -import com.topjohnwu.magisk.model.entity.toMap -import java.util.concurrent.TimeUnit - -class LogDao : BaseDao() { - - override val table = Table.LOG - - fun deleteOutdated( - suTimeout: Long = TimeUnit.DAYS.toMillis(14) - ) = query { - condition { - lessThan("time", suTimeout.toString()) - } - }.ignoreElement() - - fun deleteAll() = query().ignoreElement() - - fun fetchAll() = query