mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 10:32:34 +00:00
Give the native call component its view of Matrix
The factory lives in libraries/matrix/impl because that is the only module compiled against the Rust SDK, and is app-scoped because a call is started for whichever account it belongs to rather than the one on screen. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -13,8 +13,18 @@ android {
|
|||||||
namespace = "io.element.android.features.callnative.api"
|
namespace = "io.element.android.features.callnative.api"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Temporary: `-PelementCallLocalVersion` points this at a locally published build of
|
||||||
|
// element-call-android. Goes with the repositories in settings.gradle.kts.
|
||||||
|
val elementCallVersion: String = providers.gradleProperty("elementCallLocalVersion")
|
||||||
|
.getOrElse(libs.versions.element.call.get())
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// api, not implementation: CallData is part of NativeCallEntryPoint's signature.
|
// api, not implementation: ElementCallMatrixTransport is part of ElementCallTransportFactory's
|
||||||
|
// signature, and CallData of NativeCallEntryPoint's.
|
||||||
|
// api, so that consumers of this module inherit the versions the BOM pins - the artifact
|
||||||
|
// below is declared without one.
|
||||||
|
api(platform("io.element.android:element-call-bom:$elementCallVersion"))
|
||||||
|
api(libs.element.call.api)
|
||||||
api(projects.features.call.api)
|
api(projects.features.call.api)
|
||||||
implementation(projects.libraries.architecture)
|
implementation(projects.libraries.architecture)
|
||||||
implementation(projects.libraries.matrix.api)
|
implementation(projects.libraries.matrix.api)
|
||||||
|
|||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2026 Element Creations Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.callnative.api
|
||||||
|
|
||||||
|
import io.element.android.call.api.matrix.ElementCallMatrixTransport
|
||||||
|
import io.element.android.libraries.matrix.api.MatrixClient
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes the native call's view of Matrix for a session.
|
||||||
|
*
|
||||||
|
* The component's turnkey transport is built over a raw Rust SDK client, and only
|
||||||
|
* `libraries/matrix/impl` is compiled against the SDK. This is the seam that keeps it that way: the
|
||||||
|
* implementation lives there, everything else takes a [MatrixClient] and asks.
|
||||||
|
*
|
||||||
|
* A factory rather than a binding for the transport itself, because the call is started from app scope
|
||||||
|
* - a call can be placed for an account that is not the one on screen - and the session it belongs to
|
||||||
|
* is known only as an id until a client is fetched for it.
|
||||||
|
*/
|
||||||
|
fun interface ElementCallTransportFactory {
|
||||||
|
fun create(client: MatrixClient): ElementCallMatrixTransport
|
||||||
|
}
|
||||||
@@ -20,16 +20,47 @@ android {
|
|||||||
|
|
||||||
setupDependencyInjection()
|
setupDependencyInjection()
|
||||||
|
|
||||||
|
// Temporary: `-PelementCallLocalVersion` points this at a locally published build of
|
||||||
|
// element-call-android, because the library has no remote repository yet. Goes with the mavenLocal
|
||||||
|
// block in settings.gradle.kts. Only the BOM carries a version; every other artifact follows it.
|
||||||
|
val elementCallVersion: String = providers.gradleProperty("elementCallLocalVersion")
|
||||||
|
.getOrElse(libs.versions.element.call.get())
|
||||||
|
|
||||||
|
val usesLocalRustSdk = file("${rootDir.path}/libraries/rustsdk/matrix-rust-sdk.aar").exists()
|
||||||
|
|
||||||
|
if (usesLocalRustSdk) {
|
||||||
|
// element-call-matrix declares the Rust SDK as an ordinary Maven dependency, so with the local
|
||||||
|
// AAR in place a debug classpath would carry two copies of org.matrix.rustcomponents.sdk.
|
||||||
|
// Point the library's dependency at the same local AAR the app is using.
|
||||||
|
configurations.matching { it.name.startsWith("debug") }.configureEach {
|
||||||
|
resolutionStrategy.dependencySubstitution {
|
||||||
|
substitute(module("org.matrix.rustcomponents:sdk-android"))
|
||||||
|
.using(project(":libraries:rustsdk"))
|
||||||
|
.because("the local Rust SDK AAR replaces the published one on debug builds")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
releaseImplementation(libs.matrix.sdk)
|
releaseImplementation(libs.matrix.sdk)
|
||||||
if (file("${rootDir.path}/libraries/rustsdk/matrix-rust-sdk.aar").exists()) {
|
if (usesLocalRustSdk) {
|
||||||
println("\nNote: Using local binary of the Rust SDK.\n")
|
println(
|
||||||
|
"\nNote: Using local binary of the Rust SDK." +
|
||||||
|
"\n element-call-matrix is substituted onto it as well, so the native call runs" +
|
||||||
|
"\n against this SDK rather than the one it was published against.\n"
|
||||||
|
)
|
||||||
debugImplementation(projects.libraries.rustsdk)
|
debugImplementation(projects.libraries.rustsdk)
|
||||||
} else {
|
} else {
|
||||||
debugImplementation(libs.matrix.sdk)
|
debugImplementation(libs.matrix.sdk)
|
||||||
}
|
}
|
||||||
implementation(variantOf(libs.rustls.platform.verifier) { artifactType("aar") })
|
implementation(variantOf(libs.rustls.platform.verifier) { artifactType("aar") })
|
||||||
|
|
||||||
|
// The native call's Matrix transport. Only this module may hand it a raw SDK client.
|
||||||
|
implementation(platform("io.element.android:element-call-bom:$elementCallVersion"))
|
||||||
|
implementation(libs.element.call.api)
|
||||||
|
implementation(projects.features.callnative.api)
|
||||||
|
implementation(libs.element.call.matrix)
|
||||||
|
|
||||||
implementation(projects.appconfig)
|
implementation(projects.appconfig)
|
||||||
implementation(projects.features.enterprise.api)
|
implementation(projects.features.enterprise.api)
|
||||||
implementation(projects.libraries.androidutils)
|
implementation(projects.libraries.androidutils)
|
||||||
|
|||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2026 Element Creations Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.libraries.matrix.impl.di
|
||||||
|
|
||||||
|
import dev.zacsweers.metro.AppScope
|
||||||
|
import dev.zacsweers.metro.ContributesBinding
|
||||||
|
import io.element.android.call.api.matrix.ElementCallMatrixTransport
|
||||||
|
import io.element.android.call.matrix.ElementCallSdkTransport
|
||||||
|
import io.element.android.features.callnative.api.ElementCallTransportFactory
|
||||||
|
import io.element.android.libraries.matrix.api.MatrixClient
|
||||||
|
import io.element.android.libraries.matrix.impl.RustMatrixClient
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gives the native call component its view of Matrix.
|
||||||
|
*
|
||||||
|
* Here because this is the only module in the app compiled against the Rust SDK, and the component's
|
||||||
|
* turnkey transport needs a raw SDK client. No feature module ever sees the SDK, the rule that no
|
||||||
|
* feature depends on `libraries/matrix/impl` still holds, and the SDK version contract is checked where
|
||||||
|
* the app's own SDK pin lives.
|
||||||
|
*
|
||||||
|
* The transport is built on the client's own coroutine scope, which is what ties it to the session: the
|
||||||
|
* component has no shutdown of its own, so cancelling that scope at logout is the only thing that stops
|
||||||
|
* the RTC core and its to-device subscription.
|
||||||
|
*/
|
||||||
|
@ContributesBinding(AppScope::class)
|
||||||
|
class DefaultElementCallTransportFactory : ElementCallTransportFactory {
|
||||||
|
override fun create(client: MatrixClient): ElementCallMatrixTransport {
|
||||||
|
return ElementCallSdkTransport(
|
||||||
|
client = (client as RustMatrixClient).innerClient,
|
||||||
|
sessionScope = client.sessionCoroutineScope,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user