Merge "Allow alertOverride if the summary GROUP_ALERT_ALL" into sc-v2-dev am: 7be755663f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16664219 Change-Id: I9f5c1a2d7266aee25dc4dbe6bcb67825898cf800
This commit is contained in:
@@ -384,9 +384,9 @@ public class NotificationGroupManagerLegacy implements
|
|||||||
// * Only necessary when all notifications in the group use GROUP_ALERT_SUMMARY
|
// * Only necessary when all notifications in the group use GROUP_ALERT_SUMMARY
|
||||||
// * Only necessary when at least one notification in the group is on a priority channel
|
// * Only necessary when at least one notification in the group is on a priority channel
|
||||||
if (group.summary.getSbn().getNotification().getGroupAlertBehavior()
|
if (group.summary.getSbn().getNotification().getGroupAlertBehavior()
|
||||||
!= Notification.GROUP_ALERT_SUMMARY) {
|
== Notification.GROUP_ALERT_CHILDREN) {
|
||||||
if (SPEW) {
|
if (SPEW) {
|
||||||
Log.d(TAG, "getPriorityConversationAlertOverride: summary != GROUP_ALERT_SUMMARY");
|
Log.d(TAG, "getPriorityConversationAlertOverride: summary == GROUP_ALERT_CHILDREN");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,21 +177,69 @@ public class NotificationGroupManagerLegacyTest extends SysuiTestCase {
|
|||||||
helpTestAlertOverrideWithSiblings(2);
|
helpTestAlertOverrideWithSiblings(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper for testing various sibling counts
|
||||||
|
*/
|
||||||
|
private void helpTestAlertOverrideWithSiblings(int numSiblings) {
|
||||||
|
helpTestAlertOverride(
|
||||||
|
/* numSiblings */ numSiblings,
|
||||||
|
/* summaryAlert */ Notification.GROUP_ALERT_SUMMARY,
|
||||||
|
/* childAlert */ Notification.GROUP_ALERT_SUMMARY,
|
||||||
|
/* siblingAlert */ Notification.GROUP_ALERT_SUMMARY,
|
||||||
|
/* expectAlertOverride */ true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAlertOverrideWithParentAlertAll() {
|
||||||
|
// tests that summary can have GROUP_ALERT_ALL and this still works
|
||||||
|
helpTestAlertOverride(
|
||||||
|
/* numSiblings */ 1,
|
||||||
|
/* summaryAlert */ Notification.GROUP_ALERT_ALL,
|
||||||
|
/* childAlert */ Notification.GROUP_ALERT_SUMMARY,
|
||||||
|
/* siblingAlert */ Notification.GROUP_ALERT_SUMMARY,
|
||||||
|
/* expectAlertOverride */ true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAlertOverrideWithParentAlertChild() {
|
||||||
|
// Tests that if the summary alerts CHILDREN, there's no alertOverride
|
||||||
|
helpTestAlertOverride(
|
||||||
|
/* numSiblings */ 1,
|
||||||
|
/* summaryAlert */ Notification.GROUP_ALERT_CHILDREN,
|
||||||
|
/* childAlert */ Notification.GROUP_ALERT_SUMMARY,
|
||||||
|
/* siblingAlert */ Notification.GROUP_ALERT_SUMMARY,
|
||||||
|
/* expectAlertOverride */ false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAlertOverrideWithChildrenAlertAll() {
|
||||||
|
// Tests that if the children alert ALL, there's no alertOverride
|
||||||
|
helpTestAlertOverride(
|
||||||
|
/* numSiblings */ 1,
|
||||||
|
/* summaryAlert */ Notification.GROUP_ALERT_SUMMARY,
|
||||||
|
/* childAlert */ Notification.GROUP_ALERT_ALL,
|
||||||
|
/* siblingAlert */ Notification.GROUP_ALERT_ALL,
|
||||||
|
/* expectAlertOverride */ false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This tests, for a group with a priority entry and the given number of siblings, that:
|
* This tests, for a group with a priority entry and the given number of siblings, that:
|
||||||
* 1) the priority entry is identified as the alertOverride for the group
|
* 1) the priority entry is identified as the alertOverride for the group
|
||||||
* 2) the onAlertOverrideChanged method is called at that time
|
* 2) the onAlertOverrideChanged method is called at that time
|
||||||
* 3) when the priority entry is removed, these are reversed
|
* 3) when the priority entry is removed, these are reversed
|
||||||
*/
|
*/
|
||||||
private void helpTestAlertOverrideWithSiblings(int numSiblings) {
|
private void helpTestAlertOverride(int numSiblings,
|
||||||
int groupAlert = Notification.GROUP_ALERT_SUMMARY;
|
@Notification.GroupAlertBehavior int summaryAlert,
|
||||||
|
@Notification.GroupAlertBehavior int childAlert,
|
||||||
|
@Notification.GroupAlertBehavior int siblingAlert,
|
||||||
|
boolean expectAlertOverride) {
|
||||||
// Create entries in an order so that the priority entry can be deemed the newest child.
|
// Create entries in an order so that the priority entry can be deemed the newest child.
|
||||||
NotificationEntry[] siblings = new NotificationEntry[numSiblings];
|
NotificationEntry[] siblings = new NotificationEntry[numSiblings];
|
||||||
for (int i = 0; i < numSiblings; i++) {
|
for (int i = 0; i < numSiblings; i++) {
|
||||||
siblings[i] = mGroupTestHelper.createChildNotification(groupAlert);
|
siblings[i] = mGroupTestHelper.createChildNotification(siblingAlert);
|
||||||
}
|
}
|
||||||
NotificationEntry priorityEntry = mGroupTestHelper.createChildNotification(groupAlert);
|
NotificationEntry priorityEntry = mGroupTestHelper.createChildNotification(childAlert);
|
||||||
NotificationEntry summaryEntry = mGroupTestHelper.createSummaryNotification(groupAlert);
|
NotificationEntry summaryEntry = mGroupTestHelper.createSummaryNotification(summaryAlert);
|
||||||
|
|
||||||
// The priority entry is an important conversation.
|
// The priority entry is an important conversation.
|
||||||
when(mPeopleNotificationIdentifier.getPeopleNotificationType(eq(priorityEntry)))
|
when(mPeopleNotificationIdentifier.getPeopleNotificationType(eq(priorityEntry)))
|
||||||
@@ -208,6 +256,14 @@ public class NotificationGroupManagerLegacyTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
mGroupManager.onEntryAdded(priorityEntry);
|
mGroupManager.onEntryAdded(priorityEntry);
|
||||||
|
|
||||||
|
if (!expectAlertOverride) {
|
||||||
|
// Test expectation is that there will NOT be an alert, so verify that!
|
||||||
|
NotificationGroup summaryGroup =
|
||||||
|
mGroupManager.getGroupForSummary(summaryEntry.getSbn());
|
||||||
|
assertNull(summaryGroup.alertOverride);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Verify that the summary group has the priority child as its alertOverride
|
// Verify that the summary group has the priority child as its alertOverride
|
||||||
NotificationGroup summaryGroup = mGroupManager.getGroupForSummary(summaryEntry.getSbn());
|
NotificationGroup summaryGroup = mGroupManager.getGroupForSummary(summaryEntry.getSbn());
|
||||||
assertEquals(priorityEntry, summaryGroup.alertOverride);
|
assertEquals(priorityEntry, summaryGroup.alertOverride);
|
||||||
|
|||||||
Reference in New Issue
Block a user