*Service: Remove notifications when stopping the service

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2023-09-23 18:38:30 +05:30
parent 3414c2d622
commit 9bbd03fdec
2 changed files with 17 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import androidx.lifecycle.LifecycleService
import com.aurora.Constants
import com.aurora.extensions.isNAndAbove
import com.aurora.gplayapi.data.models.App
import com.aurora.gplayapi.data.models.File
import com.aurora.store.BuildConfig
@@ -86,7 +87,11 @@ class SelfUpdateService : LifecycleService() {
private fun destroyService() {
Log.d("Self-update service destroyed")
fetch.removeListener(fetchListener)
stopForeground(true)
if (isNAndAbove()) {
stopForeground(STOP_FOREGROUND_REMOVE)
} else {
stopForeground(true)
}
stopSelf()
}

View File

@@ -9,6 +9,7 @@ import androidx.core.content.ContextCompat
import androidx.lifecycle.LifecycleService
import androidx.lifecycle.MutableLiveData
import com.aurora.Constants
import com.aurora.extensions.isNAndAbove
import com.aurora.extensions.isOAndAbove
import com.aurora.extensions.stackTraceToString
import com.aurora.gplayapi.data.models.App
@@ -55,6 +56,11 @@ class UpdateService: LifecycleService() {
if (!data && isEmptyInstalling() && fetchListeners.isEmpty() && appMetadataListeners.isEmpty()) {
Handler(Looper.getMainLooper()).postDelayed ({
if (isEmptyInstalling() && fetchListeners.isEmpty() && appMetadataListeners.isEmpty()) {
if (isNAndAbove()) {
stopForeground(STOP_FOREGROUND_REMOVE)
} else {
stopForeground(true)
}
stopSelf()
}
}, 5 * 1000)
@@ -593,6 +599,11 @@ class UpdateService: LifecycleService() {
fetch.hasActiveDownloads(true) { hasActiveDownloads ->
if (!hasActiveDownloads && isEmptyInstalling() && fetchListeners.isEmpty() && appMetadataListeners.isEmpty()) {
Handler(Looper.getMainLooper()).post {
if (isNAndAbove()) {
stopForeground(STOP_FOREGROUND_REMOVE)
} else {
stopForeground(true)
}
stopSelf()
}
}