Skip to content

Commit 7a3cc5a

Browse files
committed
remove AutofillFeatureExceptionStore
1 parent c67a894 commit 7a3cc5a

File tree

11 files changed

+137
-199
lines changed

11 files changed

+137
-199
lines changed

autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/RealAutofill.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package com.duckduckgo.autofill.impl
1818

1919
import com.duckduckgo.app.browser.UriString.Companion.sameOrSubdomain
2020
import com.duckduckgo.autofill.api.Autofill
21-
import com.duckduckgo.autofill.store.feature.AutofillFeatureRepository
21+
import com.duckduckgo.autofill.impl.feature.plugin.AutofillFeatureRepository
2222
import com.duckduckgo.di.scopes.AppScope
2323
import com.duckduckgo.privacy.config.api.UnprotectedTemporary
2424
import com.squareup.anvil.annotations.ContributesBinding

autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/di/AutofillModule.kt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ package com.duckduckgo.autofill.impl.di
1919
import android.content.Context
2020
import androidx.room.Room
2121
import com.duckduckgo.anvil.annotations.ContributesPluginPoint
22-
import com.duckduckgo.app.di.AppCoroutineScope
23-
import com.duckduckgo.app.di.IsMainProcess
2422
import com.duckduckgo.autofill.api.AutofillFeature
2523
import com.duckduckgo.autofill.api.AutofillFragmentResultsPlugin
2624
import com.duckduckgo.autofill.api.InternalTestUserChecker
@@ -39,20 +37,16 @@ import com.duckduckgo.autofill.store.RealInternalTestUserStore
3937
import com.duckduckgo.autofill.store.RealLastUpdatedTimeProvider
4038
import com.duckduckgo.autofill.store.engagement.AutofillEngagementDatabase
4139
import com.duckduckgo.autofill.store.feature.AutofillDefaultStateDecider
42-
import com.duckduckgo.autofill.store.feature.AutofillFeatureRepository
4340
import com.duckduckgo.autofill.store.feature.RealAutofillDefaultStateDecider
44-
import com.duckduckgo.autofill.store.feature.RealAutofillFeatureRepository
4541
import com.duckduckgo.autofill.store.targets.DomainTargetAppDao
4642
import com.duckduckgo.autofill.store.targets.DomainTargetAppsDatabase
4743
import com.duckduckgo.browser.api.UserBrowserProperties
48-
import com.duckduckgo.common.utils.DispatcherProvider
4944
import com.duckduckgo.di.scopes.ActivityScope
5045
import com.duckduckgo.di.scopes.AppScope
5146
import com.squareup.anvil.annotations.ContributesTo
5247
import dagger.Module
5348
import dagger.Provides
5449
import dagger.SingleInstanceIn
55-
import kotlinx.coroutines.CoroutineScope
5650

5751
@Module
5852
@ContributesTo(AppScope::class)
@@ -99,17 +93,6 @@ class AutofillModule {
9993
.build()
10094
}
10195

102-
@SingleInstanceIn(AppScope::class)
103-
@Provides
104-
fun provideAutofillRepository(
105-
database: AutofillDatabase,
106-
@AppCoroutineScope appCoroutineScope: CoroutineScope,
107-
dispatcherProvider: DispatcherProvider,
108-
@IsMainProcess isMainProcess: Boolean,
109-
): AutofillFeatureRepository {
110-
return RealAutofillFeatureRepository(database, appCoroutineScope, dispatcherProvider, isMainProcess)
111-
}
112-
11396
@Provides
11497
@SingleInstanceIn(AppScope::class)
11598
fun providesCredentialsSyncDao(

autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/feature/plugin/AutofillFeatureExceptionStore.kt

Lines changed: 0 additions & 38 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (c) 2025 DuckDuckGo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.duckduckgo.autofill.impl.feature.plugin
18+
19+
import com.duckduckgo.app.di.AppCoroutineScope
20+
import com.duckduckgo.app.di.IsMainProcess
21+
import com.duckduckgo.autofill.api.AutofillFeature
22+
import com.duckduckgo.common.utils.DispatcherProvider
23+
import com.duckduckgo.di.scopes.AppScope
24+
import com.duckduckgo.feature.toggles.api.FeatureExceptions.FeatureException
25+
import com.duckduckgo.privacy.config.api.PrivacyConfigCallbackPlugin
26+
import com.squareup.anvil.annotations.ContributesBinding
27+
import com.squareup.anvil.annotations.ContributesMultibinding
28+
import dagger.SingleInstanceIn
29+
import java.util.concurrent.CopyOnWriteArrayList
30+
import javax.inject.Inject
31+
import kotlinx.coroutines.CoroutineScope
32+
import kotlinx.coroutines.launch
33+
34+
interface AutofillFeatureRepository {
35+
val exceptions: CopyOnWriteArrayList<FeatureException>
36+
}
37+
38+
@ContributesMultibinding(
39+
scope = AppScope::class,
40+
boundType = PrivacyConfigCallbackPlugin::class,
41+
)
42+
@ContributesBinding(
43+
scope = AppScope::class,
44+
boundType = AutofillFeatureRepository::class,
45+
)
46+
@SingleInstanceIn(AppScope::class)
47+
class RealAutofillFeatureRepository @Inject constructor(
48+
private val feature: AutofillFeature,
49+
@AppCoroutineScope private val coroutineScope: CoroutineScope,
50+
private val dispatcherProvider: DispatcherProvider,
51+
@IsMainProcess private val isMainProcess: Boolean,
52+
) : AutofillFeatureRepository, PrivacyConfigCallbackPlugin {
53+
54+
override val exceptions = CopyOnWriteArrayList<FeatureException>()
55+
56+
init {
57+
loadToMemory()
58+
}
59+
60+
override fun onPrivacyConfigDownloaded() {
61+
loadToMemory()
62+
}
63+
64+
private fun loadToMemory() {
65+
coroutineScope.launch(dispatcherProvider.io()) {
66+
if (isMainProcess) {
67+
exceptions.clear()
68+
exceptions.addAll(feature.self().getExceptions())
69+
}
70+
}
71+
}
72+
}

autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/feature/plugin/UnusedAutofillRemoteFeatureCodegenTrigger.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import com.duckduckgo.di.scopes.AppScope
2424
scope = AppScope::class,
2525
boundType = AutofillFeature::class,
2626
featureName = "autofill",
27-
exceptionsStore = AutofillFeatureExceptionStore::class,
2827
)
2928
@Suppress("unused")
3029
private interface UnusedAutofillRemoteFeatureCodegenTrigger

