Skip to content

Commit

Permalink
DO NOT MERGE: log notification flags right before cancelling
Browse files Browse the repository at this point in the history
  • Loading branch information
grote committed Jul 3, 2024
1 parent e07e043 commit 9edc28c
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 9edc28c

Please sign in to comment.