From 4f7498de45c1c9456b2f4d0dabf967c41320d2ca Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 12 May 2022 00:08:26 +0200 Subject: [PATCH] Rename existing SyncService to SyncAndroidService to avoid confusion --- .../job/{SyncService.kt => SyncAndroidService.kt} | 2 +- .../fdroid/receiver/AlarmSyncBroadcastReceiver.kt | 14 +++++++------- vector/src/main/AndroidManifest.xml | 2 +- .../java/im/vector/app/core/extensions/Session.kt | 4 ++-- ...rSyncService.kt => VectorSyncAndroidService.kt} | 14 +++++++------- 5 files changed, 18 insertions(+), 18 deletions(-) rename matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/job/{SyncService.kt => SyncAndroidService.kt} (99%) rename vector/src/main/java/im/vector/app/core/services/{VectorSyncService.kt => VectorSyncAndroidService.kt} (95%) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/job/SyncService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/job/SyncAndroidService.kt similarity index 99% rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/job/SyncService.kt rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/job/SyncAndroidService.kt index 6f526480d75..50da34b3193 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/job/SyncService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/job/SyncAndroidService.kt @@ -46,7 +46,7 @@ import java.util.concurrent.atomic.AtomicBoolean * in order to be able to perform a sync even if the app is not running. * The and must be declared in the Manifest or the app using the SDK */ -abstract class SyncService : Service() { +abstract class SyncAndroidService : Service() { private var sessionId: String? = null private var mIsSelfDestroyed: Boolean = false diff --git a/vector/src/fdroid/java/im/vector/app/fdroid/receiver/AlarmSyncBroadcastReceiver.kt b/vector/src/fdroid/java/im/vector/app/fdroid/receiver/AlarmSyncBroadcastReceiver.kt index 09bd56654d4..bd1e0eb0eed 100644 --- a/vector/src/fdroid/java/im/vector/app/fdroid/receiver/AlarmSyncBroadcastReceiver.kt +++ b/vector/src/fdroid/java/im/vector/app/fdroid/receiver/AlarmSyncBroadcastReceiver.kt @@ -26,9 +26,9 @@ import androidx.core.content.ContextCompat import androidx.core.content.getSystemService import im.vector.app.core.extensions.singletonEntryPoint import im.vector.app.core.platform.PendingIntentCompat -import im.vector.app.core.services.VectorSyncService +import im.vector.app.core.services.VectorSyncAndroidService import im.vector.app.core.time.Clock -import org.matrix.android.sdk.api.session.sync.job.SyncService +import org.matrix.android.sdk.api.session.sync.job.SyncAndroidService import timber.log.Timber class AlarmSyncBroadcastReceiver : BroadcastReceiver() { @@ -43,8 +43,8 @@ class AlarmSyncBroadcastReceiver : BroadcastReceiver() { val vectorPreferences = singletonEntryPoint.vectorPreferences() val clock = singletonEntryPoint.clock() - val sessionId = intent.getStringExtra(SyncService.EXTRA_SESSION_ID) ?: return - VectorSyncService.newPeriodicIntent( + val sessionId = intent.getStringExtra(SyncAndroidService.EXTRA_SESSION_ID) ?: return + VectorSyncAndroidService.newPeriodicIntent( context = context, sessionId = sessionId, syncTimeoutSeconds = vectorPreferences.backgroundSyncTimeOut(), @@ -69,8 +69,8 @@ class AlarmSyncBroadcastReceiver : BroadcastReceiver() { // Reschedule Timber.v("## Sync: Scheduling alarm for background sync in $delayInSeconds seconds") val intent = Intent(context, AlarmSyncBroadcastReceiver::class.java).apply { - putExtra(SyncService.EXTRA_SESSION_ID, sessionId) - putExtra(SyncService.EXTRA_PERIODIC, true) + putExtra(SyncAndroidService.EXTRA_SESSION_ID, sessionId) + putExtra(SyncAndroidService.EXTRA_PERIODIC, true) } val pIntent = PendingIntent.getBroadcast( context, @@ -100,7 +100,7 @@ class AlarmSyncBroadcastReceiver : BroadcastReceiver() { alarmMgr.cancel(pIntent) // Stop current service to restart - VectorSyncService.stopIntent(context).let { + VectorSyncAndroidService.stopIntent(context).let { try { ContextCompat.startForegroundService(context, it) } catch (ex: Throwable) { diff --git a/vector/src/main/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml index 8c2e25bc7e8..4d501d9d0e2 100644 --- a/vector/src/main/AndroidManifest.xml +++ b/vector/src/main/AndroidManifest.xml @@ -360,7 +360,7 @@ diff --git a/vector/src/main/java/im/vector/app/core/extensions/Session.kt b/vector/src/main/java/im/vector/app/core/extensions/Session.kt index ca57fe3e8ec..6e1fea090c8 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/Session.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/Session.kt @@ -20,7 +20,7 @@ import android.content.Context import androidx.core.content.ContextCompat import androidx.lifecycle.Lifecycle import androidx.lifecycle.ProcessLifecycleOwner -import im.vector.app.core.services.VectorSyncService +import im.vector.app.core.services.VectorSyncAndroidService import im.vector.app.features.session.VectorSessionStore import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupState @@ -42,7 +42,7 @@ fun Session.startSyncing(context: Context) { val applicationContext = context.applicationContext if (!syncService().hasAlreadySynced()) { // initial sync is done as a service so it can continue below app lifecycle - VectorSyncService.newOneShotIntent( + VectorSyncAndroidService.newOneShotIntent( context = applicationContext, sessionId = sessionId ) diff --git a/vector/src/main/java/im/vector/app/core/services/VectorSyncService.kt b/vector/src/main/java/im/vector/app/core/services/VectorSyncAndroidService.kt similarity index 95% rename from vector/src/main/java/im/vector/app/core/services/VectorSyncService.kt rename to vector/src/main/java/im/vector/app/core/services/VectorSyncAndroidService.kt index 131276bea61..33be6be85d5 100644 --- a/vector/src/main/java/im/vector/app/core/services/VectorSyncService.kt +++ b/vector/src/main/java/im/vector/app/core/services/VectorSyncAndroidService.kt @@ -38,18 +38,18 @@ import im.vector.app.core.time.DefaultClock import im.vector.app.features.notifications.NotificationUtils import im.vector.app.features.settings.BackgroundSyncMode import org.matrix.android.sdk.api.Matrix -import org.matrix.android.sdk.api.session.sync.job.SyncService +import org.matrix.android.sdk.api.session.sync.job.SyncAndroidService import timber.log.Timber import javax.inject.Inject @AndroidEntryPoint -class VectorSyncService : SyncService() { +class VectorSyncAndroidService : SyncAndroidService() { companion object { fun newOneShotIntent(context: Context, sessionId: String): Intent { - return Intent(context, VectorSyncService::class.java).also { + return Intent(context, VectorSyncAndroidService::class.java).also { it.putExtra(EXTRA_SESSION_ID, sessionId) it.putExtra(EXTRA_TIMEOUT_SECONDS, 0) it.putExtra(EXTRA_PERIODIC, false) @@ -61,7 +61,7 @@ class VectorSyncService : SyncService() { syncTimeoutSeconds: Int, syncDelaySeconds: Int, isNetworkBack: Boolean): Intent { - return Intent(context, VectorSyncService::class.java).also { + return Intent(context, VectorSyncAndroidService::class.java).also { it.putExtra(EXTRA_SESSION_ID, sessionId) it.putExtra(EXTRA_TIMEOUT_SECONDS, syncTimeoutSeconds) it.putExtra(EXTRA_PERIODIC, true) @@ -71,7 +71,7 @@ class VectorSyncService : SyncService() { } fun stopIntent(context: Context): Intent { - return Intent(context, VectorSyncService::class.java).also { + return Intent(context, VectorSyncAndroidService::class.java).also { it.action = ACTION_STOP } } @@ -198,7 +198,7 @@ private fun Context.rescheduleSyncService(sessionId: String, currentTimeMillis: Long) { Timber.d("## Sync: rescheduleSyncService") val intent = if (isPeriodic) { - VectorSyncService.newPeriodicIntent( + VectorSyncAndroidService.newPeriodicIntent( context = this, sessionId = sessionId, syncTimeoutSeconds = syncTimeoutSeconds, @@ -206,7 +206,7 @@ private fun Context.rescheduleSyncService(sessionId: String, isNetworkBack = isNetworkBack ) } else { - VectorSyncService.newOneShotIntent( + VectorSyncAndroidService.newOneShotIntent( context = this, sessionId = sessionId )