mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-15 10:48:54 +03:00
Restart fdroid sync on application boot
This commit is contained in:
parent
971b425e17
commit
43c24e55ab
1 changed files with 18 additions and 1 deletions
|
@ -21,6 +21,8 @@ import android.content.BroadcastReceiver
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import im.vector.app.core.di.HasVectorInjector
|
||||
import im.vector.app.core.extensions.vectorComponent
|
||||
import im.vector.app.features.settings.BackgroundSyncMode
|
||||
import timber.log.Timber
|
||||
|
||||
class OnApplicationUpgradeOrRebootReceiver : BroadcastReceiver() {
|
||||
|
@ -30,8 +32,23 @@ class OnApplicationUpgradeOrRebootReceiver : BroadcastReceiver() {
|
|||
val appContext = context.applicationContext
|
||||
if (appContext is HasVectorInjector) {
|
||||
val activeSession = appContext.injector().activeSessionHolder().getSafeActiveSession()
|
||||
val preferences = appContext.vectorComponent().vectorPreferences()
|
||||
if (activeSession != null) {
|
||||
AlarmSyncBroadcastReceiver.scheduleAlarm(context, activeSession.sessionId, 10)
|
||||
when (preferences.getFdroidSyncBackgroundMode()) {
|
||||
BackgroundSyncMode.FDROID_BACKGROUND_SYNC_MODE_FOR_BATTERY -> {
|
||||
Timber.i("## Sync: OnBoot Work scheduled to periodically sync")
|
||||
activeSession.startAutomaticBackgroundSync(
|
||||
preferences.backgroundSyncTimeOut().toLong(),
|
||||
preferences.backgroundSyncDelay().toLong()
|
||||
)
|
||||
}
|
||||
BackgroundSyncMode.FDROID_BACKGROUND_SYNC_MODE_FOR_REALTIME -> {
|
||||
AlarmSyncBroadcastReceiver.scheduleAlarm(context, activeSession.sessionId, preferences.backgroundSyncDelay())
|
||||
}
|
||||
BackgroundSyncMode.FDROID_BACKGROUND_SYNC_MODE_DISABLED -> {
|
||||
// nop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue