From 3c7a108940376ff68dc88494563ce3fdc4dca1c1 Mon Sep 17 00:00:00 2001 From: ganfra Date: Tue, 9 Mar 2021 18:18:28 +0100 Subject: [PATCH] Send: clean and update CHANGES --- CHANGES.md | 1 + .../matrix/android/sdk/internal/session/SessionModule.kt | 1 - .../session/room/send/queue/EventSenderProcessor.kt | 3 +-- .../room/send/queue/EventSenderProcessorCoroutine.kt | 7 +++---- .../session/room/send/queue/EventSenderProcessorThread.kt | 5 ----- .../room/send/queue/HomeServerAvailabilityChecker.kt | 3 +-- .../sdk/internal/session/room/send/queue/QueueMemento.kt | 3 +-- .../sdk/internal/session/room/send/queue/QueuedTask.kt | 2 +- 8 files changed, 8 insertions(+), 17 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index ea78fcaf7d..8136abeffd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ Improvements 🙌: - PIP support for Jitsi call (#2418) - Add tooltip for room quick actions - Pre-share session keys when opening a room or start typing (#2771) + - Sending is now queuing by room and not uniquely to the session Bugfix 🐛: - Try to fix crash about UrlPreview (#2640) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt index 1b0a2fa027..f10eb67921 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt @@ -371,5 +371,4 @@ internal abstract class SessionModule { @Binds abstract fun bindEventSenderProcessor(processor: EventSenderProcessorCoroutine): EventSenderProcessor - } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessor.kt index 05d0876ef0..8bafa5f882 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessor.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 New Vector Ltd + * Copyright 2021 The Matrix.org Foundation C.I.C. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,5 +33,4 @@ internal interface EventSenderProcessor: SessionLifecycleObserver { fun postTask(task: QueuedTask): Cancelable fun cancel(eventId: String, roomId: String) - } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorCoroutine.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorCoroutine.kt index 56fb3b8539..e93ebe9048 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorCoroutine.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorCoroutine.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 New Vector Ltd + * Copyright 2021 The Matrix.org Foundation C.I.C. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,6 @@ import org.matrix.android.sdk.internal.task.TaskExecutor import org.matrix.android.sdk.internal.util.toCancelable import timber.log.Timber import java.io.IOException -import java.util.Queue import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.atomic.AtomicBoolean import javax.inject.Inject @@ -57,7 +56,7 @@ internal class EventSenderProcessorCoroutine @Inject constructor( private val sessionParams: SessionParams, private val queuedTaskFactory: QueuedTaskFactory, private val taskExecutor: TaskExecutor, - private val memento: QueueMemento, + private val memento: QueueMemento ) : EventSenderProcessor { private val waitForNetworkSequencer = SemaphoreCoroutineSequencer() @@ -165,7 +164,7 @@ internal class EventSenderProcessorCoroutine @Inject constructor( markAsFinished(task) } - private suspend fun QueuedTask.markAsFailedOrRetry(failure: Throwable, retryDelay: Long){ + private suspend fun QueuedTask.markAsFailedOrRetry(failure: Throwable, retryDelay: Long) { if (retryCount.incrementAndGet() >= MAX_RETRY_COUNT) { onTaskFailed() } else { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorThread.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorThread.kt index 2e1acf710c..2d2111f838 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorThread.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorThread.kt @@ -33,9 +33,6 @@ import org.matrix.android.sdk.internal.session.SessionScope import org.matrix.android.sdk.internal.task.TaskExecutor import timber.log.Timber import java.io.IOException -import java.net.InetAddress -import java.net.InetSocketAddress -import java.net.Socket import java.util.Timer import java.util.TimerTask import java.util.concurrent.LinkedBlockingQueue @@ -74,7 +71,6 @@ internal class EventSenderProcessorThread @Inject constructor( interrupt() } - override fun start() { super.start() // We should check for sending events not handled because app was killed @@ -234,5 +230,4 @@ internal class EventSenderProcessorThread @Inject constructor( } synchronized(networkAvailableLock) { networkAvailableLock.wait() } } - } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/HomeServerAvailabilityChecker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/HomeServerAvailabilityChecker.kt index c68be74a64..2d53699917 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/HomeServerAvailabilityChecker.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/HomeServerAvailabilityChecker.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 New Vector Ltd + * Copyright 2021 The Matrix.org Foundation C.I.C. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,5 +41,4 @@ internal class HomeServerAvailabilityChecker(val sessionParams: SessionParams) { return false } } - } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/QueueMemento.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/QueueMemento.kt index 472e4d440f..116c8d5c6b 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/QueueMemento.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/QueueMemento.kt @@ -54,8 +54,7 @@ internal class QueueMemento @Inject constructor(context: Context, persist() } - fun trackedTasks() = synchronized(trackedTasks){ - + fun trackedTasks() = synchronized(trackedTasks) { } private fun persist() { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/QueuedTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/QueuedTask.kt index e5302c171c..948786677d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/QueuedTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/QueuedTask.kt @@ -29,7 +29,7 @@ internal abstract class QueuedTask( val taskIdentifier: String ) : Cancelable { - override fun toString() = "${javaClass.simpleName} queueIdentifier: $queueIdentifier, taskIdentifier: ${taskIdentifier})" + override fun toString() = "${javaClass.simpleName} queueIdentifier: $queueIdentifier, taskIdentifier: $taskIdentifier)" var retryCount = AtomicInteger(0)