foreground info fixes

pull/593/head
zaednasr 2 years ago
parent e14cd4fccb
commit ecc1844e3a
No known key found for this signature in database
GPG Key ID: 92B1DE23AD3D0E9E

@ -23,6 +23,8 @@
<!-- queueing processing downloads in the background-->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<!-- foreground service permission for android 14 and up-->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<application
@ -485,6 +487,10 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="specialUse"/>
</application>
</manifest>

@ -511,7 +511,7 @@ class HistoryFragment : Fragment(), HistoryAdapter.OnItemClickListener{
websiteList = mutableListOf()
for (item in list){
if (item.website == "null" || item.website.isEmpty()) continue
if (!websiteList.contains(item.website)) websiteList.add(item.website)
if (!websiteList.any { it.contentEquals(item.website, true) }) websiteList.add(item.website)
}
}

@ -1,6 +1,8 @@
package com.deniscerri.ytdl.work
import android.content.Context
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
import android.os.Build
import androidx.work.CoroutineWorker
import androidx.work.ForegroundInfo
import androidx.work.WorkerParameters
@ -23,8 +25,11 @@ class CleanUpLeftoverDownloads(
val id = System.currentTimeMillis().toInt()
val notification = notificationUtil.createDeletingLeftoverDownloadsNotification()
val foregroundInfo = ForegroundInfo(id, notification)
setForegroundAsync(foregroundInfo)
if (Build.VERSION.SDK_INT > 33) {
setForegroundAsync(ForegroundInfo(id, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE))
}else{
setForegroundAsync(ForegroundInfo(id, notification))
}
val dbManager = DBManager.getInstance(context)
val downloadRepo = DownloadRepository(dbManager.downloadDao)

@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
import android.content.res.Configuration
import android.content.res.Resources
import android.os.Build
@ -105,8 +106,12 @@ class DownloadWorker(
)
val workNotif = notificationUtil.createDefaultWorkerNotification()
val foregroundInfo = ForegroundInfo(1000000000, workNotif)
setForegroundAsync(foregroundInfo)
val notificationID = 1000000000
if (Build.VERSION.SDK_INT > 33) {
setForegroundAsync(ForegroundInfo(notificationID, workNotif, FOREGROUND_SERVICE_TYPE_SPECIAL_USE))
}else{
setForegroundAsync(ForegroundInfo(notificationID, workNotif))
}
queuedItems.collectLatest { items ->
if (this@DownloadWorker.isStopped) return@collectLatest

@ -3,6 +3,7 @@ package com.deniscerri.ytdl.work
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
import android.os.Build
import android.os.Environment
import android.os.Handler
@ -39,8 +40,12 @@ class MoveCacheFilesWorker(
val intent = Intent(context, MainActivity::class.java)
val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE)
val notification = notificationUtil.createMoveCacheFilesNotification(pendingIntent, NotificationUtil.DOWNLOAD_MISC_CHANNEL_ID)
val foregroundInfo = ForegroundInfo(id, notification)
setForegroundAsync(foregroundInfo)
if (Build.VERSION.SDK_INT > 33) {
setForegroundAsync(ForegroundInfo(id, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE))
}else{
setForegroundAsync(ForegroundInfo(id, notification))
}
var progress = 0
allContent.forEach {

@ -1,6 +1,8 @@
package com.deniscerri.ytdl.work
import android.content.Context
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
import android.os.Build
import android.util.Log
import androidx.preference.PreferenceManager
import androidx.work.Constraints
@ -52,8 +54,11 @@ class ObserveSourceWorker(
val workerID = System.currentTimeMillis().toInt()
val notification = notificationUtil.createObserveSourcesNotification(item.name)
val foregroundInfo = ForegroundInfo(workerID, notification)
setForegroundAsync(foregroundInfo)
if (Build.VERSION.SDK_INT > 33) {
setForegroundAsync(ForegroundInfo(workerID, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE))
}else{
setForegroundAsync(ForegroundInfo(workerID, notification))
}
val list = kotlin.runCatching {
ytdlpUtil.getFromYTDL(item.url)

@ -3,6 +3,8 @@ package com.deniscerri.ytdl.work
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
import android.os.Build
import android.os.Handler
import android.os.Looper
import android.util.Log
@ -50,9 +52,12 @@ class TerminalDownloadWorker(
val intent = Intent(context, TerminalActivity::class.java)
val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE)
val notification = notificationUtil.createDownloadServiceNotification(pendingIntent, command.take(65), NotificationUtil.DOWNLOAD_TERMINAL_RUNNING_NOTIFICATION_ID)
val foregroundInfo = ForegroundInfo(itemId, notification)
setForegroundAsync(foregroundInfo)
if (Build.VERSION.SDK_INT > 33) {
setForegroundAsync(ForegroundInfo(itemId, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE))
}else{
setForegroundAsync(ForegroundInfo(itemId, notification))
}
val request = YoutubeDLRequest(emptyList())
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)

@ -1,6 +1,8 @@
package com.deniscerri.ytdl.work
import android.content.Context
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
import android.os.Build
import androidx.work.ForegroundInfo
import androidx.work.Worker
import androidx.work.WorkerParameters
@ -28,8 +30,12 @@ class UpdateMultipleDownloadsFormatsWorker(
if (workID == 0) return Result.failure()
val notification = notificationUtil.createFormatsUpdateNotification()
val foregroundInfo = ForegroundInfo(workID, notification)
setForegroundAsync(foregroundInfo)
if (Build.VERSION.SDK_INT > 33) {
setForegroundAsync(ForegroundInfo(workID, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE))
}else{
setForegroundAsync(ForegroundInfo(workID, notification))
}
var count = 0

Loading…
Cancel
Save