diff --git a/app/src/main/kotlin/at/bitfire/davdroid/servicedetection/RefreshCollectionsWorker.kt b/app/src/main/kotlin/at/bitfire/davdroid/servicedetection/RefreshCollectionsWorker.kt index 8efd63168117130b56c14f93fc6424736b8e26a4..45aea5d2fc99baaa86e203f59e70b0f9f2405204 100644 --- a/app/src/main/kotlin/at/bitfire/davdroid/servicedetection/RefreshCollectionsWorker.kt +++ b/app/src/main/kotlin/at/bitfire/davdroid/servicedetection/RefreshCollectionsWorker.kt @@ -13,9 +13,11 @@ import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import androidx.hilt.work.HiltWorker import androidx.lifecycle.map +import androidx.work.Constraints import androidx.work.Data import androidx.work.ExistingWorkPolicy import androidx.work.ForegroundInfo +import androidx.work.NetworkType import androidx.work.OneTimeWorkRequestBuilder import androidx.work.OutOfQuotaPolicy import androidx.work.WorkInfo @@ -139,9 +141,15 @@ class RefreshCollectionsWorker @AssistedInject constructor( val arguments = Data.Builder() .putLong(ARG_SERVICE_ID, serviceId) .build() + + val constraints = Constraints.Builder() + .setRequiredNetworkType(NetworkType.CONNECTED) + .build() + val workRequest = OneTimeWorkRequestBuilder() .setInputData(arguments) .setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST) + .setConstraints(constraints) .build() WorkManager.getInstance(context).enqueueUniqueWork(