mirror of
https://github.com/bitwarden/android.git
synced 2026-03-12 05:04:17 -05:00
Remove unused lastDatabaseSchemeChangeInstant from settings disk source (#4374)
This commit is contained in:
@@ -68,17 +68,6 @@ interface SettingsDiskSource {
|
||||
*/
|
||||
val hasUserLoggedInOrCreatedAccountFlow: Flow<Boolean?>
|
||||
|
||||
/**
|
||||
* The instant when the last database scheme change was applied. `null` if no scheme changes
|
||||
* have been applied yet.
|
||||
*/
|
||||
var lastDatabaseSchemeChangeInstant: Instant?
|
||||
|
||||
/**
|
||||
* Emits updates that track [lastDatabaseSchemeChangeInstant].
|
||||
*/
|
||||
val lastDatabaseSchemeChangeInstantFlow: Flow<Instant?>
|
||||
|
||||
/**
|
||||
* Clears all the settings data for the given user.
|
||||
*/
|
||||
|
||||
@@ -36,7 +36,6 @@ private const val HAS_USER_LOGGED_IN_OR_CREATED_AN_ACCOUNT_KEY = "hasUserLoggedI
|
||||
private const val SHOW_AUTOFILL_SETTING_BADGE = "showAutofillSettingBadge"
|
||||
private const val SHOW_UNLOCK_SETTING_BADGE = "showUnlockSettingBadge"
|
||||
private const val SHOW_IMPORT_LOGINS_SETTING_BADGE = "showImportLoginsSettingBadge"
|
||||
private const val LAST_SCHEME_CHANGE_INSTANT = "lastDatabaseSchemeChangeInstant"
|
||||
private const val IS_VAULT_REGISTERED_FOR_EXPORT = "isVaultRegisteredForExport"
|
||||
|
||||
/**
|
||||
@@ -76,8 +75,6 @@ class SettingsDiskSourceImpl(
|
||||
|
||||
private val mutableHasUserLoggedInOrCreatedAccountFlow = bufferedMutableSharedFlow<Boolean?>()
|
||||
|
||||
private val mutableLastDatabaseSchemeChangeInstantFlow = bufferedMutableSharedFlow<Instant?>()
|
||||
|
||||
private val mutableScreenCaptureAllowedFlowMap =
|
||||
mutableMapOf<String, MutableSharedFlow<Boolean?>>()
|
||||
|
||||
@@ -162,17 +159,6 @@ class SettingsDiskSourceImpl(
|
||||
get() = mutableHasUserLoggedInOrCreatedAccountFlow
|
||||
.onSubscription { emit(getBoolean(HAS_USER_LOGGED_IN_OR_CREATED_AN_ACCOUNT_KEY)) }
|
||||
|
||||
override var lastDatabaseSchemeChangeInstant: Instant?
|
||||
get() = getLong(LAST_SCHEME_CHANGE_INSTANT)?.let { Instant.ofEpochMilli(it) }
|
||||
set(value) {
|
||||
putLong(LAST_SCHEME_CHANGE_INSTANT, value?.toEpochMilli())
|
||||
mutableLastDatabaseSchemeChangeInstantFlow.tryEmit(value)
|
||||
}
|
||||
|
||||
override val lastDatabaseSchemeChangeInstantFlow: Flow<Instant?>
|
||||
get() = mutableLastDatabaseSchemeChangeInstantFlow
|
||||
.onSubscription { emit(lastDatabaseSchemeChangeInstant) }
|
||||
|
||||
override fun clearData(userId: String) {
|
||||
storeVaultTimeoutInMinutes(userId = userId, vaultTimeoutInMinutes = null)
|
||||
storeVaultTimeoutAction(userId = userId, vaultTimeoutAction = null)
|
||||
|
||||
@@ -1117,55 +1117,6 @@ class SettingsDiskSourceTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `lastDatabaseSchemeChangeInstant should pull from SharedPreferences`() {
|
||||
val schemeChangeKey = "bwPreferencesStorage:lastDatabaseSchemeChangeInstant"
|
||||
val expected: Long = Instant.now().toEpochMilli()
|
||||
|
||||
fakeSharedPreferences
|
||||
.edit {
|
||||
remove(schemeChangeKey)
|
||||
}
|
||||
assertEquals(0, fakeSharedPreferences.getLong(schemeChangeKey, 0))
|
||||
assertNull(settingsDiskSource.lastDatabaseSchemeChangeInstant)
|
||||
|
||||
// Updating the shared preferences should update disk source.
|
||||
fakeSharedPreferences
|
||||
.edit {
|
||||
putLong(
|
||||
schemeChangeKey,
|
||||
expected,
|
||||
)
|
||||
}
|
||||
val actual = settingsDiskSource.lastDatabaseSchemeChangeInstant
|
||||
assertEquals(
|
||||
expected,
|
||||
actual?.toEpochMilli(),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `setting lastDatabaseSchemeChangeInstant should update SharedPreferences`() {
|
||||
val schemeChangeKey = "bwPreferencesStorage:lastDatabaseSchemeChangeInstant"
|
||||
val schemeChangeInstant = Instant.now()
|
||||
|
||||
// Setting to null should update disk source
|
||||
settingsDiskSource.lastDatabaseSchemeChangeInstant = null
|
||||
assertEquals(0, fakeSharedPreferences.getLong(schemeChangeKey, 0))
|
||||
assertNull(settingsDiskSource.lastDatabaseSchemeChangeInstant)
|
||||
|
||||
// Setting to value should update disk source
|
||||
settingsDiskSource.lastDatabaseSchemeChangeInstant = schemeChangeInstant
|
||||
val actual = fakeSharedPreferences.getLong(
|
||||
schemeChangeKey,
|
||||
0,
|
||||
)
|
||||
assertEquals(
|
||||
schemeChangeInstant.toEpochMilli(),
|
||||
actual,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getShowImportLoginsSettingBadge should pull from shared preferences`() {
|
||||
val mockUserId = "mockUserId"
|
||||
|
||||
@@ -42,9 +42,6 @@ class FakeSettingsDiskSource : SettingsDiskSource {
|
||||
private val mutableScreenCaptureAllowedFlowMap =
|
||||
mutableMapOf<String, MutableSharedFlow<Boolean?>>()
|
||||
|
||||
private val mutableLastDatabaseSchemeChangeInstant =
|
||||
bufferedMutableSharedFlow<Instant?>()
|
||||
|
||||
private var storedAppTheme: AppTheme = AppTheme.DEFAULT
|
||||
private val storedLastSyncTime = mutableMapOf<String, Instant?>()
|
||||
private val storedVaultTimeoutActions = mutableMapOf<String, VaultTimeoutAction?>()
|
||||
@@ -67,7 +64,6 @@ class FakeSettingsDiskSource : SettingsDiskSource {
|
||||
private val userShowAutoFillBadge = mutableMapOf<String, Boolean?>()
|
||||
private val userShowUnlockBadge = mutableMapOf<String, Boolean?>()
|
||||
private val userShowImportLoginsBadge = mutableMapOf<String, Boolean?>()
|
||||
private var storedLastDatabaseSchemeChangeInstant: Instant? = null
|
||||
private val vaultRegisteredForExport = mutableMapOf<String, Boolean?>()
|
||||
|
||||
private val mutableShowAutoFillSettingBadgeFlowMap =
|
||||
@@ -144,17 +140,6 @@ class FakeSettingsDiskSource : SettingsDiskSource {
|
||||
emit(hasUserLoggedInOrCreatedAccount)
|
||||
}
|
||||
|
||||
override var lastDatabaseSchemeChangeInstant: Instant?
|
||||
get() = storedLastDatabaseSchemeChangeInstant
|
||||
set(value) {
|
||||
storedLastDatabaseSchemeChangeInstant = value
|
||||
}
|
||||
|
||||
override val lastDatabaseSchemeChangeInstantFlow: Flow<Instant?>
|
||||
get() = mutableLastDatabaseSchemeChangeInstant.onSubscription {
|
||||
emit(lastDatabaseSchemeChangeInstant)
|
||||
}
|
||||
|
||||
override fun getAccountBiometricIntegrityValidity(
|
||||
userId: String,
|
||||
systemBioIntegrityState: String,
|
||||
|
||||
Reference in New Issue
Block a user