From 9874bdeeab92495a33a1c9f0e358c020fe43f195 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 31 May 2022 15:56:16 +0200 Subject: [PATCH 1/3] Adding changelog entry --- changelog.d/6209.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/6209.bugfix diff --git a/changelog.d/6209.bugfix b/changelog.d/6209.bugfix new file mode 100644 index 0000000000..3eac2c9df6 --- /dev/null +++ b/changelog.d/6209.bugfix @@ -0,0 +1 @@ +Fix wrong status of live location sharing in timeline From 102684ed88ab97192d7f314f4863985a431e3836 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 31 May 2022 15:56:23 +0200 Subject: [PATCH 2/3] Fixing aggregation process --- .../livelocation/LiveLocationAggregationProcessor.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/aggregation/livelocation/LiveLocationAggregationProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/aggregation/livelocation/LiveLocationAggregationProcessor.kt index 8f4682a9d5..05bde8f83f 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/aggregation/livelocation/LiveLocationAggregationProcessor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/aggregation/livelocation/LiveLocationAggregationProcessor.kt @@ -67,16 +67,18 @@ internal class LiveLocationAggregationProcessor @Inject constructor( eventId = targetEventId ) - Timber.d("updating summary of id=$targetEventId with isLive=${content.isLive}") - + // remote event can stay with isLive == true while the local summary is no more active + val isActive = aggregatedSummary.isActive.orTrue() && isLive val endOfLiveTimestampMillis = content.getBestTimestampMillis()?.let { it + (content.timeout ?: 0) } + Timber.d("updating summary of id=$targetEventId with isActive=$isActive and endTimestamp=$endOfLiveTimestampMillis") + aggregatedSummary.endOfLiveTimestampMillis = endOfLiveTimestampMillis - aggregatedSummary.isActive = isLive + aggregatedSummary.isActive = isActive aggregatedSummary.userId = event.senderId deactivateAllPreviousBeacons(realm, roomId, event.senderId, targetEventId) - if (isLive) { + if (isActive) { scheduleDeactivationAfterTimeout(targetEventId, roomId, endOfLiveTimestampMillis) } else { cancelDeactivationAfterTimeout(targetEventId, roomId) @@ -90,6 +92,7 @@ internal class LiveLocationAggregationProcessor @Inject constructor( val workData = WorkerParamsFactory.toData(workParams) val workName = DeactivateLiveLocationShareWorker.getWorkName(eventId = eventId, roomId = roomId) val workDelayMillis = (endOfLiveTimestampMillis - clock.epochMillis()).coerceAtLeast(0) + Timber.d("scheduling deactivation of $eventId after $workDelayMillis millis") val workRequest = workManagerProvider.matrixOneTimeWorkRequestBuilder() .setInitialDelay(workDelayMillis, TimeUnit.MILLISECONDS) .setInputData(workData) From b1750c1c21e9f96f339219aa971b15eb9c3cfec9 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 31 May 2022 15:56:36 +0200 Subject: [PATCH 3/3] Adding log in worker --- .../livelocation/DeactivateLiveLocationShareWorker.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/aggregation/livelocation/DeactivateLiveLocationShareWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/aggregation/livelocation/DeactivateLiveLocationShareWorker.kt index 2b83c8028b..b17753b25a 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/aggregation/livelocation/DeactivateLiveLocationShareWorker.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/aggregation/livelocation/DeactivateLiveLocationShareWorker.kt @@ -75,6 +75,7 @@ internal class DeactivateLiveLocationShareWorker(context: Context, params: Worke private suspend fun deactivateLiveLocationShare(params: Params) { awaitTransaction(realmConfiguration) { realm -> + Timber.d("deactivating live with id=${params.eventId}") val aggregatedSummary = LiveLocationShareAggregatedSummaryEntity.get( realm = realm, roomId = params.roomId,