Set foreground service types for remaining jobs

This commit is contained in:
arkon 2023-12-16 12:08:08 -05:00
parent cd16522805
commit db3ddf07ee
3 changed files with 21 additions and 0 deletions

View file

@ -1,7 +1,9 @@
package eu.kanade.tachiyomi.data.backup.create package eu.kanade.tachiyomi.data.backup.create
import android.content.Context import android.content.Context
import android.content.pm.ServiceInfo
import android.net.Uri import android.net.Uri
import android.os.Build
import androidx.core.net.toUri import androidx.core.net.toUri
import androidx.work.BackoffPolicy import androidx.work.BackoffPolicy
import androidx.work.Constraints import androidx.work.Constraints
@ -70,6 +72,11 @@ class BackupCreateJob(private val context: Context, workerParams: WorkerParamete
return ForegroundInfo( return ForegroundInfo(
Notifications.ID_BACKUP_PROGRESS, Notifications.ID_BACKUP_PROGRESS,
notifier.showBackupProgress().build(), notifier.showBackupProgress().build(),
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
} else {
0
},
) )
} }

View file

@ -1,7 +1,9 @@
package eu.kanade.tachiyomi.data.backup.restore package eu.kanade.tachiyomi.data.backup.restore
import android.content.Context import android.content.Context
import android.content.pm.ServiceInfo
import android.net.Uri import android.net.Uri
import android.os.Build
import androidx.core.net.toUri import androidx.core.net.toUri
import androidx.work.CoroutineWorker import androidx.work.CoroutineWorker
import androidx.work.ExistingWorkPolicy import androidx.work.ExistingWorkPolicy
@ -54,6 +56,11 @@ class BackupRestoreJob(private val context: Context, workerParams: WorkerParamet
return ForegroundInfo( return ForegroundInfo(
Notifications.ID_RESTORE_PROGRESS, Notifications.ID_RESTORE_PROGRESS,
notifier.showRestoreProgress().build(), notifier.showRestoreProgress().build(),
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
} else {
0
},
) )
} }

View file

@ -1,6 +1,8 @@
package eu.kanade.tachiyomi.data.updater package eu.kanade.tachiyomi.data.updater
import android.content.Context import android.content.Context
import android.content.pm.ServiceInfo
import android.os.Build
import androidx.work.Constraints import androidx.work.Constraints
import androidx.work.CoroutineWorker import androidx.work.CoroutineWorker
import androidx.work.ExistingWorkPolicy import androidx.work.ExistingWorkPolicy
@ -55,6 +57,11 @@ class AppUpdateDownloadJob(private val context: Context, workerParams: WorkerPar
return ForegroundInfo( return ForegroundInfo(
Notifications.ID_APP_UPDATER, Notifications.ID_APP_UPDATER,
notifier.onDownloadStarted().build(), notifier.onDownloadStarted().build(),
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
} else {
0
},
) )
} }