code quality
This commit is contained in:
parent
b3d8b1527c
commit
6e371b7d2d
@ -24,7 +24,7 @@ import org.matrix.android.sdk.api.util.Optional
|
|||||||
|
|
||||||
interface CrossSigningService {
|
interface CrossSigningService {
|
||||||
/**
|
/**
|
||||||
* Is our own device signed by our own cross signing identity
|
* Is our own device signed by our own cross signing identity.
|
||||||
*/
|
*/
|
||||||
suspend fun isCrossSigningVerified(): Boolean
|
suspend fun isCrossSigningVerified(): Boolean
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ interface CrossSigningService {
|
|||||||
sskPrivateKey: String?): UserTrustResult
|
sskPrivateKey: String?): UserTrustResult
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the public cross signing keys for the given user
|
* Get the public cross signing keys for the given user.
|
||||||
*
|
*
|
||||||
* @param otherUserId The ID of the user for which we would like to fetch the cross signing keys.
|
* @param otherUserId The ID of the user for which we would like to fetch the cross signing keys.
|
||||||
*/
|
*/
|
||||||
@ -70,10 +70,10 @@ interface CrossSigningService {
|
|||||||
|
|
||||||
fun getLiveCrossSigningKeys(userId: String): LiveData<Optional<MXCrossSigningInfo>>
|
fun getLiveCrossSigningKeys(userId: String): LiveData<Optional<MXCrossSigningInfo>>
|
||||||
|
|
||||||
/** Get our own public cross signing keys */
|
/** Get our own public cross signing keys. */
|
||||||
suspend fun getMyCrossSigningKeys(): MXCrossSigningInfo?
|
suspend fun getMyCrossSigningKeys(): MXCrossSigningInfo?
|
||||||
|
|
||||||
/** Get our own private cross signing keys */
|
/** Get our own private cross signing keys. */
|
||||||
suspend fun getCrossSigningPrivateKeys(): PrivateKeysInfo?
|
suspend fun getCrossSigningPrivateKeys(): PrivateKeysInfo?
|
||||||
|
|
||||||
fun getLiveCrossSigningPrivateKeys(): LiveData<Optional<PrivateKeysInfo>>
|
fun getLiveCrossSigningPrivateKeys(): LiveData<Optional<PrivateKeysInfo>>
|
||||||
@ -88,10 +88,10 @@ interface CrossSigningService {
|
|||||||
/** Do we have all our private cross signing keys in storage? */
|
/** Do we have all our private cross signing keys in storage? */
|
||||||
fun allPrivateKeysKnown(): Boolean
|
fun allPrivateKeysKnown(): Boolean
|
||||||
|
|
||||||
/** Mark a user identity as trusted and sign and upload signatures of our user-signing key to the server */
|
/** Mark a user identity as trusted and sign and upload signatures of our user-signing key to the server. */
|
||||||
suspend fun trustUser(otherUserId: String)
|
suspend fun trustUser(otherUserId: String)
|
||||||
|
|
||||||
/** Mark our own master key as trusted */
|
/** Mark our own master key as trusted. */
|
||||||
suspend fun markMyMasterKeyAsTrusted()
|
suspend fun markMyMasterKeyAsTrusted()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,7 +107,6 @@ interface KeysBackupService {
|
|||||||
* @param password an optional passphrase string that can be entered by the user
|
* @param password an optional passphrase string that can be entered by the user
|
||||||
* when restoring the backup as an alternative to entering the recovery key.
|
* when restoring the backup as an alternative to entering the recovery key.
|
||||||
* @param progressListener a progress listener, as generating private key from password may take a while
|
* @param progressListener a progress listener, as generating private key from password may take a while
|
||||||
* @param callback Asynchronous callback
|
|
||||||
*/
|
*/
|
||||||
suspend fun prepareKeysBackupVersion(password: String?, progressListener: ProgressListener?): MegolmBackupCreationInfo
|
suspend fun prepareKeysBackupVersion(password: String?, progressListener: ProgressListener?): MegolmBackupCreationInfo
|
||||||
|
|
||||||
@ -165,7 +164,6 @@ interface KeysBackupService {
|
|||||||
* @param roomId the id of the room to get backup data from.
|
* @param roomId the id of the room to get backup data from.
|
||||||
* @param sessionId the id of the session to restore.
|
* @param sessionId the id of the session to restore.
|
||||||
* @param stepProgressListener the step progress listener
|
* @param stepProgressListener the step progress listener
|
||||||
* @param callback Callback. It provides the number of found keys and the number of successfully imported keys.
|
|
||||||
*/
|
*/
|
||||||
suspend fun restoreKeysWithRecoveryKey(
|
suspend fun restoreKeysWithRecoveryKey(
|
||||||
keysVersionResult: KeysVersionResult,
|
keysVersionResult: KeysVersionResult,
|
||||||
|
@ -19,6 +19,6 @@ package org.matrix.android.sdk.api.session.crypto.model
|
|||||||
data class ImportRoomKeysResult(
|
data class ImportRoomKeysResult(
|
||||||
val totalNumberOfKeys: Int,
|
val totalNumberOfKeys: Int,
|
||||||
val successfullyNumberOfImportedKeys: Int,
|
val successfullyNumberOfImportedKeys: Int,
|
||||||
/**It's a map from room id to a map of the sender key to a list of session*/
|
/* It's a map from room id to a map of the sender key to a list of session. */
|
||||||
val importedSessionInfo: Map<String, Map<String, List<String>>>
|
val importedSessionInfo: Map<String, Map<String, List<String>>>
|
||||||
)
|
)
|
||||||
|
@ -56,7 +56,7 @@ internal interface CryptoApi {
|
|||||||
suspend fun getDeviceInfo(@Path("deviceId") deviceId: String): DeviceInfo
|
suspend fun getDeviceInfo(@Path("deviceId") deviceId: String): DeviceInfo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload device and one-time keys
|
* Upload device and one-time keys.
|
||||||
* @param body the keys to be sent.
|
* @param body the keys to be sent.
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/upload")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/upload")
|
||||||
|
@ -109,12 +109,12 @@ internal class RustCrossSigningService @Inject constructor(
|
|||||||
return olmMachine.getLiveUserIdentity(userId)
|
return olmMachine.getLiveUserIdentity(userId)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get our own public cross signing keys */
|
/** Get our own public cross signing keys. */
|
||||||
override suspend fun getMyCrossSigningKeys(): MXCrossSigningInfo? {
|
override suspend fun getMyCrossSigningKeys(): MXCrossSigningInfo? {
|
||||||
return getUserCrossSigningKeys(olmMachine.userId())
|
return getUserCrossSigningKeys(olmMachine.userId())
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get our own private cross signing keys */
|
/** Get our own private cross signing keys. */
|
||||||
override suspend fun getCrossSigningPrivateKeys(): PrivateKeysInfo? {
|
override suspend fun getCrossSigningPrivateKeys(): PrivateKeysInfo? {
|
||||||
return olmMachine.exportCrossSigningKeys()
|
return olmMachine.exportCrossSigningKeys()
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ internal class RustCrossSigningService @Inject constructor(
|
|||||||
return status.hasMaster && status.hasSelfSigning && status.hasUserSigning
|
return status.hasMaster && status.hasSelfSigning && status.hasUserSigning
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Mark a user identity as trusted and sign and upload signatures of our user-signing key to the server */
|
/** Mark a user identity as trusted and sign and upload signatures of our user-signing key to the server. */
|
||||||
override suspend fun trustUser(otherUserId: String) {
|
override suspend fun trustUser(otherUserId: String) {
|
||||||
// This is only used in a test
|
// This is only used in a test
|
||||||
val userIdentity = olmMachine.getIdentity(otherUserId)
|
val userIdentity = olmMachine.getIdentity(otherUserId)
|
||||||
@ -151,7 +151,7 @@ internal class RustCrossSigningService @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Mark our own master key as trusted */
|
/** Mark our own master key as trusted. */
|
||||||
override suspend fun markMyMasterKeyAsTrusted() {
|
override suspend fun markMyMasterKeyAsTrusted() {
|
||||||
// This doesn't seem to be used?
|
// This doesn't seem to be used?
|
||||||
trustUser(olmMachine.userId())
|
trustUser(olmMachine.userId())
|
||||||
|
@ -197,7 +197,7 @@ internal class VerificationRequest @AssistedInject constructor(
|
|||||||
requestSender.sendVerificationRequest(result.request)
|
requestSender.sendVerificationRequest(result.request)
|
||||||
sasVerificationFactory.create(result.sas)
|
sasVerificationFactory.create(result.sas)
|
||||||
} catch (failure: Throwable) {
|
} catch (failure: Throwable) {
|
||||||
cancel(CancelCode.UserError)
|
cancel()
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -225,7 +225,7 @@ internal class VerificationRequest @AssistedInject constructor(
|
|||||||
try {
|
try {
|
||||||
requestSender.sendVerificationRequest(result.request)
|
requestSender.sendVerificationRequest(result.request)
|
||||||
} catch (failure: Throwable) {
|
} catch (failure: Throwable) {
|
||||||
cancel(CancelCode.UserError)
|
cancel()
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
return qrCodeVerificationFactory.create(result.qr)
|
return qrCodeVerificationFactory.create(result.qr)
|
||||||
@ -241,14 +241,9 @@ internal class VerificationRequest @AssistedInject constructor(
|
|||||||
*
|
*
|
||||||
* The method turns into a noop, if the verification flow has already been cancelled.
|
* The method turns into a noop, if the verification flow has already been cancelled.
|
||||||
*/
|
*/
|
||||||
internal suspend fun cancel(cancelCode: CancelCode = CancelCode.User) = withContext(NonCancellable) {
|
internal suspend fun cancel() = withContext(NonCancellable) {
|
||||||
// TODO damir how to add the code?
|
// TODO damir how to add the code?
|
||||||
val request = innerVerificationRequest.cancel() ?: return@withContext
|
val request = innerVerificationRequest.cancel() ?: return@withContext
|
||||||
// val request = innerOlmMachine.cancelVerification(
|
|
||||||
// innerVerificationRequest.otherUserId,
|
|
||||||
// innerVerificationRequest.flowId,
|
|
||||||
// cancelCode.value
|
|
||||||
// ) ?: return@withContext
|
|
||||||
dispatchRequestUpdated()
|
dispatchRequestUpdated()
|
||||||
tryOrNull("Fail to send cancel request") {
|
tryOrNull("Fail to send cancel request") {
|
||||||
requestSender.sendVerificationRequest(request, retryCount = Int.MAX_VALUE)
|
requestSender.sendVerificationRequest(request, retryCount = Int.MAX_VALUE)
|
||||||
|
@ -168,6 +168,7 @@ class KeysBackupSetupSharedViewModel @Inject constructor(
|
|||||||
navigateEvent.postValue(LiveEvent(NAVIGATE_PROMPT_REPLACE))
|
navigateEvent.postValue(LiveEvent(NAVIGATE_PROMPT_REPLACE))
|
||||||
}
|
}
|
||||||
} catch (failure: Throwable) {
|
} catch (failure: Throwable) {
|
||||||
|
Timber.w(failure, "Failed to createKeysBackup")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ import javax.inject.Inject
|
|||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specific to other users verification (not self verification)
|
* Specific to other users verification (not self verification).
|
||||||
*/
|
*/
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class UserVerificationBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetVerificationBinding>() {
|
class UserVerificationBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetVerificationBinding>() {
|
||||||
|
Loading…
Reference in New Issue
Block a user