Make default sync timeout configurable
and reduce for tests
This commit is contained in:
parent
d40f8b0c56
commit
605cbb0b55
@ -68,7 +68,8 @@ class CommonTestHelper(context: Context) {
|
|||||||
context,
|
context,
|
||||||
MatrixConfiguration(
|
MatrixConfiguration(
|
||||||
applicationFlavor = "TestFlavor",
|
applicationFlavor = "TestFlavor",
|
||||||
roomDisplayNameFallbackProvider = TestRoomDisplayNameFallbackProvider()
|
roomDisplayNameFallbackProvider = TestRoomDisplayNameFallbackProvider(),
|
||||||
|
defaultLongPoolTimeout = 5_000L
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,12 @@ data class MatrixConfiguration(
|
|||||||
* Thread messages default enable/disabled value
|
* Thread messages default enable/disabled value
|
||||||
*/
|
*/
|
||||||
val threadMessagesEnabledDefault: Boolean = false,
|
val threadMessagesEnabledDefault: Boolean = false,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sync loop parameter: The maximum time to wait, in milliseconds, before returning this request.
|
||||||
|
* If no events (or other data) become available before this time elapses, the server will return a response with empty fields.
|
||||||
|
*/
|
||||||
|
val defaultLongPoolTimeout: Long = 30_000L,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,6 +30,7 @@ import kotlinx.coroutines.flow.MutableSharedFlow
|
|||||||
import kotlinx.coroutines.flow.SharedFlow
|
import kotlinx.coroutines.flow.SharedFlow
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import org.matrix.android.sdk.api.MatrixConfiguration
|
||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import org.matrix.android.sdk.api.failure.Failure
|
import org.matrix.android.sdk.api.failure.Failure
|
||||||
import org.matrix.android.sdk.api.failure.isTokenError
|
import org.matrix.android.sdk.api.failure.isTokenError
|
||||||
@ -52,7 +53,6 @@ import javax.inject.Inject
|
|||||||
import kotlin.concurrent.schedule
|
import kotlin.concurrent.schedule
|
||||||
|
|
||||||
private const val RETRY_WAIT_TIME_MS = 10_000L
|
private const val RETRY_WAIT_TIME_MS = 10_000L
|
||||||
private const val DEFAULT_LONG_POOL_TIMEOUT = 30_000L
|
|
||||||
|
|
||||||
private val loggerTag = LoggerTag("SyncThread", LoggerTag.SYNC)
|
private val loggerTag = LoggerTag("SyncThread", LoggerTag.SYNC)
|
||||||
|
|
||||||
@ -60,6 +60,7 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask,
|
|||||||
private val networkConnectivityChecker: NetworkConnectivityChecker,
|
private val networkConnectivityChecker: NetworkConnectivityChecker,
|
||||||
private val backgroundDetectionObserver: BackgroundDetectionObserver,
|
private val backgroundDetectionObserver: BackgroundDetectionObserver,
|
||||||
private val activeCallHandler: ActiveCallHandler,
|
private val activeCallHandler: ActiveCallHandler,
|
||||||
|
private val matrixConfiguration: MatrixConfiguration,
|
||||||
private val lightweightSettingsStorage: DefaultLightweightSettingsStorage
|
private val lightweightSettingsStorage: DefaultLightweightSettingsStorage
|
||||||
) : Thread("SyncThread"), NetworkConnectivityChecker.Listener, BackgroundDetectionObserver.Listener {
|
) : Thread("SyncThread"), NetworkConnectivityChecker.Listener, BackgroundDetectionObserver.Listener {
|
||||||
|
|
||||||
@ -180,7 +181,7 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask,
|
|||||||
val timeout = when {
|
val timeout = when {
|
||||||
previousSyncResponseHasToDevice -> 0L /* Force timeout to 0 */
|
previousSyncResponseHasToDevice -> 0L /* Force timeout to 0 */
|
||||||
afterPause -> 0L /* No timeout after a pause */
|
afterPause -> 0L /* No timeout after a pause */
|
||||||
else -> DEFAULT_LONG_POOL_TIMEOUT
|
else -> matrixConfiguration.defaultLongPoolTimeout
|
||||||
}
|
}
|
||||||
Timber.tag(loggerTag.value).d("Execute sync request with timeout $timeout")
|
Timber.tag(loggerTag.value).d("Execute sync request with timeout $timeout")
|
||||||
val presence = lightweightSettingsStorage.getSyncPresenceStatus()
|
val presence = lightweightSettingsStorage.getSyncPresenceStatus()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user