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

Commit 31bfaed3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Convert BubblesManager to use CommonNotifCollection."

parents 36084b10 4ef8de99
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import com.android.systemui.statusbar.notification.collection.NotifPipeline;
import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder;
import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinderImpl;
import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy;
import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection;
import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider;
import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider;
import com.android.systemui.statusbar.notification.people.PeopleHubModule;
@@ -208,6 +209,7 @@ public abstract class SystemUIModule {
            NotificationInterruptStateProvider interruptionStateProvider,
            ZenModeController zenModeController, NotificationLockscreenUserManager notifUserManager,
            NotificationGroupManagerLegacy groupManager, NotificationEntryManager entryManager,
            CommonNotifCollection notifCollection,
            NotifPipeline notifPipeline, SysUiState sysUiState,
            NotifPipelineFlags notifPipelineFlags, DumpManager dumpManager,
            @Main Executor sysuiMainExecutor) {
@@ -216,7 +218,7 @@ public abstract class SystemUIModule {
                configurationController, statusBarService, notificationManager,
                visibilityProvider,
                interruptionStateProvider, zenModeController, notifUserManager,
                groupManager, entryManager, notifPipeline, sysUiState, notifPipelineFlags,
                dumpManager, sysuiMainExecutor));
                groupManager, entryManager, notifCollection, notifPipeline, sysUiState,
                notifPipelineFlags, dumpManager, sysuiMainExecutor));
    }
}
+24 −24
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ import com.android.systemui.statusbar.notification.collection.NotifPipeline;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.coordinator.BubbleCoordinator;
import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy;
import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection;
import com.android.systemui.statusbar.notification.collection.notifcollection.DismissedByUserStats;
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener;
import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider;
@@ -88,6 +89,7 @@ import com.android.wm.shell.bubbles.Bubbles;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
@@ -111,8 +113,10 @@ public class BubblesManager implements Dumpable {
    private final INotificationManager mNotificationManager;
    private final NotificationVisibilityProvider mVisibilityProvider;
    private final NotificationInterruptStateProvider mNotificationInterruptStateProvider;
    private final NotificationLockscreenUserManager mNotifUserManager;
    private final NotificationGroupManagerLegacy mNotificationGroupManager;
    private final NotificationEntryManager mNotificationEntryManager;
    private final CommonNotifCollection mCommonNotifCollection;
    private final NotifPipeline mNotifPipeline;
    private final Executor mSysuiMainExecutor;

@@ -139,6 +143,7 @@ public class BubblesManager implements Dumpable {
            NotificationLockscreenUserManager notifUserManager,
            NotificationGroupManagerLegacy groupManager,
            NotificationEntryManager entryManager,
            CommonNotifCollection notifCollection,
            NotifPipeline notifPipeline,
            SysUiState sysUiState,
            NotifPipelineFlags notifPipelineFlags,
@@ -150,8 +155,8 @@ public class BubblesManager implements Dumpable {
                    configurationController, statusBarService, notificationManager,
                    visibilityProvider,
                    interruptionStateProvider, zenModeController, notifUserManager,
                    groupManager, entryManager, notifPipeline, sysUiState, notifPipelineFlags,
                    dumpManager, sysuiMainExecutor);
                    groupManager, entryManager, notifCollection, notifPipeline, sysUiState,
                    notifPipelineFlags, dumpManager, sysuiMainExecutor);
        } else {
            return null;
        }
