From 3fa3eb11298543006d8e9de983dfa670e5215b48 Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 14 Mar 2024 10:54:31 +0100 Subject: [PATCH] fix rust device to CryptoDeviceInfo mapping --- .../matrix/android/sdk/internal/crypto/Device.kt | 2 -- .../android/sdk/internal/crypto/OlmMachine.kt | 14 +++++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/Device.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/Device.kt index 0bd6ed06d1..d2865f0f65 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/Device.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/Device.kt @@ -172,8 +172,6 @@ internal class Device @AssistedInject constructor( * This will not fetch out fresh data from the Rust side. **/ internal fun toCryptoDeviceInfo(): CryptoDeviceInfo { -// val keys = innerDevice.keys.map { (keyId, key) -> keyId to key }.toMap() - return CryptoDeviceInfo( deviceId = innerDevice.deviceId, userId = innerDevice.userId, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OlmMachine.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OlmMachine.kt index f90ae4a345..4fe59fb1dd 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OlmMachine.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OlmMachine.kt @@ -189,18 +189,21 @@ internal class OlmMachine @Inject constructor( is OwnUserIdentity -> ownIdentity.trustsOurOwnDevice() else -> false } + val ownDevice = inner.getDevice(userId(), deviceId, 0u)!! + val creationTime = ownDevice.firstTimeSeenTs.toLong() return CryptoDeviceInfo( deviceId(), userId(), - // TODO pass the algorithms here. - listOf(), + ownDevice.algorithms, keys, mapOf(), - UnsignedDeviceInfo(), + UnsignedDeviceInfo( + deviceDisplayName = ownDevice.displayName + ), DeviceTrustLevel(crossSigningVerified, locallyVerified = true), false, - null + creationTime ) } @@ -291,7 +294,7 @@ internal class OlmMachine @Inject constructor( // checking the returned to devices to check for room keys. // XXX Anyhow there is now proper signaling we should soon stop parsing them manually receiveSyncChanges.toDeviceEvents.map { - outAdapter.fromJson(it) ?: Event() + outAdapter.fromJson(it) ?: Event() } } @@ -882,6 +885,7 @@ internal class OlmMachine @Inject constructor( inner.queryMissingSecretsFromOtherSessions() } } + @Throws(CryptoStoreException::class) suspend fun enableBackupV1(key: String, version: String) { return withContext(coroutineDispatchers.computation) {