Merge "Exempt ongoing and media notifications from unseen filter" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
56b489b539
@@ -119,6 +119,9 @@ constructor(
|
|||||||
// Don't apply the filter to (non-promoted) group summaries
|
// Don't apply the filter to (non-promoted) group summaries
|
||||||
// - summary will be pruned if necessary, depending on if children are filtered
|
// - summary will be pruned if necessary, depending on if children are filtered
|
||||||
entry.parent?.summary == entry -> false
|
entry.parent?.summary == entry -> false
|
||||||
|
// Check that the entry satisfies certain characteristics that would bypass the
|
||||||
|
// filter
|
||||||
|
shouldIgnoreUnseenCheck(entry) -> false
|
||||||
else -> true
|
else -> true
|
||||||
}.also { hasFiltered -> hasFilteredAnyNotifs = hasFilteredAnyNotifs || hasFiltered }
|
}.also { hasFiltered -> hasFilteredAnyNotifs = hasFilteredAnyNotifs || hasFiltered }
|
||||||
|
|
||||||
@@ -134,6 +137,13 @@ constructor(
|
|||||||
keyguardNotificationVisibilityProvider.shouldHideNotification(entry)
|
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
|
// TODO(b/206118999): merge this class with SensitiveContentCoordinator which also depends on
|
||||||
// these same updates
|
// these same updates
|
||||||
private fun setupInvalidateNotifListCallbacks() {}
|
private fun setupInvalidateNotifListCallbacks() {}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.notification.collection.coordinator
|
package com.android.systemui.statusbar.notification.collection.coordinator
|
||||||
|
|
||||||
|
import android.app.Notification
|
||||||
import android.testing.AndroidTestingRunner
|
import android.testing.AndroidTestingRunner
|
||||||
import androidx.test.filters.SmallTest
|
import androidx.test.filters.SmallTest
|
||||||
import com.android.systemui.SysuiTestCase
|
import com.android.systemui.SysuiTestCase
|
||||||
@@ -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.SeenNotificationsProvider
|
||||||
import com.android.systemui.statusbar.notification.collection.provider.SeenNotificationsProviderImpl
|
import com.android.systemui.statusbar.notification.collection.provider.SeenNotificationsProviderImpl
|
||||||
import com.android.systemui.statusbar.notification.interruption.KeyguardNotificationVisibilityProvider
|
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.eq
|
||||||
import com.android.systemui.util.mockito.mock
|
import com.android.systemui.util.mockito.mock
|
||||||
import com.android.systemui.util.mockito.withArgCaptor
|
import com.android.systemui.util.mockito.withArgCaptor
|
||||||
@@ -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
|
@Test
|
||||||
fun unseenFilterUpdatesSeenProviderWhenSuppressing() {
|
fun unseenFilterUpdatesSeenProviderWhenSuppressing() {
|
||||||
whenever(notifPipelineFlags.shouldFilterUnseenNotifsOnKeyguard).thenReturn(true)
|
whenever(notifPipelineFlags.shouldFilterUnseenNotifsOnKeyguard).thenReturn(true)
|
||||||
|
|||||||
Reference in New Issue
Block a user