autofill/autofill-impl/src/test/java/com/duckduckgo/autofill/impl/RealAutofillTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.duckduckgo.autofill.impl
1818

1919
import androidx.test.ext.junit.runners.AndroidJUnit4
20-
import com.duckduckgo.autofill.store.feature.AutofillFeatureRepository
20+
import com.duckduckgo.autofill.impl.feature.plugin.AutofillFeatureRepository
2121
import com.duckduckgo.feature.toggles.api.FeatureExceptions.FeatureException
2222
import com.duckduckgo.privacy.config.api.UnprotectedTemporary
2323
import java.util.concurrent.CopyOnWriteArrayList
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.duckduckgo.autofill.impl.feature.plugin
2+
3+
import com.duckduckgo.autofill.api.AutofillFeature
4+
import com.duckduckgo.common.test.CoroutineTestRule
5+
import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory
6+
import com.duckduckgo.feature.toggles.api.FeatureExceptions.FeatureException
7+
import com.duckduckgo.feature.toggles.api.Toggle
8+
import kotlinx.coroutines.test.runTest
9+
import org.junit.Assert.assertEquals
10+
import org.junit.Before
11+
import org.junit.Rule
12+
import org.junit.Test
13+
14+
class RealAutofillFeatureRepositoryTest {
15+
@get:Rule
16+
var coroutineRule = CoroutineTestRule()
17+
18+
private val feature = FakeFeatureToggleFactory.create(AutofillFeature::class.java)
19+
20+
@Before
21+
fun setup() {
22+
feature.self().setRawStoredState(Toggle.State(exceptions = exceptions))
23+
}
24+
25+
@Test
26+
fun whenRepositoryIsCreatedThenExceptionsLoadIntoMemory() = runTest {
27+
val repository = RealAutofillFeatureRepository(
28+
feature,
29+
coroutineRule.testScope,
30+
coroutineRule.testDispatcherProvider,
31+
true,
32+
)
33+
34+
assertEquals(exceptions, repository.exceptions)
35+
}
36+
37+
@Test
38+
fun whenRemoteConfigUpdateThenExceptionsUpdated() = runTest {
39+
val repository = RealAutofillFeatureRepository(
40+
feature,
41+
coroutineRule.testScope,
42+
coroutineRule.testDispatcherProvider,
43+
true,
44+
)
45+
46+
assertEquals(exceptions, repository.exceptions)
47+
feature.self().setRawStoredState(Toggle.State(exceptions = emptyList()))
48+
repository.onPrivacyConfigDownloaded()
49+
assertEquals(emptyList<FeatureException>(), repository.exceptions)
50+
}
51+
52+
companion object {
53+
val exceptions = listOf(FeatureException("example.com", "reason"))
54+
}
55+
}

autofill/autofill-store/src/main/java/com/duckduckgo/autofill/store/AutofillDao.kt

Lines changed: 0 additions & 45 deletions
This file was deleted.

autofill/autofill-store/src/main/java/com/duckduckgo/autofill/store/AutofillDatabase.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@ import androidx.sqlite.db.SupportSQLiteDatabase
2323

2424
@Database(
2525
exportSchema = true,
26-
version = 2,
26+
version = 3,
2727
entities = [
28-
AutofillExceptionEntity::class,
2928
CredentialsSyncMetadataEntity::class,
3029
],
3130
)
3231
abstract class AutofillDatabase : RoomDatabase() {
33-
abstract fun autofillDao(): AutofillDao
3432
abstract fun credentialsSyncDao(): CredentialsSyncMetadataDao
3533
}
3634

@@ -46,4 +44,10 @@ val MIGRATION_1_2 = object : Migration(1, 2) {
4644
}
4745
}
4846

49-
val ALL_MIGRATIONS = arrayOf(MIGRATION_1_2)
47+
val MIGRATION_2_3 = object : Migration(2, 3) {
48+
override fun migrate(database: SupportSQLiteDatabase) {
49+
database.execSQL("DROP TABLE `autofill_exceptions`")
50+
}
51+
}
52+
53+
val ALL_MIGRATIONS = arrayOf(MIGRATION_1_2, MIGRATION_2_3)

autofill/autofill-store/src/main/java/com/duckduckgo/autofill/store/AutofillDatabaseModels.kt

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)