Skip to content

Commit b61b2b6

Browse files
committed
bump crypto sdk to 0.3.16
1 parent 979324d commit b61b2b6

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

matrix-sdk-android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ dependencies {
215215

216216
implementation libs.google.phonenumber
217217

218-
implementation("org.matrix.rustcomponents:crypto-android:0.3.15")
218+
implementation("org.matrix.rustcomponents:crypto-android:0.3.16")
219219
// api project(":library:rustCrypto")
220220

221221
testImplementation libs.tests.junit

matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/CryptoService.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ interface CryptoService {
240240
toDevice: ToDeviceSyncResponse?,
241241
deviceChanges: DeviceListResponse?,
242242
keyCounts: DeviceOneTimeKeysCountSyncResponse?,
243-
deviceUnusedFallbackKeyTypes: List<String>?)
243+
deviceUnusedFallbackKeyTypes: List<String>?,
244+
nextBatch: String?)
244245

245246
suspend fun onLiveEvent(roomId: String, event: Event, isInitialSync: Boolean, cryptoStoreAggregator: CryptoStoreAggregator?)
246247
suspend fun onStateEvent(roomId: String, event: Event, cryptoStoreAggregator: CryptoStoreAggregator?) {}

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OlmMachine.kt

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.crypto
1919
import androidx.lifecycle.LiveData
2020
import androidx.lifecycle.asLiveData
2121
import com.squareup.moshi.Moshi
22-
import com.squareup.moshi.Types
2322
import kotlinx.coroutines.flow.Flow
2423
import kotlinx.coroutines.flow.channelFlow
2524
import kotlinx.coroutines.runBlocking
@@ -262,6 +261,7 @@ internal class OlmMachine @Inject constructor(
262261
deviceChanges: DeviceListResponse?,
263262
keyCounts: DeviceOneTimeKeysCountSyncResponse?,
264263
deviceUnusedFallbackKeyTypes: List<String>?,
264+
nextBatch: String?
265265
): ToDeviceSyncResponse {
266266
val response = withContext(coroutineDispatchers.io) {
267267
val counts: MutableMap<String, Int> = mutableMapOf()
@@ -281,18 +281,16 @@ internal class OlmMachine @Inject constructor(
281281
val events = adapter.toJson(toDevice ?: ToDeviceSyncResponse())
282282

283283
// field pass in the list of unused fallback keys here
284-
val receiveSyncChanges = inner.receiveSyncChanges(events, devices, counts, deviceUnusedFallbackKeyTypes)
285-
286-
val outAdapter = moshi.adapter<List<Event>>(
287-
Types.newParameterizedType(
288-
List::class.java,
289-
Event::class.java,
290-
String::class.java,
291-
Integer::class.java,
292-
Any::class.java,
293-
)
294-
)
295-
outAdapter.fromJson(receiveSyncChanges) ?: emptyList()
284+
val receiveSyncChanges = inner.receiveSyncChanges(events, devices, counts, deviceUnusedFallbackKeyTypes, nextBatch ?: "")
285+
286+
val outAdapter = moshi.adapter(Event::class.java)
287+
288+
// we don't need to use `roomKeyInfos` as we are for now we are
289+
// checking the returned to devices to check for room keys.
290+
// XXX Anyhow there is now proper signaling we should soon stop parsing them manually
291+
receiveSyncChanges.toDeviceEvents.map {
292+
outAdapter.fromJson(it) ?: Event()
293+
}
296294
}
297295

298296
// We may get cross signing keys over a to-device event, update our listeners.

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RustCryptoService.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,10 @@ internal class RustCryptoService @Inject constructor(
618618
deviceChanges: DeviceListResponse?,
619619
keyCounts: DeviceOneTimeKeysCountSyncResponse?,
620620
deviceUnusedFallbackKeyTypes: List<String>?,
621+
nextBatch: String?,
621622
) {
622623
// Decrypt and handle our to-device events
623-
val toDeviceEvents = this.olmMachine.receiveSyncChanges(toDevice, deviceChanges, keyCounts, deviceUnusedFallbackKeyTypes)
624+
val toDeviceEvents = this.olmMachine.receiveSyncChanges(toDevice, deviceChanges, keyCounts, deviceUnusedFallbackKeyTypes, nextBatch)
624625

625626
// Notify the our listeners about room keys so decryption is retried.
626627
toDeviceEvents.events.orEmpty().forEach { event ->

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncResponseHandler.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ internal class SyncResponseHandler @Inject constructor(
184184
syncResponse.toDevice,
185185
syncResponse.deviceLists,
186186
syncResponse.deviceOneTimeKeysCount,
187-
syncResponse.deviceUnusedFallbackKeyTypes
187+
syncResponse.deviceUnusedFallbackKeyTypes,
188+
syncResponse.nextBatch
188189
)
189190
}.also {
190191
Timber.v("Finish handling toDevice in $it ms")

0 commit comments

Comments
 (0)