Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/HighPriorityProvider.java +23 −6 Original line number Diff line number Diff line Loading @@ -63,10 +63,27 @@ public class HighPriorityProvider { * - has a media session associated with it * - has messaging style * * A GroupEntry is considered high priority if its representativeEntry (summary) or children are * high priority * A GroupEntry is considered high priority if its representativeEntry (summary) or any of its * children are high priority. */ public boolean isHighPriority(@Nullable ListEntry entry) { return isHighPriority(entry, /* allowImplicit = */ true); } /** * @return true if the ListEntry is explicitly high priority, else false * * A NotificationEntry is considered explicitly high priority if has importance greater than or * equal to IMPORTANCE_DEFAULT. * * A GroupEntry is considered explicitly high priority if its representativeEntry (summary) or * any of its children are explicitly high priority. */ public boolean isExplicitlyHighPriority(@Nullable ListEntry entry) { return isHighPriority(entry, /* allowImplicit= */ false); } private boolean isHighPriority(@Nullable ListEntry entry, boolean allowImplicit) { if (entry == null) { return false; } Loading @@ -77,8 +94,8 @@ public class HighPriorityProvider { } return notifEntry.getRanking().getImportance() >= NotificationManager.IMPORTANCE_DEFAULT || hasHighPriorityCharacteristics(notifEntry) || hasHighPriorityChild(entry); || (allowImplicit && hasHighPriorityCharacteristics(notifEntry)) || hasHighPriorityChild(entry, allowImplicit); } /** Loading Loading @@ -112,7 +129,7 @@ public class HighPriorityProvider { >= NotificationManager.IMPORTANCE_DEFAULT); } private boolean hasHighPriorityChild(ListEntry entry) { private boolean hasHighPriorityChild(ListEntry entry, boolean allowImplicit) { if (entry instanceof NotificationEntry && !mGroupMembershipManager.isGroupSummary((NotificationEntry) entry)) { return false; Loading @@ -121,7 +138,7 @@ public class HighPriorityProvider { List<NotificationEntry> children = mGroupMembershipManager.getChildren(entry); if (children != null) { for (NotificationEntry child : children) { if (child != entry && isHighPriority(child)) { if (child != entry && isHighPriority(child, allowImplicit)) { return true; } } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt +2 −2 Original line number Diff line number Diff line Loading @@ -180,8 +180,8 @@ private class KeyguardNotificationVisibilityProviderImpl @Inject constructor( } private fun shouldHideIfEntrySilent(entry: ListEntry): Boolean = when { // Show if high priority (not hidden) highPriorityProvider.isHighPriority(entry) -> false // Show if explicitly high priority (not hidden) highPriorityProvider.isExplicitlyHighPriority(entry) -> false // Ambient notifications are hidden always from lock screen entry.representativeEntry?.isAmbient == true -> true // [Now notification is silent] Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/HighPriorityProviderTest.java +5 −3 Original line number Diff line number Diff line Loading @@ -92,8 +92,9 @@ public class HighPriorityProviderTest extends SysuiTestCase { .getPeopleNotificationType(entry)) .thenReturn(TYPE_PERSON); // THEN it has high priority // THEN it has high priority BUT it has low explicit priority. assertTrue(mHighPriorityProvider.isHighPriority(entry)); assertFalse(mHighPriorityProvider.isExplicitlyHighPriority(entry)); } @Test Loading @@ -115,7 +116,7 @@ public class HighPriorityProviderTest extends SysuiTestCase { @Test public void lowImportanceConversation() { // GIVEN notification is high importance and is a people notification // GIVEN notification is low importance and is a people notification final Notification notification = new Notification.Builder(mContext, "test") .build(); final NotificationEntry entry = new NotificationEntryBuilder() Loading Loading @@ -162,8 +163,9 @@ public class HighPriorityProviderTest extends SysuiTestCase { .getPeopleNotificationType(entry)) .thenReturn(TYPE_NON_PERSON); // THEN it has high priority // THEN it has high priority but low explicit priority assertTrue(mHighPriorityProvider.isHighPriority(entry)); assertFalse(mHighPriorityProvider.isExplicitlyHighPriority(entry)); } @Test Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProviderTest.java +30 −10 Original line number Diff line number Diff line Loading @@ -257,7 +257,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { .setImportance(IMPORTANCE_LOW) .setParent(parent) .build(); when(mHighPriorityProvider.isHighPriority(any())).thenReturn(false); when(mHighPriorityProvider.isExplicitlyHighPriority(any())).thenReturn(false); assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry)); } Loading @@ -270,7 +270,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { .setUser(new UserHandle(NOTIF_USER_ID)) .setImportance(IMPORTANCE_LOW) .build(); when(mHighPriorityProvider.isHighPriority(any())).thenReturn(false); when(mHighPriorityProvider.isExplicitlyHighPriority(any())).thenReturn(false); assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry)); } Loading @@ -292,7 +292,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { .setImportance(IMPORTANCE_LOW) .setParent(parent) .build(); when(mHighPriorityProvider.isHighPriority(any())).thenReturn(false); when(mHighPriorityProvider.isExplicitlyHighPriority(any())).thenReturn(false); assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry)); } Loading @@ -309,7 +309,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { mEntry = new NotificationEntryBuilder() .setImportance(IMPORTANCE_LOW) .build(); when(mHighPriorityProvider.isHighPriority(any())).thenReturn(false); when(mHighPriorityProvider.isExplicitlyHighPriority(any())).thenReturn(false); // THEN filter out the entry assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry)); Loading @@ -328,7 +328,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { mEntry = new NotificationEntryBuilder() .setImportance(IMPORTANCE_LOW) .build(); when(mHighPriorityProvider.isHighPriority(mEntry)).thenReturn(false); when(mHighPriorityProvider.isExplicitlyHighPriority(mEntry)).thenReturn(false); // THEN do not filter out the entry assertFalse(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry)); Loading @@ -345,7 +345,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { .setUser(new UserHandle(NOTIF_USER_ID)) .setImportance(IMPORTANCE_LOW) .build(); when(mHighPriorityProvider.isHighPriority(any())).thenReturn(false); when(mHighPriorityProvider.isExplicitlyHighPriority(any())).thenReturn(false); // WhHEN the show silent notifs on lockscreen setting is unset assertNull(mFakeSettings.getString(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS)); Loading Loading @@ -460,12 +460,32 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { .setKey(mEntry.getKey()) .setImportance(IMPORTANCE_MIN) .build()); when(mHighPriorityProvider.isHighPriority(mEntry)).thenReturn(false); when(mHighPriorityProvider.isExplicitlyHighPriority(mEntry)).thenReturn(false); // THEN filter out the entry assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry)); } @Test public void highPriorityCharacteristicsIgnored() { // GIVEN an 'unfiltered-keyguard-showing' state with silent notifications hidden setupUnfilteredState(mEntry); mFakeSettings.putBool(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, true); mFakeSettings.putBool(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, false); // WHEN the notification doesn't exceed the threshold to show on the lockscreen, but does // have the "high priority characteristics" that would promote it to high priority mEntry.setRanking(new RankingBuilder() .setKey(mEntry.getKey()) .setImportance(IMPORTANCE_MIN) .build()); when(mHighPriorityProvider.isHighPriority(mEntry)).thenReturn(true); when(mHighPriorityProvider.isExplicitlyHighPriority(mEntry)).thenReturn(false); // THEN filter out the entry anyway, because the user explicitly asked us to hide it assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry)); } @Test public void notificationVisibilityPublic() { // GIVEN a VISIBILITY_PUBLIC notification Loading Loading @@ -538,14 +558,14 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { // WHEN its parent does exceed threshold tot show on the lockscreen mFakeSettings.putBool(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, false); when(mHighPriorityProvider.isHighPriority(parent)).thenReturn(true); when(mHighPriorityProvider.isExplicitlyHighPriority(parent)).thenReturn(true); // THEN filter out the entry regardless of parent assertTrue( mKeyguardNotificationVisibilityProvider.shouldHideNotification(entryWithParent)); // WHEN its parent doesn't exceed threshold to show on lockscreen when(mHighPriorityProvider.isHighPriority(parent)).thenReturn(false); when(mHighPriorityProvider.isExplicitlyHighPriority(parent)).thenReturn(false); modifyEntry(parent.getSummary(), builder -> builder .setImportance(IMPORTANCE_MIN) .done()); Loading Loading @@ -591,7 +611,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { // notification doesn't have a summary // notification is high priority, so it shouldn't be filtered when(mHighPriorityProvider.isHighPriority(mEntry)).thenReturn(true); when(mHighPriorityProvider.isExplicitlyHighPriority(mEntry)).thenReturn(true); } @SysUISingleton Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/HighPriorityProvider.java +23 −6 Original line number Diff line number Diff line Loading @@ -63,10 +63,27 @@ public class HighPriorityProvider { * - has a media session associated with it * - has messaging style * * A GroupEntry is considered high priority if its representativeEntry (summary) or children are * high priority * A GroupEntry is considered high priority if its representativeEntry (summary) or any of its * children are high priority. */ public boolean isHighPriority(@Nullable ListEntry entry) { return isHighPriority(entry, /* allowImplicit = */ true); } /** * @return true if the ListEntry is explicitly high priority, else false * * A NotificationEntry is considered explicitly high priority if has importance greater than or * equal to IMPORTANCE_DEFAULT. * * A GroupEntry is considered explicitly high priority if its representativeEntry (summary) or * any of its children are explicitly high priority. */ public boolean isExplicitlyHighPriority(@Nullable ListEntry entry) { return isHighPriority(entry, /* allowImplicit= */ false); } private boolean isHighPriority(@Nullable ListEntry entry, boolean allowImplicit) { if (entry == null) { return false; } Loading @@ -77,8 +94,8 @@ public class HighPriorityProvider { } return notifEntry.getRanking().getImportance() >= NotificationManager.IMPORTANCE_DEFAULT || hasHighPriorityCharacteristics(notifEntry) || hasHighPriorityChild(entry); || (allowImplicit && hasHighPriorityCharacteristics(notifEntry)) || hasHighPriorityChild(entry, allowImplicit); } /** Loading Loading @@ -112,7 +129,7 @@ public class HighPriorityProvider { >= NotificationManager.IMPORTANCE_DEFAULT); } private boolean hasHighPriorityChild(ListEntry entry) { private boolean hasHighPriorityChild(ListEntry entry, boolean allowImplicit) { if (entry instanceof NotificationEntry && !mGroupMembershipManager.isGroupSummary((NotificationEntry) entry)) { return false; Loading @@ -121,7 +138,7 @@ public class HighPriorityProvider { List<NotificationEntry> children = mGroupMembershipManager.getChildren(entry); if (children != null) { for (NotificationEntry child : children) { if (child != entry && isHighPriority(child)) { if (child != entry && isHighPriority(child, allowImplicit)) { return true; } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt +2 −2 Original line number Diff line number Diff line Loading @@ -180,8 +180,8 @@ private class KeyguardNotificationVisibilityProviderImpl @Inject constructor( } private fun shouldHideIfEntrySilent(entry: ListEntry): Boolean = when { // Show if high priority (not hidden) highPriorityProvider.isHighPriority(entry) -> false // Show if explicitly high priority (not hidden) highPriorityProvider.isExplicitlyHighPriority(entry) -> false // Ambient notifications are hidden always from lock screen entry.representativeEntry?.isAmbient == true -> true // [Now notification is silent] Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/HighPriorityProviderTest.java +5 −3 Original line number Diff line number Diff line Loading @@ -92,8 +92,9 @@ public class HighPriorityProviderTest extends SysuiTestCase { .getPeopleNotificationType(entry)) .thenReturn(TYPE_PERSON); // THEN it has high priority // THEN it has high priority BUT it has low explicit priority. assertTrue(mHighPriorityProvider.isHighPriority(entry)); assertFalse(mHighPriorityProvider.isExplicitlyHighPriority(entry)); } @Test Loading @@ -115,7 +116,7 @@ public class HighPriorityProviderTest extends SysuiTestCase { @Test public void lowImportanceConversation() { // GIVEN notification is high importance and is a people notification // GIVEN notification is low importance and is a people notification final Notification notification = new Notification.Builder(mContext, "test") .build(); final NotificationEntry entry = new NotificationEntryBuilder() Loading Loading @@ -162,8 +163,9 @@ public class HighPriorityProviderTest extends SysuiTestCase { .getPeopleNotificationType(entry)) .thenReturn(TYPE_NON_PERSON); // THEN it has high priority // THEN it has high priority but low explicit priority assertTrue(mHighPriorityProvider.isHighPriority(entry)); assertFalse(mHighPriorityProvider.isExplicitlyHighPriority(entry)); } @Test Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProviderTest.java +30 −10 Original line number Diff line number Diff line Loading @@ -257,7 +257,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { .setImportance(IMPORTANCE_LOW) .setParent(parent) .build(); when(mHighPriorityProvider.isHighPriority(any())).thenReturn(false); when(mHighPriorityProvider.isExplicitlyHighPriority(any())).thenReturn(false); assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry)); } Loading @@ -270,7 +270,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { .setUser(new UserHandle(NOTIF_USER_ID)) .setImportance(IMPORTANCE_LOW) .build(); when(mHighPriorityProvider.isHighPriority(any())).thenReturn(false); when(mHighPriorityProvider.isExplicitlyHighPriority(any())).thenReturn(false); assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry)); } Loading @@ -292,7 +292,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { .setImportance(IMPORTANCE_LOW) .setParent(parent) .build(); when(mHighPriorityProvider.isHighPriority(any())).thenReturn(false); when(mHighPriorityProvider.isExplicitlyHighPriority(any())).thenReturn(false); assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry)); } Loading @@ -309,7 +309,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { mEntry = new NotificationEntryBuilder() .setImportance(IMPORTANCE_LOW) .build(); when(mHighPriorityProvider.isHighPriority(any())).thenReturn(false); when(mHighPriorityProvider.isExplicitlyHighPriority(any())).thenReturn(false); // THEN filter out the entry assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry)); Loading @@ -328,7 +328,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { mEntry = new NotificationEntryBuilder() .setImportance(IMPORTANCE_LOW) .build(); when(mHighPriorityProvider.isHighPriority(mEntry)).thenReturn(false); when(mHighPriorityProvider.isExplicitlyHighPriority(mEntry)).thenReturn(false); // THEN do not filter out the entry assertFalse(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry)); Loading @@ -345,7 +345,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { .setUser(new UserHandle(NOTIF_USER_ID)) .setImportance(IMPORTANCE_LOW) .build(); when(mHighPriorityProvider.isHighPriority(any())).thenReturn(false); when(mHighPriorityProvider.isExplicitlyHighPriority(any())).thenReturn(false); // WhHEN the show silent notifs on lockscreen setting is unset assertNull(mFakeSettings.getString(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS)); Loading Loading @@ -460,12 +460,32 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { .setKey(mEntry.getKey()) .setImportance(IMPORTANCE_MIN) .build()); when(mHighPriorityProvider.isHighPriority(mEntry)).thenReturn(false); when(mHighPriorityProvider.isExplicitlyHighPriority(mEntry)).thenReturn(false); // THEN filter out the entry assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry)); } @Test public void highPriorityCharacteristicsIgnored() { // GIVEN an 'unfiltered-keyguard-showing' state with silent notifications hidden setupUnfilteredState(mEntry); mFakeSettings.putBool(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, true); mFakeSettings.putBool(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, false); // WHEN the notification doesn't exceed the threshold to show on the lockscreen, but does // have the "high priority characteristics" that would promote it to high priority mEntry.setRanking(new RankingBuilder() .setKey(mEntry.getKey()) .setImportance(IMPORTANCE_MIN) .build()); when(mHighPriorityProvider.isHighPriority(mEntry)).thenReturn(true); when(mHighPriorityProvider.isExplicitlyHighPriority(mEntry)).thenReturn(false); // THEN filter out the entry anyway, because the user explicitly asked us to hide it assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry)); } @Test public void notificationVisibilityPublic() { // GIVEN a VISIBILITY_PUBLIC notification Loading Loading @@ -538,14 +558,14 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { // WHEN its parent does exceed threshold tot show on the lockscreen mFakeSettings.putBool(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, false); when(mHighPriorityProvider.isHighPriority(parent)).thenReturn(true); when(mHighPriorityProvider.isExplicitlyHighPriority(parent)).thenReturn(true); // THEN filter out the entry regardless of parent assertTrue( mKeyguardNotificationVisibilityProvider.shouldHideNotification(entryWithParent)); // WHEN its parent doesn't exceed threshold to show on lockscreen when(mHighPriorityProvider.isHighPriority(parent)).thenReturn(false); when(mHighPriorityProvider.isExplicitlyHighPriority(parent)).thenReturn(false); modifyEntry(parent.getSummary(), builder -> builder .setImportance(IMPORTANCE_MIN) .done()); Loading Loading @@ -591,7 +611,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { // notification doesn't have a summary // notification is high priority, so it shouldn't be filtered when(mHighPriorityProvider.isHighPriority(mEntry)).thenReturn(true); when(mHighPriorityProvider.isExplicitlyHighPriority(mEntry)).thenReturn(true); } @SysUISingleton Loading