Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/KeyguardCoordinator.kt +10 −0 Original line number Diff line number Diff line Loading @@ -119,6 +119,9 @@ constructor( // Don't apply the filter to (non-promoted) group summaries // - summary will be pruned if necessary, depending on if children are filtered entry.parent?.summary == entry -> false // Check that the entry satisfies certain characteristics that would bypass the // filter shouldIgnoreUnseenCheck(entry) -> false else -> true }.also { hasFiltered -> hasFilteredAnyNotifs = hasFilteredAnyNotifs || hasFiltered } Loading @@ -134,6 +137,13 @@ constructor( keyguardNotificationVisibilityProvider.shouldHideNotification(entry) } private fun shouldIgnoreUnseenCheck(entry: NotificationEntry): Boolean = when { entry.isMediaNotification -> true entry.sbn.isOngoing -> true else -> false } // TODO(b/206118999): merge this class with SensitiveContentCoordinator which also depends on // these same updates private fun setupInvalidateNotifListCallbacks() {} Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/KeyguardCoordinatorTest.kt +46 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.notification.collection.coordinator import android.app.Notification import android.testing.AndroidTestingRunner import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase Loading @@ -33,6 +34,7 @@ import com.android.systemui.statusbar.notification.collection.provider.SectionHe import com.android.systemui.statusbar.notification.collection.provider.SeenNotificationsProvider import com.android.systemui.statusbar.notification.collection.provider.SeenNotificationsProviderImpl import com.android.systemui.statusbar.notification.interruption.KeyguardNotificationVisibilityProvider import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.util.mockito.eq import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.withArgCaptor Loading Loading @@ -104,6 +106,50 @@ class KeyguardCoordinatorTest : SysuiTestCase() { } } @Test fun unseenFilterDoesNotSuppressSeenOngoingNotifWhileKeyguardShowing() { whenever(notifPipelineFlags.shouldFilterUnseenNotifsOnKeyguard).thenReturn(true) // GIVEN: Keyguard is not showing, and an ongoing notification is present keyguardRepository.setKeyguardShowing(false) runKeyguardCoordinatorTest { val fakeEntry = NotificationEntryBuilder() .setNotification(Notification.Builder(mContext).setOngoing(true).build()) .build() collectionListener.onEntryAdded(fakeEntry) // WHEN: The keyguard is now showing keyguardRepository.setKeyguardShowing(true) testScheduler.runCurrent() // THEN: The notification is recognized as "ongoing" and is not filtered out. assertThat(unseenFilter.shouldFilterOut(fakeEntry, 0L)).isFalse() } } @Test fun unseenFilterDoesNotSuppressSeenMediaNotifWhileKeyguardShowing() { whenever(notifPipelineFlags.shouldFilterUnseenNotifsOnKeyguard).thenReturn(true) // GIVEN: Keyguard is not showing, and a media notification is present keyguardRepository.setKeyguardShowing(false) runKeyguardCoordinatorTest { val fakeEntry = NotificationEntryBuilder().build().apply { row = mock<ExpandableNotificationRow>().apply { whenever(isMediaRow).thenReturn(true) } } collectionListener.onEntryAdded(fakeEntry) // WHEN: The keyguard is now showing keyguardRepository.setKeyguardShowing(true) testScheduler.runCurrent() // THEN: The notification is recognized as "media" and is not filtered out. assertThat(unseenFilter.shouldFilterOut(fakeEntry, 0L)).isFalse() } } @Test fun unseenFilterUpdatesSeenProviderWhenSuppressing() { whenever(notifPipelineFlags.shouldFilterUnseenNotifsOnKeyguard).thenReturn(true) Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/KeyguardCoordinator.kt +10 −0 Original line number Diff line number Diff line Loading @@ -119,6 +119,9 @@ constructor( // Don't apply the filter to (non-promoted) group summaries // - summary will be pruned if necessary, depending on if children are filtered entry.parent?.summary == entry -> false // Check that the entry satisfies certain characteristics that would bypass the // filter shouldIgnoreUnseenCheck(entry) -> false else -> true }.also { hasFiltered -> hasFilteredAnyNotifs = hasFilteredAnyNotifs || hasFiltered } Loading @@ -134,6 +137,13 @@ constructor( keyguardNotificationVisibilityProvider.shouldHideNotification(entry) } private fun shouldIgnoreUnseenCheck(entry: NotificationEntry): Boolean = when { entry.isMediaNotification -> true entry.sbn.isOngoing -> true else -> false } // TODO(b/206118999): merge this class with SensitiveContentCoordinator which also depends on // these same updates private fun setupInvalidateNotifListCallbacks() {} Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/KeyguardCoordinatorTest.kt +46 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.notification.collection.coordinator import android.app.Notification import android.testing.AndroidTestingRunner import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase Loading @@ -33,6 +34,7 @@ import com.android.systemui.statusbar.notification.collection.provider.SectionHe import com.android.systemui.statusbar.notification.collection.provider.SeenNotificationsProvider import com.android.systemui.statusbar.notification.collection.provider.SeenNotificationsProviderImpl import com.android.systemui.statusbar.notification.interruption.KeyguardNotificationVisibilityProvider import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.util.mockito.eq import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.withArgCaptor Loading Loading @@ -104,6 +106,50 @@ class KeyguardCoordinatorTest : SysuiTestCase() { } } @Test fun unseenFilterDoesNotSuppressSeenOngoingNotifWhileKeyguardShowing() { whenever(notifPipelineFlags.shouldFilterUnseenNotifsOnKeyguard).thenReturn(true) // GIVEN: Keyguard is not showing, and an ongoing notification is present keyguardRepository.setKeyguardShowing(false) runKeyguardCoordinatorTest { val fakeEntry = NotificationEntryBuilder() .setNotification(Notification.Builder(mContext).setOngoing(true).build()) .build() collectionListener.onEntryAdded(fakeEntry) // WHEN: The keyguard is now showing keyguardRepository.setKeyguardShowing(true) testScheduler.runCurrent() // THEN: The notification is recognized as "ongoing" and is not filtered out. assertThat(unseenFilter.shouldFilterOut(fakeEntry, 0L)).isFalse() } } @Test fun unseenFilterDoesNotSuppressSeenMediaNotifWhileKeyguardShowing() { whenever(notifPipelineFlags.shouldFilterUnseenNotifsOnKeyguard).thenReturn(true) // GIVEN: Keyguard is not showing, and a media notification is present keyguardRepository.setKeyguardShowing(false) runKeyguardCoordinatorTest { val fakeEntry = NotificationEntryBuilder().build().apply { row = mock<ExpandableNotificationRow>().apply { whenever(isMediaRow).thenReturn(true) } } collectionListener.onEntryAdded(fakeEntry) // WHEN: The keyguard is now showing keyguardRepository.setKeyguardShowing(true) testScheduler.runCurrent() // THEN: The notification is recognized as "media" and is not filtered out. assertThat(unseenFilter.shouldFilterOut(fakeEntry, 0L)).isFalse() } } @Test fun unseenFilterUpdatesSeenProviderWhenSuppressing() { whenever(notifPipelineFlags.shouldFilterUnseenNotifsOnKeyguard).thenReturn(true) Loading