Loading packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +3 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ import com.android.systemui.smartspace.dagger.SmartspaceModule; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.NotificationLockscreenUserManager; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.notification.NotifPipelineFlags; import com.android.systemui.statusbar.notification.collection.NotifPipeline; import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder; import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinderImpl; Loading Loading @@ -266,6 +267,7 @@ public abstract class SystemUIModule { NotifPipeline notifPipeline, SysUiState sysUiState, FeatureFlags featureFlags, NotifPipelineFlags notifPipelineFlags, @Main Executor sysuiMainExecutor) { return Optional.ofNullable(BubblesManager.create(context, bubblesOptional, Loading @@ -283,6 +285,7 @@ public abstract class SystemUIModule { notifPipeline, sysUiState, featureFlags, notifPipelineFlags, sysuiMainExecutor)); } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/NotificationDismissibilityProviderImpl.kt +5 −5 Original line number Diff line number Diff line Loading @@ -17,11 +17,10 @@ package com.android.systemui.statusbar.notification.collection.provider import androidx.annotation.VisibleForTesting import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags.ALLOW_DISMISS_ONGOING import com.android.systemui.Dumpable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dump.DumpManager import com.android.systemui.statusbar.notification.NotifPipelineFlags import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.util.asIndenting import com.android.systemui.util.withIncreasedIndent Loading @@ -29,7 +28,9 @@ import java.io.PrintWriter import javax.inject.Inject @SysUISingleton class NotificationDismissibilityProviderImpl @Inject constructor(dumpManager: DumpManager) : class NotificationDismissibilityProviderImpl @Inject constructor(private val notifPipelineFlags: NotifPipelineFlags, dumpManager: DumpManager) : NotificationDismissibilityProvider, Dumpable { init { Loading @@ -42,8 +43,7 @@ class NotificationDismissibilityProviderImpl @Inject constructor(dumpManager: Du private set override fun isDismissable(entry: NotificationEntry): Boolean { // TODO(b/268380968): inject FlagResolver return if (SystemUiSystemPropertiesFlags.getResolver().isEnabled(ALLOW_DISMISS_ONGOING)) { return if (notifPipelineFlags.allowDismissOngoing()) { entry.key !in nonDismissableEntryKeys } else { entry.legacyIsDismissableRecursive() Loading packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java +10 −6 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import static android.service.notification.NotificationListenerService.REASON_GR import static android.service.notification.NotificationStats.DISMISSAL_BUBBLE; import static android.service.notification.NotificationStats.DISMISS_SENTIMENT_NEUTRAL; import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags.ALLOW_DISMISS_ONGOING; import static com.android.systemui.flags.Flags.WM_BUBBLE_BAR; import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_BUBBLES; import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME; Loading @@ -51,7 +50,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags; import com.android.internal.statusbar.IStatusBarService; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.flags.FeatureFlags; Loading @@ -60,6 +58,7 @@ import com.android.systemui.shade.ShadeController; import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.statusbar.NotificationLockscreenUserManager; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.notification.NotifPipelineFlags; import com.android.systemui.statusbar.notification.NotificationChannelHelper; import com.android.systemui.statusbar.notification.collection.NotifCollection; import com.android.systemui.statusbar.notification.collection.NotifPipeline; Loading Loading @@ -106,6 +105,7 @@ public class BubblesManager { private final NotificationLockscreenUserManager mNotifUserManager; private final CommonNotifCollection mCommonNotifCollection; private final NotifPipeline mNotifPipeline; private final NotifPipelineFlags mNotifPipelineFlags; private final Executor mSysuiMainExecutor; private final Bubbles.SysuiProxy mSysuiProxy; Loading Loading @@ -134,6 +134,7 @@ public class BubblesManager { NotifPipeline notifPipeline, SysUiState sysUiState, FeatureFlags featureFlags, NotifPipelineFlags notifPipelineFlags, Executor sysuiMainExecutor) { if (bubblesOptional.isPresent()) { return new BubblesManager(context, Loading @@ -152,6 +153,7 @@ public class BubblesManager { notifPipeline, sysUiState, featureFlags, notifPipelineFlags, sysuiMainExecutor); } else { return null; Loading @@ -175,6 +177,7 @@ public class BubblesManager { NotifPipeline notifPipeline, SysUiState sysUiState, FeatureFlags featureFlags, NotifPipelineFlags notifPipelineFlags, Executor sysuiMainExecutor) { mContext = context; mBubbles = bubbles; Loading @@ -187,6 +190,7 @@ public class BubblesManager { mNotifUserManager = notifUserManager; mCommonNotifCollection = notifCollection; mNotifPipeline = notifPipeline; mNotifPipelineFlags = notifPipelineFlags; mSysuiMainExecutor = sysuiMainExecutor; mBarService = statusBarService == null Loading Loading @@ -618,15 +622,15 @@ public class BubblesManager { } } static BubbleEntry notifToBubbleEntry(NotificationEntry e) { @VisibleForTesting BubbleEntry notifToBubbleEntry(NotificationEntry e) { return new BubbleEntry(e.getSbn(), e.getRanking(), isDismissableFromBubbles(e), e.shouldSuppressNotificationDot(), e.shouldSuppressNotificationList(), e.shouldSuppressPeek()); } private static boolean isDismissableFromBubbles(NotificationEntry e) { // TODO(b/268380968): inject FlagResolver if (SystemUiSystemPropertiesFlags.getResolver().isEnabled(ALLOW_DISMISS_ONGOING)) { private boolean isDismissableFromBubbles(NotificationEntry e) { if (mNotifPipelineFlags.allowDismissOngoing()) { // Bubbles are only accessible from the unlocked state, // so we can calculate this from the Notification flags only. return e.isDismissableForState(/*isLocked=*/ false); Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/DismissibilityCoordinatorTest.kt +7 −9 Original line number Diff line number Diff line Loading @@ -19,10 +19,9 @@ package com.android.systemui.statusbar.notification.collection.coordinator import android.app.Notification import android.testing.AndroidTestingRunner import androidx.test.filters.SmallTest import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags import com.android.systemui.SysuiTestCase import com.android.systemui.dump.DumpManager import com.android.systemui.statusbar.notification.NotifPipelineFlags import com.android.systemui.statusbar.notification.collection.GroupEntryBuilder import com.android.systemui.statusbar.notification.collection.NotifPipeline import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder Loading @@ -48,15 +47,14 @@ class DismissibilityCoordinatorTest : SysuiTestCase() { private lateinit var onBeforeRenderListListener: OnBeforeRenderListListener private val keyguardStateController: KeyguardStateController = mock() private val pipeline: NotifPipeline = mock() private val flagResolver: SystemUiSystemPropertiesFlags.FlagResolver = mock() private val flags: NotifPipelineFlags = mock() private val dumpManager: DumpManager = mock() @Before fun setUp() { setTestFlagResolver(flagResolver) whenever(flagResolver.isEnabled(NotificationFlags.ALLOW_DISMISS_ONGOING)).thenReturn(true) whenever(flags.allowDismissOngoing()).thenReturn(true) dismissibilityProvider = NotificationDismissibilityProviderImpl(dumpManager) dismissibilityProvider = NotificationDismissibilityProviderImpl(flags, dumpManager) coordinator = DismissibilityCoordinator(keyguardStateController, dismissibilityProvider) coordinator.attach(pipeline) onBeforeRenderListListener = withArgCaptor { Loading Loading @@ -314,7 +312,7 @@ class DismissibilityCoordinatorTest : SysuiTestCase() { @Test fun testFeatureToggleOffNonDismissibleEntry() { whenever(flagResolver.isEnabled(NotificationFlags.ALLOW_DISMISS_ONGOING)).thenReturn(false) whenever(flags.allowDismissOngoing()).thenReturn(false) val entry = NotificationEntryBuilder() .setTag("entry") Loading @@ -331,7 +329,7 @@ class DismissibilityCoordinatorTest : SysuiTestCase() { @Test fun testFeatureToggleOffOngoingNotifWhenPhoneIsLocked() { whenever(flagResolver.isEnabled(NotificationFlags.ALLOW_DISMISS_ONGOING)).thenReturn(false) whenever(flags.allowDismissOngoing()).thenReturn(false) whenever(keyguardStateController.isUnlocked).thenReturn(false) val entry = NotificationEntryBuilder() Loading @@ -349,7 +347,7 @@ class DismissibilityCoordinatorTest : SysuiTestCase() { @Test fun testFeatureToggleOffOngoingNotifWhenPhoneIsUnLocked() { whenever(flagResolver.isEnabled(NotificationFlags.ALLOW_DISMISS_ONGOING)).thenReturn(false) whenever(flags.allowDismissOngoing()).thenReturn(false) whenever(keyguardStateController.isUnlocked).thenReturn(true) val entry = NotificationEntryBuilder() Loading packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +30 −33 Original line number Diff line number Diff line Loading @@ -82,8 +82,6 @@ import android.view.WindowManager; import androidx.test.filters.SmallTest; import com.android.internal.colorextraction.ColorExtractor; import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags; import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags; import com.android.internal.logging.UiEventLogger; import com.android.internal.statusbar.IStatusBarService; import com.android.systemui.SysuiTestCase; Loading Loading @@ -285,7 +283,7 @@ public class BubblesTest extends SysuiTestCase { @Mock private ShadeWindowLogger mShadeWindowLogger; @Mock private SystemUiSystemPropertiesFlags.FlagResolver mFlagResolver; private NotifPipelineFlags mNotifPipelineFlags; private TestableBubblePositioner mPositioner; Loading @@ -298,8 +296,6 @@ public class BubblesTest extends SysuiTestCase { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); setTestFlagResolver(mFlagResolver); mTestableLooper = TestableLooper.get(this); // For the purposes of this test, just run everything synchronously Loading @@ -318,24 +314,6 @@ public class BubblesTest extends SysuiTestCase { mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView); mNotificationShadeWindowController.attach(); // Need notifications for bubbles mNotificationTestHelper = new NotificationTestHelper( mContext, mDependency, TestableLooper.get(this)); mRow = mNotificationTestHelper.createBubble(mDeleteIntent); mRow2 = mNotificationTestHelper.createBubble(mDeleteIntent); mNonBubbleNotifRow = mNotificationTestHelper.createRow(); mBubbleEntry = BubblesManager.notifToBubbleEntry(mRow); mBubbleEntry2 = BubblesManager.notifToBubbleEntry(mRow2); UserHandle handle = mock(UserHandle.class); when(handle.getIdentifier()).thenReturn(11); mBubbleEntryUser11 = BubblesManager.notifToBubbleEntry( mNotificationTestHelper.createBubble(handle)); mBubbleEntry2User11 = BubblesManager.notifToBubbleEntry( mNotificationTestHelper.createBubble(handle)); mAppBubbleIntent = new Intent(mContext, BubblesTestActivity.class); mAppBubbleIntent.setPackage(mContext.getPackageName()); Loading Loading @@ -420,9 +398,28 @@ public class BubblesTest extends SysuiTestCase { mNotifPipeline, mSysUiState, mock(FeatureFlags.class), mNotifPipelineFlags, syncExecutor); mBubblesManager.addNotifCallback(mNotifCallback); // Need notifications for bubbles mNotificationTestHelper = new NotificationTestHelper( mContext, mDependency, TestableLooper.get(this)); mRow = mNotificationTestHelper.createBubble(mDeleteIntent); mRow2 = mNotificationTestHelper.createBubble(mDeleteIntent); mNonBubbleNotifRow = mNotificationTestHelper.createRow(); mBubbleEntry = mBubblesManager.notifToBubbleEntry(mRow); mBubbleEntry2 = mBubblesManager.notifToBubbleEntry(mRow2); UserHandle handle = mock(UserHandle.class); when(handle.getIdentifier()).thenReturn(11); mBubbleEntryUser11 = mBubblesManager.notifToBubbleEntry( mNotificationTestHelper.createBubble(handle)); mBubbleEntry2User11 = mBubblesManager.notifToBubbleEntry( mNotificationTestHelper.createBubble(handle)); // Get a reference to the BubbleController's entry listener verify(mNotifPipeline, atLeastOnce()) .addCollectionListener(mNotifListenerCaptor.capture()); Loading Loading @@ -1185,7 +1182,7 @@ public class BubblesTest extends SysuiTestCase { @Test public void testDeleteShortcutsDeletesXml() throws Exception { ExpandableNotificationRow row = mNotificationTestHelper.createShortcutBubble("shortcutId"); BubbleEntry shortcutBubbleEntry = BubblesManager.notifToBubbleEntry(row.getEntry()); BubbleEntry shortcutBubbleEntry = mBubblesManager.notifToBubbleEntry(row.getEntry()); mBubbleController.updateBubble(shortcutBubbleEntry); mBubbleData.dismissBubbleWithKey(shortcutBubbleEntry.getKey(), Loading Loading @@ -1297,7 +1294,7 @@ public class BubblesTest extends SysuiTestCase { entry.getChannel().setConversationId( row.getEntry().getChannel().getParentChannelId(), "shortcutId"); mBubbleController.updateBubble(BubblesManager.notifToBubbleEntry(row.getEntry())); mBubbleController.updateBubble(mBubblesManager.notifToBubbleEntry(row.getEntry())); assertTrue(mBubbleController.hasBubbles()); // Overflow it Loading @@ -1323,7 +1320,7 @@ public class BubblesTest extends SysuiTestCase { entry.getChannel().setConversationId( row.getEntry().getChannel().getParentChannelId(), "shortcutId"); mBubbleController.updateBubble(BubblesManager.notifToBubbleEntry(row.getEntry())); mBubbleController.updateBubble(mBubblesManager.notifToBubbleEntry(row.getEntry())); assertTrue(mBubbleController.hasBubbles()); // Overflow it Loading Loading @@ -1706,13 +1703,13 @@ public class BubblesTest extends SysuiTestCase { @Test public void testCreateBubbleFromOngoingNotification_OngoingDismissalEnabled() { when(mFlagResolver.isEnabled(NotificationFlags.ALLOW_DISMISS_ONGOING)).thenReturn(true); when(mNotifPipelineFlags.allowDismissOngoing()).thenReturn(true); NotificationEntry notif = new NotificationEntryBuilder() .setFlag(mContext, Notification.FLAG_ONGOING_EVENT, true) .setCanBubble(true) .build(); BubbleEntry bubble = BubblesManager.notifToBubbleEntry(notif); BubbleEntry bubble = mBubblesManager.notifToBubbleEntry(notif); assertTrue("Ongoing Notifis should be dismissable", bubble.isDismissable()); } Loading @@ -1720,13 +1717,13 @@ public class BubblesTest extends SysuiTestCase { @Test public void testCreateBubbleFromNoDismissNotification_OngoingDismissalEnabled() { when(mFlagResolver.isEnabled(NotificationFlags.ALLOW_DISMISS_ONGOING)).thenReturn(true); when(mNotifPipelineFlags.allowDismissOngoing()).thenReturn(true); NotificationEntry notif = new NotificationEntryBuilder() .setFlag(mContext, Notification.FLAG_NO_DISMISS, true) .setCanBubble(true) .build(); BubbleEntry bubble = BubblesManager.notifToBubbleEntry(notif); BubbleEntry bubble = mBubblesManager.notifToBubbleEntry(notif); assertFalse("FLAG_NO_DISMISS Notifs should be non-dismissable", bubble.isDismissable()); } Loading @@ -1738,7 +1735,7 @@ public class BubblesTest extends SysuiTestCase { .setCanBubble(true) .build(); BubbleEntry bubble = BubblesManager.notifToBubbleEntry(notif); BubbleEntry bubble = mBubblesManager.notifToBubbleEntry(notif); assertFalse( "Ongoing Notifis should be dismissable, if the feature is off", Loading @@ -1754,7 +1751,7 @@ public class BubblesTest extends SysuiTestCase { .setCanBubble(true) .build(); BubbleEntry bubble = BubblesManager.notifToBubbleEntry(notif); BubbleEntry bubble = mBubblesManager.notifToBubbleEntry(notif); assertTrue( "FLAG_NO_DISMISS should be ignored, if the feature is off", Loading @@ -1772,7 +1769,7 @@ public class BubblesTest extends SysuiTestCase { workEntry.setBubbleMetadata(getMetadata()); workEntry.setFlagBubble(true); return new Bubble(BubblesManager.notifToBubbleEntry(workEntry), return new Bubble(mBubblesManager.notifToBubbleEntry(workEntry), null, mock(Bubbles.PendingIntentCanceledListener.class), new SyncExecutor()); } Loading Loading
packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +3 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ import com.android.systemui.smartspace.dagger.SmartspaceModule; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.NotificationLockscreenUserManager; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.notification.NotifPipelineFlags; import com.android.systemui.statusbar.notification.collection.NotifPipeline; import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder; import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinderImpl; Loading Loading @@ -266,6 +267,7 @@ public abstract class SystemUIModule { NotifPipeline notifPipeline, SysUiState sysUiState, FeatureFlags featureFlags, NotifPipelineFlags notifPipelineFlags, @Main Executor sysuiMainExecutor) { return Optional.ofNullable(BubblesManager.create(context, bubblesOptional, Loading @@ -283,6 +285,7 @@ public abstract class SystemUIModule { notifPipeline, sysUiState, featureFlags, notifPipelineFlags, sysuiMainExecutor)); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/NotificationDismissibilityProviderImpl.kt +5 −5 Original line number Diff line number Diff line Loading @@ -17,11 +17,10 @@ package com.android.systemui.statusbar.notification.collection.provider import androidx.annotation.VisibleForTesting import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags.ALLOW_DISMISS_ONGOING import com.android.systemui.Dumpable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dump.DumpManager import com.android.systemui.statusbar.notification.NotifPipelineFlags import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.util.asIndenting import com.android.systemui.util.withIncreasedIndent Loading @@ -29,7 +28,9 @@ import java.io.PrintWriter import javax.inject.Inject @SysUISingleton class NotificationDismissibilityProviderImpl @Inject constructor(dumpManager: DumpManager) : class NotificationDismissibilityProviderImpl @Inject constructor(private val notifPipelineFlags: NotifPipelineFlags, dumpManager: DumpManager) : NotificationDismissibilityProvider, Dumpable { init { Loading @@ -42,8 +43,7 @@ class NotificationDismissibilityProviderImpl @Inject constructor(dumpManager: Du private set override fun isDismissable(entry: NotificationEntry): Boolean { // TODO(b/268380968): inject FlagResolver return if (SystemUiSystemPropertiesFlags.getResolver().isEnabled(ALLOW_DISMISS_ONGOING)) { return if (notifPipelineFlags.allowDismissOngoing()) { entry.key !in nonDismissableEntryKeys } else { entry.legacyIsDismissableRecursive() Loading
packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java +10 −6 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import static android.service.notification.NotificationListenerService.REASON_GR import static android.service.notification.NotificationStats.DISMISSAL_BUBBLE; import static android.service.notification.NotificationStats.DISMISS_SENTIMENT_NEUTRAL; import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags.ALLOW_DISMISS_ONGOING; import static com.android.systemui.flags.Flags.WM_BUBBLE_BAR; import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_BUBBLES; import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME; Loading @@ -51,7 +50,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags; import com.android.internal.statusbar.IStatusBarService; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.flags.FeatureFlags; Loading @@ -60,6 +58,7 @@ import com.android.systemui.shade.ShadeController; import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.statusbar.NotificationLockscreenUserManager; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.notification.NotifPipelineFlags; import com.android.systemui.statusbar.notification.NotificationChannelHelper; import com.android.systemui.statusbar.notification.collection.NotifCollection; import com.android.systemui.statusbar.notification.collection.NotifPipeline; Loading Loading @@ -106,6 +105,7 @@ public class BubblesManager { private final NotificationLockscreenUserManager mNotifUserManager; private final CommonNotifCollection mCommonNotifCollection; private final NotifPipeline mNotifPipeline; private final NotifPipelineFlags mNotifPipelineFlags; private final Executor mSysuiMainExecutor; private final Bubbles.SysuiProxy mSysuiProxy; Loading Loading @@ -134,6 +134,7 @@ public class BubblesManager { NotifPipeline notifPipeline, SysUiState sysUiState, FeatureFlags featureFlags, NotifPipelineFlags notifPipelineFlags, Executor sysuiMainExecutor) { if (bubblesOptional.isPresent()) { return new BubblesManager(context, Loading @@ -152,6 +153,7 @@ public class BubblesManager { notifPipeline, sysUiState, featureFlags, notifPipelineFlags, sysuiMainExecutor); } else { return null; Loading @@ -175,6 +177,7 @@ public class BubblesManager { NotifPipeline notifPipeline, SysUiState sysUiState, FeatureFlags featureFlags, NotifPipelineFlags notifPipelineFlags, Executor sysuiMainExecutor) { mContext = context; mBubbles = bubbles; Loading @@ -187,6 +190,7 @@ public class BubblesManager { mNotifUserManager = notifUserManager; mCommonNotifCollection = notifCollection; mNotifPipeline = notifPipeline; mNotifPipelineFlags = notifPipelineFlags; mSysuiMainExecutor = sysuiMainExecutor; mBarService = statusBarService == null Loading Loading @@ -618,15 +622,15 @@ public class BubblesManager { } } static BubbleEntry notifToBubbleEntry(NotificationEntry e) { @VisibleForTesting BubbleEntry notifToBubbleEntry(NotificationEntry e) { return new BubbleEntry(e.getSbn(), e.getRanking(), isDismissableFromBubbles(e), e.shouldSuppressNotificationDot(), e.shouldSuppressNotificationList(), e.shouldSuppressPeek()); } private static boolean isDismissableFromBubbles(NotificationEntry e) { // TODO(b/268380968): inject FlagResolver if (SystemUiSystemPropertiesFlags.getResolver().isEnabled(ALLOW_DISMISS_ONGOING)) { private boolean isDismissableFromBubbles(NotificationEntry e) { if (mNotifPipelineFlags.allowDismissOngoing()) { // Bubbles are only accessible from the unlocked state, // so we can calculate this from the Notification flags only. return e.isDismissableForState(/*isLocked=*/ false); Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/DismissibilityCoordinatorTest.kt +7 −9 Original line number Diff line number Diff line Loading @@ -19,10 +19,9 @@ package com.android.systemui.statusbar.notification.collection.coordinator import android.app.Notification import android.testing.AndroidTestingRunner import androidx.test.filters.SmallTest import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags import com.android.systemui.SysuiTestCase import com.android.systemui.dump.DumpManager import com.android.systemui.statusbar.notification.NotifPipelineFlags import com.android.systemui.statusbar.notification.collection.GroupEntryBuilder import com.android.systemui.statusbar.notification.collection.NotifPipeline import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder Loading @@ -48,15 +47,14 @@ class DismissibilityCoordinatorTest : SysuiTestCase() { private lateinit var onBeforeRenderListListener: OnBeforeRenderListListener private val keyguardStateController: KeyguardStateController = mock() private val pipeline: NotifPipeline = mock() private val flagResolver: SystemUiSystemPropertiesFlags.FlagResolver = mock() private val flags: NotifPipelineFlags = mock() private val dumpManager: DumpManager = mock() @Before fun setUp() { setTestFlagResolver(flagResolver) whenever(flagResolver.isEnabled(NotificationFlags.ALLOW_DISMISS_ONGOING)).thenReturn(true) whenever(flags.allowDismissOngoing()).thenReturn(true) dismissibilityProvider = NotificationDismissibilityProviderImpl(dumpManager) dismissibilityProvider = NotificationDismissibilityProviderImpl(flags, dumpManager) coordinator = DismissibilityCoordinator(keyguardStateController, dismissibilityProvider) coordinator.attach(pipeline) onBeforeRenderListListener = withArgCaptor { Loading Loading @@ -314,7 +312,7 @@ class DismissibilityCoordinatorTest : SysuiTestCase() { @Test fun testFeatureToggleOffNonDismissibleEntry() { whenever(flagResolver.isEnabled(NotificationFlags.ALLOW_DISMISS_ONGOING)).thenReturn(false) whenever(flags.allowDismissOngoing()).thenReturn(false) val entry = NotificationEntryBuilder() .setTag("entry") Loading @@ -331,7 +329,7 @@ class DismissibilityCoordinatorTest : SysuiTestCase() { @Test fun testFeatureToggleOffOngoingNotifWhenPhoneIsLocked() { whenever(flagResolver.isEnabled(NotificationFlags.ALLOW_DISMISS_ONGOING)).thenReturn(false) whenever(flags.allowDismissOngoing()).thenReturn(false) whenever(keyguardStateController.isUnlocked).thenReturn(false) val entry = NotificationEntryBuilder() Loading @@ -349,7 +347,7 @@ class DismissibilityCoordinatorTest : SysuiTestCase() { @Test fun testFeatureToggleOffOngoingNotifWhenPhoneIsUnLocked() { whenever(flagResolver.isEnabled(NotificationFlags.ALLOW_DISMISS_ONGOING)).thenReturn(false) whenever(flags.allowDismissOngoing()).thenReturn(false) whenever(keyguardStateController.isUnlocked).thenReturn(true) val entry = NotificationEntryBuilder() Loading
packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +30 −33 Original line number Diff line number Diff line Loading @@ -82,8 +82,6 @@ import android.view.WindowManager; import androidx.test.filters.SmallTest; import com.android.internal.colorextraction.ColorExtractor; import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags; import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags; import com.android.internal.logging.UiEventLogger; import com.android.internal.statusbar.IStatusBarService; import com.android.systemui.SysuiTestCase; Loading Loading @@ -285,7 +283,7 @@ public class BubblesTest extends SysuiTestCase { @Mock private ShadeWindowLogger mShadeWindowLogger; @Mock private SystemUiSystemPropertiesFlags.FlagResolver mFlagResolver; private NotifPipelineFlags mNotifPipelineFlags; private TestableBubblePositioner mPositioner; Loading @@ -298,8 +296,6 @@ public class BubblesTest extends SysuiTestCase { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); setTestFlagResolver(mFlagResolver); mTestableLooper = TestableLooper.get(this); // For the purposes of this test, just run everything synchronously Loading @@ -318,24 +314,6 @@ public class BubblesTest extends SysuiTestCase { mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView); mNotificationShadeWindowController.attach(); // Need notifications for bubbles mNotificationTestHelper = new NotificationTestHelper( mContext, mDependency, TestableLooper.get(this)); mRow = mNotificationTestHelper.createBubble(mDeleteIntent); mRow2 = mNotificationTestHelper.createBubble(mDeleteIntent); mNonBubbleNotifRow = mNotificationTestHelper.createRow(); mBubbleEntry = BubblesManager.notifToBubbleEntry(mRow); mBubbleEntry2 = BubblesManager.notifToBubbleEntry(mRow2); UserHandle handle = mock(UserHandle.class); when(handle.getIdentifier()).thenReturn(11); mBubbleEntryUser11 = BubblesManager.notifToBubbleEntry( mNotificationTestHelper.createBubble(handle)); mBubbleEntry2User11 = BubblesManager.notifToBubbleEntry( mNotificationTestHelper.createBubble(handle)); mAppBubbleIntent = new Intent(mContext, BubblesTestActivity.class); mAppBubbleIntent.setPackage(mContext.getPackageName()); Loading Loading @@ -420,9 +398,28 @@ public class BubblesTest extends SysuiTestCase { mNotifPipeline, mSysUiState, mock(FeatureFlags.class), mNotifPipelineFlags, syncExecutor); mBubblesManager.addNotifCallback(mNotifCallback); // Need notifications for bubbles mNotificationTestHelper = new NotificationTestHelper( mContext, mDependency, TestableLooper.get(this)); mRow = mNotificationTestHelper.createBubble(mDeleteIntent); mRow2 = mNotificationTestHelper.createBubble(mDeleteIntent); mNonBubbleNotifRow = mNotificationTestHelper.createRow(); mBubbleEntry = mBubblesManager.notifToBubbleEntry(mRow); mBubbleEntry2 = mBubblesManager.notifToBubbleEntry(mRow2); UserHandle handle = mock(UserHandle.class); when(handle.getIdentifier()).thenReturn(11); mBubbleEntryUser11 = mBubblesManager.notifToBubbleEntry( mNotificationTestHelper.createBubble(handle)); mBubbleEntry2User11 = mBubblesManager.notifToBubbleEntry( mNotificationTestHelper.createBubble(handle)); // Get a reference to the BubbleController's entry listener verify(mNotifPipeline, atLeastOnce()) .addCollectionListener(mNotifListenerCaptor.capture()); Loading Loading @@ -1185,7 +1182,7 @@ public class BubblesTest extends SysuiTestCase { @Test public void testDeleteShortcutsDeletesXml() throws Exception { ExpandableNotificationRow row = mNotificationTestHelper.createShortcutBubble("shortcutId"); BubbleEntry shortcutBubbleEntry = BubblesManager.notifToBubbleEntry(row.getEntry()); BubbleEntry shortcutBubbleEntry = mBubblesManager.notifToBubbleEntry(row.getEntry()); mBubbleController.updateBubble(shortcutBubbleEntry); mBubbleData.dismissBubbleWithKey(shortcutBubbleEntry.getKey(), Loading Loading @@ -1297,7 +1294,7 @@ public class BubblesTest extends SysuiTestCase { entry.getChannel().setConversationId( row.getEntry().getChannel().getParentChannelId(), "shortcutId"); mBubbleController.updateBubble(BubblesManager.notifToBubbleEntry(row.getEntry())); mBubbleController.updateBubble(mBubblesManager.notifToBubbleEntry(row.getEntry())); assertTrue(mBubbleController.hasBubbles()); // Overflow it Loading @@ -1323,7 +1320,7 @@ public class BubblesTest extends SysuiTestCase { entry.getChannel().setConversationId( row.getEntry().getChannel().getParentChannelId(), "shortcutId"); mBubbleController.updateBubble(BubblesManager.notifToBubbleEntry(row.getEntry())); mBubbleController.updateBubble(mBubblesManager.notifToBubbleEntry(row.getEntry())); assertTrue(mBubbleController.hasBubbles()); // Overflow it Loading Loading @@ -1706,13 +1703,13 @@ public class BubblesTest extends SysuiTestCase { @Test public void testCreateBubbleFromOngoingNotification_OngoingDismissalEnabled() { when(mFlagResolver.isEnabled(NotificationFlags.ALLOW_DISMISS_ONGOING)).thenReturn(true); when(mNotifPipelineFlags.allowDismissOngoing()).thenReturn(true); NotificationEntry notif = new NotificationEntryBuilder() .setFlag(mContext, Notification.FLAG_ONGOING_EVENT, true) .setCanBubble(true) .build(); BubbleEntry bubble = BubblesManager.notifToBubbleEntry(notif); BubbleEntry bubble = mBubblesManager.notifToBubbleEntry(notif); assertTrue("Ongoing Notifis should be dismissable", bubble.isDismissable()); } Loading @@ -1720,13 +1717,13 @@ public class BubblesTest extends SysuiTestCase { @Test public void testCreateBubbleFromNoDismissNotification_OngoingDismissalEnabled() { when(mFlagResolver.isEnabled(NotificationFlags.ALLOW_DISMISS_ONGOING)).thenReturn(true); when(mNotifPipelineFlags.allowDismissOngoing()).thenReturn(true); NotificationEntry notif = new NotificationEntryBuilder() .setFlag(mContext, Notification.FLAG_NO_DISMISS, true) .setCanBubble(true) .build(); BubbleEntry bubble = BubblesManager.notifToBubbleEntry(notif); BubbleEntry bubble = mBubblesManager.notifToBubbleEntry(notif); assertFalse("FLAG_NO_DISMISS Notifs should be non-dismissable", bubble.isDismissable()); } Loading @@ -1738,7 +1735,7 @@ public class BubblesTest extends SysuiTestCase { .setCanBubble(true) .build(); BubbleEntry bubble = BubblesManager.notifToBubbleEntry(notif); BubbleEntry bubble = mBubblesManager.notifToBubbleEntry(notif); assertFalse( "Ongoing Notifis should be dismissable, if the feature is off", Loading @@ -1754,7 +1751,7 @@ public class BubblesTest extends SysuiTestCase { .setCanBubble(true) .build(); BubbleEntry bubble = BubblesManager.notifToBubbleEntry(notif); BubbleEntry bubble = mBubblesManager.notifToBubbleEntry(notif); assertTrue( "FLAG_NO_DISMISS should be ignored, if the feature is off", Loading @@ -1772,7 +1769,7 @@ public class BubblesTest extends SysuiTestCase { workEntry.setBubbleMetadata(getMetadata()); workEntry.setFlagBubble(true); return new Bubble(BubblesManager.notifToBubbleEntry(workEntry), return new Bubble(mBubblesManager.notifToBubbleEntry(workEntry), null, mock(Bubbles.PendingIntentCanceledListener.class), new SyncExecutor()); } Loading