@@ -172,6 +177,7 @@ public class BubblesManager implements Dumpable {
            NotificationLockscreenUserManager notifUserManager,
            NotificationGroupManagerLegacy groupManager,
            NotificationEntryManager entryManager,
            CommonNotifCollection notifCollection,
            NotifPipeline notifPipeline,
            SysUiState sysUiState,
            NotifPipelineFlags notifPipelineFlags,
@@ -184,8 +190,10 @@ public class BubblesManager implements Dumpable {
        mNotificationManager = notificationManager;
        mVisibilityProvider = visibilityProvider;
        mNotificationInterruptStateProvider = interruptionStateProvider;
        mNotifUserManager = notifUserManager;
        mNotificationGroupManager = groupManager;
        mNotificationEntryManager = entryManager;
        mCommonNotifCollection = notifCollection;
        mNotifPipeline = notifPipeline;
        mSysuiMainExecutor = sysuiMainExecutor;

@@ -264,8 +272,7 @@ public class BubblesManager implements Dumpable {
            @Override
            public void getPendingOrActiveEntry(String key, Consumer<BubbleEntry> callback) {
                sysuiMainExecutor.execute(() -> {
                    NotificationEntry entry =
                            mNotificationEntryManager.getPendingOrActiveNotif(key);
                    final NotificationEntry entry = mCommonNotifCollection.getEntry(key);
                    callback.accept(entry == null ? null : notifToBubbleEntry(entry));
                });
            }
@@ -275,11 +282,11 @@ public class BubblesManager implements Dumpable {
                    Consumer<List<BubbleEntry>> callback) {
                sysuiMainExecutor.execute(() -> {
                    List<BubbleEntry> result = new ArrayList<>();
                    List<NotificationEntry> activeEntries =
                            mNotificationEntryManager.getActiveNotificationsForCurrentUser();
                    for (int i = 0; i < activeEntries.size(); i++) {
                        NotificationEntry entry = activeEntries.get(i);
                        if (savedBubbleKeys.contains(entry.getKey())
                    final Collection<NotificationEntry> activeEntries =
                            mCommonNotifCollection.getAllNotifs();
                    for (NotificationEntry entry : activeEntries) {
                        if (mNotifUserManager.isCurrentProfile(entry.getSbn().getUserId())
                                && savedBubbleKeys.contains(entry.getKey())
                                && mNotificationInterruptStateProvider.shouldBubbleUp(entry)
                                && entry.isBubble()) {
                            result.add(notifToBubbleEntry(entry));
@@ -292,8 +299,7 @@ public class BubblesManager implements Dumpable {
            @Override
            public void setNotificationInterruption(String key) {
                sysuiMainExecutor.execute(() -> {
                    final NotificationEntry entry =
                            mNotificationEntryManager.getPendingOrActiveNotif(key);
                    final NotificationEntry entry = mCommonNotifCollection.getEntry(key);
                    if (entry != null
                            && entry.getImportance() >= NotificationManager.IMPORTANCE_HIGH) {
                        entry.setInterruption();
@@ -311,8 +317,7 @@ public class BubblesManager implements Dumpable {
            @Override
            public void notifyRemoveNotification(String key, int reason) {
                sysuiMainExecutor.execute(() -> {
                    final NotificationEntry entry =
                            mNotificationEntryManager.getPendingOrActiveNotif(key);
                    final NotificationEntry entry = mCommonNotifCollection.getEntry(key);
                    if (entry != null) {
                        for (NotifCallback cb : mCallbacks) {
                            cb.removeNotification(entry, getDismissedByUserStats(entry, true),
@@ -334,8 +339,7 @@ public class BubblesManager implements Dumpable {
            @Override
            public void notifyMaybeCancelSummary(String key) {
                sysuiMainExecutor.execute(() -> {
                    final NotificationEntry entry =
                            mNotificationEntryManager.getPendingOrActiveNotif(key);
                    final NotificationEntry entry = mCommonNotifCollection.getEntry(key);
                    if (entry != null) {
                        for (NotifCallback cb : mCallbacks) {
                            cb.maybeCancelSummary(entry);
@@ -347,8 +351,7 @@ public class BubblesManager implements Dumpable {
            @Override
            public void removeNotificationEntry(String key) {
                sysuiMainExecutor.execute(() -> {
                    final NotificationEntry entry =
                            mNotificationEntryManager.getPendingOrActiveNotif(key);
                    final NotificationEntry entry = mCommonNotifCollection.getEntry(key);
                    if (entry != null) {
                        mNotificationGroupManager.onEntryRemoved(entry);
                    }
@@ -358,8 +361,7 @@ public class BubblesManager implements Dumpable {
            @Override
            public void updateNotificationBubbleButton(String key) {
                sysuiMainExecutor.execute(() -> {
                    final NotificationEntry entry =
                            mNotificationEntryManager.getPendingOrActiveNotif(key);
                    final NotificationEntry entry = mCommonNotifCollection.getEntry(key);
                    if (entry != null && entry.getRow() != null) {
                        entry.getRow().updateBubbleButton();
                    }
@@ -369,8 +371,7 @@ public class BubblesManager implements Dumpable {
            @Override
            public void updateNotificationSuppression(String key) {
                sysuiMainExecutor.execute(() -> {
                    final NotificationEntry entry =
                            mNotificationEntryManager.getPendingOrActiveNotif(key);
                    final NotificationEntry entry = mCommonNotifCollection.getEntry(key);
                    if (entry != null) {
                        mNotificationGroupManager.updateSuppression(entry);
                    }
@@ -402,8 +403,7 @@ public class BubblesManager implements Dumpable {
            @Override
            public void onUnbubbleConversation(String key) {
                sysuiMainExecutor.execute(() -> {
                    final NotificationEntry entry =
                            mNotificationEntryManager.getPendingOrActiveNotif(key);
                    final NotificationEntry entry = mCommonNotifCollection.getEntry(key);
                    if (entry != null) {
                        onUserChangedBubble(entry, false /* shouldBubble */);
                    }
@@ -580,7 +580,7 @@ public class BubblesManager implements Dumpable {
        HashMap<String, Pair<BubbleEntry, Boolean>> pendingOrActiveNotif = new HashMap<>();
        for (int i = 0; i < orderedKeys.length; i++) {
            String key = orderedKeys[i];
            NotificationEntry entry = mNotificationEntryManager.getPendingOrActiveNotif(key);
            final NotificationEntry entry = mCommonNotifCollection.getEntry(key);
            BubbleEntry bubbleEntry = entry != null
                    ? notifToBubbleEntry(entry)
                    : null;
+17 −20
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ import com.android.systemui.statusbar.notification.collection.NotifPipeline;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy;
import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection;
import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationTestHelper;
@@ -152,6 +153,8 @@ public class BubblesTest extends SysuiTestCase {
    @Mock
    private NotificationEntryManager mNotificationEntryManager;
    @Mock
    private CommonNotifCollection mCommonNotifCollection;
    @Mock
    private NotificationGroupManagerLegacy mNotificationGroupManager;
    @Mock
    private WindowManager mWindowManager;
@@ -299,9 +302,8 @@ public class BubblesTest extends SysuiTestCase {
        mBubbleEntry2User11 = BubblesManager.notifToBubbleEntry(
                mNotificationTestHelper.createBubble(handle));

        // Return non-null notification data from the NEM
        when(mNotificationEntryManager
                .getActiveNotificationUnfiltered(mRow.getKey())).thenReturn(mRow);
        // Return non-null notification data from the CommonNotifCollection
        when(mCommonNotifCollection.getEntry(mRow.getKey())).thenReturn(mRow);

        mZenModeConfig.suppressedVisualEffects = 0;
        when(mZenModeController.getConfig()).thenReturn(mZenModeConfig);
@@ -371,12 +373,14 @@ public class BubblesTest extends SysuiTestCase {
                mLockscreenUserManager,
                mNotificationGroupManager,
                mNotificationEntryManager,
                mCommonNotifCollection,
                mNotifPipeline,
                mSysUiState,
                mNotifPipelineFlags,
                mDumpManager,
                syncExecutor);

        // XXX: Does *this* need to be changed?
        // Get a reference to the BubbleController's entry listener
        verify(mNotificationEntryManager, atLeastOnce())
                .addNotificationEntryListener(mEntryListenerCaptor.capture());
@@ -421,10 +425,8 @@ public class BubblesTest extends SysuiTestCase {
    public void testPromoteBubble_autoExpand() throws Exception {
        mBubbleController.updateBubble(mBubbleEntry2);
        mBubbleController.updateBubble(mBubbleEntry);
        when(mNotificationEntryManager.getPendingOrActiveNotif(mRow.getKey()))
                .thenReturn(mRow);
        when(mNotificationEntryManager.getPendingOrActiveNotif(mRow2.getKey()))
                .thenReturn(mRow2);
        when(mCommonNotifCollection.getEntry(mRow.getKey())).thenReturn(mRow);
        when(mCommonNotifCollection.getEntry(mRow2.getKey())).thenReturn(mRow2);
        mBubbleController.removeBubble(
                mRow.getKey(), Bubbles.DISMISS_USER_GESTURE);

@@ -452,10 +454,8 @@ public class BubblesTest extends SysuiTestCase {
        mBubbleController.updateBubble(mBubbleEntry2);
        mBubbleController.updateBubble(mBubbleEntry, /* suppressFlyout */
                false, /* showInShade */ true);
        when(mNotificationEntryManager.getPendingOrActiveNotif(mRow.getKey()))
                .thenReturn(mRow);
        when(mNotificationEntryManager.getPendingOrActiveNotif(mRow2.getKey()))
                .thenReturn(mRow2);
        when(mCommonNotifCollection.getEntry(mRow.getKey())).thenReturn(mRow);
        when(mCommonNotifCollection.getEntry(mRow2.getKey())).thenReturn(mRow2);
        mBubbleController.removeBubble(
                mRow.getKey(), Bubbles.DISMISS_USER_GESTURE);

@@ -958,12 +958,9 @@ public class BubblesTest extends SysuiTestCase {
                mBubbleEntry2, /* suppressFlyout */ false, /* showInShade */ false);
        mBubbleController.updateBubble(
                mBubbleEntry3, /* suppressFlyout */ false, /* showInShade */ false);
        when(mNotificationEntryManager.getPendingOrActiveNotif(mRow.getKey()))
                .thenReturn(mRow);
        when(mNotificationEntryManager.getPendingOrActiveNotif(mRow2.getKey()))
                .thenReturn(mRow2);
        when(mNotificationEntryManager.getPendingOrActiveNotif(mRow3.getKey()))
                .thenReturn(mRow3);
        when(mCommonNotifCollection.getEntry(mRow.getKey())).thenReturn(mRow);
        when(mCommonNotifCollection.getEntry(mRow2.getKey())).thenReturn(mRow2);
        when(mCommonNotifCollection.getEntry(mRow3.getKey())).thenReturn(mRow3);
        assertEquals(mBubbleData.getBubbles().size(), 3);

        mBubbleData.setMaxOverflowBubbles(1);
@@ -1021,7 +1018,7 @@ public class BubblesTest extends SysuiTestCase {
        // GIVEN a group summary with a bubble child
        ExpandableNotificationRow groupSummary = mNotificationTestHelper.createGroup(0);
        ExpandableNotificationRow groupedBubble = mNotificationTestHelper.createBubbleInGroup();
        when(mNotificationEntryManager.getPendingOrActiveNotif(groupedBubble.getEntry().getKey()))
        when(mCommonNotifCollection.getEntry(groupedBubble.getEntry().getKey()))
                .thenReturn(groupedBubble.getEntry());
        mEntryListener.onPendingEntryAdded(groupedBubble.getEntry());
        groupSummary.addChildNotification(groupedBubble);
@@ -1046,7 +1043,7 @@ public class BubblesTest extends SysuiTestCase {
        ExpandableNotificationRow groupSummary = mNotificationTestHelper.createGroup(0);
        ExpandableNotificationRow groupedBubble = mNotificationTestHelper.createBubbleInGroup();
        mEntryListener.onPendingEntryAdded(groupedBubble.getEntry());
        when(mNotificationEntryManager.getPendingOrActiveNotif(groupedBubble.getEntry().getKey()))
        when(mCommonNotifCollection.getEntry(groupedBubble.getEntry().getKey()))
                .thenReturn(groupedBubble.getEntry());
        groupSummary.addChildNotification(groupedBubble);
        assertTrue(mBubbleData.hasBubbleInStackWithKey(groupedBubble.getEntry().getKey()));
@@ -1069,7 +1066,7 @@ public class BubblesTest extends SysuiTestCase {
        // GIVEN a group summary with two (non-bubble) children and one bubble child
        ExpandableNotificationRow groupSummary = mNotificationTestHelper.createGroup(2);
        ExpandableNotificationRow groupedBubble = mNotificationTestHelper.createBubbleInGroup();
        when(mNotificationEntryManager.getPendingOrActiveNotif(groupedBubble.getEntry().getKey()))
        when(mCommonNotifCollection.getEntry(groupedBubble.getEntry().getKey()))
                .thenReturn(groupedBubble.getEntry());
        mEntryListener.onPendingEntryAdded(groupedBubble.getEntry());
        groupSummary.addChildNotification(groupedBubble);
+11 −9
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ import com.android.systemui.statusbar.notification.NotificationFilter;
import com.android.systemui.statusbar.notification.collection.NotifPipeline;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy;
import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection;
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener;
import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
@@ -133,6 +134,8 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
    @Mock
    private NotificationEntryManager mNotificationEntryManager;
    @Mock
    private CommonNotifCollection mCommonNotifCollection;
    @Mock
    private NotificationGroupManagerLegacy mNotificationGroupManager;
    @Mock
    private BubblesManager.NotifCallback mNotifCallback;
@@ -336,6 +339,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
                mLockscreenUserManager,
                mNotificationGroupManager,
                mNotificationEntryManager,
                mCommonNotifCollection,
                mNotifPipeline,
                mSysUiState,
                mNotifPipelineFlags,
@@ -404,8 +408,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
    public void testRemoveBubble_withDismissedNotif_notInOverflow() {
        mEntryListener.onEntryAdded(mRow);
        mBubbleController.updateBubble(mBubbleEntry);
        when(mNotificationEntryManager.getPendingOrActiveNotif(mRow.getKey()))
                .thenReturn(mRow);
        when(mCommonNotifCollection.getEntry(mRow.getKey())).thenReturn(mRow);

        assertTrue(mBubbleController.hasBubbles());
        assertBubbleNotificationNotSuppressedFromShade(mBubbleEntry);
@@ -887,7 +890,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
        ExpandableNotificationRow groupSummary = mNotificationTestHelper.createGroup(0);
        ExpandableNotificationRow groupedBubble = mNotificationTestHelper.createBubbleInGroup();
        mEntryListener.onEntryAdded(groupedBubble.getEntry());
        when(mNotificationEntryManager.getPendingOrActiveNotif(groupedBubble.getEntry().getKey()))
        when(mCommonNotifCollection.getEntry(groupedBubble.getEntry().getKey()))
                .thenReturn(groupedBubble.getEntry());
        groupSummary.addChildNotification(groupedBubble);
        assertTrue(mBubbleData.hasBubbleInStackWithKey(groupedBubble.getEntry().getKey()));
@@ -911,7 +914,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
        ExpandableNotificationRow groupSummary = mNotificationTestHelper.createGroup(0);
        ExpandableNotificationRow groupedBubble = mNotificationTestHelper.createBubbleInGroup();
        mEntryListener.onEntryAdded(groupedBubble.getEntry());
        when(mNotificationEntryManager.getPendingOrActiveNotif(groupedBubble.getEntry().getKey()))
        when(mCommonNotifCollection.getEntry(groupedBubble.getEntry().getKey()))
                .thenReturn(groupedBubble.getEntry());
        groupSummary.addChildNotification(groupedBubble);
        assertTrue(mBubbleData.hasBubbleInStackWithKey(groupedBubble.getEntry().getKey()));
@@ -935,7 +938,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
        ExpandableNotificationRow groupSummary = mNotificationTestHelper.createGroup(2);
        ExpandableNotificationRow groupedBubble = mNotificationTestHelper.createBubbleInGroup();
        mEntryListener.onEntryAdded(groupedBubble.getEntry());
        when(mNotificationEntryManager.getPendingOrActiveNotif(groupedBubble.getEntry().getKey()))
        when(mCommonNotifCollection.getEntry(groupedBubble.getEntry().getKey()))
                .thenReturn(groupedBubble.getEntry());
        groupSummary.addChildNotification(groupedBubble);

@@ -1011,10 +1014,9 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
     */
    @Test
    public void testOverflowLoadedOnce() {
        when(mNotificationEntryManager.getPendingOrActiveNotif(mRow.getKey()))
                .thenReturn(mRow);
        when(mNotificationEntryManager.getPendingOrActiveNotif(mRow2.getKey()))
                .thenReturn(mRow2);
        // XXX
        when(mCommonNotifCollection.getEntry(mRow.getKey())).thenReturn(mRow);
        when(mCommonNotifCollection.getEntry(mRow2.getKey())).thenReturn(mRow2);

        mEntryListener.onEntryAdded(mRow);
        mEntryListener.onEntryAdded(mRow2);