Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions user-agent/user-agent-impl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ abstract class ClientBrandHintDatabase : RoomDatabase() {
abstract fun clientBrandHintDao(): ClientBrandHintDao
}

val ALL_MIGRATIONS = emptyArray<Migration>()
val ALL_MIGRATIONS = emptyList<Migration>()
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ abstract class UserAgentDatabase : RoomDatabase() {
abstract fun userAgentExceptionsDao(): UserAgentExceptionsDao
}

val ALL_MIGRATIONS = emptyArray<Migration>()
val ALL_MIGRATIONS = emptyList<Migration>()
Loading