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

Commit 181de624 authored by Evan Laird's avatar Evan Laird
Browse files

Remove NotificationData

Ye olde NotificationData class was responsible for a few general things:
- Keep a list of visible `NotificationEntry`s
- Filter / sort the visible entries
- Keep a sorted / filtered list of those entries
- Answer lots of questions about the entries themselves (rank,
isAmbient, list of entries for current user, etc.)
- Keep track of the current RankingMap
- Set priority buckets on entries
- Tell the group manager when things changed

The basic idea here is to remove NotificationData in favor of 3 other
changes:

1. Any place which needed to query NotificationData for info about the
entry (in particular its ranking) can just ask the entry for it now.
Entries all keep a reference to their rank

2. NotificationEntryManager now just maintains its own list of visible
notifications. It was already the point of contact to get a handle to
NotificationData so this makes call sites simpler.

3. Create a simpler NotificationRankingManager (maybe delete this
eventually) to encapsulate the sorting logic and hang on to the latest
RankingMap

Test: atest SystemUITests
Change-Id: I14073e103c6d50da37207ca8fd86828da0aaaff9
parent bc7671b9
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ import com.android.systemui.statusbar.car.CarStatusBar;
import com.android.systemui.statusbar.car.CarStatusBarKeyguardViewManager;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
import com.android.systemui.statusbar.notification.collection.NotificationData;
import com.android.systemui.statusbar.phone.KeyguardEnvironmentImpl;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;
@@ -101,7 +100,7 @@ abstract class CarSystemUIModule {
    abstract DockManager bindDockManager(DockManagerImpl dockManager);

    @Binds
    abstract NotificationData.KeyguardEnvironment bindKeyguardEnvironment(
    abstract NotificationEntryManager.KeyguardEnvironment bindKeyguardEnvironment(
            KeyguardEnvironmentImpl keyguardEnvironment);

    @Binds
+8 −3
Original line number Diff line number Diff line
@@ -19,8 +19,9 @@ import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;

import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.collection.NotificationData;
import com.android.systemui.statusbar.notification.collection.NotificationRankingManager;
import com.android.systemui.statusbar.notification.logging.NotifLog;
import com.android.systemui.statusbar.phone.NotificationGroupManager;

import javax.inject.Inject;
import javax.inject.Singleton;
@@ -35,8 +36,12 @@ import javax.inject.Singleton;
public class CarNotificationEntryManager extends NotificationEntryManager {

    @Inject
    public CarNotificationEntryManager(NotificationData notificationData, NotifLog notifLog) {
        super(notificationData, notifLog);
    public CarNotificationEntryManager(
            NotifLog notifLog,
            NotificationGroupManager groupManager,
            NotificationRankingManager rankingManager,
            KeyguardEnvironment keyguardEnvironment) {
        super(notifLog, groupManager, rankingManager, keyguardEnvironment);
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -75,10 +75,10 @@ import com.android.systemui.statusbar.SmartReplyController;
import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.notification.NotificationAlertingManager;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationEntryManager.KeyguardEnvironment;
import com.android.systemui.statusbar.notification.NotificationFilter;
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
import com.android.systemui.statusbar.notification.VisualStabilityManager;
import com.android.systemui.statusbar.notification.collection.NotificationData.KeyguardEnvironment;
import com.android.systemui.statusbar.notification.logging.NotificationLogger;
import com.android.systemui.statusbar.notification.row.ChannelEditorDialogController;
import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager;
+1 −2
Original line number Diff line number Diff line
@@ -139,8 +139,7 @@ public class ForegroundServiceController {
        // Update appOp if there's an associated pending or visible notification:
        final String foregroundKey = getStandardLayoutKey(userId, packageName);
        if (foregroundKey != null) {
            final NotificationEntry entry = mEntryManager.getPendingOrCurrentNotif(
                    foregroundKey);
            final NotificationEntry entry = mEntryManager.getPendingOrActiveNotif(foregroundKey);
            if (entry != null
                    && uid == entry.getSbn().getUid()
                    && packageName.equals(entry.getSbn().getPackageName())) {
+6 −7
Original line number Diff line number Diff line
@@ -78,7 +78,6 @@ import com.android.systemui.statusbar.NotificationRemoveInterceptor;
import com.android.systemui.statusbar.notification.NotificationEntryListener;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
import com.android.systemui.statusbar.notification.collection.NotificationData;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.ShadeController;
@@ -352,14 +351,13 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
     * @param userId the id of the user
     */
    private void restoreBubbles(@UserIdInt int userId) {
        NotificationData notificationData =
                mNotificationEntryManager.getNotificationData();
        ArraySet<String> savedBubbleKeys = mSavedBubbleKeysPerUser.get(userId);
        if (savedBubbleKeys == null) {
            // There were no bubbles saved for this used.
            return;
        }
        for (NotificationEntry e : notificationData.getNotificationsForCurrentUser()) {
        for (NotificationEntry e :
                mNotificationEntryManager.getActiveNotificationsForCurrentUser()) {
            if (savedBubbleKeys.contains(e.getKey())
                    && mNotificationInterruptionStateProvider.shouldBubbleUp(e)
                    && canLaunchInActivityView(mContext, e)) {
@@ -458,7 +456,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
    public boolean isBubbleNotificationSuppressedFromShade(String key) {
        boolean isBubbleAndSuppressed = mBubbleData.hasBubbleWithKey(key)
                && !mBubbleData.getBubbleWithKey(key).showInShadeWhenBubble();
        NotificationEntry entry = mNotificationEntryManager.getNotificationData().get(key);
        NotificationEntry entry = mNotificationEntryManager.getActiveNotificationUnfiltered(key);
        String groupKey = entry != null ? entry.getSbn().getGroupKey() : null;
        boolean isSuppressedSummary = mBubbleData.isSummarySuppressed(groupKey);
        boolean isSummary = key.equals(mBubbleData.getSummaryKey(groupKey));
@@ -571,7 +569,8 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
            new NotificationRemoveInterceptor() {
            @Override
            public boolean onNotificationRemoveRequested(String key, int reason) {
                NotificationEntry entry = mNotificationEntryManager.getNotificationData().get(key);
                NotificationEntry entry =
                        mNotificationEntryManager.getActiveNotificationUnfiltered(key);
                String groupKey = entry != null ? entry.getSbn().getGroupKey() : null;
                ArrayList<Bubble> bubbleChildren = mBubbleData.getBubblesInGroup(groupKey);

@@ -768,7 +767,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
                        String notifKey = mBubbleData.getSummaryKey(groupKey);
                        mBubbleData.removeSuppressedSummary(groupKey);
                        NotificationEntry entry =
                                mNotificationEntryManager.getNotificationData().get(notifKey);
                                mNotificationEntryManager.getActiveNotificationUnfiltered(notifKey);
                        mNotificationEntryManager.performRemoveNotification(
                                entry.getSbn(), UNDEFINED_DISMISS_REASON);
                    }
Loading