File tree 2 files changed +15
-3
lines changed
app/src/main/kotlin/at/bitfire/davdroid
2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ import android.accounts.Account
8
8
import android.app.PendingIntent
9
9
import android.content.Context
10
10
import android.content.Intent
11
+ import android.content.pm.ServiceInfo
12
+ import android.os.Build
11
13
import androidx.core.app.NotificationCompat
12
14
import androidx.core.app.NotificationManagerCompat
13
15
import androidx.hilt.work.HiltWorker
@@ -248,7 +250,11 @@ class RefreshCollectionsWorker @AssistedInject constructor(
248
250
.setOngoing(true )
249
251
.setPriority(NotificationCompat .PRIORITY_LOW )
250
252
.build()
251
- return ForegroundInfo (NotificationUtils .NOTIFY_SYNC_EXPEDITED , notification)
253
+ return if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
254
+ ForegroundInfo (NotificationUtils .NOTIFY_SYNC_EXPEDITED , notification, ServiceInfo .FOREGROUND_SERVICE_TYPE_DATA_SYNC )
255
+ } else {
256
+ ForegroundInfo (NotificationUtils .NOTIFY_SYNC_EXPEDITED , notification)
257
+ }
252
258
}
253
259
254
260
private fun notifyRefreshError (contentText : String , contentIntent : Intent ) {
@@ -574,4 +580,4 @@ class RefreshCollectionsWorker @AssistedInject constructor(
574
580
}
575
581
}
576
582
577
- }
583
+ }
Original file line number Diff line number Diff line change @@ -10,8 +10,10 @@ import android.content.ContentResolver
10
10
import android.content.Context
11
11
import android.content.Intent
12
12
import android.content.SyncResult
13
+ import android.content.pm.ServiceInfo
13
14
import android.net.ConnectivityManager
14
15
import android.net.wifi.WifiManager
16
+ import android.os.Build
15
17
import android.provider.CalendarContract
16
18
import android.provider.ContactsContract
17
19
import androidx.annotation.IntDef
@@ -436,7 +438,11 @@ class SyncWorker @AssistedInject constructor(
436
438
.setOngoing(true )
437
439
.setPriority(NotificationCompat .PRIORITY_LOW )
438
440
.build()
439
- return ForegroundInfo (NotificationUtils .NOTIFY_SYNC_EXPEDITED , notification)
441
+ return if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
442
+ ForegroundInfo (NotificationUtils .NOTIFY_SYNC_EXPEDITED , notification, ServiceInfo .FOREGROUND_SERVICE_TYPE_DATA_SYNC )
443
+ } else {
444
+ ForegroundInfo (NotificationUtils .NOTIFY_SYNC_EXPEDITED , notification)
445
+ }
440
446
}
441
447
442
448
}
You can’t perform that action at this time.
0 commit comments