From b8be82a194a82eca1b8cdcf305d2711aeb00de60 Mon Sep 17 00:00:00 2001 From: Julia Tuttle Date: Tue, 28 Mar 2023 13:42:21 -0400 Subject: [PATCH] Migrate Bubble checks to new Provider Update BubblesManager and associated tests to use the new VisualInterruptionDecisionProvider interface instead of the old NotificationInterruptStateProvider one. Bug: 261728888 Test: atest BubblesTest Change-Id: Id64648818905b324c5a2c96da81f1a30c1f0e829 --- .../systemui/dagger/SystemUIModule.java | 4 +-- .../systemui/wmshell/BubblesManager.java | 33 +++++++++---------- .../android/systemui/wmshell/BubblesTest.java | 3 +- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index 044dd6a47241d..8f78e1f83ebd4 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -284,7 +284,7 @@ public abstract class SystemUIModule { INotificationManager notificationManager, IDreamManager dreamManager, NotificationVisibilityProvider visibilityProvider, - NotificationInterruptStateProvider interruptionStateProvider, + VisualInterruptionDecisionProvider visualInterruptionDecisionProvider, ZenModeController zenModeController, NotificationLockscreenUserManager notifUserManager, CommonNotifCollection notifCollection, @@ -302,7 +302,7 @@ public abstract class SystemUIModule { notificationManager, dreamManager, visibilityProvider, - interruptionStateProvider, + visualInterruptionDecisionProvider, zenModeController, notifUserManager, notifCollection, diff --git a/packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java b/packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java index a4b093d1832af..a5365fbc3d5d8 100644 --- a/packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java +++ b/packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java @@ -66,7 +66,7 @@ import com.android.systemui.statusbar.notification.collection.notifcollection.Co import com.android.systemui.statusbar.notification.collection.notifcollection.DismissedByUserStats; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener; import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; -import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider; +import com.android.systemui.statusbar.notification.interruption.VisualInterruptionDecisionProvider; import com.android.systemui.statusbar.phone.StatusBarWindowCallback; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.statusbar.policy.ZenModeController; @@ -100,7 +100,7 @@ public class BubblesManager { private final INotificationManager mNotificationManager; private final IDreamManager mDreamManager; private final NotificationVisibilityProvider mVisibilityProvider; - private final NotificationInterruptStateProvider mNotificationInterruptStateProvider; + private final VisualInterruptionDecisionProvider mVisualInterruptionDecisionProvider; private final NotificationLockscreenUserManager mNotifUserManager; private final CommonNotifCollection mCommonNotifCollection; private final NotifPipeline mNotifPipeline; @@ -126,7 +126,7 @@ public class BubblesManager { INotificationManager notificationManager, IDreamManager dreamManager, NotificationVisibilityProvider visibilityProvider, - NotificationInterruptStateProvider interruptionStateProvider, + VisualInterruptionDecisionProvider visualInterruptionDecisionProvider, ZenModeController zenModeController, NotificationLockscreenUserManager notifUserManager, CommonNotifCollection notifCollection, @@ -145,7 +145,7 @@ public class BubblesManager { notificationManager, dreamManager, visibilityProvider, - interruptionStateProvider, + visualInterruptionDecisionProvider, zenModeController, notifUserManager, notifCollection, @@ -169,7 +169,7 @@ public class BubblesManager { INotificationManager notificationManager, IDreamManager dreamManager, NotificationVisibilityProvider visibilityProvider, - NotificationInterruptStateProvider interruptionStateProvider, + VisualInterruptionDecisionProvider visualInterruptionDecisionProvider, ZenModeController zenModeController, NotificationLockscreenUserManager notifUserManager, CommonNotifCollection notifCollection, @@ -185,7 +185,7 @@ public class BubblesManager { mNotificationManager = notificationManager; mDreamManager = dreamManager; mVisibilityProvider = visibilityProvider; - mNotificationInterruptStateProvider = interruptionStateProvider; + mVisualInterruptionDecisionProvider = visualInterruptionDecisionProvider; mNotifUserManager = notifUserManager; mCommonNotifCollection = notifCollection; mNotifPipeline = notifPipeline; @@ -272,7 +272,7 @@ public class BubblesManager { for (NotificationEntry entry : activeEntries) { if (mNotifUserManager.isCurrentProfile(entry.getSbn().getUserId()) && savedBubbleKeys.contains(entry.getKey()) - && mNotificationInterruptStateProvider.shouldBubbleUp(entry) + && shouldBubbleUp(entry) && entry.isBubble()) { result.add(notifToBubbleEntry(entry)); } @@ -416,16 +416,13 @@ public class BubblesManager { } void onEntryAdded(NotificationEntry entry) { - if (mNotificationInterruptStateProvider.shouldBubbleUp(entry) - && entry.isBubble()) { + if (shouldBubbleUp(entry) && entry.isBubble()) { mBubbles.onEntryAdded(notifToBubbleEntry(entry)); } } void onEntryUpdated(NotificationEntry entry, boolean fromSystem) { - boolean shouldBubble = mNotificationInterruptStateProvider.shouldBubbleUp(entry); - mBubbles.onEntryUpdated(notifToBubbleEntry(entry), - shouldBubble, fromSystem); + mBubbles.onEntryUpdated(notifToBubbleEntry(entry), shouldBubbleUp(entry), fromSystem); } void onEntryRemoved(NotificationEntry entry) { @@ -438,12 +435,8 @@ public class BubblesManager { for (int i = 0; i < orderedKeys.length; i++) { String key = orderedKeys[i]; final NotificationEntry entry = mCommonNotifCollection.getEntry(key); - BubbleEntry bubbleEntry = entry != null - ? notifToBubbleEntry(entry) - : null; - boolean shouldBubbleUp = entry != null - ? mNotificationInterruptStateProvider.shouldBubbleUp(entry) - : false; + BubbleEntry bubbleEntry = entry != null ? notifToBubbleEntry(entry) : null; + boolean shouldBubbleUp = entry != null ? shouldBubbleUp(entry) : false; pendingOrActiveNotif.put(key, new Pair<>(bubbleEntry, shouldBubbleUp)); } mBubbles.onRankingUpdated(rankingMap, pendingOrActiveNotif); @@ -637,6 +630,10 @@ public class BubblesManager { } } + private boolean shouldBubbleUp(NotificationEntry e) { + return mVisualInterruptionDecisionProvider.makeAndLogBubbleDecision(e).getShouldInterrupt(); + } + /** * Callback for when the BubbleController wants to interact with the notification pipeline to: * - Remove a previously bubbled notification diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java index 9a99538650373..62595271900da 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java @@ -116,6 +116,7 @@ import com.android.systemui.statusbar.notification.collection.notifcollection.No import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; import com.android.systemui.statusbar.notification.interruption.KeyguardNotificationVisibilityProvider; import com.android.systemui.statusbar.notification.interruption.NotificationInterruptLogger; +import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProviderWrapper; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.NotificationTestHelper; import com.android.systemui.statusbar.phone.DozeParameters; @@ -399,7 +400,7 @@ public class BubblesTest extends SysuiTestCase { mock(INotificationManager.class), mIDreamManager, mVisibilityProvider, - interruptionStateProvider, + new NotificationInterruptStateProviderWrapper(interruptionStateProvider), mZenModeController, mLockscreenUserManager, mCommonNotifCollection,