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

Commit 70a648c8 authored by Evan Laird's avatar Evan Laird
Browse files

DO NOT MERGE Filter out suppressed notifications in entry manager

`NotificationEntryManager#hasActiveNotifications` used to be in 1:1
correspondence with the visible notifications in the shade, and as such
was suitable for code that needs to do things like calculate the height
of the shade. However if there is a bubble, it's still backed by a
notification but is suppressed from the shade.

This CL is unfortunately hacky because the API for
NotificationEntryManager doesn't have the concept of "a notification
which exists but is not in the shade" and therefore the correct fix
actually would involve creating the correct api and updating all call
sites with the correct semantics.

Test: manual
Bug: 161461739
Change-Id: I9b0fc0f48609b64371d3cb7677228b4bb1fa6aef
parent b8c40cde
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.Dumpable;
import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.NotificationLifetimeExtender;
import com.android.systemui.statusbar.NotificationListener;
@@ -189,6 +190,8 @@ public class NotificationEntryManager implements
        }
    }

    private final Lazy<BubbleController> mBubbleControllerLazy;

    /**
     * Injected constructor. See {@link NotificationsModule}.
     */
@@ -201,6 +204,7 @@ public class NotificationEntryManager implements
            Lazy<NotificationRowBinder> notificationRowBinderLazy,
            Lazy<NotificationRemoteInputManager> notificationRemoteInputManagerLazy,
            LeakDetector leakDetector,
            Lazy<BubbleController> bubbleController,
            ForegroundServiceDismissalFeatureController fgsFeatureController) {
        mLogger = logger;
        mGroupManager = groupManager;
@@ -211,6 +215,7 @@ public class NotificationEntryManager implements
        mRemoteInputManagerLazy = notificationRemoteInputManagerLazy;
        mLeakDetector = leakDetector;
        mFgsFeatureController = fgsFeatureController;
        mBubbleControllerLazy = bubbleController;
    }

    /** Once called, the NEM will start processing notification events from system server. */
@@ -920,8 +925,20 @@ public class NotificationEntryManager implements
    /**
     * @return {@code true} if there is at least one notification that should be visible right now
     */
    public boolean hasActiveNotifications() {
        return mReadOnlyNotifications.size() != 0;
    public boolean hasVisibleNotifications() {
        if (mReadOnlyNotifications.size() == 0) {
            return false;
        }

        // Filter out suppressed notifications, which are active notifications backing a bubble
        // but are not present in the shade
        for (NotificationEntry e : mSortedAndFiltered) {
            if (!mBubbleControllerLazy.get().isBubbleNotificationSuppressedFromShade(e)) {
                return true;
            }
        }

        return false;
    }

    @Override
+2 −0
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ public interface NotificationsModule {
            Lazy<NotificationRowBinder> notificationRowBinderLazy,
            Lazy<NotificationRemoteInputManager> notificationRemoteInputManagerLazy,
            LeakDetector leakDetector,
            Lazy<BubbleController> bubbleController,
            ForegroundServiceDismissalFeatureController fgsFeatureController) {
        return new NotificationEntryManager(
                logger,
@@ -97,6 +98,7 @@ public interface NotificationsModule {
                notificationRowBinderLazy,
                notificationRemoteInputManagerLazy,
                leakDetector,
                bubbleController,
                fgsFeatureController);
    }

+1 −1
Original line number Diff line number Diff line
@@ -6580,7 +6580,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
        if (mFeatureFlags.isNewNotifPipelineRenderingEnabled()) {
            return !mNotifPipeline.getShadeList().isEmpty();
        } else {
            return mEntryManager.hasActiveNotifications();
            return mEntryManager.hasVisibleNotifications();
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ public class LightsOutNotifController {
    }

    private boolean hasActiveNotifications() {
        return mEntryManager.hasActiveNotifications();
        return mEntryManager.hasVisibleNotifications();
    }

    @VisibleForTesting
+1 −1
Original line number Diff line number Diff line
@@ -3003,7 +3003,7 @@ public class NotificationPanelViewController extends PanelViewController {
    private void updateShowEmptyShadeView() {
        boolean
                showEmptyShadeView =
                mBarState != StatusBarState.KEYGUARD && !mEntryManager.hasActiveNotifications();
                mBarState != StatusBarState.KEYGUARD && !mEntryManager.hasVisibleNotifications();
        showEmptyShadeView(showEmptyShadeView);
    }

Loading