diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupTest.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupTest.kt index 3c77661b8b..81096424d5 100644 --- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupTest.kt +++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupTest.kt @@ -1161,7 +1161,7 @@ class KeysBackupTest : InstrumentedTest { assertFalse(keysBackup2.isEnabled) // - Validate the old device from the new one - aliceSession2.setDeviceVerification(DeviceTrustLevel(false, true), oldDeviceId, aliceSession2.myUserId) + aliceSession2.setDeviceVerification(DeviceTrustLevel(false, true), aliceSession2.myUserId, oldDeviceId) // -> Backup should automatically enable on the new device val latch4 = CountDownLatch(1) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/CryptoService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/CryptoService.kt index de657e6abb..2b1e92c317 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/CryptoService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/CryptoService.kt @@ -59,7 +59,7 @@ interface CryptoService { fun setWarnOnUnknownDevices(warn: Boolean) - fun setDeviceVerification(trustLevel: DeviceTrustLevel, deviceId: String, userId: String) + fun setDeviceVerification(trustLevel: DeviceTrustLevel, userId: String, deviceId: String) fun getUserDevices(userId: String): MutableList diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt index 53b2442625..aaa712e666 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt @@ -428,12 +428,12 @@ internal class DefaultCryptoService @Inject constructor( /** * Update the blocked/verified state of the given device. * - * @param verificationStatus the new verification status - * @param deviceId the unique identifier for the device. - * @param userId the owner of the device + * @param trustLevel the new trust level + * @param userId the owner of the device + * @param deviceId the unique identifier for the device. */ - override fun setDeviceVerification(trustLevel: DeviceTrustLevel, deviceId: String, userId: String) { - setDeviceVerificationAction.handle(trustLevel, deviceId, userId) + override fun setDeviceVerification(trustLevel: DeviceTrustLevel, userId: String, deviceId: String) { + setDeviceVerificationAction.handle(trustLevel, userId, deviceId) } /** diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/actions/SetDeviceVerificationAction.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/actions/SetDeviceVerificationAction.kt index 6d5c6687d4..8dad832617 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/actions/SetDeviceVerificationAction.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/actions/SetDeviceVerificationAction.kt @@ -28,7 +28,7 @@ internal class SetDeviceVerificationAction @Inject constructor( @UserId private val userId: String, private val keysBackup: KeysBackup) { - fun handle(trustLevel: DeviceTrustLevel, deviceId: String, userId: String) { + fun handle(trustLevel: DeviceTrustLevel, userId: String, deviceId: String) { val device = cryptoStore.getUserDevice(userId, deviceId) // Sanity check diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultSasVerificationService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultSasVerificationService.kt index faa21f9356..6e73169b28 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultSasVerificationService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultSasVerificationService.kt @@ -204,8 +204,8 @@ internal class DefaultSasVerificationService @Inject constructor( override fun markedLocallyAsManuallyVerified(userId: String, deviceID: String) { setDeviceVerificationAction.handle(DeviceTrustLevel(false, true), - deviceID, - userId) + userId, + deviceID) listeners.forEach { try { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SASVerificationTransaction.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SASVerificationTransaction.kt index 7742d328ad..682c54f45f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SASVerificationTransaction.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SASVerificationTransaction.kt @@ -332,17 +332,17 @@ internal abstract class SASVerificationTransaction( // TODO what if the otherDevice is not in this list? and should we verifiedDevices.forEach { - setDeviceVerified(it, otherUserId) + setDeviceVerified(otherUserId, it) } transport.done(transactionId) state = SasVerificationTxState.Verified } - private fun setDeviceVerified(deviceId: String, userId: String) { + private fun setDeviceVerified(userId: String, deviceId: String) { // TODO should not override cross sign status setDeviceVerificationAction.handle(DeviceTrustLevel(false, true), - deviceId, - userId) + userId, + deviceId) } override fun cancel() { diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/keysrequest/KeyRequestHandler.kt b/vector/src/main/java/im/vector/riotx/features/crypto/keysrequest/KeyRequestHandler.kt index 0f4b651d43..28155e2d59 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/keysrequest/KeyRequestHandler.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/keysrequest/KeyRequestHandler.kt @@ -89,7 +89,7 @@ class KeyRequestHandler @Inject constructor(private val context: Context) } // Do we already have alerts for this user/device - val mappingKey = keyForMap(deviceId, userId) + val mappingKey = keyForMap(userId, deviceId) if (alertsToRequests.containsKey(mappingKey)) { // just add the request, there is already an alert for this alertsToRequests[mappingKey]?.add(request) @@ -110,7 +110,7 @@ class KeyRequestHandler @Inject constructor(private val context: Context) } if (deviceInfo.isUnknown) { - session?.setDeviceVerification(DeviceTrustLevel(false, false), deviceId, userId) + session?.setDeviceVerification(DeviceTrustLevel(false, false), userId, deviceId) deviceInfo.trustLevel = DeviceTrustLevel(false, false) @@ -181,7 +181,7 @@ class KeyRequestHandler @Inject constructor(private val context: Context) } val alert = PopupAlertManager.VectorAlert( - alertManagerId(deviceId, userId), + alertManagerId(userId, deviceId), context.getString(R.string.key_share_request), dialogText, R.drawable.key_small @@ -189,7 +189,7 @@ class KeyRequestHandler @Inject constructor(private val context: Context) alert.colorRes = R.color.key_share_req_accent_color - val mappingKey = keyForMap(deviceId, userId) + val mappingKey = keyForMap(userId, deviceId) alert.dismissedAction = Runnable { denyAllRequests(mappingKey) } @@ -249,7 +249,7 @@ class KeyRequestHandler @Inject constructor(private val context: Context) return } - val alertMgrUniqueKey = alertManagerId(deviceId, userId) + val alertMgrUniqueKey = alertManagerId(userId, deviceId) alertsToRequests[alertMgrUniqueKey]?.removeAll { it.deviceId == request.deviceId && it.userId == request.userId @@ -257,7 +257,7 @@ class KeyRequestHandler @Inject constructor(private val context: Context) } if (alertsToRequests[alertMgrUniqueKey]?.isEmpty() == true) { PopupAlertManager.cancelAlert(alertMgrUniqueKey) - alertsToRequests.remove(keyForMap(deviceId, userId)) + alertsToRequests.remove(keyForMap(userId, deviceId)) } } @@ -275,11 +275,11 @@ class KeyRequestHandler @Inject constructor(private val context: Context) override fun markedAsManuallyVerified(userId: String, deviceId: String) { // accept related requests - shareAllSessions(keyForMap(deviceId, userId)) - PopupAlertManager.cancelAlert(alertManagerId(deviceId, userId)) + shareAllSessions(keyForMap(userId, deviceId)) + PopupAlertManager.cancelAlert(alertManagerId(userId, deviceId)) } - private fun keyForMap(deviceId: String, userId: String) = "$deviceId$userId" + private fun keyForMap(userId: String, deviceId: String) = "$deviceId$userId" - private fun alertManagerId(deviceId: String, userId: String) = "ikr_$deviceId$userId" + private fun alertManagerId(userId: String, deviceId: String) = "ikr_$deviceId$userId" }