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

Commit bac7f008 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Add feature flag check for setting groupKey

In the 'shadow' new notification pipeline we cannot immediately set
the new override group key when the ranking is updated because the
old pipeline relies on checking whether the new/old override key is
different before updating. Therefore, only update the override group
key in the new pipeline once we're only using the new pipeline to render
notifications.

Note: this means that the shadow pipeline currently relies on the old
pipeline to set the override group keys (which may cause some
discrepancies since the timing is unreliable).

Test: manual + atest SystemUITests
Change-Id: I1afb303a86bf99d500163e108a9f141787267077
parent ed242597
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import android.util.Log;
import com.android.internal.statusbar.IStatusBarService;
import com.android.systemui.DumpController;
import com.android.systemui.Dumpable;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.notification.collection.coalescer.CoalescedEvent;
import com.android.systemui.statusbar.notification.collection.coalescer.GroupCoalescer;
import com.android.systemui.statusbar.notification.collection.coalescer.GroupCoalescer.BatchableNotificationHandler;
@@ -98,6 +99,7 @@ import javax.inject.Singleton;
@Singleton
public class NotifCollection implements Dumpable {
    private final IStatusBarService mStatusBarService;
    private final FeatureFlags mFeatureFlags;

    private final Map<String, NotificationEntry> mNotificationSet = new ArrayMap<>();
    private final Collection<NotificationEntry> mReadOnlyNotificationSet =
@@ -111,10 +113,14 @@ public class NotifCollection implements Dumpable {
    private boolean mAmDispatchingToOtherCode;

    @Inject
    public NotifCollection(IStatusBarService statusBarService, DumpController dumpController) {
    public NotifCollection(
            IStatusBarService statusBarService,
            DumpController dumpController,
            FeatureFlags featureFlags) {
        Assert.isMainThread();
        mStatusBarService = statusBarService;
        dumpController.registerDumpable(TAG, this);
        mFeatureFlags = featureFlags;
    }

    /** Initializes the NotifCollection and registers it to receive notification events. */
@@ -301,13 +307,16 @@ public class NotifCollection implements Dumpable {
                // TODO: (b/145659174) update the sbn's overrideGroupKey in
                //  NotificationEntry.setRanking instead of here once we fully migrate to the
                //  NewNotifPipeline
                if (mFeatureFlags.isNewNotifPipelineRenderingEnabled()) {
                    final String newOverrideGroupKey = ranking.getOverrideGroupKey();
                if (!Objects.equals(entry.getSbn().getOverrideGroupKey(), newOverrideGroupKey)) {
                    if (!Objects.equals(entry.getSbn().getOverrideGroupKey(),
                            newOverrideGroupKey)) {
                        entry.getSbn().setOverrideGroupKey(newOverrideGroupKey);
                    }
                }
            }
        }
    }

    private void rebuildList() {
        if (mBuildListener != null) {
+9 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import static java.util.Objects.requireNonNull;

@@ -51,6 +52,7 @@ import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.DumpController;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.RankingBuilder;
import com.android.systemui.statusbar.notification.collection.NoManSimulator.NotifEvent;
import com.android.systemui.statusbar.notification.collection.NotifCollection.CancellationReason;
@@ -86,6 +88,7 @@ public class NotifCollectionTest extends SysuiTestCase {
    @Mock private GroupCoalescer mGroupCoalescer;
    @Spy private RecordingCollectionListener mCollectionListener;
    @Mock private CollectionReadyForBuildListener mBuildListener;
    @Mock private FeatureFlags mFeatureFlags;

    @Spy private RecordingLifetimeExtender mExtender1 = new RecordingLifetimeExtender("Extender1");
    @Spy private RecordingLifetimeExtender mExtender2 = new RecordingLifetimeExtender("Extender2");
@@ -105,7 +108,12 @@ public class NotifCollectionTest extends SysuiTestCase {
        MockitoAnnotations.initMocks(this);
        Assert.sMainLooper = TestableLooper.get(this).getLooper();

        mCollection = new NotifCollection(mStatusBarService, mock(DumpController.class));
        when(mFeatureFlags.isNewNotifPipelineRenderingEnabled()).thenReturn(true);
        when(mFeatureFlags.isNewNotifPipelineEnabled()).thenReturn(true);

        mCollection = new NotifCollection(mStatusBarService,
                mock(DumpController.class),
                mFeatureFlags);
        mCollection.attach(mGroupCoalescer);
        mCollection.addCollectionListener(mCollectionListener);
        mCollection.setBuildListener(mBuildListener);