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

Commit a3c5d000 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Clean up NotificationIconAreaController.shouldShowNotificationIcon() for new pipeline

In the new pipeline:
* rows are never GONE.
* the List<ListEntry> is hierarchical, so isTopLevelChild() is redundant.
* "low priority" and "ambient" map to "silent section" and "minimized", so use the pipeline-assigned section to perform the filtering.

Understanding the pipeline-assigned section's type required adding the "silent" section classifications to the SectionStyleProvider.

isTopLevelChild() is now unused, so it has been removed.  Yay!

Fixes: 237296171
Test: atest NotificationIconAreaControllerTest
Change-Id: I8c4b0435fdb43be2b0f99728ef8fbc8733ea1c43
parent d9d6622f
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -619,14 +619,6 @@ public final class NotificationEntry extends ListEntry {
        return row.isMediaRow();
    }

    /**
     * We are a top level child if our parent is the list of notifications duh
     * @return {@code true} if we're a top level notification
     */
    public boolean isTopLevelChild() {
        return row != null && row.isTopLevelChild();
    }

    public void resetUserExpansion() {
        if (row != null) row.resetUserExpansion();
    }
+5 −2
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import com.android.systemui.statusbar.notification.dagger.AlertingHeader;
import com.android.systemui.statusbar.notification.dagger.SilentHeader;
import com.android.systemui.statusbar.notification.stack.NotificationPriorityBucketKt;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@@ -78,6 +79,8 @@ public class RankingCoordinator implements Coordinator {
    public void attach(NotifPipeline pipeline) {
        mStatusBarStateController.addCallback(mStatusBarStateCallback);
        mSectionStyleProvider.setMinimizedSections(Collections.singleton(mMinimizedNotifSectioner));
        mSectionStyleProvider.setSilentSections(
                Arrays.asList(mSilentNotifSectioner, mMinimizedNotifSectioner));

        pipeline.addPreGroupFilter(mSuspendedFilter);
        pipeline.addPreGroupFilter(mDndVisualEffectsFilter);
+36 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.notification.collection.provider

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.statusbar.notification.collection.ListEntry
import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner
import javax.inject.Inject
@@ -27,6 +28,7 @@ import javax.inject.Inject
 */
@SysUISingleton
class SectionStyleProvider @Inject constructor() {
    private lateinit var silentSections: Set<NotifSectioner>
    private lateinit var lowPrioritySections: Set<NotifSectioner>

    /**
@@ -38,9 +40,42 @@ class SectionStyleProvider @Inject constructor() {
    }

    /**
     * Determine if the given section is minimized
     * Determine if the given section is minimized.
     */
    fun isMinimizedSection(section: NotifSection): Boolean {
        return lowPrioritySections.contains(section.sectioner)
    }

    /**
     * Determine if the given entry is minimized.
     */
    @JvmOverloads
    fun isMinimized(entry: ListEntry, ifNotInSection: Boolean = true): Boolean {
        val section = entry.section ?: return ifNotInSection
        return isMinimizedSection(section)
    }

    /**
     * Feed the provider the information it needs about which sections are silent, so that it can
     * calculate which entries are in a "silent" section.
     */
    fun setSilentSections(sections: Collection<NotifSectioner>) {
        silentSections = sections.toSet()
    }

    /**
     * Determine if the given section is silent.
     */
    fun isSilentSection(section: NotifSection): Boolean {
        return silentSections.contains(section.sectioner)
    }

    /**
     * Determine if the given entry is silent.
     */
    @JvmOverloads
    fun isSilent(entry: ListEntry, ifNotInSection: Boolean = true): Boolean {
        val section = entry.section ?: return ifNotInSection
        return isSilentSection(section)
    }
}
+0 −5
Original line number Diff line number Diff line
@@ -110,7 +110,6 @@ import com.android.systemui.statusbar.notification.stack.AmbientState;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.notification.stack.ExpandableViewState;
import com.android.systemui.statusbar.notification.stack.NotificationChildrenContainer;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.SwipeableView;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.policy.HeadsUpManager;
@@ -3587,10 +3586,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        return mEntry.getSbn().getNotification().isMediaNotification();
    }

    public boolean isTopLevelChild() {
        return getParent() instanceof NotificationStackScrollLayout;
    }

    public boolean isGroupNotFullyVisible() {
        return getClipTopAmount() > 0 || getTranslationY() < 0;
    }
+6 −9
Original line number Diff line number Diff line
package com.android.systemui.statusbar.phone;

import android.app.NotificationManager;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
@@ -39,6 +38,7 @@ import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator
import com.android.systemui.statusbar.notification.PropertyAnimator;
import com.android.systemui.statusbar.notification.collection.ListEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.provider.SectionStyleProvider;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.window.StatusBarWindowController;
import com.android.wm.shell.bubbles.Bubbles;
@@ -73,6 +73,7 @@ public class NotificationIconAreaController implements
    private final NotificationWakeUpCoordinator mWakeUpCoordinator;
    private final KeyguardBypassController mBypassController;
    private final DozeParameters mDozeParameters;
    private final SectionStyleProvider mSectionStyleProvider;
    private final Optional<Bubbles> mBubblesOptional;
    private final StatusBarWindowController mStatusBarWindowController;
    private final ScreenOffAnimationController mScreenOffAnimationController;
@@ -117,6 +118,7 @@ public class NotificationIconAreaController implements
            NotificationMediaManager notificationMediaManager,
            NotificationListener notificationListener,
            DozeParameters dozeParameters,
            SectionStyleProvider sectionStyleProvider,
            Optional<Bubbles> bubblesOptional,
            DemoModeController demoModeController,
            DarkIconDispatcher darkIconDispatcher,
@@ -128,6 +130,7 @@ public class NotificationIconAreaController implements
        mStatusBarStateController.addCallback(this);
        mMediaManager = notificationMediaManager;
        mDozeParameters = dozeParameters;
        mSectionStyleProvider = sectionStyleProvider;
        mWakeUpCoordinator = wakeUpCoordinator;
        wakeUpCoordinator.addListener(this);
        mBypassController = keyguardBypassController;
@@ -260,19 +263,13 @@ public class NotificationIconAreaController implements
    protected boolean shouldShowNotificationIcon(NotificationEntry entry,
            boolean showAmbient, boolean showLowPriority, boolean hideDismissed,
            boolean hideRepliedMessages, boolean hideCurrentMedia, boolean hidePulsing) {
        if (entry.getRanking().isAmbient() && !showAmbient) {
        if (!showAmbient && mSectionStyleProvider.isMinimized(entry)) {
            return false;
        }
        if (hideCurrentMedia && entry.getKey().equals(mMediaManager.getMediaNotificationKey())) {
            return false;
        }
        if (!showLowPriority && entry.getImportance() < NotificationManager.IMPORTANCE_DEFAULT) {
            return false;
        }
        if (!entry.isTopLevelChild()) {
            return false;
        }
        if (entry.getRow().getVisibility() == View.GONE) {
        if (!showLowPriority && mSectionStyleProvider.isSilent(entry)) {
            return false;
        }
        if (entry.isRowDismissed() && hideDismissed) {
Loading