From bf02746d8739f3340c4290233532d84fcb429d1d Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 11 Feb 2020 18:25:01 +0100 Subject: [PATCH] Clenaup VerificationService.VerificationListener --- .../internal/crypto/verification/SASTest.kt | 42 ------------------- .../session/crypto/sas/VerificationService.kt | 10 ++--- .../crypto/keysrequest/KeyRequestHandler.kt | 3 -- .../IncomingVerificationRequestHandler.kt | 6 --- .../settings/devices/DevicesViewModel.kt | 1 - 5 files changed, 4 insertions(+), 58 deletions(-) diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/SASTest.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/SASTest.kt index 6ae2489993..6b254efd5d 100644 --- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/SASTest.kt +++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/SASTest.kt @@ -67,13 +67,9 @@ class SASTest : InstrumentedTest { val bobTxCreatedLatch = CountDownLatch(1) val bobListener = object : VerificationService.VerificationListener { - override fun transactionCreated(tx: VerificationTransaction) {} - override fun transactionUpdated(tx: VerificationTransaction) { bobTxCreatedLatch.countDown() } - - override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } bobVerificationService.addListener(bobListener) @@ -107,8 +103,6 @@ class SASTest : InstrumentedTest { val cancelLatch = CountDownLatch(1) val bobListener2 = object : VerificationService.VerificationListener { - override fun transactionCreated(tx: VerificationTransaction) {} - override fun transactionUpdated(tx: VerificationTransaction) { if (tx.transactionId == txID) { val immutableState = (tx as SASDefaultVerificationTransaction).state @@ -117,8 +111,6 @@ class SASTest : InstrumentedTest { } } } - - override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } bobVerificationService.addListener(bobListener2) @@ -158,16 +150,12 @@ class SASTest : InstrumentedTest { val cancelLatch = CountDownLatch(1) val bobListener = object : VerificationService.VerificationListener { - override fun transactionCreated(tx: VerificationTransaction) {} - override fun transactionUpdated(tx: VerificationTransaction) { if (tx.transactionId == tid && tx.state is VerificationTxState.Cancelled) { cancelReason = (tx.state as VerificationTxState.Cancelled).cancelCode cancelLatch.countDown() } } - - override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } bobSession.getVerificationService().addListener(bobListener) @@ -187,15 +175,11 @@ class SASTest : InstrumentedTest { val aliceDevice = aliceSession.getMyDevice().deviceId val aliceListener = object : VerificationService.VerificationListener { - override fun transactionCreated(tx: VerificationTransaction) {} - override fun transactionUpdated(tx: VerificationTransaction) { if ((tx as IncomingSasVerificationTransaction).uxState === IncomingSasVerificationTransaction.UxState.SHOW_ACCEPT) { (tx as IncomingSasVerificationTransaction).performAccept() } } - - override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } aliceSession.getVerificationService().addListener(aliceListener) @@ -339,8 +323,6 @@ class SASTest : InstrumentedTest { aliceCancelledLatch.countDown() } } - - override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } aliceVerificationService.addListener(aliceListener) @@ -373,10 +355,6 @@ class SASTest : InstrumentedTest { val aliceAcceptedLatch = CountDownLatch(1) val aliceListener = object : VerificationService.VerificationListener { - override fun markedAsManuallyVerified(userId: String, deviceId: String) {} - - override fun transactionCreated(tx: VerificationTransaction) {} - override fun transactionUpdated(tx: VerificationTransaction) { if ((tx as SASDefaultVerificationTransaction).state === VerificationTxState.OnAccepted) { val at = tx as SASDefaultVerificationTransaction @@ -389,16 +367,12 @@ class SASTest : InstrumentedTest { aliceVerificationService.addListener(aliceListener) val bobListener = object : VerificationService.VerificationListener { - override fun transactionCreated(tx: VerificationTransaction) {} - override fun transactionUpdated(tx: VerificationTransaction) { if ((tx as IncomingSasVerificationTransaction).uxState === IncomingSasVerificationTransaction.UxState.SHOW_ACCEPT) { val at = tx as IncomingSasVerificationTransaction at.performAccept() } } - - override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } bobVerificationService.addListener(bobListener) @@ -434,8 +408,6 @@ class SASTest : InstrumentedTest { val aliceSASLatch = CountDownLatch(1) val aliceListener = object : VerificationService.VerificationListener { - override fun transactionCreated(tx: VerificationTransaction) {} - override fun transactionUpdated(tx: VerificationTransaction) { val uxState = (tx as OutgoingSasVerificationTransaction).uxState when (uxState) { @@ -445,15 +417,11 @@ class SASTest : InstrumentedTest { else -> Unit } } - - override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } aliceVerificationService.addListener(aliceListener) val bobSASLatch = CountDownLatch(1) val bobListener = object : VerificationService.VerificationListener { - override fun transactionCreated(tx: VerificationTransaction) {} - override fun transactionUpdated(tx: VerificationTransaction) { val uxState = (tx as IncomingSasVerificationTransaction).uxState when (uxState) { @@ -466,8 +434,6 @@ class SASTest : InstrumentedTest { bobSASLatch.countDown() } } - - override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } bobVerificationService.addListener(bobListener) @@ -498,8 +464,6 @@ class SASTest : InstrumentedTest { val aliceSASLatch = CountDownLatch(1) val aliceListener = object : VerificationService.VerificationListener { - override fun transactionCreated(tx: VerificationTransaction) {} - override fun transactionUpdated(tx: VerificationTransaction) { val uxState = (tx as OutgoingSasVerificationTransaction).uxState when (uxState) { @@ -512,15 +476,11 @@ class SASTest : InstrumentedTest { else -> Unit } } - - override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } aliceVerificationService.addListener(aliceListener) val bobSASLatch = CountDownLatch(1) val bobListener = object : VerificationService.VerificationListener { - override fun transactionCreated(tx: VerificationTransaction) {} - override fun transactionUpdated(tx: VerificationTransaction) { val uxState = (tx as IncomingSasVerificationTransaction).uxState when (uxState) { @@ -536,8 +496,6 @@ class SASTest : InstrumentedTest { else -> Unit } } - - override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } bobVerificationService.addListener(bobListener) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/VerificationService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/VerificationService.kt index 3572905019..9df2dc9a89 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/VerificationService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/VerificationService.kt @@ -95,15 +95,13 @@ interface VerificationService { otherUserId: String, transactionId: String): Boolean - // fun transactionUpdated(tx: SasVerificationTransaction) - interface VerificationListener { - fun transactionCreated(tx: VerificationTransaction) - fun transactionUpdated(tx: VerificationTransaction) - fun markedAsManuallyVerified(userId: String, deviceId: String) {} - fun verificationRequestCreated(pr: PendingVerificationRequest) {} fun verificationRequestUpdated(pr: PendingVerificationRequest) {} + + fun transactionCreated(tx: VerificationTransaction) {} + fun transactionUpdated(tx: VerificationTransaction) {} + fun markedAsManuallyVerified(userId: String, deviceId: String) {} } companion object { 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 856c71f888..bc97ac5ee5 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 @@ -262,9 +262,6 @@ class KeyRequestHandler @Inject constructor(private val context: Context) } } - override fun transactionCreated(tx: VerificationTransaction) { - } - override fun transactionUpdated(tx: VerificationTransaction) { if (tx is SasVerificationTransaction) { val state = tx.state diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/IncomingVerificationRequestHandler.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/IncomingVerificationRequestHandler.kt index 0ed29a9058..99c28b52dc 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/IncomingVerificationRequestHandler.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/IncomingVerificationRequestHandler.kt @@ -48,8 +48,6 @@ class IncomingVerificationRequestHandler @Inject constructor(private val context this.session = null } - override fun transactionCreated(tx: VerificationTransaction) {} - override fun transactionUpdated(tx: VerificationTransaction) { if (!tx.isToDeviceTransport()) return // TODO maybe check also if @@ -111,9 +109,6 @@ class IncomingVerificationRequestHandler @Inject constructor(private val context } } - override fun markedAsManuallyVerified(userId: String, deviceId: String) { - } - override fun verificationRequestCreated(pr: PendingVerificationRequest) { // For incoming request we should prompt (if not in activity where this request apply) if (pr.isIncoming) { @@ -162,7 +157,6 @@ class IncomingVerificationRequestHandler @Inject constructor(private val context if (pr.isIncoming && (pr.isReady || pr.handledByOtherSession)) { PopupAlertManager.cancelAlert(uniqueIdForVerificationRequest(pr)) } - super.verificationRequestUpdated(pr) } private fun uniqueIdForVerificationRequest(pr: PendingVerificationRequest) = diff --git a/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesViewModel.kt b/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesViewModel.kt index 333249f3de..1862412cb5 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesViewModel.kt @@ -89,7 +89,6 @@ class DevicesViewModel @AssistedInject constructor(@Assisted initialState: Devic super.onCleared() } - override fun transactionCreated(tx: VerificationTransaction) {} override fun transactionUpdated(tx: VerificationTransaction) { if (tx.state == VerificationTxState.Verified) { refreshDevicesList()