Also keep the same parameter order: (userId, deviceId) to avoid silly errors
This commit is contained in:
parent
79df6b8402
commit
81337d1624
|
@ -1161,7 +1161,7 @@ class KeysBackupTest : InstrumentedTest {
|
||||||
assertFalse(keysBackup2.isEnabled)
|
assertFalse(keysBackup2.isEnabled)
|
||||||
|
|
||||||
// - Validate the old device from the new one
|
// - 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
|
// -> Backup should automatically enable on the new device
|
||||||
val latch4 = CountDownLatch(1)
|
val latch4 = CountDownLatch(1)
|
||||||
|
|
|
@ -59,7 +59,7 @@ interface CryptoService {
|
||||||
|
|
||||||
fun setWarnOnUnknownDevices(warn: Boolean)
|
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<CryptoDeviceInfo>
|
fun getUserDevices(userId: String): MutableList<CryptoDeviceInfo>
|
||||||
|
|
||||||
|
|
|
@ -428,12 +428,12 @@ internal class DefaultCryptoService @Inject constructor(
|
||||||
/**
|
/**
|
||||||
* Update the blocked/verified state of the given device.
|
* Update the blocked/verified state of the given device.
|
||||||
*
|
*
|
||||||
* @param verificationStatus the new verification status
|
* @param trustLevel the new trust level
|
||||||
* @param deviceId the unique identifier for the device.
|
* @param userId the owner of the device
|
||||||
* @param userId the owner of the device
|
* @param deviceId the unique identifier for the device.
|
||||||
*/
|
*/
|
||||||
override fun setDeviceVerification(trustLevel: DeviceTrustLevel, deviceId: String, userId: String) {
|
override fun setDeviceVerification(trustLevel: DeviceTrustLevel, userId: String, deviceId: String) {
|
||||||
setDeviceVerificationAction.handle(trustLevel, deviceId, userId)
|
setDeviceVerificationAction.handle(trustLevel, userId, deviceId)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,7 +28,7 @@ internal class SetDeviceVerificationAction @Inject constructor(
|
||||||
@UserId private val userId: String,
|
@UserId private val userId: String,
|
||||||
private val keysBackup: KeysBackup) {
|
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)
|
val device = cryptoStore.getUserDevice(userId, deviceId)
|
||||||
|
|
||||||
// Sanity check
|
// Sanity check
|
||||||
|
|
|
@ -204,8 +204,8 @@ internal class DefaultSasVerificationService @Inject constructor(
|
||||||
|
|
||||||
override fun markedLocallyAsManuallyVerified(userId: String, deviceID: String) {
|
override fun markedLocallyAsManuallyVerified(userId: String, deviceID: String) {
|
||||||
setDeviceVerificationAction.handle(DeviceTrustLevel(false, true),
|
setDeviceVerificationAction.handle(DeviceTrustLevel(false, true),
|
||||||
deviceID,
|
userId,
|
||||||
userId)
|
deviceID)
|
||||||
|
|
||||||
listeners.forEach {
|
listeners.forEach {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -332,17 +332,17 @@ internal abstract class SASVerificationTransaction(
|
||||||
|
|
||||||
// TODO what if the otherDevice is not in this list? and should we
|
// TODO what if the otherDevice is not in this list? and should we
|
||||||
verifiedDevices.forEach {
|
verifiedDevices.forEach {
|
||||||
setDeviceVerified(it, otherUserId)
|
setDeviceVerified(otherUserId, it)
|
||||||
}
|
}
|
||||||
transport.done(transactionId)
|
transport.done(transactionId)
|
||||||
state = SasVerificationTxState.Verified
|
state = SasVerificationTxState.Verified
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setDeviceVerified(deviceId: String, userId: String) {
|
private fun setDeviceVerified(userId: String, deviceId: String) {
|
||||||
// TODO should not override cross sign status
|
// TODO should not override cross sign status
|
||||||
setDeviceVerificationAction.handle(DeviceTrustLevel(false, true),
|
setDeviceVerificationAction.handle(DeviceTrustLevel(false, true),
|
||||||
deviceId,
|
userId,
|
||||||
userId)
|
deviceId)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun cancel() {
|
override fun cancel() {
|
||||||
|
|
|
@ -89,7 +89,7 @@ class KeyRequestHandler @Inject constructor(private val context: Context)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we already have alerts for this user/device
|
// Do we already have alerts for this user/device
|
||||||
val mappingKey = keyForMap(deviceId, userId)
|
val mappingKey = keyForMap(userId, deviceId)
|
||||||
if (alertsToRequests.containsKey(mappingKey)) {
|
if (alertsToRequests.containsKey(mappingKey)) {
|
||||||
// just add the request, there is already an alert for this
|
// just add the request, there is already an alert for this
|
||||||
alertsToRequests[mappingKey]?.add(request)
|
alertsToRequests[mappingKey]?.add(request)
|
||||||
|
@ -110,7 +110,7 @@ class KeyRequestHandler @Inject constructor(private val context: Context)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deviceInfo.isUnknown) {
|
if (deviceInfo.isUnknown) {
|
||||||
session?.setDeviceVerification(DeviceTrustLevel(false, false), deviceId, userId)
|
session?.setDeviceVerification(DeviceTrustLevel(false, false), userId, deviceId)
|
||||||
|
|
||||||
deviceInfo.trustLevel = DeviceTrustLevel(false, false)
|
deviceInfo.trustLevel = DeviceTrustLevel(false, false)
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ class KeyRequestHandler @Inject constructor(private val context: Context)
|
||||||
}
|
}
|
||||||
|
|
||||||
val alert = PopupAlertManager.VectorAlert(
|
val alert = PopupAlertManager.VectorAlert(
|
||||||
alertManagerId(deviceId, userId),
|
alertManagerId(userId, deviceId),
|
||||||
context.getString(R.string.key_share_request),
|
context.getString(R.string.key_share_request),
|
||||||
dialogText,
|
dialogText,
|
||||||
R.drawable.key_small
|
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
|
alert.colorRes = R.color.key_share_req_accent_color
|
||||||
|
|
||||||
val mappingKey = keyForMap(deviceId, userId)
|
val mappingKey = keyForMap(userId, deviceId)
|
||||||
alert.dismissedAction = Runnable {
|
alert.dismissedAction = Runnable {
|
||||||
denyAllRequests(mappingKey)
|
denyAllRequests(mappingKey)
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ class KeyRequestHandler @Inject constructor(private val context: Context)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val alertMgrUniqueKey = alertManagerId(deviceId, userId)
|
val alertMgrUniqueKey = alertManagerId(userId, deviceId)
|
||||||
alertsToRequests[alertMgrUniqueKey]?.removeAll {
|
alertsToRequests[alertMgrUniqueKey]?.removeAll {
|
||||||
it.deviceId == request.deviceId
|
it.deviceId == request.deviceId
|
||||||
&& it.userId == request.userId
|
&& it.userId == request.userId
|
||||||
|
@ -257,7 +257,7 @@ class KeyRequestHandler @Inject constructor(private val context: Context)
|
||||||
}
|
}
|
||||||
if (alertsToRequests[alertMgrUniqueKey]?.isEmpty() == true) {
|
if (alertsToRequests[alertMgrUniqueKey]?.isEmpty() == true) {
|
||||||
PopupAlertManager.cancelAlert(alertMgrUniqueKey)
|
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) {
|
override fun markedAsManuallyVerified(userId: String, deviceId: String) {
|
||||||
// accept related requests
|
// accept related requests
|
||||||
shareAllSessions(keyForMap(deviceId, userId))
|
shareAllSessions(keyForMap(userId, deviceId))
|
||||||
PopupAlertManager.cancelAlert(alertManagerId(deviceId, userId))
|
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"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue