Set foreground service types for library update jobs

(cherry picked from commit 82d9ae31bdde0abaefeb78995d60b6c6b22e6052)
This commit is contained in:
arkon 2023-12-02 11:20:41 -05:00 committed by Jobobby04
parent 2387db1972
commit d1c8c2d18e
2 changed files with 14 additions and 0 deletions

View File

@ -1,6 +1,8 @@
package eu.kanade.tachiyomi.data.library
import android.content.Context
import android.content.pm.ServiceInfo
import android.os.Build
import androidx.work.BackoffPolicy
import androidx.work.Constraints
import androidx.work.CoroutineWorker
@ -192,6 +194,11 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
return ForegroundInfo(
Notifications.ID_LIBRARY_PROGRESS,
notifier.progressNotificationBuilder.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.library
import android.content.Context
import android.content.pm.ServiceInfo
import android.os.Build
import androidx.work.CoroutineWorker
import androidx.work.ExistingWorkPolicy
import androidx.work.ForegroundInfo
@ -82,6 +84,11 @@ class MetadataUpdateJob(private val context: Context, workerParams: WorkerParame
return ForegroundInfo(
Notifications.ID_LIBRARY_PROGRESS,
notifier.progressNotificationBuilder.build(),
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
} else {
0
},
)
}