Compare commits

...

4 Commits

Author SHA1 Message Date
Benoit Marty
0803f25a32
Merge branch 'develop' into feature/bca/configurable_synctimeout_for_test 2022-05-31 18:22:35 +02:00
Valere
7ad39fdc99 Better naming and doc 2022-05-14 11:38:05 +02:00
Valere
301ab2af64 change log 2022-05-13 18:19:16 +02:00
Valere
605cbb0b55 Make default sync timeout configurable
and reduce for tests
2022-05-13 17:33:50 +02:00
4 changed files with 13 additions and 4 deletions

1
changelog.d/6050.sdk Normal file
View File

@ -0,0 +1 @@
Default sync timeout is now configurable via MatrixConfiguration (no change to default)

View File

@ -96,7 +96,8 @@ class CommonTestHelper private constructor(context: Context) {
context,
MatrixConfiguration(
applicationFlavor = "TestFlavor",
roomDisplayNameFallbackProvider = TestRoomDisplayNameFallbackProvider()
roomDisplayNameFallbackProvider = TestRoomDisplayNameFallbackProvider(),
syncRequestTimeoutMillis = 5_000L
)
)
}

View File

@ -65,4 +65,11 @@ data class MatrixConfiguration(
* Thread messages default enable/disabled value.
*/
val threadMessagesEnabledDefault: Boolean = false,
/**
* Server API configuration for the sync process:
* The maximum time to wait by the homeserver, in milliseconds, before returning the sync response.
* If no events (or other data) become available before this time elapses, the server will return a response with empty fields.
*/
val syncRequestTimeoutMillis: Long = 30_000L,
)

View File

@ -30,6 +30,7 @@ import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.launch
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.failure.Failure
import org.matrix.android.sdk.api.failure.isTokenError
@ -52,7 +53,6 @@ import javax.inject.Inject
import kotlin.concurrent.schedule
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)
@ -61,7 +61,7 @@ internal class SyncThread @Inject constructor(
private val networkConnectivityChecker: NetworkConnectivityChecker,
private val backgroundDetectionObserver: BackgroundDetectionObserver,
private val activeCallHandler: ActiveCallHandler,
private val lightweightSettingsStorage: DefaultLightweightSettingsStorage
private val lightweightSettingsStorage: DefaultLightweightSettingsStorage,
) : Thread("SyncThread"), NetworkConnectivityChecker.Listener, BackgroundDetectionObserver.Listener {
private var state: SyncState = SyncState.Idle
@ -181,7 +181,7 @@ internal class SyncThread @Inject constructor(
val timeout = when {
previousSyncResponseHasToDevice -> 0L /* Force timeout to 0 */
afterPause -> 0L /* No timeout after a pause */
else -> DEFAULT_LONG_POOL_TIMEOUT
else -> matrixConfiguration.syncRequestTimeoutMillis
}
Timber.tag(loggerTag.value).d("Execute sync request with timeout $timeout")
val presence = lightweightSettingsStorage.getSyncPresenceStatus()