Skip to content

Commit 1a94114

Browse files
authored
Merge pull request #8679 from vector-im/feature/bca/bump_crypto_sdk_version
bump crypto sdk to 0.3.16
2 parents 98e09ee + d339107 commit 1a94114

File tree

6 files changed

+21
-17
lines changed

6 files changed

+21
-17
lines changed

changelog.d/8679.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bump crypto sdk bindings to v0.3.16

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: 13 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
@@ -254,6 +253,8 @@ internal class OlmMachine @Inject constructor(
254253
*
255254
* @param deviceUnusedFallbackKeyTypes The key algorithms for which the server has an unused fallback key for the device.
256255
*
256+
* @param nextBatch The batch token to pass in the next sync request.
257+
*
257258
* @return The handled events, decrypted if needed (secrets are zeroised).
258259
*/
259260
@Throws(CryptoStoreException::class)
@@ -262,6 +263,7 @@ internal class OlmMachine @Inject constructor(
262263
deviceChanges: DeviceListResponse?,
263264
keyCounts: DeviceOneTimeKeysCountSyncResponse?,
264265
deviceUnusedFallbackKeyTypes: List<String>?,
266+
nextBatch: String?
265267
): ToDeviceSyncResponse {
266268
val response = withContext(coroutineDispatchers.io) {
267269
val counts: MutableMap<String, Int> = mutableMapOf()
@@ -281,18 +283,16 @@ internal class OlmMachine @Inject constructor(
281283
val events = adapter.toJson(toDevice ?: ToDeviceSyncResponse())
282284

283285
// 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()
286+
val receiveSyncChanges = inner.receiveSyncChanges(events, devices, counts, deviceUnusedFallbackKeyTypes, nextBatch ?: "")
287+
288+
val outAdapter = moshi.adapter(Event::class.java)
289+
290+
// we don't need to use `roomKeyInfos` as for now we are manually
291+
// checking the returned to devices to check for room keys.
292+
// XXX Anyhow there is now proper signaling we should soon stop parsing them manually
293+
receiveSyncChanges.toDeviceEvents.map {
294+
outAdapter.fromJson(it) ?: Event()
295+
}
296296
}
297297

298298
// 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)