Move SecretsSynchronisationInfo to its file
And do some other cleanup
This commit is contained in:
parent
aa1843774a
commit
de5f182f29
|
@ -17,6 +17,7 @@
|
|||
package im.vector.matrix.rx
|
||||
|
||||
import androidx.paging.PagedList
|
||||
import im.vector.matrix.android.api.extensions.orFalse
|
||||
import im.vector.matrix.android.api.query.QueryStringValue
|
||||
import im.vector.matrix.android.api.session.Session
|
||||
import im.vector.matrix.android.api.session.crypto.crosssigning.KEYBACKUP_SECRET_SSSS_NAME
|
||||
|
@ -172,16 +173,6 @@ class RxSession(private val session: Session) {
|
|||
}
|
||||
}
|
||||
|
||||
data class SecretsSynchronisationInfo(
|
||||
val isBackupSetup: Boolean = false,
|
||||
val isCrossSigningEnabled: Boolean = false,
|
||||
val isCrossSigningTrusted: Boolean = false,
|
||||
val allPrivateKeysKnown: Boolean = false,
|
||||
val megolmBackupAvailable: Boolean = false,
|
||||
val megolmSecretKnown: Boolean = false,
|
||||
val isMegolmKeyIn4S: Boolean = false
|
||||
)
|
||||
|
||||
fun liveSecretSynchronisationInfo(): Observable<SecretsSynchronisationInfo> {
|
||||
return Observable.combineLatest<List<UserAccountData>, Optional<MXCrossSigningInfo>, Optional<PrivateKeysInfo>, SecretsSynchronisationInfo>(
|
||||
liveAccountData(setOf(MASTER_KEY_SSSS_NAME, USER_SIGNING_KEY_SSSS_NAME, SELF_SIGNING_KEY_SSSS_NAME, KEYBACKUP_SECRET_SSSS_NAME)),
|
||||
|
@ -192,9 +183,9 @@ class RxSession(private val session: Session) {
|
|||
val is4SSetup = session.sharedSecretStorageService.isRecoverySetup()
|
||||
val isCrossSigningEnabled = crossSigningInfo.getOrNull() != null
|
||||
val isCrossSigningTrusted = crossSigningInfo.getOrNull()?.isTrusted() == true
|
||||
val allPrivateKeysKnown = pInfo.getOrNull()?.master != null
|
||||
&& pInfo.getOrNull()?.selfSigned != null
|
||||
&& pInfo.getOrNull()?.user != null
|
||||
val allPrivateKeysKnown = pInfo.getOrNull()
|
||||
?.let { it.master != null && it.selfSigned != null && it.user != null }
|
||||
.orFalse()
|
||||
|
||||
val keysBackupService = session.cryptoService().keysBackupService()
|
||||
val currentBackupVersion = keysBackupService.currentBackupVersion
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2020 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.matrix.rx
|
||||
|
||||
data class SecretsSynchronisationInfo(
|
||||
val isBackupSetup: Boolean,
|
||||
val isCrossSigningEnabled: Boolean,
|
||||
val isCrossSigningTrusted: Boolean,
|
||||
val allPrivateKeysKnown: Boolean,
|
||||
val megolmBackupAvailable: Boolean,
|
||||
val megolmSecretKnown: Boolean,
|
||||
val isMegolmKeyIn4S: Boolean
|
||||
)
|
|
@ -33,7 +33,7 @@ import im.vector.matrix.android.internal.crypto.crosssigning.isVerified
|
|||
import im.vector.matrix.android.internal.crypto.model.ImportRoomKeysResult
|
||||
import im.vector.matrix.android.internal.crypto.model.rest.DeviceInfo
|
||||
import im.vector.matrix.android.internal.crypto.model.rest.DevicesListResponse
|
||||
import im.vector.matrix.rx.RxSession
|
||||
import im.vector.matrix.rx.SecretsSynchronisationInfo
|
||||
import im.vector.matrix.rx.rx
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.di.ActiveSessionHolder
|
||||
|
@ -128,7 +128,7 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
|
|||
disposables.clear()
|
||||
}
|
||||
|
||||
private fun refresh4SSection(state: RxSession.SecretsSynchronisationInfo) {
|
||||
private fun refresh4SSection(state: SecretsSynchronisationInfo) {
|
||||
secureBackupCategory?.isVisible = false
|
||||
|
||||
// it's a lot of if / else if / else
|
||||
|
|
Loading…
Reference in New Issue