Realm 10: upgrade lib and make it works on our current code.

This commit is contained in:
ganfra 2020-11-03 16:53:30 +01:00
parent 0db1095373
commit 9f3f5d8053
6 changed files with 8 additions and 4 deletions

View File

@ -35,7 +35,7 @@ Build 🧱:
- -
Other changes: Other changes:
- - Upgrade Realm dependency to 10.0.0
Changes in Element 1.0.9 (2020-10-16) Changes in Element 1.0.9 (2020-10-16)
=================================================== ===================================================

View File

@ -9,7 +9,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath "io.realm:realm-gradle-plugin:6.1.0" classpath "io.realm:realm-gradle-plugin:10.0.0"
} }
} }
@ -149,7 +149,7 @@ dependencies {
implementation 'androidx.exifinterface:exifinterface:1.3.0' implementation 'androidx.exifinterface:exifinterface:1.3.0'
// Database // Database
implementation 'com.github.Zhuinden:realm-monarchy:0.5.1' implementation 'com.github.Zhuinden:realm-monarchy:0.7.1'
kapt 'dk.ilios:realmfieldnameshelper:1.1.1' kapt 'dk.ilios:realmfieldnameshelper:1.1.1'
// Work // Work

View File

@ -123,6 +123,7 @@ internal abstract class CryptoModule {
} }
.name("crypto_store.realm") .name("crypto_store.realm")
.modules(RealmCryptoStoreModule()) .modules(RealmCryptoStoreModule())
.allowWritesOnUiThread(true)
.schemaVersion(RealmCryptoStoreMigration.CRYPTO_STORE_SCHEMA_VERSION) .schemaVersion(RealmCryptoStoreMigration.CRYPTO_STORE_SCHEMA_VERSION)
.migration(realmCryptoStoreMigration) .migration(realmCryptoStoreMigration)
.build() .build()

View File

@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.database
import android.content.Context import android.content.Context
import android.util.Base64 import android.util.Base64
import androidx.core.content.edit import androidx.core.content.edit
import io.realm.Realm
import org.matrix.android.sdk.BuildConfig import org.matrix.android.sdk.BuildConfig
import org.matrix.android.sdk.internal.session.securestorage.SecretStoringUtils import org.matrix.android.sdk.internal.session.securestorage.SecretStoringUtils
import io.realm.RealmConfiguration import io.realm.RealmConfiguration
@ -46,7 +47,7 @@ internal class RealmKeysUtils @Inject constructor(context: Context,
private val sharedPreferences = context.getSharedPreferences("im.vector.matrix.android.keys", Context.MODE_PRIVATE) private val sharedPreferences = context.getSharedPreferences("im.vector.matrix.android.keys", Context.MODE_PRIVATE)
private fun generateKeyForRealm(): ByteArray { private fun generateKeyForRealm(): ByteArray {
val keyForRealm = ByteArray(RealmConfiguration.KEY_LENGTH) val keyForRealm = ByteArray(Realm.ENCRYPTION_KEY_LENGTH)
rng.nextBytes(keyForRealm) rng.nextBytes(keyForRealm)
return keyForRealm return keyForRealm
} }

View File

@ -69,6 +69,7 @@ internal class SessionRealmConfigurationFactory @Inject constructor(
.apply { .apply {
realmKeysUtils.configureEncryption(this, SessionModule.getKeyAlias(userMd5)) realmKeysUtils.configureEncryption(this, SessionModule.getKeyAlias(userMd5))
} }
.allowWritesOnUiThread(true)
.modules(SessionRealmModule()) .modules(SessionRealmModule())
.schemaVersion(RealmSessionStoreMigration.SESSION_STORE_SCHEMA_VERSION) .schemaVersion(RealmSessionStoreMigration.SESSION_STORE_SCHEMA_VERSION)
.migration(migration) .migration(migration)

View File

@ -66,6 +66,7 @@ internal abstract class IdentityModule {
.apply { .apply {
realmKeysUtils.configureEncryption(this, SessionModule.getKeyAlias(userMd5)) realmKeysUtils.configureEncryption(this, SessionModule.getKeyAlias(userMd5))
} }
.allowWritesOnUiThread(true)
.modules(IdentityRealmModule()) .modules(IdentityRealmModule())
.build() .build()
} }