Merge "Ignore group alert setting when opening bubbles" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
677db6dba8
@@ -194,6 +194,10 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!canAlertHeadsUpCommon(entry)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!canAlertAwakeCommon(entry)) {
|
||||
return false;
|
||||
}
|
||||
@@ -267,6 +271,11 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!canAlertHeadsUpCommon(entry)) {
|
||||
mLogger.logNoPulsingNoAlert(sbn);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entry.shouldSuppressAmbient()) {
|
||||
mLogger.logNoPulsingNoAmbientEffect(sbn);
|
||||
return false;
|
||||
@@ -294,12 +303,6 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't alert notifications that are suppressed due to group alert behavior
|
||||
if (sbn.isGroup() && sbn.getNotification().suppressAlertingDueToGrouping()) {
|
||||
mLogger.logNoAlertingGroupAlertBehavior(sbn);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < mSuppressors.size(); i++) {
|
||||
if (mSuppressors.get(i).suppressInterruptions(entry)) {
|
||||
mLogger.logNoAlertingSuppressedBy(sbn, mSuppressors.get(i), /* awake */ false);
|
||||
@@ -307,13 +310,31 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.hasJustLaunchedFullScreenIntent()) {
|
||||
mLogger.logNoAlertingRecentFullscreen(sbn);
|
||||
if (mKeyguardNotificationVisibilityProvider.shouldHideNotification(entry)) {
|
||||
mLogger.keyguardHideNotification(entry.getKey());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mKeyguardNotificationVisibilityProvider.shouldHideNotification(entry)) {
|
||||
mLogger.keyguardHideNotification(entry.getKey());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Common checks for heads up notifications on regular and AOD displays.
|
||||
*
|
||||
* @param entry the entry to check
|
||||
* @return true if these checks pass, false if the notification should not alert
|
||||
*/
|
||||
private boolean canAlertHeadsUpCommon(NotificationEntry entry) {
|
||||
StatusBarNotification sbn = entry.getSbn();
|
||||
|
||||
// Don't alert notifications that are suppressed due to group alert behavior
|
||||
if (sbn.isGroup() && sbn.getNotification().suppressAlertingDueToGrouping()) {
|
||||
mLogger.logNoAlertingGroupAlertBehavior(sbn);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entry.hasJustLaunchedFullScreenIntent()) {
|
||||
mLogger.logNoAlertingRecentFullscreen(sbn);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.android.systemui.statusbar.notification.interruption;
|
||||
|
||||
|
||||
import static android.app.Notification.FLAG_BUBBLE;
|
||||
import static android.app.Notification.GROUP_ALERT_SUMMARY;
|
||||
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
|
||||
import static android.app.NotificationManager.IMPORTANCE_HIGH;
|
||||
import static android.app.NotificationManager.IMPORTANCE_LOW;
|
||||
@@ -430,6 +431,17 @@ public class NotificationInterruptStateProviderImplTest extends SysuiTestCase {
|
||||
assertThat(mNotifInterruptionStateProvider.shouldBubbleUp(createBubble())).isTrue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that notification can bubble even if it is a child in a group and group settings are
|
||||
* set to alert only for summary notifications.
|
||||
*/
|
||||
@Test
|
||||
public void testShouldBubbleUp_notifInGroupWithOnlySummaryAlerts() {
|
||||
ensureStateForBubbleUp();
|
||||
NotificationEntry bubble = createBubble("testgroup", GROUP_ALERT_SUMMARY);
|
||||
assertThat(mNotifInterruptionStateProvider.shouldBubbleUp(bubble)).isTrue();
|
||||
}
|
||||
|
||||
/**
|
||||
* If the notification doesn't have permission to bubble, it shouldn't bubble.
|
||||
*/
|
||||
@@ -497,16 +509,27 @@ public class NotificationInterruptStateProviderImplTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
private NotificationEntry createBubble() {
|
||||
return createBubble(null, null);
|
||||
}
|
||||
|
||||
private NotificationEntry createBubble(String groupKey, Integer groupAlert) {
|
||||
Notification.BubbleMetadata data = new Notification.BubbleMetadata.Builder(
|
||||
PendingIntent.getActivity(mContext, 0, new Intent(),
|
||||
PendingIntent.FLAG_MUTABLE),
|
||||
Icon.createWithResource(mContext.getResources(), R.drawable.android))
|
||||
.build();
|
||||
Notification n = new Notification.Builder(getContext(), "a")
|
||||
Notification.Builder nb = new Notification.Builder(getContext(), "a")
|
||||
.setContentTitle("title")
|
||||
.setContentText("content text")
|
||||
.setBubbleMetadata(data)
|
||||
.build();
|
||||
.setBubbleMetadata(data);
|
||||
if (groupKey != null) {
|
||||
nb.setGroup(groupKey);
|
||||
nb.setGroupSummary(false);
|
||||
}
|
||||
if (groupAlert != null) {
|
||||
nb.setGroupAlertBehavior(groupAlert);
|
||||
}
|
||||
Notification n = nb.build();
|
||||
n.flags |= FLAG_BUBBLE;
|
||||
|
||||
return new NotificationEntryBuilder()
|
||||
|
||||
Reference in New Issue
Block a user