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

Commit 8621bd27 authored by Gus Prevas's avatar Gus Prevas
Browse files

Combines NotificationEntryManager listener interfaces (part 3).

This change eliminates the mCallback field on NotificationEntryManager,
instead adding the listener which used to be in that field to the list
of listeners.

Test: atest SystemUITests, manual
Change-Id: I3b489ad87cf9d757c9ad9e49cf3c12c35972dee5
parent b43dc656
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -96,8 +96,6 @@ public class NotificationEntryManager implements
    private final AmbientPulseManager mAmbientPulseManager =
            Dependency.get(AmbientPulseManager.class);
    private final BubbleController mBubbleController = Dependency.get(BubbleController.class);
    private final NotificationInterruptionStateProvider mNotificationInterruptionStateProvider =
            Dependency.get(NotificationInterruptionStateProvider.class);

    // Lazily retrieved dependencies
    private NotificationRemoteInputManager mRemoteInputManager;
@@ -109,7 +107,6 @@ public class NotificationEntryManager implements

    protected IStatusBarService mBarService;
    private NotificationPresenter mPresenter;
    private NotificationEntryListener mCallback;
    protected PowerManager mPowerManager;
    private NotificationListenerService.RankingMap mLatestRankingMap;
    protected HeadsUpManager mHeadsUpManager;
@@ -186,11 +183,10 @@ public class NotificationEntryManager implements
    }

    public void setUpWithPresenter(NotificationPresenter presenter,
            NotificationListContainer listContainer, NotificationEntryListener callback,
            NotificationListContainer listContainer,
            HeadsUpManager headsUpManager) {
        mPresenter = presenter;
        mUpdateNotificationViewsCallback = mPresenter::updateNotificationViews;
        mCallback = callback;
        mHeadsUpManager = headsUpManager;
        mNotificationData.setHeadsUpManager(mHeadsUpManager);
        mListContainer = listContainer;
@@ -256,7 +252,9 @@ public class NotificationEntryManager implements
            // system process is dead if we're here.
        }

        mCallback.onPerformRemoveNotification(n);
        for (NotificationEntryListener listener : mNotificationEntryListeners) {
            listener.onPerformRemoveNotification(n);
        }
    }

    @Override
@@ -313,7 +311,9 @@ public class NotificationEntryManager implements
        mNotificationData.add(shadeEntry);
        tagForeground(shadeEntry.notification);
        updateNotifications();
        mCallback.onNotificationAdded(shadeEntry);
        for (NotificationEntryListener listener : mNotificationEntryListeners) {
            listener.onNotificationAdded(shadeEntry);
        }

        maybeScheduleUpdateNotificationViews(shadeEntry);
    }
@@ -370,7 +370,9 @@ public class NotificationEntryManager implements
        }

        if (entry == null) {
            mCallback.onNotificationRemoved(key, null /* old */);
            for (NotificationEntryListener listener : mNotificationEntryListeners) {
                listener.onNotificationRemoved(key, null /* old */);
            }
            return;
        }

@@ -406,7 +408,9 @@ public class NotificationEntryManager implements

        StatusBarNotification old = removeNotificationViews(key, ranking);

        mCallback.onNotificationRemoved(key, old);
        for (NotificationEntryListener listener : mNotificationEntryListeners) {
            listener.onNotificationRemoved(key, old);
        }
    }

    private StatusBarNotification removeNotificationViews(String key,
@@ -598,7 +602,6 @@ public class NotificationEntryManager implements
        for (NotificationEntryListener listener : mNotificationEntryListeners) {
            listener.onEntryUpdated(entry);
        }
        mCallback.onEntryUpdated(entry);

        maybeScheduleUpdateNotificationViews(entry);
    }
