@@ -7,6 +7,20 @@ import android.service.notification.StatusBarNotification
77import androidx.core.app.NotificationManagerCompat
88import timber.log.Timber
99
10+ // Groups are defined here:
11+ // https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/services/core/java/com/android/server/notification/GroupHelper.java;drc=d5d4670d8a245da5468af767b17d1e57ed7c9278;l=2106
12+ // Section names are defined here:
13+ // https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/services/core/java/com/android/server/notification/GroupHelper.java;drc=d5d4670d8a245da5468af767b17d1e57ed7c9278;l=195-199
14+ private val ANDROID_AUTO_GROUP_SUFFIXES = listOf (
15+ " |g:ranker_group" ,
16+ " |g:Aggregate_AlertingSection" ,
17+ " |g:Aggregate_NewsSection" ,
18+ " |g:Aggregate_PromotionsSection" ,
19+ " |g:Aggregate_RecsSection" ,
20+ " |g:Aggregate_SocialSection" ,
21+ " |g:Aggregate_SilentSection" ,
22+ )
23+
1024fun NotificationManagerCompat.getNotificationManager (): NotificationManager {
1125 val field = this .javaClass.declaredFields
1226 .toList().first { it.name == " mNotificationManager" }
@@ -49,8 +63,8 @@ fun cancelNotificationGroupIfNeeded(
4963 // Yes it has a group.
5064 Timber .d(" Notification is in a group ($groupKey ). Get all notifications for this group..." )
5165
52- // Check if the group is the auto group of android ("ranker_group")
53- if (! groupKey.endsWith(" |g:ranker_group " ) ) {
66+ // Check if the group is one of the auto groups of android
67+ if (ANDROID_AUTO_GROUP_SUFFIXES .none { groupKey.endsWith(it) } ) {
5468 // Nope it is a custom group. Get notifications of the group...
5569 val groupNotifications =
5670 currentActiveNotifications.filter { s -> s.groupKey == groupKey }
@@ -116,7 +130,7 @@ fun cancelNotificationGroupIfNeeded(
116130 }
117131 }
118132 } else {
119- Timber .d(" Notification is in a group ($groupKey ), but it is in the auto group. Cancel notification" )
133+ Timber .d(" Notification is in a group ($groupKey ), but it is in an auto group. Cancel notification" )
120134 }
121135 } else {
122136 if (statusBarNotification == null ) {
0 commit comments