From 5c84abb12571a75038d4a6f0938f0a0d09eb20b5 Mon Sep 17 00:00:00 2001 From: Gus Prevas Date: Fri, 28 Dec 2018 16:41:49 -0500 Subject: [PATCH] Factors out list of lifetime extenders from NotificationEntryManager. This allows us to remove the dependency from NotificationEntryManager on AmbientPulseManager, which at this point was just there as a lifetime extender. Test: atest SystemUITests, manual Change-Id: I3c995fb81c9e628368b720d9e3ac582b2dae7a74 --- .../NotificationEntryManager.java | 25 ++++++++++--------- .../phone/StatusBarNotificationPresenter.java | 9 ++++++- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java index 39236fad1def4..e9989fffe8c40 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java @@ -39,7 +39,6 @@ import com.android.systemui.Dependency; import com.android.systemui.Dumpable; import com.android.systemui.ForegroundServiceController; import com.android.systemui.bubbles.BubbleController; -import com.android.systemui.statusbar.AmbientPulseManager; import com.android.systemui.statusbar.NotificationLifetimeExtender; import com.android.systemui.statusbar.NotificationPresenter; import com.android.systemui.statusbar.NotificationRemoteInputManager; @@ -87,8 +86,6 @@ public class NotificationEntryManager implements Dependency.get(DeviceProvisionedController.class); private final ForegroundServiceController mForegroundServiceController = Dependency.get(ForegroundServiceController.class); - private final AmbientPulseManager mAmbientPulseManager = - Dependency.get(AmbientPulseManager.class); private final BubbleController mBubbleController = Dependency.get(BubbleController.class); // Lazily retrieved dependencies @@ -177,18 +174,22 @@ public class NotificationEntryManager implements mNotificationData.setHeadsUpManager(mHeadsUpManager); mListContainer = listContainer; - mNotificationLifetimeExtenders.add(mHeadsUpManager); - mNotificationLifetimeExtenders.add(mAmbientPulseManager); - mNotificationLifetimeExtenders.add(mGutsManager); - mNotificationLifetimeExtenders.addAll(getRemoteInputManager().getLifetimeExtenders()); - - for (NotificationLifetimeExtender extender : mNotificationLifetimeExtenders) { - extender.setCallback(key -> removeNotification(key, mLatestRankingMap)); - } - mDeviceProvisionedController.addCallback(mDeviceProvisionedListener); } + /** Adds multiple {@link NotificationLifetimeExtender}s. */ + public void addNotificationLifetimeExtenders(List extenders) { + for (NotificationLifetimeExtender extender : extenders) { + addNotificationLifetimeExtender(extender); + } + } + + /** Adds a {@link NotificationLifetimeExtender}. */ + public void addNotificationLifetimeExtender(NotificationLifetimeExtender extender) { + mNotificationLifetimeExtenders.add(extender); + extender.setCallback(key -> removeNotification(key, mLatestRankingMap)); + } + public NotificationData getNotificationData() { return mNotificationData; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java index 252b92c2f37fe..c15ddc05afdde 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java @@ -206,9 +206,16 @@ public class StatusBarNotificationPresenter implements NotificationPresenter, } }; + NotificationGutsManager gutsManager = Dependency.get(NotificationGutsManager.class); + mViewHierarchyManager.setUpWithPresenter(this, notifListContainer); mEntryManager.setUpWithPresenter(this, notifListContainer, mHeadsUpManager); mEntryManager.addNotificationEntryListener(notificationEntryListener); + mEntryManager.addNotificationLifetimeExtender(mHeadsUpManager); + mEntryManager.addNotificationLifetimeExtender(mAmbientPulseManager); + mEntryManager.addNotificationLifetimeExtender(gutsManager); + mEntryManager.addNotificationLifetimeExtenders( + remoteInputManager.getLifetimeExtenders()); mNotificationRowBinder.setUpWithPresenter(this, notifListContainer, mHeadsUpManager, mEntryManager, this); mNotificationInterruptionStateProvider.setUpWithPresenter( @@ -216,7 +223,7 @@ public class StatusBarNotificationPresenter implements NotificationPresenter, mLockscreenUserManager.setUpWithPresenter(this); mMediaManager.setUpWithPresenter(this); mVisualStabilityManager.setUpWithPresenter(this); - Dependency.get(NotificationGutsManager.class).setUpWithPresenter(this, + gutsManager.setUpWithPresenter(this, notifListContainer, mCheckSaveListener, mOnSettingsClickListener); onUserSwitched(mLockscreenUserManager.getCurrentUserId());