Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.x8bit.bitwarden.data.platform.repository

import android.view.autofill.AutofillManager
import com.bitwarden.authenticatorbridge.util.generateSecretKey
import com.bitwarden.core.data.manager.BuildInfoManager
import com.bitwarden.core.data.manager.dispatcher.DispatcherManager
import com.bitwarden.data.manager.flightrecorder.FlightRecorderManager
import com.bitwarden.policies.PolicyType
Expand Down Expand Up @@ -51,6 +52,7 @@ class SettingsRepositoryImpl(
private val autofillManager: AutofillManager,
private val autofillEnabledManager: AutofillEnabledManager,
private val authDiskSource: AuthDiskSource,
private val buildInfoManager: BuildInfoManager,
private val settingsDiskSource: SettingsDiskSource,
private val vaultSdkSource: VaultSdkSource,
flightRecorderManager: FlightRecorderManager,
Expand Down Expand Up @@ -375,11 +377,12 @@ class SettingsRepositoryImpl(
override val hasShownAccessibilityDisclaimerFlow: StateFlow<Boolean>
get() = settingsDiskSource
.hasShownAccessibilityDisclaimerFlow
.map { it ?: false }
.map { buildInfoManager.isFdroid || it ?: false }
.stateIn(
scope = unconfinedScope,
started = SharingStarted.Lazily,
initialValue = settingsDiskSource.hasShownAccessibilityDisclaimer ?: false,
initialValue = buildInfoManager.isFdroid ||
settingsDiskSource.hasShownAccessibilityDisclaimer ?: false,
)

init {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.x8bit.bitwarden.data.platform.repository.di

import android.view.autofill.AutofillManager
import com.bitwarden.core.data.manager.BuildInfoManager
import com.bitwarden.core.data.manager.dispatcher.DispatcherManager
import com.bitwarden.data.manager.flightrecorder.FlightRecorderManager
import com.bitwarden.data.repository.ServerConfigRepository
Expand Down Expand Up @@ -67,6 +68,7 @@ object PlatformRepositoryModule {
autofillManager: AutofillManager,
autofillEnabledManager: AutofillEnabledManager,
authDiskSource: AuthDiskSource,
buildInfoManager: BuildInfoManager,
settingsDiskSource: SettingsDiskSource,
vaultSdkSource: VaultSdkSource,
accessibilityEnabledManager: AccessibilityEnabledManager,
Expand All @@ -78,6 +80,7 @@ object PlatformRepositoryModule {
autofillManager = autofillManager,
autofillEnabledManager = autofillEnabledManager,
authDiskSource = authDiskSource,
buildInfoManager = buildInfoManager,
settingsDiskSource = settingsDiskSource,
vaultSdkSource = vaultSdkSource,
accessibilityEnabledManager = accessibilityEnabledManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.view.autofill.AutofillManager
import app.cash.turbine.test
import com.bitwarden.authenticatorbridge.util.generateSecretKey
import com.bitwarden.core.EnrollPinResponse
import com.bitwarden.core.data.manager.BuildInfoManager
import com.bitwarden.core.data.manager.dispatcher.FakeDispatcherManager
import com.bitwarden.core.data.repository.util.bufferedMutableSharedFlow
import com.bitwarden.core.data.util.asFailure
Expand Down Expand Up @@ -75,6 +76,9 @@ class SettingsRepositoryTest {
} returns mutableActivePolicyFlow
}
private val flightRecorderManager = mockk<FlightRecorderManager>()
private val buildInfoManager: BuildInfoManager = mockk {
every { isFdroid } returns false
}

private val settingsRepository = SettingsRepositoryImpl(
autofillManager = autofillManager,
Expand All @@ -86,6 +90,7 @@ class SettingsRepositoryTest {
dispatcherManager = FakeDispatcherManager(),
policyManager = policyManager,
flightRecorderManager = flightRecorderManager,
buildInfoManager = buildInfoManager,
)

@BeforeEach
Expand Down Expand Up @@ -1119,8 +1124,9 @@ class SettingsRepositoryTest {
}
}

@Suppress("MaxLineLength")
@Test
fun `hasShownAccessibilityDisclaimerFlow should emit changes from SettingsDiskSource`() =
fun `hasShownAccessibilityDisclaimerFlow should emit changes from SettingsDiskSource when fdroid is false`() =
runTest {
fakeSettingsDiskSource.hasShownAccessibilityDisclaimer = null
settingsRepository.hasShownAccessibilityDisclaimerFlow.test {
Expand All @@ -1134,6 +1140,23 @@ class SettingsRepositoryTest {
}
}

@Suppress("MaxLineLength")
@Test
fun `hasShownAccessibilityDisclaimerFlow should emit changes from SettingsDiskSource when fdroid is true`() =
runTest {
every { buildInfoManager.isFdroid } returns true
fakeSettingsDiskSource.hasShownAccessibilityDisclaimer = null
settingsRepository.hasShownAccessibilityDisclaimerFlow.test {
assertTrue(awaitItem())

fakeSettingsDiskSource.hasShownAccessibilityDisclaimer = true
expectNoEvents()

fakeSettingsDiskSource.hasShownAccessibilityDisclaimer = false
expectNoEvents()
}
}

@Test
fun `accessibilityDisclaimerHasBeenShown should update SettingsDiskSource`() {
assertNull(fakeSettingsDiskSource.hasShownAccessibilityDisclaimer)
Expand Down
Loading