mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Implement io-free state update and fallback mechanism for backups state.
This commit is contained in:
@@ -9,6 +9,7 @@ import org.thoughtcrime.securesms.backup.RestoreState
|
||||
import org.thoughtcrime.securesms.backup.v2.BackupFrequency
|
||||
import org.thoughtcrime.securesms.backup.v2.BackupRepository
|
||||
import org.thoughtcrime.securesms.backup.v2.MessageBackupTier
|
||||
import org.thoughtcrime.securesms.components.settings.app.backups.BackupStateObserver
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.BackupMessagesConstraintObserver
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.DeletionNotAwaitingMediaDownloadConstraint
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NoRemoteArchiveGarbageCollectionPendingConstraint
|
||||
@@ -212,12 +213,6 @@ class BackupValues(store: KeyValueStore) : SignalStoreValues(store) {
|
||||
return MessageBackupTier.deserialize(getLong(KEY_LATEST_BACKUP_TIER, -1))
|
||||
}
|
||||
|
||||
/**
|
||||
* Denotes if there was a mismatch detected between the user's Signal subscription, on-device Google Play subscription,
|
||||
* and what zk authorization we think we have.
|
||||
*/
|
||||
var subscriptionStateMismatchDetected: Boolean by booleanValue(KEY_SUBSCRIPTION_STATE_MISMATCH, false).withPrecondition { backupTierInternalOverride == null }
|
||||
|
||||
/**
|
||||
* When setting the backup tier, we also want to write to the latestBackupTier, as long as
|
||||
* the value is non-null. This gives us a 1-deep history of the selected backup tier for
|
||||
@@ -247,11 +242,21 @@ class BackupValues(store: KeyValueStore) : SignalStoreValues(store) {
|
||||
} else {
|
||||
putLong(KEY_BACKUP_TIER, serializedValue)
|
||||
}
|
||||
|
||||
BackupStateObserver.notifyBackupTierChanged()
|
||||
}
|
||||
|
||||
/** An internal setting that can override the backup tier for a user. */
|
||||
var backupTierInternalOverride: MessageBackupTier? by enumValue(KEY_BACKUP_TIER_INTERNAL_OVERRIDE, null, MessageBackupTier.Serializer).withPrecondition { RemoteConfig.internalUser }
|
||||
|
||||
/**
|
||||
* Denotes if there was a mismatch detected between the user's Signal subscription, on-device Google Play subscription,
|
||||
* and what zk authorization we think we have.
|
||||
*/
|
||||
val subscriptionStateMismatchDetectedValue = booleanValue(KEY_SUBSCRIPTION_STATE_MISMATCH, false).withPrecondition { backupTierInternalOverride == null }
|
||||
var subscriptionStateMismatchDetected: Boolean by subscriptionStateMismatchDetectedValue
|
||||
val subscriptionStateMismatchDetectedFlow: Flow<Boolean> by lazy { subscriptionStateMismatchDetectedValue.toFlow() }
|
||||
|
||||
/** Set to true if we successfully restored a backup file timestamp or didn't find a file at all so a "no timestamp" value is restored. */
|
||||
var isBackupTimestampRestored: Boolean by booleanValue(KEY_BACKUP_TIMESTAMP_RESTORED, false)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user