+2 −2
Original line number Diff line number Diff line
@@ -200,8 +200,8 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
            };

            mViewHierarchyManager.setUpWithPresenter(this, notifListContainer);
            mEntryManager.setUpWithPresenter(
                    this, notifListContainer, notificationEntryListener, mHeadsUpManager);
            mEntryManager.setUpWithPresenter(this, notifListContainer, mHeadsUpManager);
            mEntryManager.addNotificationEntryListener(notificationEntryListener);
            mNotificationRowBinder.setUpWithPresenter(this, notifListContainer, mHeadsUpManager,
                    mEntryManager, this);
            mNotificationInterruptionStateProvider.setUpWithPresenter(
+3 −3
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ public class NonPhoneDependencyTest extends SysuiTestCase {
    @Mock private NotificationPresenter mPresenter;
    @Mock private NotificationListContainer mListContainer;
    @Mock
    private NotificationEntryListener mEntryManagerCallback;
    private NotificationEntryListener mEntryListener;
    @Mock private HeadsUpManager mHeadsUpManager;
    @Mock private RemoteInputController.Delegate mDelegate;
    @Mock private NotificationRemoteInputManager.Callback mRemoteInputManagerCallback;
@@ -87,8 +87,8 @@ public class NonPhoneDependencyTest extends SysuiTestCase {
        NotificationViewHierarchyManager viewHierarchyManager =
                Dependency.get(NotificationViewHierarchyManager.class);
        Dependency.get(InitController.class).executePostInitTasks();
        entryManager.setUpWithPresenter(mPresenter, mListContainer, mEntryManagerCallback,
                mHeadsUpManager);
        entryManager.setUpWithPresenter(mPresenter, mListContainer, mHeadsUpManager);
        entryManager.addNotificationEntryListener(mEntryListener);
        gutsManager.setUpWithPresenter(mPresenter, mListContainer,
                mCheckSaveListener, mOnSettingsClickListener);
        notificationLogger.setUpWithContainer(mListContainer);
+6 −5
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase {
    @Mock private ExpandableNotificationRow mRow;
    @Mock private NotificationListContainer mListContainer;
    @Mock
    private NotificationEntryListener mCallback;
    private NotificationEntryListener mEntryListener;
    @Mock
    private NotificationRowBinder.BindRowCallback mBindCallback;
    @Mock private HeadsUpManager mHeadsUpManager;
@@ -232,7 +232,8 @@ public class NotificationEntryManagerTest extends SysuiTestCase {

        mEntryManager = new TestableNotificationEntryManager(mContext, mBarService);
        Dependency.get(InitController.class).executePostInitTasks();
        mEntryManager.setUpWithPresenter(mPresenter, mListContainer, mCallback, mHeadsUpManager);
        mEntryManager.setUpWithPresenter(mPresenter, mListContainer, mHeadsUpManager);
        mEntryManager.addNotificationEntryListener(mEntryListener);

        NotificationRowBinder notificationRowBinder = Dependency.get(NotificationRowBinder.class);
        notificationRowBinder.setUpWithPresenter(
@@ -272,7 +273,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase {
        verify(mRemoteInputManager).bindRow(entry.getRow());

        // Row content inflation:
        verify(mCallback).onNotificationAdded(entry);
        verify(mEntryListener).onNotificationAdded(entry);
        verify(mPresenter).updateNotificationViews();

        assertEquals(mEntryManager.getNotificationData().get(mSbn.getKey()), entry);
@@ -300,7 +301,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase {

        verify(mPresenter).updateNotificationViews();
        verify(mForegroundServiceController).updateNotification(eq(mSbn), anyInt());
        verify(mCallback).onEntryUpdated(mEntry);
        verify(mEntryListener).onEntryUpdated(mEntry);
        assertNotNull(mEntry.getRow());
        assertEquals(mEntry.userSentiment,
                NotificationListenerService.Ranking.USER_SENTIMENT_NEGATIVE);
@@ -322,7 +323,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase {
        verify(mForegroundServiceController).removeNotification(mSbn);
        verify(mListContainer).cleanUpViewStateForEntry(mEntry);
        verify(mPresenter).updateNotificationViews();
        verify(mCallback).onNotificationRemoved(mSbn.getKey(), mSbn);
        verify(mEntryListener).onNotificationRemoved(mSbn.getKey(), mSbn);
        verify(mRow).setRemoved();

        assertNull(mEntryManager.getNotificationData().get(mSbn.getKey()));
+1 −1
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
                mContext);
        mDependency.injectTestDependency(NotificationEntryManager.class, mEntryManager);
        Dependency.get(InitController.class).executePostInitTasks();
        mEntryManager.setUpForTest(mock(NotificationPresenter.class), null, null, mHeadsUpManager,
        mEntryManager.setUpForTest(mock(NotificationPresenter.class), null, mHeadsUpManager,
                mNotificationData);


Loading