mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
code cleaning
This commit is contained in:
parent
b56a41bec7
commit
cfcec04029
15 changed files with 7 additions and 30 deletions
|
@ -187,7 +187,6 @@ class KeyShareTests : InstrumentedTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun test_ShareSSSSSecret() {
|
fun test_ShareSSSSSecret() {
|
||||||
|
|
||||||
val aliceSession1 = mTestHelper.createAccount(TestConstants.USER_ALICE, SessionTestParams(true))
|
val aliceSession1 = mTestHelper.createAccount(TestConstants.USER_ALICE, SessionTestParams(true))
|
||||||
|
|
||||||
mTestHelper.doSync<Unit> {
|
mTestHelper.doSync<Unit> {
|
||||||
|
@ -203,7 +202,7 @@ class KeyShareTests : InstrumentedTest {
|
||||||
val aliceVerificationService1 = aliceSession1.cryptoService().verificationService()
|
val aliceVerificationService1 = aliceSession1.cryptoService().verificationService()
|
||||||
val aliceVerificationService2 = aliceSession2.cryptoService().verificationService()
|
val aliceVerificationService2 = aliceSession2.cryptoService().verificationService()
|
||||||
|
|
||||||
//force keys download
|
// force keys download
|
||||||
mTestHelper.doSync<MXUsersDevicesMap<CryptoDeviceInfo>> {
|
mTestHelper.doSync<MXUsersDevicesMap<CryptoDeviceInfo>> {
|
||||||
aliceSession1.cryptoService().downloadKeys(listOf(aliceSession1.myUserId), true, it)
|
aliceSession1.cryptoService().downloadKeys(listOf(aliceSession1.myUserId), true, it)
|
||||||
}
|
}
|
||||||
|
@ -245,7 +244,6 @@ class KeyShareTests : InstrumentedTest {
|
||||||
aliceVerificationService2.beginKeyVerification(VerificationMethod.SAS, aliceSession1.myUserId, aliceSession1.sessionParams.credentials.deviceId
|
aliceVerificationService2.beginKeyVerification(VerificationMethod.SAS, aliceSession1.myUserId, aliceSession1.sessionParams.credentials.deviceId
|
||||||
?: "", txId)
|
?: "", txId)
|
||||||
|
|
||||||
|
|
||||||
mTestHelper.waitWithLatch { latch ->
|
mTestHelper.waitWithLatch { latch ->
|
||||||
mTestHelper.retryPeriodicallyWithLatch(latch) {
|
mTestHelper.retryPeriodicallyWithLatch(latch) {
|
||||||
aliceSession1.cryptoService().getDeviceInfo(aliceSession1.myUserId, aliceSession2.sessionParams.credentials.deviceId ?: "")?.isVerified == true
|
aliceSession1.cryptoService().getDeviceInfo(aliceSession1.myUserId, aliceSession2.sessionParams.credentials.deviceId ?: "")?.isVerified == true
|
||||||
|
@ -267,5 +265,4 @@ class KeyShareTests : InstrumentedTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,7 +287,6 @@ internal class IncomingGossipingRequestManager @Inject constructor(
|
||||||
}?.let { secretValue ->
|
}?.let { secretValue ->
|
||||||
Timber.i("## GOSSIP processIncomingSecretShareRequest() : Sharing secret $secretName with $device locally trusted")
|
Timber.i("## GOSSIP processIncomingSecretShareRequest() : Sharing secret $secretName with $device locally trusted")
|
||||||
if (isDeviceLocallyVerified == true && hasBeenVerifiedLessThanFiveMinutesFromNow(deviceId)) {
|
if (isDeviceLocallyVerified == true && hasBeenVerifiedLessThanFiveMinutesFromNow(deviceId)) {
|
||||||
|
|
||||||
val params = SendGossipWorker.Params(
|
val params = SendGossipWorker.Params(
|
||||||
sessionId = sessionId,
|
sessionId = sessionId,
|
||||||
secretValue = secretValue,
|
secretValue = secretValue,
|
||||||
|
|
|
@ -99,7 +99,6 @@ internal class SendGossipWorker(context: Context,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val payloadJson = mapOf(
|
val payloadJson = mapOf(
|
||||||
"type" to EventType.SEND_SECRET,
|
"type" to EventType.SEND_SECRET,
|
||||||
"content" to toDeviceContent.toContent()
|
"content" to toDeviceContent.toContent()
|
||||||
|
@ -112,7 +111,6 @@ internal class SendGossipWorker(context: Context,
|
||||||
Timber.e("## Fail to encrypt gossip + ${failure.localizedMessage}")
|
Timber.e("## Fail to encrypt gossip + ${failure.localizedMessage}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cryptoStore.saveGossipingEvent(Event(
|
cryptoStore.saveGossipingEvent(Event(
|
||||||
type = eventType,
|
type = eventType,
|
||||||
content = toDeviceContent.toContent(),
|
content = toDeviceContent.toContent(),
|
||||||
|
|
|
@ -456,7 +456,7 @@ internal class DefaultVerificationService @Inject constructor(
|
||||||
private suspend fun handleStart(otherUserId: String?,
|
private suspend fun handleStart(otherUserId: String?,
|
||||||
startReq: ValidVerificationInfoStart,
|
startReq: ValidVerificationInfoStart,
|
||||||
txConfigure: (DefaultVerificationTransaction) -> Unit): CancelCode? {
|
txConfigure: (DefaultVerificationTransaction) -> Unit): CancelCode? {
|
||||||
Timber.d("## SAS onStartRequestReceived ${startReq}")
|
Timber.d("## SAS onStartRequestReceived $startReq")
|
||||||
if (otherUserId?.let { checkKeysAreDownloaded(it, startReq.fromDevice) } != null) {
|
if (otherUserId?.let { checkKeysAreDownloaded(it, startReq.fromDevice) } != null) {
|
||||||
val tid = startReq.transactionId
|
val tid = startReq.transactionId
|
||||||
var existing = getExistingTransaction(otherUserId, tid)
|
var existing = getExistingTransaction(otherUserId, tid)
|
||||||
|
@ -549,7 +549,7 @@ internal class DefaultVerificationService @Inject constructor(
|
||||||
existing.onStartReceived(startReq)
|
existing.onStartReceived(startReq)
|
||||||
return null
|
return null
|
||||||
} else {
|
} else {
|
||||||
Timber.w("## SAS onStartRequestReceived - unexpected message ${startReq.transactionId} / ${existing}")
|
Timber.w("## SAS onStartRequestReceived - unexpected message ${startReq.transactionId} / $existing")
|
||||||
return CancelCode.UnexpectedMessage
|
return CancelCode.UnexpectedMessage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ internal class TimelineEventDecryptor @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (t: Throwable) {
|
} catch (t: Throwable) {
|
||||||
Timber.e( "Failed to decrypt event $eventId, ${t.localizedMessage}")
|
Timber.e("Failed to decrypt event $eventId, ${t.localizedMessage}")
|
||||||
} finally {
|
} finally {
|
||||||
synchronized(existingRequests) {
|
synchronized(existingRequests) {
|
||||||
existingRequests.remove(request)
|
existingRequests.remove(request)
|
||||||
|
|
|
@ -38,7 +38,6 @@ import im.vector.matrix.android.internal.crypto.model.rest.DevicesListResponse
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import im.vector.riotx.features.popup.DefaultVectorAlert
|
import im.vector.riotx.features.popup.DefaultVectorAlert
|
||||||
import im.vector.riotx.features.popup.PopupAlertManager
|
import im.vector.riotx.features.popup.PopupAlertManager
|
||||||
import im.vector.riotx.features.popup.VectorAlert
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.text.DateFormat
|
import java.text.DateFormat
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
|
|
@ -78,7 +78,6 @@ class IncomingVerificationRequestHandler @Inject constructor(
|
||||||
} else true
|
} else true
|
||||||
})
|
})
|
||||||
.apply {
|
.apply {
|
||||||
|
|
||||||
matrixItem = session?.getUser(tx.otherUserId ?: "")?.toMatrixItem()
|
matrixItem = session?.getUser(tx.otherUserId ?: "")?.toMatrixItem()
|
||||||
|
|
||||||
contentAction = Runnable {
|
contentAction = Runnable {
|
||||||
|
@ -135,7 +134,6 @@ class IncomingVerificationRequestHandler @Inject constructor(
|
||||||
} else true
|
} else true
|
||||||
})
|
})
|
||||||
.apply {
|
.apply {
|
||||||
|
|
||||||
matrixItem = session?.getUser(pr.otherUserId)?.toMatrixItem()
|
matrixItem = session?.getUser(pr.otherUserId)?.toMatrixItem()
|
||||||
|
|
||||||
contentAction = Runnable {
|
contentAction = Runnable {
|
||||||
|
|
|
@ -155,7 +155,6 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment() {
|
||||||
|
|
||||||
state.otherUserMxItem?.let { matrixItem ->
|
state.otherUserMxItem?.let { matrixItem ->
|
||||||
if (state.isMe) {
|
if (state.isMe) {
|
||||||
|
|
||||||
avatarRenderer.render(matrixItem, otherUserAvatarImageView)
|
avatarRenderer.render(matrixItem, otherUserAvatarImageView)
|
||||||
if (state.sasTransactionState == VerificationTxState.Verified
|
if (state.sasTransactionState == VerificationTxState.Verified
|
||||||
|| state.qrTransactionState == VerificationTxState.Verified
|
|| state.qrTransactionState == VerificationTxState.Verified
|
||||||
|
|
|
@ -43,7 +43,6 @@ class VerificationNotMeController @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun buildModels() {
|
override fun buildModels() {
|
||||||
|
|
||||||
bottomSheetVerificationNoticeItem {
|
bottomSheetVerificationNoticeItem {
|
||||||
id("notice")
|
id("notice")
|
||||||
notice(eventHtmlRenderer.render(stringProvider.getString(R.string.verify_not_me_self_verification)))
|
notice(eventHtmlRenderer.render(stringProvider.getString(R.string.verify_not_me_self_verification)))
|
||||||
|
|
|
@ -95,7 +95,6 @@ class VerificationRequestController @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bottomSheetVerificationNoticeItem {
|
bottomSheetVerificationNoticeItem {
|
||||||
id("notice")
|
id("notice")
|
||||||
notice(styledText)
|
notice(styledText)
|
||||||
|
@ -142,7 +141,6 @@ class VerificationRequestController @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.isMe && state.currentDeviceCanCrossSign) {
|
if (state.isMe && state.currentDeviceCanCrossSign) {
|
||||||
|
|
||||||
dividerItem {
|
dividerItem {
|
||||||
id("sep_notMe")
|
id("sep_notMe")
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,6 @@ import im.vector.riotx.core.pushers.PushersManager
|
||||||
import im.vector.riotx.features.disclaimer.showDisclaimerDialog
|
import im.vector.riotx.features.disclaimer.showDisclaimerDialog
|
||||||
import im.vector.riotx.features.notifications.NotificationDrawerManager
|
import im.vector.riotx.features.notifications.NotificationDrawerManager
|
||||||
import im.vector.riotx.features.popup.PopupAlertManager
|
import im.vector.riotx.features.popup.PopupAlertManager
|
||||||
import im.vector.riotx.features.popup.VectorAlert
|
|
||||||
import im.vector.riotx.features.popup.VerificationVectorAlert
|
import im.vector.riotx.features.popup.VerificationVectorAlert
|
||||||
import im.vector.riotx.features.rageshake.VectorUncaughtExceptionHandler
|
import im.vector.riotx.features.rageshake.VectorUncaughtExceptionHandler
|
||||||
import im.vector.riotx.features.settings.VectorPreferences
|
import im.vector.riotx.features.settings.VectorPreferences
|
||||||
|
|
|
@ -91,7 +91,7 @@ class HomeDetailFragment @Inject constructor(
|
||||||
it.unknownSessions.invoke()?.let { unknownDevices ->
|
it.unknownSessions.invoke()?.let { unknownDevices ->
|
||||||
Timber.v("## Detector - ${unknownDevices.size} Unknown sessions")
|
Timber.v("## Detector - ${unknownDevices.size} Unknown sessions")
|
||||||
unknownDevices.forEachIndexed { index, deviceInfo ->
|
unknownDevices.forEachIndexed { index, deviceInfo ->
|
||||||
Timber.v("## Detector - #${index} deviceId:${deviceInfo.second.deviceId} lastSeenTs:${deviceInfo.second.lastSeenTs}")
|
Timber.v("## Detector - #$index deviceId:${deviceInfo.second.deviceId} lastSeenTs:${deviceInfo.second.lastSeenTs}")
|
||||||
}
|
}
|
||||||
if (it.canCrossSign && unknownDevices.isNotEmpty()) {
|
if (it.canCrossSign && unknownDevices.isNotEmpty()) {
|
||||||
val newest = unknownDevices.first().second
|
val newest = unknownDevices.first().second
|
||||||
|
|
|
@ -16,15 +16,7 @@
|
||||||
|
|
||||||
package im.vector.riotx.features.home
|
package im.vector.riotx.features.home
|
||||||
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
|
||||||
import im.vector.matrix.android.api.session.Session
|
|
||||||
import im.vector.matrix.android.api.util.NoOpCancellable
|
|
||||||
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.rx
|
|
||||||
import im.vector.matrix.rx.singleBuilder
|
|
||||||
import im.vector.riotx.core.platform.VectorSharedActionViewModel
|
import im.vector.riotx.core.platform.VectorSharedActionViewModel
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class HomeSharedActionViewModel @Inject constructor() : VectorSharedActionViewModel<HomeActivitySharedAction>() {
|
class HomeSharedActionViewModel @Inject constructor() : VectorSharedActionViewModel<HomeActivitySharedAction>() {
|
||||||
|
|
|
@ -36,8 +36,8 @@ import im.vector.riotx.core.platform.VectorViewModel
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
|
|
||||||
data class UnknownDevicesState(
|
data class UnknownDevicesState(
|
||||||
val unknownSessions: Async<List<Pair<MatrixItem?,DeviceInfo>>?> = Uninitialized,
|
val unknownSessions: Async<List<Pair<MatrixItem?, DeviceInfo>>?> = Uninitialized,
|
||||||
val verifiedSessions: Async<List<Pair<MatrixItem?,DeviceInfo>>?> = Uninitialized,
|
val verifiedSessions: Async<List<Pair<MatrixItem?, DeviceInfo>>?> = Uninitialized,
|
||||||
val canCrossSign: Boolean = false
|
val canCrossSign: Boolean = false
|
||||||
) : MvRxState
|
) : MvRxState
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ import android.app.Activity
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import im.vector.riotx.features.popup.PopupAlertManager
|
import im.vector.riotx.features.popup.PopupAlertManager
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
class VectorActivityLifecycleCallbacks constructor(private val popupAlertManager: PopupAlertManager) : Application.ActivityLifecycleCallbacks {
|
class VectorActivityLifecycleCallbacks constructor(private val popupAlertManager: PopupAlertManager) : Application.ActivityLifecycleCallbacks {
|
||||||
override fun onActivityPaused(activity: Activity) {
|
override fun onActivityPaused(activity: Activity) {
|
||||||
|
|
Loading…
Reference in a new issue