bump crypto sdk to 0.3.16

This commit is contained in:
Valere 2023-11-13 22:23:11 +01:00
parent 979324da84
commit b61b2b6f16
5 changed files with 17 additions and 16 deletions

View File

@ -215,7 +215,7 @@ dependencies {
implementation libs.google.phonenumber implementation libs.google.phonenumber
implementation("org.matrix.rustcomponents:crypto-android:0.3.15") implementation("org.matrix.rustcomponents:crypto-android:0.3.16")
// api project(":library:rustCrypto") // api project(":library:rustCrypto")
testImplementation libs.tests.junit testImplementation libs.tests.junit

View File

@ -240,7 +240,8 @@ interface CryptoService {
toDevice: ToDeviceSyncResponse?, toDevice: ToDeviceSyncResponse?,
deviceChanges: DeviceListResponse?, deviceChanges: DeviceListResponse?,
keyCounts: DeviceOneTimeKeysCountSyncResponse?, keyCounts: DeviceOneTimeKeysCountSyncResponse?,
deviceUnusedFallbackKeyTypes: List<String>?) deviceUnusedFallbackKeyTypes: List<String>?,
nextBatch: String?)
suspend fun onLiveEvent(roomId: String, event: Event, isInitialSync: Boolean, cryptoStoreAggregator: CryptoStoreAggregator?) suspend fun onLiveEvent(roomId: String, event: Event, isInitialSync: Boolean, cryptoStoreAggregator: CryptoStoreAggregator?)
suspend fun onStateEvent(roomId: String, event: Event, cryptoStoreAggregator: CryptoStoreAggregator?) {} suspend fun onStateEvent(roomId: String, event: Event, cryptoStoreAggregator: CryptoStoreAggregator?) {}

View File

@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.crypto
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.asLiveData import androidx.lifecycle.asLiveData
import com.squareup.moshi.Moshi import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.channelFlow import kotlinx.coroutines.flow.channelFlow
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
@ -262,6 +261,7 @@ internal class OlmMachine @Inject constructor(
deviceChanges: DeviceListResponse?, deviceChanges: DeviceListResponse?,
keyCounts: DeviceOneTimeKeysCountSyncResponse?, keyCounts: DeviceOneTimeKeysCountSyncResponse?,
deviceUnusedFallbackKeyTypes: List<String>?, deviceUnusedFallbackKeyTypes: List<String>?,
nextBatch: String?
): ToDeviceSyncResponse { ): ToDeviceSyncResponse {
val response = withContext(coroutineDispatchers.io) { val response = withContext(coroutineDispatchers.io) {
val counts: MutableMap<String, Int> = mutableMapOf() val counts: MutableMap<String, Int> = mutableMapOf()
@ -281,18 +281,16 @@ internal class OlmMachine @Inject constructor(
val events = adapter.toJson(toDevice ?: ToDeviceSyncResponse()) val events = adapter.toJson(toDevice ?: ToDeviceSyncResponse())
// field pass in the list of unused fallback keys here // field pass in the list of unused fallback keys here
val receiveSyncChanges = inner.receiveSyncChanges(events, devices, counts, deviceUnusedFallbackKeyTypes) val receiveSyncChanges = inner.receiveSyncChanges(events, devices, counts, deviceUnusedFallbackKeyTypes, nextBatch ?: "")
val outAdapter = moshi.adapter<List<Event>>( val outAdapter = moshi.adapter(Event::class.java)
Types.newParameterizedType(
List::class.java, // we don't need to use `roomKeyInfos` as we are for now we are
Event::class.java, // checking the returned to devices to check for room keys.
String::class.java, // XXX Anyhow there is now proper signaling we should soon stop parsing them manually
Integer::class.java, receiveSyncChanges.toDeviceEvents.map {
Any::class.java, outAdapter.fromJson(it) ?: Event()
) }
)
outAdapter.fromJson(receiveSyncChanges) ?: emptyList()
} }
// We may get cross signing keys over a to-device event, update our listeners. // We may get cross signing keys over a to-device event, update our listeners.

View File

@ -618,9 +618,10 @@ internal class RustCryptoService @Inject constructor(
deviceChanges: DeviceListResponse?, deviceChanges: DeviceListResponse?,
keyCounts: DeviceOneTimeKeysCountSyncResponse?, keyCounts: DeviceOneTimeKeysCountSyncResponse?,
deviceUnusedFallbackKeyTypes: List<String>?, deviceUnusedFallbackKeyTypes: List<String>?,
nextBatch: String?,
) { ) {
// Decrypt and handle our to-device events // Decrypt and handle our to-device events
val toDeviceEvents = this.olmMachine.receiveSyncChanges(toDevice, deviceChanges, keyCounts, deviceUnusedFallbackKeyTypes) val toDeviceEvents = this.olmMachine.receiveSyncChanges(toDevice, deviceChanges, keyCounts, deviceUnusedFallbackKeyTypes, nextBatch)
// Notify the our listeners about room keys so decryption is retried. // Notify the our listeners about room keys so decryption is retried.
toDeviceEvents.events.orEmpty().forEach { event -> toDeviceEvents.events.orEmpty().forEach { event ->

View File

@ -184,7 +184,8 @@ internal class SyncResponseHandler @Inject constructor(
syncResponse.toDevice, syncResponse.toDevice,
syncResponse.deviceLists, syncResponse.deviceLists,
syncResponse.deviceOneTimeKeysCount, syncResponse.deviceOneTimeKeysCount,
syncResponse.deviceUnusedFallbackKeyTypes syncResponse.deviceUnusedFallbackKeyTypes,
syncResponse.nextBatch
) )
}.also { }.also {
Timber.v("Finish handling toDevice in $it ms") Timber.v("Finish handling toDevice in $it ms")