Skip to content

Commit 454ba7b

Browse files
authored
Merge branch 'develop' into feature/bca/clean_up_legacy_crypto
2 parents d4c1416 + b14338d commit 454ba7b

File tree

23 files changed

+203
-23
lines changed

23 files changed

+203
-23
lines changed

changelog.d/8658.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove unused WebRTC dependency

changelog.d/8662.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Take into account boolean "io.element.disable_network_constraint" from the .well-known file.

matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/data/DiscoveryInformation.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,11 @@ data class DiscoveryInformation(
3636
* Note: matrix.org does not send this field
3737
*/
3838
@Json(name = "m.identity_server")
39-
val identityServer: WellKnownBaseConfig? = null
39+
val identityServer: WellKnownBaseConfig? = null,
40+
41+
/**
42+
* If set to true, the SDK will not use the network constraint when configuring Worker for the WorkManager.
43+
*/
44+
@Json(name = "io.element.disable_network_constraint")
45+
val disableNetworkConstraint: Boolean? = null,
4046
)

matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/data/WellKnown.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,10 @@ data class WellKnown(
6161
*/
6262
@Json(name = "org.matrix.msc2965.authentication")
6363
val unstableDelegatedAuthConfig: DelegatedAuthConfig? = null,
64+
65+
/**
66+
* If set to true, the SDK will not use the network constraint when configuring Worker for the WorkManager.
67+
*/
68+
@Json(name = "io.element.disable_network_constraint")
69+
val disableNetworkConstraint: Boolean? = null,
6470
)

matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/homeserver/HomeServerCapabilities.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ data class HomeServerCapabilities(
9090
* Authentication issuer for use with MSC3824 delegated OIDC, provided in Wellknown.
9191
*/
9292
val authenticationIssuer: String? = null,
93+
94+
/**
95+
* If set to true, the SDK will not use the network constraint when configuring Worker for the WorkManager, provided in Wellknown.
96+
*/
97+
val disableNetworkConstraint: Boolean? = null,
9398
) {
9499

95100
enum class RoomCapabilitySupport {

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo050
7070
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo051
7171
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo052
7272
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo053
73+
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo054
7374
import org.matrix.android.sdk.internal.util.Normalizer
7475
import org.matrix.android.sdk.internal.util.database.MatrixRealmMigration
7576
import javax.inject.Inject
@@ -78,7 +79,7 @@ internal class RealmSessionStoreMigration @Inject constructor(
7879
private val normalizer: Normalizer
7980
) : MatrixRealmMigration(
8081
dbName = "Session",
81-
schemaVersion = 53L,
82+
schemaVersion = 54L,
8283
) {
8384
/**
8485
* Forces all RealmSessionStoreMigration instances to be equal.
@@ -141,5 +142,6 @@ internal class RealmSessionStoreMigration @Inject constructor(
141142
if (oldVersion < 51) MigrateSessionTo051(realm).perform()
142143
if (oldVersion < 52) MigrateSessionTo052(realm).perform()
143144
if (oldVersion < 53) MigrateSessionTo053(realm).perform()
145+
if (oldVersion < 54) MigrateSessionTo054(realm).perform()
144146
}
145147
}

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/HomeServerCapabilitiesMapper.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ internal object HomeServerCapabilitiesMapper {
5050
canRedactRelatedEvents = entity.canRedactEventWithRelations,
5151
externalAccountManagementUrl = entity.externalAccountManagementUrl,
5252
authenticationIssuer = entity.authenticationIssuer,
53+
disableNetworkConstraint = entity.disableNetworkConstraint,
5354
)
5455
}
5556

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2023 The Matrix.org Foundation C.I.C.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.matrix.android.sdk.internal.database.migration
18+
19+
import io.realm.DynamicRealm
20+
import org.matrix.android.sdk.internal.database.model.HomeServerCapabilitiesEntityFields
21+
import org.matrix.android.sdk.internal.extensions.forceRefreshOfHomeServerCapabilities
22+
import org.matrix.android.sdk.internal.util.database.RealmMigrator
23+
24+
internal class MigrateSessionTo054(realm: DynamicRealm) : RealmMigrator(realm, 54) {
25+
override fun doMigrate(realm: DynamicRealm) {
26+
realm.schema.get("HomeServerCapabilitiesEntity")
27+
?.addField(HomeServerCapabilitiesEntityFields.DISABLE_NETWORK_CONSTRAINT, Boolean::class.java)
28+
?.setNullable(HomeServerCapabilitiesEntityFields.DISABLE_NETWORK_CONSTRAINT, true)
29+
?.forceRefreshOfHomeServerCapabilities()
30+
}
31+
}

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/HomeServerCapabilitiesEntity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ internal open class HomeServerCapabilitiesEntity(
3737
var canRedactEventWithRelations: Boolean = false,
3838
var externalAccountManagementUrl: String? = null,
3939
var authenticationIssuer: String? = null,
40+
var disableNetworkConstraint: Boolean? = null,
4041
) : RealmObject() {
4142

4243
companion object

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/WorkManagerProvider.kt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ import kotlinx.coroutines.CoroutineScope
3030
import kotlinx.coroutines.launch
3131
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
3232
import org.matrix.android.sdk.internal.session.SessionScope
33+
import org.matrix.android.sdk.internal.session.workmanager.WorkManagerConfig
3334
import org.matrix.android.sdk.internal.worker.MatrixWorkerFactory
35+
import timber.log.Timber
3436
import java.util.concurrent.TimeUnit
3537
import javax.inject.Inject
3638

@@ -102,12 +104,20 @@ internal class WorkManagerProvider @Inject constructor(
102104
companion object {
103105
private const val MATRIX_SDK_TAG_PREFIX = "MatrixSDK-"
104106

105-
/**
106-
* Default constraints: connected network.
107-
*/
108-
val workConstraints = Constraints.Builder()
109-
.setRequiredNetworkType(NetworkType.CONNECTED)
110-
.build()
107+
fun getWorkConstraints(
108+
workManagerConfig: WorkManagerConfig,
109+
): Constraints {
110+
val withNetworkConstraint = workManagerConfig.withNetworkConstraint()
111+
return Constraints.Builder()
112+
.apply {
113+
if (withNetworkConstraint) {
114+
setRequiredNetworkType(NetworkType.CONNECTED)
115+
} else {
116+
Timber.w("Network constraint is disabled")
117+
}
118+
}
119+
.build()
120+
}
111121

112122
// Use min value, smaller value will be ignored
113123
const val BACKOFF_DELAY_MILLIS = WorkRequest.MIN_BACKOFF_MILLIS

0 commit comments

Comments
 (0)