diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index a1fe9b05b2..cd60cd5482 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -14,8 +14,9 @@
-
-
+
+
+
+
+ android:name="androidx.work.impl.foreground.SystemForegroundService"
+ tools:node="remove" />
diff --git a/app/src/main/java/com/nononsenseapps/feeder/archmodel/Repository.kt b/app/src/main/java/com/nononsenseapps/feeder/archmodel/Repository.kt
index 4e5c78a653..11adf36e2a 100644
--- a/app/src/main/java/com/nononsenseapps/feeder/archmodel/Repository.kt
+++ b/app/src/main/java/com/nononsenseapps/feeder/archmodel/Repository.kt
@@ -710,7 +710,6 @@ class Repository(override val di: DI) : DIAware {
val constraints =
Constraints.Builder()
- // This prevents expedited if true
.setRequiresCharging(syncOnlyWhenCharging.value)
if (syncOnlyOnWifi.value) {
diff --git a/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/BaseWorker.kt b/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/BaseWorker.kt
index 073586b701..e63330326f 100644
--- a/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/BaseWorker.kt
+++ b/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/BaseWorker.kt
@@ -4,17 +4,12 @@ import android.annotation.TargetApi
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
-import android.content.pm.ServiceInfo
import android.os.Build
import androidx.annotation.RequiresApi
-import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
-import androidx.work.ForegroundInfo
import com.nononsenseapps.feeder.R
-private const val SYNC_NOTIFICATION_ID = 42623
private const val SYNC_CHANNEL_ID = "feederSyncNotifications"
-private const val SYNC_NOTIFICATION_GROUP = "com.nononsenseapps.feeder.SYNC"
/**
* This is safe to call multiple times
@@ -34,37 +29,3 @@ private fun createNotificationChannel(
notificationManager.createNotificationChannel(channel)
}
-
-/**
- * Necessary for expedited work.
- * Pre Android 12 they will run as foreground services, but on Android 12+ they will run as expedited Jobs.
- */
-fun createForegroundInfo(
- context: Context,
- notificationManager: NotificationManagerCompat,
-): ForegroundInfo {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- createNotificationChannel(context, notificationManager)
- }
-
- val syncingText = context.getString(R.string.syncing)
-
- val notification =
- NotificationCompat.Builder(context.applicationContext, SYNC_CHANNEL_ID)
- .setContentTitle(syncingText)
- .setTicker(syncingText)
- .setGroup(SYNC_NOTIFICATION_GROUP)
- .setSmallIcon(R.drawable.ic_stat_sync)
- .setOngoing(true)
- .build()
-
- return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
- ForegroundInfo(
- SYNC_NOTIFICATION_ID,
- notification,
- ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC,
- )
- } else {
- ForegroundInfo(SYNC_NOTIFICATION_ID, notification)
- }
-}
diff --git a/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/BlockListWorker.kt b/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/BlockListWorker.kt
index dbbcd931d2..6b9d87ce92 100644
--- a/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/BlockListWorker.kt
+++ b/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/BlockListWorker.kt
@@ -1,9 +1,7 @@
package com.nononsenseapps.feeder.model.workmanager
import android.content.Context
-import androidx.core.app.NotificationManagerCompat
import androidx.work.CoroutineWorker
-import androidx.work.ForegroundInfo
import androidx.work.WorkerParameters
import com.nononsenseapps.feeder.db.room.BlocklistDao
import com.nononsenseapps.feeder.db.room.ID_UNSET
@@ -20,13 +18,8 @@ class BlockListWorker(val context: Context, workerParams: WorkerParameters) :
CoroutineWorker(context, workerParams), DIAware {
override val di: DI by closestDI(context)
- private val notificationManager: NotificationManagerCompat by instance()
private val blocklistDao: BlocklistDao by instance()
- override suspend fun getForegroundInfo(): ForegroundInfo {
- return createForegroundInfo(context, notificationManager)
- }
-
override suspend fun doWork(): Result {
logDebug(LOG_TAG, "Doing work...")
diff --git a/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/FeedSyncer.kt b/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/FeedSyncer.kt
index 641647ee22..3170259115 100644
--- a/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/FeedSyncer.kt
+++ b/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/FeedSyncer.kt
@@ -2,14 +2,11 @@ package com.nononsenseapps.feeder.model.workmanager
import android.content.Context
import android.util.Log
-import androidx.core.app.NotificationManagerCompat
import androidx.work.Constraints
import androidx.work.CoroutineWorker
import androidx.work.ExistingWorkPolicy
-import androidx.work.ForegroundInfo
import androidx.work.NetworkType
import androidx.work.OneTimeWorkRequestBuilder
-import androidx.work.OutOfQuotaPolicy
import androidx.work.WorkManager
import androidx.work.WorkerParameters
import androidx.work.workDataOf
@@ -42,13 +39,8 @@ class FeedSyncer(val context: Context, workerParams: WorkerParameters) :
CoroutineWorker(context, workerParams), DIAware {
override val di: DI by closestDI(context)
- private val notificationManager: NotificationManagerCompat by instance()
private val rssLocalSync: RssLocalSync by instance()
- override suspend fun getForegroundInfo(): ForegroundInfo {
- return createForegroundInfo(context, notificationManager)
- }
-
override suspend fun doWork(): Result {
var success: Boolean
@@ -98,7 +90,6 @@ fun requestFeedSync(
val workRequest =
OneTimeWorkRequestBuilder()
.addTag("feeder")
- .setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
.keepResultsForAtLeast(5, TimeUnit.MINUTES)
.setConstraints(constraints.build())
diff --git a/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/SyncServiceGetUpdatesWorker.kt b/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/SyncServiceGetUpdatesWorker.kt
index 9cc4dda7ad..61c81be2b8 100644
--- a/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/SyncServiceGetUpdatesWorker.kt
+++ b/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/SyncServiceGetUpdatesWorker.kt
@@ -2,11 +2,9 @@ package com.nononsenseapps.feeder.model.workmanager
import android.content.Context
import android.util.Log
-import androidx.core.app.NotificationManagerCompat
import androidx.work.Constraints
import androidx.work.CoroutineWorker
import androidx.work.ExistingWorkPolicy
-import androidx.work.ForegroundInfo
import androidx.work.NetworkType
import androidx.work.OneTimeWorkRequestBuilder
import androidx.work.WorkManager
@@ -24,14 +22,9 @@ class SyncServiceGetUpdatesWorker(val context: Context, workerParams: WorkerPara
CoroutineWorker(context, workerParams), DIAware {
override val di: DI by closestDI(context)
- private val notificationManager: NotificationManagerCompat by instance()
private val syncClient: SyncRestClient by instance()
private val repository: Repository by instance()
- override suspend fun getForegroundInfo(): ForegroundInfo {
- return createForegroundInfo(context, notificationManager)
- }
-
override suspend fun doWork(): Result {
return try {
Log.d(LOG_TAG, "Doing work")
@@ -57,7 +50,6 @@ fun scheduleGetUpdates(di: DI) {
val constraints =
Constraints.Builder()
- // This prevents expedited if true
.setRequiresCharging(repository.syncOnlyWhenCharging.value)
if (repository.syncOnlyOnWifi.value) {
diff --git a/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/SyncServiceSendReadWorker.kt b/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/SyncServiceSendReadWorker.kt
index 07bb127372..77ea2b239c 100644
--- a/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/SyncServiceSendReadWorker.kt
+++ b/app/src/main/java/com/nononsenseapps/feeder/model/workmanager/SyncServiceSendReadWorker.kt
@@ -2,9 +2,7 @@ package com.nononsenseapps.feeder.model.workmanager
import android.content.Context
import android.util.Log
-import androidx.core.app.NotificationManagerCompat
import androidx.work.CoroutineWorker
-import androidx.work.ForegroundInfo
import androidx.work.WorkerParameters
import com.nononsenseapps.feeder.sync.SyncRestClient
import org.kodein.di.DI
@@ -16,13 +14,8 @@ class SyncServiceSendReadWorker(val context: Context, workerParams: WorkerParame
CoroutineWorker(context, workerParams), DIAware {
override val di: DI by closestDI(context)
- private val notificationManager: NotificationManagerCompat by instance()
private val syncClient: SyncRestClient by di.instance()
- override suspend fun getForegroundInfo(): ForegroundInfo {
- return createForegroundInfo(context, notificationManager)
- }
-
override suspend fun doWork(): Result {
return try {
Log.d(LOG_TAG, "Doing work")