mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Rotate MRBK when rotating AEP.
This commit is contained in:
@@ -15,6 +15,7 @@ import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.signal.core.util.concurrent.SignalDispatchers
|
||||
import org.thoughtcrime.securesms.backup.v2.BackupRepository
|
||||
import org.thoughtcrime.securesms.backup.v2.StagedBackupKeyRotations
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobs.RestoreOptimizedMediaJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
@@ -32,13 +33,14 @@ class BackupKeyDisplayViewModel : ViewModel(), BackupKeyCredentialManagerHandler
|
||||
viewModelScope.launch {
|
||||
_uiState.update { it.copy(rotationState = BackupKeyRotationState.GENERATING_KEY) }
|
||||
|
||||
val stagedAEP = withContext(SignalDispatchers.IO) {
|
||||
BackupRepository.stageAEPKeyRotation()
|
||||
val stagedKeyRotations = withContext(SignalDispatchers.IO) {
|
||||
BackupRepository.stageBackupKeyRotations()
|
||||
}
|
||||
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
accountEntropyPool = stagedAEP,
|
||||
accountEntropyPool = stagedKeyRotations.aep,
|
||||
stagedKeyRotations = stagedKeyRotations,
|
||||
rotationState = BackupKeyRotationState.USER_VERIFICATION
|
||||
)
|
||||
}
|
||||
@@ -49,8 +51,10 @@ class BackupKeyDisplayViewModel : ViewModel(), BackupKeyCredentialManagerHandler
|
||||
viewModelScope.launch {
|
||||
_uiState.update { it.copy(rotationState = BackupKeyRotationState.COMMITTING_KEY) }
|
||||
|
||||
val keyRotations = _uiState.value.stagedKeyRotations ?: error("No key rotations to commit!")
|
||||
|
||||
withContext(SignalDispatchers.IO) {
|
||||
BackupRepository.commitAEPKeyRotation(_uiState.value.accountEntropyPool)
|
||||
BackupRepository.commitAEPKeyRotation(keyRotations)
|
||||
}
|
||||
|
||||
_uiState.update { it.copy(rotationState = BackupKeyRotationState.FINISHED) }
|
||||
@@ -68,7 +72,8 @@ data class BackupKeyDisplayUiState(
|
||||
val accountEntropyPool: AccountEntropyPool = SignalStore.account.accountEntropyPool,
|
||||
val keySaveState: BackupKeySaveState? = null,
|
||||
val isOptimizedStorageEnabled: Boolean = SignalStore.backup.optimizeStorage,
|
||||
val rotationState: BackupKeyRotationState = BackupKeyRotationState.NOT_STARTED
|
||||
val rotationState: BackupKeyRotationState = BackupKeyRotationState.NOT_STARTED,
|
||||
val stagedKeyRotations: StagedBackupKeyRotations? = null
|
||||
)
|
||||
|
||||
enum class BackupKeyRotationState {
|
||||
|
||||
Reference in New Issue
Block a user