diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt index c9dfa06126..4b6d0fde63 100755 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt @@ -130,7 +130,6 @@ internal class DefaultCryptoService @Inject constructor( private val deviceId: String?, @SessionFilesDirectory private val dataDir: File, - private val myDeviceInfoHolder: Lazy, // the crypto store private val cryptoStore: IMXCryptoStore, // Set of parameters used to configure/customize the end-to-end crypto. @@ -218,7 +217,7 @@ internal class DefaultCryptoService @Inject constructor( } override fun getMyDevice(): CryptoDeviceInfo { - return myDeviceInfoHolder.get().myDevice + return olmMachine!!.ownDevice() } override fun fetchDevicesList(callback: MatrixCallback) { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/newCrypto.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/newCrypto.kt index c3f123ac6d..ff651d0de0 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/newCrypto.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/newCrypto.kt @@ -27,6 +27,9 @@ import org.matrix.android.sdk.internal.di.MoshiProvider import org.matrix.android.sdk.internal.session.sync.model.DeviceListResponse import org.matrix.android.sdk.internal.session.sync.model.DeviceOneTimeKeysCountSyncResponse import org.matrix.android.sdk.internal.session.sync.model.ToDeviceSyncResponse +import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo +import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustLevel +import org.matrix.android.sdk.internal.crypto.model.rest.UnsignedDeviceInfo import org.matrix.android.sdk.api.session.events.model.Content import timber.log.Timber import uniffi.olm.Device as InnerDevice @@ -67,6 +70,26 @@ class Device(inner: InnerDevice, machine: InnerMachine) { fun startVerification(): InnerSas { return this.machine.startVerification(this.inner) } + + fun toCryptoDeviceInfo(): CryptoDeviceInfo { + return CryptoDeviceInfo( + this.deviceId(), + this.userId(), + // TODO pass the algorithms here. + listOf(), + this.keys(), + // TODO pass the signatures here. + mapOf(), + // TODO pass the display name here. + UnsignedDeviceInfo(), + // TODO pass trust levels here + DeviceTrustLevel(false, false), + // TODO is the device blacklisted + false, + // TODO + null + ) + } } internal class OlmMachine(user_id: String, device_id: String, path: File) { @@ -84,6 +107,22 @@ internal class OlmMachine(user_id: String, device_id: String, path: File) { return this.inner.identityKeys() } + fun ownDevice(): CryptoDeviceInfo { + return CryptoDeviceInfo( + this.deviceId(), + this.userId(), + // TODO pass the algorithms here. + listOf(), + this.identityKeys(), + mapOf(), + UnsignedDeviceInfo(), + DeviceTrustLevel(false, true), + false, + null + ) + + } + suspend fun outgoingRequests(): List = withContext(Dispatchers.IO) { inner.outgoingRequests() }