crypto: Enable the use of unsigned ints for now and update the bindings wrapper
This commit is contained in:
parent
628f530633
commit
f01e2460e1
@ -70,6 +70,7 @@ allprojects {
|
|||||||
// Warnings are potential errors, so stop ignoring them
|
// Warnings are potential errors, so stop ignoring them
|
||||||
// You can override by passing `-PallWarningsAsErrors=false` in the command line
|
// You can override by passing `-PallWarningsAsErrors=false` in the command line
|
||||||
kotlinOptions.allWarningsAsErrors = project.getProperties().getOrDefault("allWarningsAsErrors", "true").toBoolean()
|
kotlinOptions.allWarningsAsErrors = project.getProperties().getOrDefault("allWarningsAsErrors", "true").toBoolean()
|
||||||
|
kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.ExperimentalUnsignedTypes"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ import org.matrix.android.sdk.internal.crypto.tasks.UploadKeysTask
|
|||||||
import org.matrix.android.sdk.internal.crypto.verification.DefaultVerificationService
|
import org.matrix.android.sdk.internal.crypto.verification.DefaultVerificationService
|
||||||
import org.matrix.android.sdk.internal.di.DeviceId
|
import org.matrix.android.sdk.internal.di.DeviceId
|
||||||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||||
|
import org.matrix.android.sdk.internal.di.SessionFilesDirectory
|
||||||
import org.matrix.android.sdk.internal.di.UserId
|
import org.matrix.android.sdk.internal.di.UserId
|
||||||
import org.matrix.android.sdk.internal.extensions.foldToCallback
|
import org.matrix.android.sdk.internal.extensions.foldToCallback
|
||||||
import org.matrix.android.sdk.internal.session.SessionScope
|
import org.matrix.android.sdk.internal.session.SessionScope
|
||||||
@ -97,6 +98,7 @@ import org.matrix.android.sdk.internal.util.JsonCanonicalizer
|
|||||||
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
||||||
import org.matrix.olm.OlmManager
|
import org.matrix.olm.OlmManager
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
import java.io.File
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.jvm.Throws
|
import kotlin.jvm.Throws
|
||||||
@ -120,6 +122,8 @@ internal class DefaultCryptoService @Inject constructor(
|
|||||||
private val userId: String,
|
private val userId: String,
|
||||||
@DeviceId
|
@DeviceId
|
||||||
private val deviceId: String?,
|
private val deviceId: String?,
|
||||||
|
@SessionFilesDirectory
|
||||||
|
private val dataDir: File,
|
||||||
private val myDeviceInfoHolder: Lazy<MyDeviceInfoHolder>,
|
private val myDeviceInfoHolder: Lazy<MyDeviceInfoHolder>,
|
||||||
// the crypto store
|
// the crypto store
|
||||||
private val cryptoStore: IMXCryptoStore,
|
private val cryptoStore: IMXCryptoStore,
|
||||||
@ -171,6 +175,7 @@ internal class DefaultCryptoService @Inject constructor(
|
|||||||
|
|
||||||
private val isStarting = AtomicBoolean(false)
|
private val isStarting = AtomicBoolean(false)
|
||||||
private val isStarted = AtomicBoolean(false)
|
private val isStarted = AtomicBoolean(false)
|
||||||
|
private var olmMachine: OlmMachine? = null
|
||||||
|
|
||||||
fun onStateEvent(roomId: String, event: Event) {
|
fun onStateEvent(roomId: String, event: Event) {
|
||||||
when (event.getClearType()) {
|
when (event.getClearType()) {
|
||||||
@ -310,7 +315,7 @@ internal class DefaultCryptoService @Inject constructor(
|
|||||||
* devices.
|
* devices.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
fun start() {
|
suspend fun start() {
|
||||||
cryptoCoroutineScope.launch(coroutineDispatchers.crypto) {
|
cryptoCoroutineScope.launch(coroutineDispatchers.crypto) {
|
||||||
internalStart()
|
internalStart()
|
||||||
}
|
}
|
||||||
@ -363,14 +368,14 @@ internal class DefaultCryptoService @Inject constructor(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
isStarting.set(true)
|
isStarting.set(true)
|
||||||
|
Timber.v("HELLLO WORLD STARTING CRYPTO")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val dataDir = "/data/data/im.vector.app.debug/files"
|
olmMachine = OlmMachine(userId, deviceId!!, dataDir)
|
||||||
val olmMachine = OlmMachine("@example:localhost", "DEVICEID", dataDir)
|
Timber.v("HELLLO WORLD STARTING CRYPTO ${olmMachine?.identityKeys()}")
|
||||||
Timber.v("HELLLO WORLD STARTING CRYPTO ${olmMachine.identityKeys()}")
|
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
Timber.v("HELLLO WORLD FAILED CRYPTO $throwable")
|
Timber.v("HELLLO WORLD FAILED CRYPTO $throwable")
|
||||||
}
|
}
|
||||||
Timber.v("HELLLO WORLD STARTING CRYPTO")
|
|
||||||
|
|
||||||
// Open the store
|
// Open the store
|
||||||
cryptoStore.open()
|
cryptoStore.open()
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal
|
package org.matrix.android.sdk.internal
|
||||||
|
|
||||||
import kotlinx.coroutines.withContext
|
import java.io.File
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import uniffi.olm.OlmMachine as InnerMachine
|
|
||||||
import uniffi.olm.Device as InnerDevice
|
import uniffi.olm.Device as InnerDevice
|
||||||
|
import uniffi.olm.OlmMachine as InnerMachine
|
||||||
import uniffi.olm.Sas as InnerSas
|
import uniffi.olm.Sas as InnerSas
|
||||||
|
|
||||||
class Device(inner: InnerDevice, machine: InnerMachine) {
|
class Device(inner: InnerDevice, machine: InnerMachine) {
|
||||||
@ -44,8 +44,8 @@ class Device(inner: InnerDevice, machine: InnerMachine) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OlmMachine(user_id: String, device_id: String, path: String) {
|
class OlmMachine(user_id: String, device_id: String, path: File) {
|
||||||
private val inner: InnerMachine = InnerMachine(user_id, device_id, path)
|
private val inner: InnerMachine = InnerMachine(user_id, device_id, path.toString())
|
||||||
|
|
||||||
fun userId(): String {
|
fun userId(): String {
|
||||||
return this.inner.userId()
|
return this.inner.userId()
|
||||||
@ -59,10 +59,6 @@ class OlmMachine(user_id: String, device_id: String, path: String) {
|
|||||||
return this.inner.identityKeys()
|
return this.inner.identityKeys()
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun slowUserId(): String = withContext(Dispatchers.Default) {
|
|
||||||
inner.slowUserId()
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun getDevice(user_id: String, device_id: String): Device? = withContext(Dispatchers.IO) {
|
suspend fun getDevice(user_id: String, device_id: String): Device? = withContext(Dispatchers.IO) {
|
||||||
when (val device: InnerDevice? = inner.getDevice(user_id, device_id)) {
|
when (val device: InnerDevice? = inner.getDevice(user_id, device_id)) {
|
||||||
null -> null
|
null -> null
|
||||||
|
Loading…
Reference in New Issue
Block a user