diff --git a/user-agent/user-agent-impl/build.gradle b/user-agent/user-agent-impl/build.gradle index 10f27111d8b2..cdf4b7fdd4ed 100644 --- a/user-agent/user-agent-impl/build.gradle +++ b/user-agent/user-agent-impl/build.gradle @@ -30,6 +30,7 @@ dependencies { implementation project(':di') implementation project(':common-utils') implementation project(':browser-api') + implementation project(':data-store-api') implementation project(':feature-toggles-api') implementation project(':privacy-config-api') implementation project(':app-build-config-api') diff --git a/user-agent/user-agent-impl/src/main/java/com/duckduckgo/user/agent/impl/di/ClientBrandHintModule.kt b/user-agent/user-agent-impl/src/main/java/com/duckduckgo/user/agent/impl/di/ClientBrandHintModule.kt index e673351983ba..08229b4f788c 100644 --- a/user-agent/user-agent-impl/src/main/java/com/duckduckgo/user/agent/impl/di/ClientBrandHintModule.kt +++ b/user-agent/user-agent-impl/src/main/java/com/duckduckgo/user/agent/impl/di/ClientBrandHintModule.kt @@ -16,8 +16,8 @@ package com.duckduckgo.user.agent.impl.di -import android.content.Context -import androidx.room.Room +import com.duckduckgo.data.store.api.DatabaseProvider +import com.duckduckgo.data.store.api.RoomDatabaseConfig import com.duckduckgo.di.scopes.AppScope import com.duckduckgo.user.agent.impl.store.ALL_MIGRATIONS import com.duckduckgo.user.agent.impl.store.ClientBrandHintDatabase @@ -32,10 +32,14 @@ class ClientBrandHintModule { @Provides @SingleInstanceIn(AppScope::class) - fun provideClientHintDatabase(context: Context): ClientBrandHintDatabase { - return Room.databaseBuilder(context, ClientBrandHintDatabase::class.java, "clientbrandhints.db") - .fallbackToDestructiveMigration() - .addMigrations(*ALL_MIGRATIONS) - .build() + fun provideClientBrandHintDatabase(databaseProvider: DatabaseProvider): ClientBrandHintDatabase { + return databaseProvider.buildRoomDatabase( + ClientBrandHintDatabase::class.java, + "client_brand_hint.db", + config = RoomDatabaseConfig( + fallbackToDestructiveMigration = true, + migrations = ALL_MIGRATIONS, + ), + ) } } diff --git a/user-agent/user-agent-impl/src/main/java/com/duckduckgo/user/agent/impl/di/UserAgentModule.kt b/user-agent/user-agent-impl/src/main/java/com/duckduckgo/user/agent/impl/di/UserAgentModule.kt index 1dc322c35e1c..4b9acb9f11a0 100644 --- a/user-agent/user-agent-impl/src/main/java/com/duckduckgo/user/agent/impl/di/UserAgentModule.kt +++ b/user-agent/user-agent-impl/src/main/java/com/duckduckgo/user/agent/impl/di/UserAgentModule.kt @@ -18,10 +18,11 @@ package com.duckduckgo.user.agent.impl.di import android.content.Context import android.webkit.WebSettings -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.user.agent.impl.RealUserAgentProvider import com.duckduckgo.user.agent.store.ALL_MIGRATIONS @@ -85,10 +86,14 @@ class UserAgentModule { @SingleInstanceIn(AppScope::class) @Provides - fun provideDatabase(context: Context): UserAgentDatabase { - return Room.databaseBuilder(context, UserAgentDatabase::class.java, "user_agent.db") - .fallbackToDestructiveMigration() - .addMigrations(*ALL_MIGRATIONS) - .build() + fun provideUserAgentDatabase(databaseProvider: DatabaseProvider): UserAgentDatabase { + return databaseProvider.buildRoomDatabase( + UserAgentDatabase::class.java, + "user_agent.db", + config = RoomDatabaseConfig( + fallbackToDestructiveMigration = true, + migrations = ALL_MIGRATIONS, + ), + ) } } diff --git a/user-agent/user-agent-impl/src/main/java/com/duckduckgo/user/agent/impl/store/ClientBrandHintDatabase.kt b/user-agent/user-agent-impl/src/main/java/com/duckduckgo/user/agent/impl/store/ClientBrandHintDatabase.kt index 504950fece46..e63cd495ccd6 100644 --- a/user-agent/user-agent-impl/src/main/java/com/duckduckgo/user/agent/impl/store/ClientBrandHintDatabase.kt +++ b/user-agent/user-agent-impl/src/main/java/com/duckduckgo/user/agent/impl/store/ClientBrandHintDatabase.kt @@ -32,4 +32,4 @@ abstract class ClientBrandHintDatabase : RoomDatabase() { abstract fun clientBrandHintDao(): ClientBrandHintDao } -val ALL_MIGRATIONS = emptyArray() +val ALL_MIGRATIONS = emptyList() diff --git a/user-agent/user-agent-store/src/main/java/com/duckduckgo/user/agent/store/UserAgentDatabase.kt b/user-agent/user-agent-store/src/main/java/com/duckduckgo/user/agent/store/UserAgentDatabase.kt index d25b34cd0c26..8f63f202ca86 100644 --- a/user-agent/user-agent-store/src/main/java/com/duckduckgo/user/agent/store/UserAgentDatabase.kt +++ b/user-agent/user-agent-store/src/main/java/com/duckduckgo/user/agent/store/UserAgentDatabase.kt @@ -31,4 +31,4 @@ abstract class UserAgentDatabase : RoomDatabase() { abstract fun userAgentExceptionsDao(): UserAgentExceptionsDao } -val ALL_MIGRATIONS = emptyArray() +val ALL_MIGRATIONS = emptyList()