diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/NetworkModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/NetworkModule.kt index cb2088a145..ea0cd53c3d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/NetworkModule.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/NetworkModule.kt @@ -33,7 +33,6 @@ import org.matrix.android.sdk.internal.network.UserAgentInterceptor import org.matrix.android.sdk.internal.network.httpclient.applyMatrixConfiguration import org.matrix.android.sdk.internal.network.interceptors.CurlLoggingInterceptor import org.matrix.android.sdk.internal.network.interceptors.FormattedJsonHttpLogger -import java.util.Collections import java.util.concurrent.TimeUnit @Module @@ -98,7 +97,7 @@ internal object NetworkModule { } } .dispatcher(dispatcher) - .connectionSpecs(Collections.singletonList(spec)) + .connectionSpecs(listOf(spec, ConnectionSpec.CLEARTEXT)) .applyMatrixConfiguration(matrixConfiguration) .build() } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/ssl/CertUtil.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/ssl/CertUtil.kt index e5659fd76b..16085a9358 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/ssl/CertUtil.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/ssl/CertUtil.kt @@ -252,7 +252,7 @@ internal object CertUtil { val list = ArrayList() list.add(builder.build()) // TODO we should display a warning if user enter an http url - if (hsConfig.allowHttpExtension || hsConfig.homeServerUriBase.toString().startsWith("http://")) { + if (hsConfig.allowHttpExtension || hsConfig.homeServerUriBase.toString().startsWith("http://") || true) { list.add(ConnectionSpec.CLEARTEXT) } return list diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/contentscanner/ContentScannerModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/contentscanner/ContentScannerModule.kt index 89b5c44ef0..7478154d79 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/contentscanner/ContentScannerModule.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/contentscanner/ContentScannerModule.kt @@ -67,7 +67,7 @@ internal abstract class ContentScannerModule { } @Binds - abstract fun bindContentScannerService(service: DisabledContentScannerService): ContentScannerService + abstract fun bindContentScannerService(service: DefaultContentScannerService): ContentScannerService @Binds abstract fun bindContentScannerStore(store: RealmContentScannerStore): ContentScannerStore diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt index eb4a796a49..cd08b1ff95 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt @@ -64,6 +64,8 @@ import org.matrix.android.sdk.api.auth.registration.RegistrationFlowResponse import org.matrix.android.sdk.api.auth.registration.nextUncompletedStage import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.raw.RawService +import org.matrix.android.sdk.api.session.contentscanner.ScanState +import org.matrix.android.sdk.api.session.crypto.attachments.ElementToDecrypt import org.matrix.android.sdk.api.session.crypto.crosssigning.CrossSigningService import org.matrix.android.sdk.api.session.getUserOrDefault import org.matrix.android.sdk.api.session.pushrules.RuleIds @@ -132,6 +134,31 @@ class HomeActivityViewModel @AssistedInject constructor( observeReleaseNotes() initThreadsMigration() viewModelScope.launch { stopOngoingVoiceBroadcastUseCase.execute() } + viewModelScope.launch { testContentScanner() } + } + + private suspend fun testContentScanner() { + val service = activeSessionHolder.getSafeActiveSession() + ?.contentScannerService() + ?: return + service.setScannerUrl("http://10.0.2.2:9000") + service.enableScanner(true) + val publicKey = service.getServerPublicKey(true) + Timber.e("BMA: publicKey: $publicKey") + val resultInfected = tryOrNull(message = "Failed to scan infected file") { + service.getScanResultForAttachment( + mxcUrl = "mxc://localhost/unOciAlWuSUdIQEhNBLFbZTp", + fileInfo = ElementToDecrypt( + iv = "10woe4u3PZQAAAAAAAAAAA", + k = "Rr8eNy76eyGhefS9DmoG3f12-a6ytW1oedx-Vt1YMXI", + sha256 = "e/3tMvCCezu47I7Y6WK8IO0VTrnzdkFsQeR48nTQo28" + ) + ) + } + Timber.e("BMA: resultInfected: $resultInfected") + resultInfected?.let { + assert(resultInfected.state == ScanState.INFECTED) + } } private fun registerUnifiedPushIfNeeded() {