From e545a89ac322dd216d63b503a716bb4712574806 Mon Sep 17 00:00:00 2001 From: Cris Barreiro Date: Wed, 26 Nov 2025 12:06:02 +0100 Subject: [PATCH] Migrate runtime-checks to DatabaseProvider --- .../runtime-checks-impl/build.gradle | 1 + .../impl/di/RuntimeChecksModule.kt | 22 +++++++++++-------- .../store/RuntimeChecksDatabase.kt | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/runtime-checks/runtime-checks-impl/build.gradle b/runtime-checks/runtime-checks-impl/build.gradle index 235c49a48309..0d3897c1ad38 100644 --- a/runtime-checks/runtime-checks-impl/build.gradle +++ b/runtime-checks/runtime-checks-impl/build.gradle @@ -39,6 +39,7 @@ dependencies { implementation project(path: ':app-build-config-api') implementation project(path: ':runtime-checks-store') implementation project(path: ':content-scope-scripts-api') + implementation project(path: ':data-store-api') implementation AndroidX.core.ktx diff --git a/runtime-checks/runtime-checks-impl/src/main/java/com/duckduckgo/runtimechecks/impl/di/RuntimeChecksModule.kt b/runtime-checks/runtime-checks-impl/src/main/java/com/duckduckgo/runtimechecks/impl/di/RuntimeChecksModule.kt index 37356bab98a3..ca82325add1b 100644 --- a/runtime-checks/runtime-checks-impl/src/main/java/com/duckduckgo/runtimechecks/impl/di/RuntimeChecksModule.kt +++ b/runtime-checks/runtime-checks-impl/src/main/java/com/duckduckgo/runtimechecks/impl/di/RuntimeChecksModule.kt @@ -16,11 +16,11 @@ package com.duckduckgo.runtimechecks.impl.di -import android.content.Context -import androidx.room.Room import com.duckduckgo.app.di.AppCoroutineScope import com.duckduckgo.app.di.IsMainProcess import com.duckduckgo.common.utils.DispatcherProvider +import com.duckduckgo.data.store.api.DatabaseProvider +import com.duckduckgo.data.store.api.RoomDatabaseConfig import com.duckduckgo.di.scopes.AppScope import com.duckduckgo.runtimechecks.store.ALL_MIGRATIONS import com.duckduckgo.runtimechecks.store.RealRuntimeChecksRepository @@ -36,14 +36,18 @@ import kotlinx.coroutines.CoroutineScope @ContributesTo(AppScope::class) object RuntimeChecksModule { - @SingleInstanceIn(AppScope::class) @Provides - fun provideRuntimeChecksDatabase(context: Context): RuntimeChecksDatabase { - return Room.databaseBuilder(context, RuntimeChecksDatabase::class.java, "runtime_checks.db") - .enableMultiInstanceInvalidation() - .fallbackToDestructiveMigration() - .addMigrations(*ALL_MIGRATIONS) - .build() + @SingleInstanceIn(AppScope::class) + fun provideRuntimeChecksDatabase(databaseProvider: DatabaseProvider): RuntimeChecksDatabase { + return databaseProvider.buildRoomDatabase( + RuntimeChecksDatabase::class.java, + "runtime_checks.db", + config = RoomDatabaseConfig( + fallbackToDestructiveMigration = true, + enableMultiInstanceInvalidation = true, + migrations = ALL_MIGRATIONS, + ), + ) } @SingleInstanceIn(AppScope::class) diff --git a/runtime-checks/runtime-checks-store/src/main/java/com/duckduckgo/runtimechecks/store/RuntimeChecksDatabase.kt b/runtime-checks/runtime-checks-store/src/main/java/com/duckduckgo/runtimechecks/store/RuntimeChecksDatabase.kt index 1511f43aae20..8673e342859d 100644 --- a/runtime-checks/runtime-checks-store/src/main/java/com/duckduckgo/runtimechecks/store/RuntimeChecksDatabase.kt +++ b/runtime-checks/runtime-checks-store/src/main/java/com/duckduckgo/runtimechecks/store/RuntimeChecksDatabase.kt @@ -31,4 +31,4 @@ abstract class RuntimeChecksDatabase : RoomDatabase() { abstract fun runtimeChecksDao(): RuntimeChecksDao } -val ALL_MIGRATIONS = emptyArray() +val ALL_MIGRATIONS = emptyList()