Parse "io.element.disable_network_constraint" from login response, to ensure that the config is retrieved.

The add pusher worker can be configured before the .well-known config is retrieved.
This commit is contained in:
Benoit Marty 2023-10-12 18:12:49 +02:00
parent 973246819a
commit d4c6a46e90
13 changed files with 141 additions and 26 deletions

View file

@ -36,5 +36,11 @@ data class DiscoveryInformation(
* Note: matrix.org does not send this field * Note: matrix.org does not send this field
*/ */
@Json(name = "m.identity_server") @Json(name = "m.identity_server")
val identityServer: WellKnownBaseConfig? = null val identityServer: WellKnownBaseConfig? = null,
/**
* If set to true, the SDK will not use the network constraint when configuring Worker for the WorkManager.
*/
@Json(name = "io.element.disable_network_constraint")
val disableNetworkConstraint: Boolean? = null,
) )

View file

@ -29,9 +29,8 @@ import androidx.work.WorkRequest
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.internal.session.SessionScope import org.matrix.android.sdk.internal.session.SessionScope
import org.matrix.android.sdk.internal.session.homeserver.HomeServerCapabilitiesDataSource import org.matrix.android.sdk.internal.session.workmanager.WorkManagerConfig
import org.matrix.android.sdk.internal.worker.MatrixWorkerFactory import org.matrix.android.sdk.internal.worker.MatrixWorkerFactory
import timber.log.Timber import timber.log.Timber
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -106,12 +105,12 @@ internal class WorkManagerProvider @Inject constructor(
private const val MATRIX_SDK_TAG_PREFIX = "MatrixSDK-" private const val MATRIX_SDK_TAG_PREFIX = "MatrixSDK-"
fun getWorkConstraints( fun getWorkConstraints(
homeServerCapabilitiesDataSource: HomeServerCapabilitiesDataSource, workManagerConfig: WorkManagerConfig,
): Constraints { ): Constraints {
val withNetworkConstraint = homeServerCapabilitiesDataSource.getHomeServerCapabilities()?.disableNetworkConstraint.orFalse().not() val widthNetworkConstraint = workManagerConfig.withNetworkConstraint()
return Constraints.Builder() return Constraints.Builder()
.apply { .apply {
if (withNetworkConstraint) { if (widthNetworkConstraint) {
setRequiredNetworkType(NetworkType.CONNECTED) setRequiredNetworkType(NetworkType.CONNECTED)
} else { } else {
Timber.w("Network constraint is disabled") Timber.w("Network constraint is disabled")

View file

@ -97,6 +97,8 @@ import org.matrix.android.sdk.internal.session.room.tombstone.RoomTombstoneEvent
import org.matrix.android.sdk.internal.session.typing.DefaultTypingUsersTracker import org.matrix.android.sdk.internal.session.typing.DefaultTypingUsersTracker
import org.matrix.android.sdk.internal.session.user.accountdata.DefaultSessionAccountDataService import org.matrix.android.sdk.internal.session.user.accountdata.DefaultSessionAccountDataService
import org.matrix.android.sdk.internal.session.widgets.DefaultWidgetURLFormatter import org.matrix.android.sdk.internal.session.widgets.DefaultWidgetURLFormatter
import org.matrix.android.sdk.internal.session.workmanager.DefaultWorkManagerConfig
import org.matrix.android.sdk.internal.session.workmanager.WorkManagerConfig
import retrofit2.Retrofit import retrofit2.Retrofit
import java.io.File import java.io.File
import javax.inject.Provider import javax.inject.Provider
@ -422,4 +424,7 @@ internal abstract class SessionModule {
@Binds @Binds
abstract fun bindPollAggregationProcessor(processor: DefaultPollAggregationProcessor): PollAggregationProcessor abstract fun bindPollAggregationProcessor(processor: DefaultPollAggregationProcessor): PollAggregationProcessor
@Binds
abstract fun bindWorkManaerConfig(config: DefaultWorkManagerConfig): WorkManagerConfig
} }

View file

@ -27,8 +27,8 @@ import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.di.SessionDatabase import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.internal.di.SessionId import org.matrix.android.sdk.internal.di.SessionId
import org.matrix.android.sdk.internal.di.WorkManagerProvider import org.matrix.android.sdk.internal.di.WorkManagerProvider
import org.matrix.android.sdk.internal.session.homeserver.HomeServerCapabilitiesDataSource
import org.matrix.android.sdk.internal.session.pushers.gateway.PushGatewayNotifyTask import org.matrix.android.sdk.internal.session.pushers.gateway.PushGatewayNotifyTask
import org.matrix.android.sdk.internal.session.workmanager.WorkManagerConfig
import org.matrix.android.sdk.internal.task.TaskExecutor import org.matrix.android.sdk.internal.task.TaskExecutor
import org.matrix.android.sdk.internal.task.configureWith import org.matrix.android.sdk.internal.task.configureWith
import org.matrix.android.sdk.internal.worker.WorkerParamsFactory import org.matrix.android.sdk.internal.worker.WorkerParamsFactory
@ -46,7 +46,7 @@ internal class DefaultPushersService @Inject constructor(
private val togglePusherTask: TogglePusherTask, private val togglePusherTask: TogglePusherTask,
private val removePusherTask: RemovePusherTask, private val removePusherTask: RemovePusherTask,
private val taskExecutor: TaskExecutor, private val taskExecutor: TaskExecutor,
private val homeServerCapabilitiesDataSource: HomeServerCapabilitiesDataSource, private val workManagerConfig: WorkManagerConfig,
) : PushersService { ) : PushersService {
override suspend fun testPush( override suspend fun testPush(
@ -132,7 +132,7 @@ internal class DefaultPushersService @Inject constructor(
private fun enqueueAddPusher(pusher: JsonPusher): UUID { private fun enqueueAddPusher(pusher: JsonPusher): UUID {
val params = AddPusherWorker.Params(sessionId, pusher) val params = AddPusherWorker.Params(sessionId, pusher)
val request = workManagerProvider.matrixOneTimeWorkRequestBuilder<AddPusherWorker>() val request = workManagerProvider.matrixOneTimeWorkRequestBuilder<AddPusherWorker>()
.setConstraints(WorkManagerProvider.getWorkConstraints(homeServerCapabilitiesDataSource)) .setConstraints(WorkManagerProvider.getWorkConstraints(workManagerConfig))
.setInputData(WorkerParamsFactory.toData(params)) .setInputData(WorkerParamsFactory.toData(params))
.setBackoffCriteria(BackoffPolicy.LINEAR, WorkManagerProvider.BACKOFF_DELAY_MILLIS, TimeUnit.MILLISECONDS) .setBackoffCriteria(BackoffPolicy.LINEAR, WorkManagerProvider.BACKOFF_DELAY_MILLIS, TimeUnit.MILLISECONDS)
.build() .build()

View file

@ -55,6 +55,7 @@ import org.matrix.android.sdk.internal.di.WorkManagerProvider
import org.matrix.android.sdk.internal.session.content.UploadContentWorker import org.matrix.android.sdk.internal.session.content.UploadContentWorker
import org.matrix.android.sdk.internal.session.homeserver.HomeServerCapabilitiesDataSource import org.matrix.android.sdk.internal.session.homeserver.HomeServerCapabilitiesDataSource
import org.matrix.android.sdk.internal.session.room.send.queue.EventSenderProcessor import org.matrix.android.sdk.internal.session.room.send.queue.EventSenderProcessor
import org.matrix.android.sdk.internal.session.workmanager.WorkManagerConfig
import org.matrix.android.sdk.internal.task.TaskExecutor import org.matrix.android.sdk.internal.task.TaskExecutor
import org.matrix.android.sdk.internal.util.CancelableWork import org.matrix.android.sdk.internal.util.CancelableWork
import org.matrix.android.sdk.internal.worker.WorkerParamsFactory import org.matrix.android.sdk.internal.worker.WorkerParamsFactory
@ -75,7 +76,7 @@ internal class DefaultSendService @AssistedInject constructor(
private val localEchoRepository: LocalEchoRepository, private val localEchoRepository: LocalEchoRepository,
private val eventSenderProcessor: EventSenderProcessor, private val eventSenderProcessor: EventSenderProcessor,
private val cancelSendTracker: CancelSendTracker, private val cancelSendTracker: CancelSendTracker,
private val homeServerCapabilitiesDataSource: HomeServerCapabilitiesDataSource, private val workManagerConfig: WorkManagerConfig,
) : SendService { ) : SendService {
@AssistedFactory @AssistedFactory
@ -375,7 +376,7 @@ internal class DefaultSendService @AssistedInject constructor(
val uploadWorkData = WorkerParamsFactory.toData(uploadMediaWorkerParams) val uploadWorkData = WorkerParamsFactory.toData(uploadMediaWorkerParams)
return workManagerProvider.matrixOneTimeWorkRequestBuilder<UploadContentWorker>() return workManagerProvider.matrixOneTimeWorkRequestBuilder<UploadContentWorker>()
.setConstraints(WorkManagerProvider.getWorkConstraints(homeServerCapabilitiesDataSource)) .setConstraints(WorkManagerProvider.getWorkConstraints(workManagerConfig))
.startChain(true) .startChain(true)
.setInputData(uploadWorkData) .setInputData(uploadWorkData)
.setBackoffCriteria(BackoffPolicy.LINEAR, WorkManagerProvider.BACKOFF_DELAY_MILLIS, TimeUnit.MILLISECONDS) .setBackoffCriteria(BackoffPolicy.LINEAR, WorkManagerProvider.BACKOFF_DELAY_MILLIS, TimeUnit.MILLISECONDS)

View file

@ -23,6 +23,7 @@ import androidx.work.OneTimeWorkRequest
import org.matrix.android.sdk.api.util.Cancelable import org.matrix.android.sdk.api.util.Cancelable
import org.matrix.android.sdk.internal.di.WorkManagerProvider import org.matrix.android.sdk.internal.di.WorkManagerProvider
import org.matrix.android.sdk.internal.session.homeserver.HomeServerCapabilitiesDataSource import org.matrix.android.sdk.internal.session.homeserver.HomeServerCapabilitiesDataSource
import org.matrix.android.sdk.internal.session.workmanager.WorkManagerConfig
import org.matrix.android.sdk.internal.util.CancelableWork import org.matrix.android.sdk.internal.util.CancelableWork
import org.matrix.android.sdk.internal.worker.startChain import org.matrix.android.sdk.internal.worker.startChain
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -36,7 +37,7 @@ import javax.inject.Inject
*/ */
internal class TimelineSendEventWorkCommon @Inject constructor( internal class TimelineSendEventWorkCommon @Inject constructor(
private val workManagerProvider: WorkManagerProvider, private val workManagerProvider: WorkManagerProvider,
private val homeServerCapabilitiesDataSource: HomeServerCapabilitiesDataSource, private val workManagerConfig: WorkManagerConfig,
) { ) {
fun postWork(roomId: String, workRequest: OneTimeWorkRequest, policy: ExistingWorkPolicy = ExistingWorkPolicy.APPEND_OR_REPLACE): Cancelable { fun postWork(roomId: String, workRequest: OneTimeWorkRequest, policy: ExistingWorkPolicy = ExistingWorkPolicy.APPEND_OR_REPLACE): Cancelable {
@ -49,7 +50,7 @@ internal class TimelineSendEventWorkCommon @Inject constructor(
inline fun <reified W : ListenableWorker> createWork(data: Data, startChain: Boolean): OneTimeWorkRequest { inline fun <reified W : ListenableWorker> createWork(data: Data, startChain: Boolean): OneTimeWorkRequest {
return workManagerProvider.matrixOneTimeWorkRequestBuilder<W>() return workManagerProvider.matrixOneTimeWorkRequestBuilder<W>()
.setConstraints(WorkManagerProvider.getWorkConstraints(homeServerCapabilitiesDataSource)) .setConstraints(WorkManagerProvider.getWorkConstraints(workManagerConfig))
.startChain(startChain) .startChain(startChain)
.setInputData(data) .setInputData(data)
.setBackoffCriteria(BackoffPolicy.LINEAR, WorkManagerProvider.BACKOFF_DELAY_MILLIS, TimeUnit.MILLISECONDS) .setBackoffCriteria(BackoffPolicy.LINEAR, WorkManagerProvider.BACKOFF_DELAY_MILLIS, TimeUnit.MILLISECONDS)

View file

@ -23,6 +23,7 @@ import org.matrix.android.sdk.internal.session.SessionState
import org.matrix.android.sdk.internal.session.homeserver.HomeServerCapabilitiesDataSource import org.matrix.android.sdk.internal.session.homeserver.HomeServerCapabilitiesDataSource
import org.matrix.android.sdk.internal.session.sync.job.SyncThread import org.matrix.android.sdk.internal.session.sync.job.SyncThread
import org.matrix.android.sdk.internal.session.sync.job.SyncWorker import org.matrix.android.sdk.internal.session.sync.job.SyncWorker
import org.matrix.android.sdk.internal.session.workmanager.WorkManagerConfig
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Provider import javax.inject.Provider
@ -34,7 +35,7 @@ internal class DefaultSyncService @Inject constructor(
private val syncTokenStore: SyncTokenStore, private val syncTokenStore: SyncTokenStore,
private val syncRequestStateTracker: SyncRequestStateTracker, private val syncRequestStateTracker: SyncRequestStateTracker,
private val sessionState: SessionState, private val sessionState: SessionState,
private val homeServerCapabilitiesDataSource: HomeServerCapabilitiesDataSource, private val workManagerConfig: WorkManagerConfig,
) : SyncService { ) : SyncService {
private var syncThread: SyncThread? = null private var syncThread: SyncThread? = null
@ -42,7 +43,7 @@ internal class DefaultSyncService @Inject constructor(
SyncWorker.requireBackgroundSync( SyncWorker.requireBackgroundSync(
workManagerProvider = workManagerProvider, workManagerProvider = workManagerProvider,
sessionId = sessionId, sessionId = sessionId,
homeServerCapabilitiesDataSource = homeServerCapabilitiesDataSource, workManagerConfig = workManagerConfig,
) )
} }
@ -50,7 +51,7 @@ internal class DefaultSyncService @Inject constructor(
SyncWorker.automaticallyBackgroundSync( SyncWorker.automaticallyBackgroundSync(
workManagerProvider = workManagerProvider, workManagerProvider = workManagerProvider,
sessionId = sessionId, sessionId = sessionId,
homeServerCapabilitiesDataSource = homeServerCapabilitiesDataSource, workManagerConfig = workManagerConfig,
serverTimeoutInSeconds = timeOutInSeconds, serverTimeoutInSeconds = timeOutInSeconds,
delayInSeconds = repeatDelayInSeconds, delayInSeconds = repeatDelayInSeconds,
) )

View file

@ -28,6 +28,7 @@ import org.matrix.android.sdk.internal.session.SessionComponent
import org.matrix.android.sdk.internal.session.homeserver.HomeServerCapabilitiesDataSource import org.matrix.android.sdk.internal.session.homeserver.HomeServerCapabilitiesDataSource
import org.matrix.android.sdk.internal.session.sync.SyncPresence import org.matrix.android.sdk.internal.session.sync.SyncPresence
import org.matrix.android.sdk.internal.session.sync.SyncTask import org.matrix.android.sdk.internal.session.sync.SyncTask
import org.matrix.android.sdk.internal.session.workmanager.WorkManagerConfig
import org.matrix.android.sdk.internal.worker.SessionSafeCoroutineWorker import org.matrix.android.sdk.internal.worker.SessionSafeCoroutineWorker
import org.matrix.android.sdk.internal.worker.SessionWorkerParams import org.matrix.android.sdk.internal.worker.SessionWorkerParams
import org.matrix.android.sdk.internal.worker.WorkerParamsFactory import org.matrix.android.sdk.internal.worker.WorkerParamsFactory
@ -60,7 +61,7 @@ internal class SyncWorker(context: Context, workerParameters: WorkerParameters,
@Inject lateinit var syncTask: SyncTask @Inject lateinit var syncTask: SyncTask
@Inject lateinit var workManagerProvider: WorkManagerProvider @Inject lateinit var workManagerProvider: WorkManagerProvider
@Inject lateinit var homeServerCapabilitiesDataSource: HomeServerCapabilitiesDataSource @Inject lateinit var workManagerConfig: WorkManagerConfig
override fun injectWith(injector: SessionComponent) { override fun injectWith(injector: SessionComponent) {
injector.inject(this) injector.inject(this)
@ -79,7 +80,7 @@ internal class SyncWorker(context: Context, workerParameters: WorkerParameters,
automaticallyBackgroundSync( automaticallyBackgroundSync(
workManagerProvider = workManagerProvider, workManagerProvider = workManagerProvider,
sessionId = params.sessionId, sessionId = params.sessionId,
homeServerCapabilitiesDataSource = homeServerCapabilitiesDataSource, workManagerConfig = workManagerConfig,
serverTimeoutInSeconds = params.timeout, serverTimeoutInSeconds = params.timeout,
delayInSeconds = params.delay, delayInSeconds = params.delay,
forceImmediate = hasToDeviceEvents forceImmediate = hasToDeviceEvents
@ -89,7 +90,7 @@ internal class SyncWorker(context: Context, workerParameters: WorkerParameters,
requireBackgroundSync( requireBackgroundSync(
workManagerProvider = workManagerProvider, workManagerProvider = workManagerProvider,
sessionId = params.sessionId, sessionId = params.sessionId,
homeServerCapabilitiesDataSource = homeServerCapabilitiesDataSource, workManagerConfig = workManagerConfig,
serverTimeoutInSeconds = 0 serverTimeoutInSeconds = 0
) )
} }
@ -127,7 +128,7 @@ internal class SyncWorker(context: Context, workerParameters: WorkerParameters,
fun requireBackgroundSync( fun requireBackgroundSync(
workManagerProvider: WorkManagerProvider, workManagerProvider: WorkManagerProvider,
sessionId: String, sessionId: String,
homeServerCapabilitiesDataSource: HomeServerCapabilitiesDataSource, workManagerConfig: WorkManagerConfig,
serverTimeoutInSeconds: Long = 0 serverTimeoutInSeconds: Long = 0
) { ) {
val data = WorkerParamsFactory.toData( val data = WorkerParamsFactory.toData(
@ -139,7 +140,7 @@ internal class SyncWorker(context: Context, workerParameters: WorkerParameters,
) )
) )
val workRequest = workManagerProvider.matrixOneTimeWorkRequestBuilder<SyncWorker>() val workRequest = workManagerProvider.matrixOneTimeWorkRequestBuilder<SyncWorker>()
.setConstraints(WorkManagerProvider.getWorkConstraints(homeServerCapabilitiesDataSource)) .setConstraints(WorkManagerProvider.getWorkConstraints(workManagerConfig))
.setBackoffCriteria(BackoffPolicy.LINEAR, WorkManagerProvider.BACKOFF_DELAY_MILLIS, TimeUnit.MILLISECONDS) .setBackoffCriteria(BackoffPolicy.LINEAR, WorkManagerProvider.BACKOFF_DELAY_MILLIS, TimeUnit.MILLISECONDS)
.setInputData(data) .setInputData(data)
.startChain(true) .startChain(true)
@ -151,7 +152,7 @@ internal class SyncWorker(context: Context, workerParameters: WorkerParameters,
fun automaticallyBackgroundSync( fun automaticallyBackgroundSync(
workManagerProvider: WorkManagerProvider, workManagerProvider: WorkManagerProvider,
sessionId: String, sessionId: String,
homeServerCapabilitiesDataSource: HomeServerCapabilitiesDataSource, workManagerConfig: WorkManagerConfig,
serverTimeoutInSeconds: Long = 0, serverTimeoutInSeconds: Long = 0,
delayInSeconds: Long = 30, delayInSeconds: Long = 30,
forceImmediate: Boolean = false forceImmediate: Boolean = false
@ -166,7 +167,7 @@ internal class SyncWorker(context: Context, workerParameters: WorkerParameters,
) )
) )
val workRequest = workManagerProvider.matrixOneTimeWorkRequestBuilder<SyncWorker>() val workRequest = workManagerProvider.matrixOneTimeWorkRequestBuilder<SyncWorker>()
.setConstraints(WorkManagerProvider.getWorkConstraints(homeServerCapabilitiesDataSource)) .setConstraints(WorkManagerProvider.getWorkConstraints(workManagerConfig))
.setInputData(data) .setInputData(data)
.setBackoffCriteria(BackoffPolicy.LINEAR, WorkManagerProvider.BACKOFF_DELAY_MILLIS, TimeUnit.MILLISECONDS) .setBackoffCriteria(BackoffPolicy.LINEAR, WorkManagerProvider.BACKOFF_DELAY_MILLIS, TimeUnit.MILLISECONDS)
.setInitialDelay(if (forceImmediate) 0 else delayInSeconds, TimeUnit.SECONDS) .setInitialDelay(if (forceImmediate) 0 else delayInSeconds, TimeUnit.SECONDS)

View file

@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.android.sdk.internal.session.workmanager
import org.matrix.android.sdk.api.auth.data.Credentials
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.internal.session.homeserver.HomeServerCapabilitiesDataSource
import javax.inject.Inject
internal class DefaultWorkManagerConfig @Inject constructor(
private val credentials: Credentials,
private val homeServerCapabilitiesDataSource: HomeServerCapabilitiesDataSource,
) : WorkManagerConfig {
override fun withNetworkConstraint(): Boolean {
return if (credentials.discoveryInformation?.disableNetworkConstraint == true) {
false
} else {
homeServerCapabilitiesDataSource.getHomeServerCapabilities()?.disableNetworkConstraint.orFalse().not()
}
}
}

View file

@ -0,0 +1,21 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.android.sdk.internal.session.workmanager
internal interface WorkManagerConfig {
fun withNetworkConstraint(): Boolean
}

View file

@ -21,11 +21,11 @@ import kotlinx.coroutines.test.runTest
import org.junit.Test import org.junit.Test
import org.matrix.android.sdk.test.fakes.FakeAddPusherTask import org.matrix.android.sdk.test.fakes.FakeAddPusherTask
import org.matrix.android.sdk.test.fakes.FakeGetPushersTask import org.matrix.android.sdk.test.fakes.FakeGetPushersTask
import org.matrix.android.sdk.test.fakes.FakeHomeServerCapabilitiesDataSource
import org.matrix.android.sdk.test.fakes.FakeMonarchy import org.matrix.android.sdk.test.fakes.FakeMonarchy
import org.matrix.android.sdk.test.fakes.FakeRemovePusherTask import org.matrix.android.sdk.test.fakes.FakeRemovePusherTask
import org.matrix.android.sdk.test.fakes.FakeTaskExecutor import org.matrix.android.sdk.test.fakes.FakeTaskExecutor
import org.matrix.android.sdk.test.fakes.FakeTogglePusherTask import org.matrix.android.sdk.test.fakes.FakeTogglePusherTask
import org.matrix.android.sdk.test.fakes.FakeWorkManagerConfig
import org.matrix.android.sdk.test.fakes.FakeWorkManagerProvider import org.matrix.android.sdk.test.fakes.FakeWorkManagerProvider
import org.matrix.android.sdk.test.fakes.internal.FakePushGatewayNotifyTask import org.matrix.android.sdk.test.fakes.internal.FakePushGatewayNotifyTask
import org.matrix.android.sdk.test.fixtures.PusherFixture import org.matrix.android.sdk.test.fixtures.PusherFixture
@ -42,7 +42,7 @@ class DefaultPushersServiceTest {
private val togglePusherTask = FakeTogglePusherTask() private val togglePusherTask = FakeTogglePusherTask()
private val removePusherTask = FakeRemovePusherTask() private val removePusherTask = FakeRemovePusherTask()
private val taskExecutor = FakeTaskExecutor() private val taskExecutor = FakeTaskExecutor()
private val homeServerCapabilitiesDataSource = FakeHomeServerCapabilitiesDataSource() private val fakeWorkManagerConfig = FakeWorkManagerConfig()
private val pushersService = DefaultPushersService( private val pushersService = DefaultPushersService(
workManagerProvider.instance, workManagerProvider.instance,
@ -54,7 +54,7 @@ class DefaultPushersServiceTest {
togglePusherTask, togglePusherTask,
removePusherTask, removePusherTask,
taskExecutor.instance, taskExecutor.instance,
homeServerCapabilitiesDataSource.instance, fakeWorkManagerConfig,
) )
@Test @Test

View file

@ -0,0 +1,20 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.android.sdk.test.fakes
class FakeWork {
}

View file

@ -0,0 +1,25 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.android.sdk.test.fakes
import org.matrix.android.sdk.internal.session.workmanager.WorkManagerConfig
class FakeWorkManagerConfig : WorkManagerConfig {
override fun withNetworkConstraint(): Boolean {
return true
}
}