@@ -643,12 +643,13 @@ class MediaNotificationListener : NotificationListenerService() {
643643 return @launch
644644 }
645645
646- // Generate unique notification ID
647- val notificationId = NotificationDismissalUtil .generateNotificationId(
648- sbn.packageName,
649- title,
650- sbn.postTime
651- )
646+ // Retrieve existing notification ID or generate a new one
647+ val notificationId = NotificationDismissalUtil .getIdBySystemKey(sbn.key)
648+ ? : NotificationDismissalUtil .generateNotificationId(
649+ sbn.packageName,
650+ title,
651+ sbn.postTime
652+ )
652653
653654 // Store notification for potential dismissal or actions
654655 NotificationDismissalUtil .storeNotification(notificationId, sbn)
@@ -670,10 +671,37 @@ class MediaNotificationListener : NotificationListenerService() {
670671 Log .w(TAG , " Failed to extract actions: ${e.message} " )
671672 }
672673
674+ // Check for progress bar extras
675+ var progress: Int? = null
676+ var progressMax: Int? = null
677+ var progressIndeterminate: Boolean? = null
678+ val ongoing = (notification.flags and Notification .FLAG_ONGOING_EVENT ) != 0
679+
680+ try {
681+ val hasProgress = extras.containsKey(Notification .EXTRA_PROGRESS ) ||
682+ extras.containsKey(Notification .EXTRA_PROGRESS_MAX )
683+ if (hasProgress) {
684+ val maxVal = extras.getInt(Notification .EXTRA_PROGRESS_MAX , 0 )
685+ val progressVal = extras.getInt(Notification .EXTRA_PROGRESS , 0 )
686+ val indeterminateVal = extras.getBoolean(Notification .EXTRA_PROGRESS_INDETERMINATE , false )
687+
688+ if (maxVal > 0 || indeterminateVal) {
689+ progress = progressVal
690+ progressMax = maxVal
691+ progressIndeterminate = indeterminateVal
692+ }
693+ }
694+ } catch (e: Exception ) {
695+ Log .w(TAG , " Failed to parse notification progress: ${e.message} " )
696+ }
697+
673698 // Get notification priority (alerting vs silent)
674- val priority = getNotificationPriority(sbn)
699+ var priority = getNotificationPriority(sbn)
700+ if (progressMax != null || progressIndeterminate == true ) {
701+ priority = " silent"
702+ }
675703
676- // Create notification JSON with actions
704+ // Create notification JSON with actions and progress details
677705 val notificationJson = JsonUtil .toSingleLine(
678706 JsonUtil .createNotificationJson(
679707 id = notificationId,
@@ -682,7 +710,11 @@ class MediaNotificationListener : NotificationListenerService() {
682710 app = appName,
683711 packageName = sbn.packageName,
684712 priority = priority,
685- actions = actions
713+ actions = actions,
714+ progress = progress,
715+ progressMax = progressMax,
716+ progressIndeterminate = progressIndeterminate,
717+ ongoing = ongoing
686718 )
687719 )
688720
0 commit comments