diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/notification/BackupNotificationManager.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/notification/BackupNotificationManager.kt index 89f006708..2acb2b454 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/ui/notification/BackupNotificationManager.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/notification/BackupNotificationManager.kt @@ -7,6 +7,8 @@ package com.stevesoltys.seedvault.ui.notification import android.annotation.SuppressLint import android.app.Notification +import android.app.Notification.FLAG_AUTOGROUP_SUMMARY +import android.app.Notification.FLAG_USER_INITIATED_JOB import android.app.NotificationChannel import android.app.NotificationManager import android.app.NotificationManager.IMPORTANCE_DEFAULT @@ -23,6 +25,7 @@ import android.util.Log import androidx.core.app.NotificationCompat.Action import androidx.core.app.NotificationCompat.Builder import androidx.core.app.NotificationCompat.CATEGORY_ERROR +import androidx.core.app.NotificationCompat.FLAG_FOREGROUND_SERVICE import androidx.core.app.NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE import androidx.core.app.NotificationCompat.PRIORITY_DEFAULT import androidx.core.app.NotificationCompat.PRIORITY_HIGH @@ -195,6 +198,28 @@ internal class BackupNotificationManager(private val context: Context) { setProgress(0, 0, false) priority = PRIORITY_LOW }.build() + + Log.e("TEST", "CANCEL NOTIFICATION!") + val mustHaveFlags = 0 + val mustNotHaveFlags = + (FLAG_FOREGROUND_SERVICE or + Notification.FLAG_USER_INITIATED_JOB or + Notification.FLAG_AUTOGROUP_SUMMARY or 0x00010000) + nm.activeNotifications.forEach { + if (it.packageName == context.packageName) { + val flags = it.notification.flags + Log.e( + "TEST", + "${it.id} ${it.isOngoing} ${it.postTime} ${it.notification.channelId}" + ) + Log.e( + "TEST", + "$ mustHaveFlags $flags - ${(flags and mustHaveFlags) != mustHaveFlags}" + ) + Log.e("TEST", "$ mustNotHaveFlags $flags - ${(flags and mustNotHaveFlags) != 0}") + } + } + nm.cancel(NOTIFICATION_ID_OBSERVER) nm.notify(NOTIFICATION_ID_SUCCESS, notification) }