Skip to content

Commit

Permalink
add service type for work manager system foreground service
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutoshgngwr committed Mar 9, 2024
1 parent 743b166 commit 079eb13
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@

</provider>

<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="dataSync"
tools:node="merge" />

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.github.ashutoshgngwr.noice.worker

import android.annotation.SuppressLint
import android.content.Context
import android.content.pm.ServiceInfo
import android.util.Log
import androidx.core.content.edit
import androidx.core.net.toUri
Expand Down Expand Up @@ -153,8 +155,13 @@ class SoundDownloadsRefreshWorker @AssistedInject constructor(
return Result.success()
}

@SuppressLint("InlinedApi") // foreground service type constant
override suspend fun getForegroundInfo(): ForegroundInfo {
return ForegroundInfo(0x03, notificationManager.refreshWorkerNotification)
return ForegroundInfo(
0x03,
notificationManager.refreshWorkerNotification,
ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC,
)
}

private suspend fun hasSubscription(): Boolean {
Expand Down

0 comments on commit 079eb13

Please sign in to comment.