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

Commit 4a96b36f authored by Eliot Courtney's avatar Eliot Courtney
Browse files

Remove NotificationPresenter#getEntryManager.

Instead, pass it along with calls to setUpWithPresenter.

Bug: 63874929
Bug: 62602530
Test: runtest systemui
Test: Compile and run
Change-Id: Icd60cf671b12b33d4565cc608c6141cd580c790e
parent 8f56b0e3
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -71,10 +71,8 @@ public class NotificationGutsManager implements Dumpable {
    // which notification is currently being longpress-examined by the user
    private NotificationGuts mNotificationGutsExposed;
    private NotificationMenuRowPlugin.MenuItem mGutsMenuItem;
    private NotificationPresenter mPresenter;

    // TODO: Create NotificationListContainer interface and use it instead of
    // NotificationStackScrollLayout here
    protected NotificationPresenter mPresenter;
    protected NotificationEntryManager mEntryManager;
    private NotificationListContainer mListContainer;
    private NotificationInfo.CheckSaveListener mCheckSaveListener;
    private OnSettingsClickListener mOnSettingsClickListener;
@@ -95,10 +93,12 @@ public class NotificationGutsManager implements Dumpable {
                mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
    }

    public void setUp(NotificationPresenter presenter, NotificationListContainer listContainer,
    public void setUpWithPresenter(NotificationPresenter presenter,
            NotificationEntryManager entryManager, NotificationListContainer listContainer,
            NotificationInfo.CheckSaveListener checkSaveListener,
            OnSettingsClickListener onSettingsClickListener) {
        mPresenter = presenter;
        mEntryManager = entryManager;
        mListContainer = listContainer;
        mCheckSaveListener = checkSaveListener;
        mOnSettingsClickListener = onSettingsClickListener;
@@ -166,8 +166,7 @@ public class NotificationGutsManager implements Dumpable {
            String key = sbn.getKey();
            if (key.equals(mKeyToRemoveOnGutsClosed)) {
                mKeyToRemoveOnGutsClosed = null;
                mPresenter.getEntryManager().removeNotification(key,
                        mPresenter.getEntryManager().getLatestRankingMap());
                mEntryManager.removeNotification(key, mEntryManager.getLatestRankingMap());
            }
        });

+13 −10
Original line number Diff line number Diff line
@@ -39,7 +39,8 @@ public class NotificationListener extends NotificationListenerWithPlugins {
    private final NotificationRemoteInputManager mRemoteInputManager;
    private final Context mContext;

    private NotificationPresenter mPresenter;
    protected NotificationPresenter mPresenter;
    protected NotificationEntryManager mEntryManager;

    public NotificationListener(NotificationRemoteInputManager remoteInputManager,
            Context context) {
@@ -59,7 +60,7 @@ public class NotificationListener extends NotificationListenerWithPlugins {
        final RankingMap currentRanking = getCurrentRanking();
        mPresenter.getHandler().post(() -> {
            for (StatusBarNotification sbn : notifications) {
                mPresenter.getEntryManager().addNotification(sbn, currentRanking);
                mEntryManager.addNotification(sbn, currentRanking);
            }
        });
    }
@@ -74,7 +75,7 @@ public class NotificationListener extends NotificationListenerWithPlugins {
                String key = sbn.getKey();
                mRemoteInputManager.getKeysKeptForRemoteInput().remove(key);
                boolean isUpdate =
                        mPresenter.getEntryManager().getNotificationData().get(key) != null;
                        mEntryManager.getNotificationData().get(key) != null;
                // In case we don't allow child notifications, we ignore children of
                // notifications that have a summary, since` we're not going to show them
                // anyway. This is true also when the summary is canceled,
@@ -87,17 +88,17 @@ public class NotificationListener extends NotificationListenerWithPlugins {

                    // Remove existing notification to avoid stale data.
                    if (isUpdate) {
                        mPresenter.getEntryManager().removeNotification(key, rankingMap);
                        mEntryManager.removeNotification(key, rankingMap);
                    } else {
                        mPresenter.getEntryManager().getNotificationData()
                        mEntryManager.getNotificationData()
                                .updateRanking(rankingMap);
                    }
                    return;
                }
                if (isUpdate) {
                    mPresenter.getEntryManager().updateNotification(sbn, rankingMap);
                    mEntryManager.updateNotification(sbn, rankingMap);
                } else {
                    mPresenter.getEntryManager().addNotification(sbn, rankingMap);
                    mEntryManager.addNotification(sbn, rankingMap);
                }
            });
        }
@@ -110,7 +111,7 @@ public class NotificationListener extends NotificationListenerWithPlugins {
        if (sbn != null && !onPluginNotificationRemoved(sbn, rankingMap)) {
            final String key = sbn.getKey();
            mPresenter.getHandler().post(() -> {
                mPresenter.getEntryManager().removeNotification(key, rankingMap);
                mEntryManager.removeNotification(key, rankingMap);
            });
        }
    }
@@ -121,13 +122,15 @@ public class NotificationListener extends NotificationListenerWithPlugins {
        if (rankingMap != null) {
            RankingMap r = onPluginRankingUpdate(rankingMap);
            mPresenter.getHandler().post(() -> {
                mPresenter.getEntryManager().updateNotificationRanking(r);
                mEntryManager.updateNotificationRanking(r);
            });
        }
    }

    public void setUpWithPresenter(NotificationPresenter presenter) {
    public void setUpWithPresenter(NotificationPresenter presenter,
            NotificationEntryManager entryManager) {
        mPresenter = presenter;
        mEntryManager = entryManager;

        try {
            registerAsSystemService(mContext,
+10 −7
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ public class NotificationLockscreenUserManager implements Dumpable {
                    isCurrentProfile(getSendingUserId())) {
                mUsersAllowingPrivateNotifications.clear();
                updateLockscreenNotificationSetting();
                mPresenter.getEntryManager().updateNotifications();
                mEntryManager.updateNotifications();
            } else if (Intent.ACTION_DEVICE_LOCKED_CHANGED.equals(action)) {
                if (userId != mCurrentUserId && isCurrentProfile(userId)) {
                    mPresenter.onWorkChallengeChanged();
@@ -157,6 +157,7 @@ public class NotificationLockscreenUserManager implements Dumpable {

    protected int mCurrentUserId = 0;
    protected NotificationPresenter mPresenter;
    protected NotificationEntryManager mEntryManager;
    protected ContentObserver mLockscreenSettingsObserver;
    protected ContentObserver mSettingsObserver;

@@ -170,8 +171,10 @@ public class NotificationLockscreenUserManager implements Dumpable {
                ServiceManager.getService(Context.STATUS_BAR_SERVICE));
    }

    public void setUpWithPresenter(NotificationPresenter presenter) {
    public void setUpWithPresenter(NotificationPresenter presenter,
            NotificationEntryManager entryManager) {
        mPresenter = presenter;
        mEntryManager = entryManager;

        mLockscreenSettingsObserver = new ContentObserver(mPresenter.getHandler()) {
            @Override
@@ -182,7 +185,7 @@ public class NotificationLockscreenUserManager implements Dumpable {
                mUsersAllowingNotifications.clear();
                // ... and refresh all the notifications
                updateLockscreenNotificationSetting();
                mPresenter.getEntryManager().updateNotifications();
                mEntryManager.updateNotifications();
            }
        };

@@ -191,7 +194,7 @@ public class NotificationLockscreenUserManager implements Dumpable {
            public void onChange(boolean selfChange) {
                updateLockscreenNotificationSetting();
                if (mDeviceProvisionedController.isDeviceProvisioned()) {
                    mPresenter.getEntryManager().updateNotifications();
                    mEntryManager.updateNotifications();
                }
            }
        };
@@ -271,13 +274,13 @@ public class NotificationLockscreenUserManager implements Dumpable {
     */
    public boolean shouldHideNotifications(String key) {
        return isLockscreenPublicMode(mCurrentUserId)
                && mPresenter.getEntryManager().getNotificationData().getVisibilityOverride(key) ==
                && mEntryManager.getNotificationData().getVisibilityOverride(key) ==
                        Notification.VISIBILITY_SECRET;
    }

    public boolean shouldShowOnKeyguard(StatusBarNotification sbn) {
        return mShowLockscreenNotifications
                && !mPresenter.getEntryManager().getNotificationData().isAmbient(sbn.getKey());
                && !mEntryManager.getNotificationData().isAmbient(sbn.getKey());
    }

    private void setShowLockscreenNotifications(boolean show) {
@@ -395,7 +398,7 @@ public class NotificationLockscreenUserManager implements Dumpable {
    }

    private boolean packageHasVisibilityOverride(String key) {
        return mPresenter.getEntryManager().getNotificationData().getVisibilityOverride(key) ==
        return mEntryManager.getNotificationData().getVisibilityOverride(key) ==
                Notification.VISIBILITY_PRIVATE;
    }

+5 −5
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ public class NotificationLogger {
    private final NotificationListenerService mNotificationListener;
    private final UiOffloadThread mUiOffloadThread;

    protected NotificationPresenter mPresenter;
    protected NotificationEntryManager mEntryManager;
    protected Handler mHandler = new Handler();
    protected IStatusBarService mBarService;
    private long mLastVisibilityReportUptimeMs;
@@ -96,8 +96,8 @@ public class NotificationLogger {
            //    notifications.
            // 3. Report newly visible and no-longer visible notifications.
            // 4. Keep currently visible notifications for next report.
            ArrayList<NotificationData.Entry> activeNotifications = mPresenter.getEntryManager().
                    getNotificationData().getActiveNotifications();
            ArrayList<NotificationData.Entry> activeNotifications = mEntryManager
                    .getNotificationData().getActiveNotifications();
            int N = activeNotifications.size();
            for (int i = 0; i < N; i++) {
                NotificationData.Entry entry = activeNotifications.get(i);
@@ -140,9 +140,9 @@ public class NotificationLogger {
                ServiceManager.getService(Context.STATUS_BAR_SERVICE));
    }

    public void setUpWithPresenter(NotificationPresenter presenter,
    public void setUpWithEntryManager(NotificationEntryManager entryManager,
            NotificationListContainer listContainer) {
        mPresenter = presenter;
        mEntryManager = entryManager;
        mListContainer = listContainer;
    }

+8 −5
Original line number Diff line number Diff line
@@ -43,7 +43,8 @@ public class NotificationMediaManager implements Dumpable {
    private final Context mContext;
    private final MediaSessionManager mMediaSessionManager;

    private NotificationPresenter mPresenter;
    protected NotificationPresenter mPresenter;
    protected NotificationEntryManager mEntryManager;
    private MediaController mMediaController;
    private String mMediaNotificationKey;
    private MediaMetadata mMediaMetadata;
@@ -82,8 +83,10 @@ public class NotificationMediaManager implements Dumpable {
        // in session state
    }

    public void setUpWithPresenter(NotificationPresenter presenter) {
    public void setUpWithPresenter(NotificationPresenter presenter,
            NotificationEntryManager entryManager) {
        mPresenter = presenter;
        mEntryManager = entryManager;
    }

    public void onNotificationRemoved(String key) {
@@ -104,8 +107,8 @@ public class NotificationMediaManager implements Dumpable {
    public void findAndUpdateMediaNotifications() {
        boolean metaDataChanged = false;

        synchronized (mPresenter.getEntryManager().getNotificationData()) {
            ArrayList<NotificationData.Entry> activeNotifications = mPresenter.getEntryManager()
        synchronized (mEntryManager.getNotificationData()) {
            ArrayList<NotificationData.Entry> activeNotifications = mEntryManager
                    .getNotificationData().getActiveNotifications();
            final int N = activeNotifications.size();

@@ -192,7 +195,7 @@ public class NotificationMediaManager implements Dumpable {
        }

        if (metaDataChanged) {
            mPresenter.getEntryManager().updateNotifications();
            mEntryManager.updateNotifications();
        }
        mPresenter.updateMediaMetaData(metaDataChanged, true);
    }
Loading