Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26ea2e5b authored by lyn's avatar lyn
Browse files

Skip HeadsUpManager for silent updates

Bug: 401068530
Test: sent HUNs marked group summaries
      => no calls to HeadsUpManager for silent grouping updates
Test: send status bar chip, tap chip
      => HUN shows
      tap chip again
      => HUN hides
Flag: com.android.systemui.notification_skip_silent_updates
Change-Id: Ib62ef56c3c1e5dc32d2d75dc1a734c056ad43719
parent 75c4c6e6
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -301,6 +301,15 @@ flag {
  }
}

flag {
    name: "notification_skip_silent_updates"
    namespace: "systemui"
    description: "Do not notify HeadsUpManager for silent updates."
    bug: "401068530"
    metadata {
       purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "scene_container"
+51 −22
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.systemui.statusbar.notification.collection.coordinator

import com.android.systemui.Flags.notificationSkipSilentUpdates

import android.app.Notification
import android.app.Notification.GROUP_ALERT_SUMMARY
import android.util.ArrayMap
@@ -465,15 +467,32 @@ constructor(
                            }
                        hunMutator.updateNotification(posted.key, pinnedStatus)
                    }
                } else {
                } else { // shouldHeadsUpEver = false
                    if (posted.isHeadsUpEntry) {
                        if (notificationSkipSilentUpdates()) {
                            if (posted.isPinnedByUser) {
                                // We don't want this to be interrupting anymore, let's remove it
                        // If the notification is pinned by the user, the only way a user can un-pin
                        // it is by tapping the status bar notification chip. Since that's a clear
                        // user action, we should remove the HUN immediately instead of waiting for
                        // any sort of minimum timeout.
                                // If the notification is pinned by the user, the only way a user
                                // can un-pin it by tapping the status bar notification chip. Since
                                // that's a clear user action, we should remove the HUN immediately
                                // instead of waiting for any sort of minimum timeout.
                                // TODO(b/401068530) Ensure that status bar chip HUNs are not
                                //  removed for silent update
                                hunMutator.removeNotification(posted.key,
                                    /* releaseImmediately= */ true)
                            } else {
                                // Do NOT remove HUN for non-user update.
                                // Let the HUN show for its remaining duration.
                            }
                        } else {
                            // We don't want this to be interrupting anymore, let's remove it
                            // If the notification is pinned by the user, the only way a user can
                            // un-pin it is by tapping the status bar notification chip. Since
                            // that's a clear user action, we should remove the HUN immediately
                            // instead of waiting for any sort of minimum timeout.
                            val shouldRemoveImmediately = posted.isPinnedByUser
                            hunMutator.removeNotification(posted.key, shouldRemoveImmediately)
                        }
                    } else {
                        // Don't let the bind finish
                        cancelHeadsUpBind(posted.entry)
@@ -573,10 +592,20 @@ constructor(
                                isBinding = isBinding,
                            )
                    }
                // Handle cancelling heads up here, rather than in the OnBeforeFinalizeFilter, so
                // that
                // work can be done before the ShadeListBuilder is run. This prevents re-entrant
                // behavior between this Coordinator, HeadsUpManager, and VisualStabilityManager.
                if (notificationSkipSilentUpdates()) {
                    // TODO(b/403703828) Move canceling to OnBeforeFinalizeFilter, since we are not
                    //  removing from HeadsUpManager and don't need to deal with re-entrant behavior
                    //  between HeadsUpCoordinator, HeadsUpManager, and VisualStabilityManager.
                    if (posted?.shouldHeadsUpEver == false
                        && !posted.isHeadsUpEntry && posted.isBinding) {
                        // Don't let the bind finish
                        cancelHeadsUpBind(posted.entry)
                    }
                } else {
                    // Handle cancelling heads up here, rather than in the OnBeforeFinalizeFilter,
                    // so that work can be done before the ShadeListBuilder is run. This prevents
                    // re-entrant behavior between this Coordinator, HeadsUpManager, and
                    // VisualStabilityManager.
                    if (posted?.shouldHeadsUpEver == false) {
                        if (posted.isHeadsUpEntry) {
                            // We don't want this to be interrupting anymore, let's remove it
@@ -590,7 +619,7 @@ constructor(
                            cancelHeadsUpBind(posted.entry)
                        }
                    }

                }
                // Update last updated time for this entry
                setUpdateTime(entry, mSystemClock.currentTimeMillis())
            }