mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-11-01 15:23:54 +01:00
UploadWorker: add foreground service type
This commit is contained in:
parent
d9494abf24
commit
03b5b278fb
2 changed files with 18 additions and 4 deletions
|
|
@ -25,6 +25,7 @@
|
|||
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED"
|
||||
android:minSdkVersion="34"/>
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||
|
||||
<queries>
|
||||
<!-- Browser -->
|
||||
|
|
@ -201,6 +202,10 @@
|
|||
android:name="org.acra.sender.SenderService"
|
||||
android:exported="false"
|
||||
android:process=":acra" />
|
||||
|
||||
<service
|
||||
android:name="androidx.work.impl.foreground.SystemForegroundService"
|
||||
android:foregroundServiceType="dataSync" />
|
||||
|
||||
<provider
|
||||
android:name=".filepicker.ExtendedFileProvider"
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.app.PendingIntent
|
|||
import android.app.TaskStackBuilder
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.ServiceInfo
|
||||
import android.graphics.BitmapFactory
|
||||
import android.os.Build
|
||||
import androidx.core.app.NotificationCompat
|
||||
|
|
@ -271,10 +272,18 @@ class UploadWorker(
|
|||
* Create new notification for foreground service
|
||||
*/
|
||||
private fun createForegroundInfo(): ForegroundInfo {
|
||||
return ForegroundInfo(
|
||||
1,
|
||||
createNotificationForForegroundService()
|
||||
)
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
ForegroundInfo(
|
||||
1,
|
||||
createNotificationForForegroundService(),
|
||||
ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
|
||||
)
|
||||
} else {
|
||||
ForegroundInfo(
|
||||
1,
|
||||
createNotificationForForegroundService()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getForegroundInfo(): ForegroundInfo {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue