Skip to content

Commit

Permalink
Rename existing SyncService to SyncAndroidService to avoid confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarty committed May 25, 2022
1 parent 7a86810 commit 4f7498d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <receiver> and <service> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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(),
Expand All @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion vector/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@

<!-- Add tools:ignore="Instantiatable" for the error reported only by Buildkite and for lintGplayRelease check :/ -->
<service
android:name=".core.services.VectorSyncService"
android:name=".core.services.VectorSyncAndroidService"
android:exported="false"
tools:ignore="Instantiatable" />

Expand Down
4 changes: 2 additions & 2 deletions vector/src/main/java/im/vector/app/core/extensions/Session.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
}
}
Expand Down Expand Up @@ -198,15 +198,15 @@ 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,
syncDelaySeconds = syncDelaySeconds,
isNetworkBack = isNetworkBack
)
} else {
VectorSyncService.newOneShotIntent(
VectorSyncAndroidService.newOneShotIntent(
context = this,
sessionId = sessionId
)
Expand Down

0 comments on commit 4f7498d

Please sign in to comment.