UpdateWorker: Drop non-required foregroundInfo method
We are not an expedited nor in foreground, no need to have foregroundInfo method with an ongoing notification. Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -7,7 +7,6 @@ import androidx.hilt.work.HiltWorker
|
||||
import androidx.work.Constraints
|
||||
import androidx.work.CoroutineWorker
|
||||
import androidx.work.ExistingPeriodicWorkPolicy.KEEP
|
||||
import androidx.work.ForegroundInfo
|
||||
import androidx.work.NetworkType
|
||||
import androidx.work.PeriodicWorkRequest
|
||||
import androidx.work.PeriodicWorkRequestBuilder
|
||||
@@ -83,7 +82,6 @@ class UpdateWorker @AssistedInject constructor(
|
||||
}
|
||||
|
||||
private val notificationID = 100
|
||||
private val workerID = 101
|
||||
|
||||
override suspend fun doWork(): Result {
|
||||
Log.i(TAG, "Checking for app updates")
|
||||
@@ -139,8 +137,4 @@ class UpdateWorker @AssistedInject constructor(
|
||||
}
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
override suspend fun getForegroundInfo(): ForegroundInfo {
|
||||
return ForegroundInfo(workerID, NotificationUtil.getOngoingUpdateNotification(appContext))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,6 @@ import java.util.UUID
|
||||
|
||||
object NotificationUtil {
|
||||
|
||||
private const val TAG = "NotificationUtil"
|
||||
|
||||
fun createNotificationChannel(context: Context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val notificationManager =
|
||||
@@ -181,27 +179,6 @@ object NotificationUtil {
|
||||
.build()
|
||||
}
|
||||
|
||||
fun getOngoingUpdateNotification(context: Context): Notification {
|
||||
val contentIntent = PendingIntent.getActivity(
|
||||
context,
|
||||
0,
|
||||
Intent(context, MainActivity::class.java),
|
||||
PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
|
||||
return NotificationCompat.Builder(context, Constants.NOTIFICATION_CHANNEL_UPDATES)
|
||||
.setSmallIcon(R.drawable.ic_logo)
|
||||
.setContentTitle(context.getString(R.string.checking_for_updates))
|
||||
.setContentIntent(contentIntent)
|
||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||
.setCategory(NotificationCompat.CATEGORY_SERVICE)
|
||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
.setForegroundServiceBehavior(NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE)
|
||||
.setProgress(100, 0, true)
|
||||
.setOngoing(true)
|
||||
.build()
|
||||
}
|
||||
|
||||
fun getUpdateNotification(context: Context, updatesList: List<App>): Notification {
|
||||
val contentIntent = NavDeepLinkBuilder(context)
|
||||
.setGraph(R.navigation.mobile_navigation)
|
||||
|
||||
Reference in New Issue
Block a user