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

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

Use onPreEntryUpdated instead of onPostEntryUpdated

Many of the registered entryListeners don't actually
care whether filtering has occured or not yet, so they should
use the onPreEntryUpdated callback to better align with the
future notification pipeline.

Test: atest SystemUITests
Change-Id: I9faeb51700631eb839910454f4133e2cc79202dd
parent 07a945d9
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public class NotificationAlertingManager {
            }

            @Override
            public void onPostEntryUpdated(NotificationEntry entry) {
            public void onPreEntryUpdated(NotificationEntry entry) {
                updateAlertState(entry);
            }

@@ -114,8 +114,8 @@ public class NotificationAlertingManager {

    private void updateAlertState(NotificationEntry entry) {
        boolean alertAgain = alertAgain(entry, entry.getSbn().getNotification());
        boolean shouldAlert;
        shouldAlert = mNotificationInterruptionStateProvider.shouldHeadsUp(entry);
        // includes check for whether this notification should be filtered:
        boolean shouldAlert = mNotificationInterruptionStateProvider.shouldHeadsUp(entry);
        final boolean wasAlerting = mHeadsUpManager.isAlerting(entry.getKey());
        if (wasAlerting) {
            if (shouldAlert) {
+3 −10
Original line number Diff line number Diff line
@@ -69,20 +69,13 @@ public class VisualStabilityManager implements OnHeadsUpChangedListener, Dumpabl
        notificationEntryManager.addNotificationEntryListener(new NotificationEntryListener() {
            @Override
            public void onPreEntryUpdated(NotificationEntry entry) {
                final boolean mAmbientStateHasChanged =
                final boolean ambientStateHasChanged =
                        entry.isAmbient() != entry.getRow().isLowPriority();
                if (mAmbientStateHasChanged) {
                if (ambientStateHasChanged) {
                    // note: entries are removed in onReorderingFinished
                    mLowPriorityReorderingViews.add(entry);
                }
            }

            @Override
            public void onPostEntryUpdated(NotificationEntry entry) {
                // This line is technically not required as we'll get called as the hierarchy
                // manager will call onReorderingFinished() immediately before this.
                // TODO: Find a way to make this relationship more explicit
                mLowPriorityReorderingViews.remove(entry);
            }
        });
    }

+3 −3
Original line number Diff line number Diff line
@@ -220,8 +220,8 @@ public class NotificationLogger implements StateListener {
            }

            @Override
            public void onEntryReinflated(NotificationEntry entry) {
                mExpansionStateLogger.onEntryReinflated(entry.getKey());
            public void onPreEntryUpdated(NotificationEntry entry) {
                mExpansionStateLogger.onEntryUpdated(entry.getKey());
            }

            @Override
@@ -480,7 +480,7 @@ public class NotificationLogger implements StateListener {
        }

        @VisibleForTesting
        void onEntryReinflated(String key) {
        void onEntryUpdated(String key) {
            // When the notification is updated, we should consider the notification as not
            // yet logged.
            mLoggedExpansionState.remove(key);
+4 −4
Original line number Diff line number Diff line
@@ -604,10 +604,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd

        mEntryManager.addNotificationEntryListener(new NotificationEntryListener() {
            @Override
            public void onPostEntryUpdated(NotificationEntry entry) {
                if (!entry.getSbn().isClearable()) {
                    // The user may have performed a dismiss action on the notification, since it's
                    // not clearable we should snap it back.
            public void onPreEntryUpdated(NotificationEntry entry) {
                if (entry.rowExists() && !entry.getSbn().isClearable()) {
                    // If the row already exists, the user may have performed a dismiss action on
                    // the notification. Since it's not clearable we should snap it back.
                    snapViewIfNeeded(entry);
                }
            }
+2 −2
Original line number Diff line number Diff line
@@ -158,7 +158,7 @@ public class ExpansionStateLoggerTest extends SysuiTestCase {
    }

    @Test
    public void testOnEntryReinflated() throws RemoteException {
    public void testOnEntryUpdated() throws RemoteException {
        mLogger.onExpansionChanged(NOTIFICATION_KEY, true, true,
                NotificationVisibility.NotificationLocation.LOCATION_UNKNOWN);
        mLogger.onVisibilityChanged(
@@ -168,7 +168,7 @@ public class ExpansionStateLoggerTest extends SysuiTestCase {
        verify(mBarService).onNotificationExpansionChanged(
                NOTIFICATION_KEY, true, true, ExpandableViewState.LOCATION_UNKNOWN);

        mLogger.onEntryReinflated(NOTIFICATION_KEY);
        mLogger.onEntryUpdated(NOTIFICATION_KEY);
        mLogger.onVisibilityChanged(
                Collections.singletonList(createNotificationVisibility(NOTIFICATION_KEY, true)),
                Collections.emptyList());