fix: data sync services stop cleanly when Android 15 ends their daily time

This commit is contained in:
xXJsonDeruloXx committed 2026-10-11 02:07:23 -04:00
1 parent 8155654420
commit 68b2bc06db
2 files changed
+14

No files matched your search

@@ -27,6 +27,11 @@ class RuntimeInstallService : Service() {
override fun onBind(intent: Intent?): IBinder? = null
override fun onTimeout(startId: Int, fgsType: Int) {
stopForeground(STOP_FOREGROUND_DETACH)
stopSelf()
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
val removal = intent?.action == ACTION_REMOVE
val release = intent?.let(::releaseFrom)
@@ -82,6 +82,15 @@ class StoreDownloadService : Service() {
override fun onBind(intent: Intent?): IBinder? = null
override fun onTimeout(startId: Int, fgsType: Int) {
Log.w(TAG, "data sync time used up; pausing downloads")
StoresState.latestDownloads.filter { it.state == DownloadState.RUNNING }.forEach {
DownloadQueue.pause(it.key)
pausedNote(this, it.key)
}
stopNow()
}
private fun pending(action: String, key: String, code: Int): PendingIntent {
val i = Intent(this, StoreDownloadService::class.java).setAction(action).putExtra(EXTRA_KEY, key)
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) PendingIntent.getForegroundService(this, code, i, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)