Merge "Ignore group alert setting when opening bubbles" into tm-qpr-dev

This commit is contained in:
TreeHugger Robot
2022-05-27 20:45:56 +00:00
committed by Android (Google) Code Review
2 changed files with 57 additions and 13 deletions

View File

@@ -194,6 +194,10 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
return false; return false;
} }
if (!canAlertHeadsUpCommon(entry)) {
return false;
}
if (!canAlertAwakeCommon(entry)) { if (!canAlertAwakeCommon(entry)) {
return false; return false;
} }
@@ -267,6 +271,11 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
return false; return false;
} }
if (!canAlertHeadsUpCommon(entry)) {
mLogger.logNoPulsingNoAlert(sbn);
return false;
}
if (entry.shouldSuppressAmbient()) { if (entry.shouldSuppressAmbient()) {
mLogger.logNoPulsingNoAmbientEffect(sbn); mLogger.logNoPulsingNoAmbientEffect(sbn);
return false; return false;
@@ -294,12 +303,6 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
return false; 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++) { for (int i = 0; i < mSuppressors.size(); i++) {
if (mSuppressors.get(i).suppressInterruptions(entry)) { if (mSuppressors.get(i).suppressInterruptions(entry)) {
mLogger.logNoAlertingSuppressedBy(sbn, mSuppressors.get(i), /* awake */ false); mLogger.logNoAlertingSuppressedBy(sbn, mSuppressors.get(i), /* awake */ false);
@@ -307,13 +310,31 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
} }
} }
if (entry.hasJustLaunchedFullScreenIntent()) { if (mKeyguardNotificationVisibilityProvider.shouldHideNotification(entry)) {
mLogger.logNoAlertingRecentFullscreen(sbn); mLogger.keyguardHideNotification(entry.getKey());
return false; return false;
} }
if (mKeyguardNotificationVisibilityProvider.shouldHideNotification(entry)) { return true;
mLogger.keyguardHideNotification(entry.getKey()); }
/**
* 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; return false;
} }

View File

@@ -17,6 +17,7 @@ package com.android.systemui.statusbar.notification.interruption;
import static android.app.Notification.FLAG_BUBBLE; 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_DEFAULT;
import static android.app.NotificationManager.IMPORTANCE_HIGH; import static android.app.NotificationManager.IMPORTANCE_HIGH;
import static android.app.NotificationManager.IMPORTANCE_LOW; import static android.app.NotificationManager.IMPORTANCE_LOW;
@@ -430,6 +431,17 @@ public class NotificationInterruptStateProviderImplTest extends SysuiTestCase {
assertThat(mNotifInterruptionStateProvider.shouldBubbleUp(createBubble())).isTrue(); 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. * 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() { private NotificationEntry createBubble() {
return createBubble(null, null);
}
private NotificationEntry createBubble(String groupKey, Integer groupAlert) {
Notification.BubbleMetadata data = new Notification.BubbleMetadata.Builder( Notification.BubbleMetadata data = new Notification.BubbleMetadata.Builder(
PendingIntent.getActivity(mContext, 0, new Intent(), PendingIntent.getActivity(mContext, 0, new Intent(),
PendingIntent.FLAG_MUTABLE), PendingIntent.FLAG_MUTABLE),
Icon.createWithResource(mContext.getResources(), R.drawable.android)) Icon.createWithResource(mContext.getResources(), R.drawable.android))
.build(); .build();
Notification n = new Notification.Builder(getContext(), "a") Notification.Builder nb = new Notification.Builder(getContext(), "a")
.setContentTitle("title") .setContentTitle("title")
.setContentText("content text") .setContentText("content text")
.setBubbleMetadata(data) .setBubbleMetadata(data);
.build(); if (groupKey != null) {
nb.setGroup(groupKey);
nb.setGroupSummary(false);
}
if (groupAlert != null) {
nb.setGroupAlertBehavior(groupAlert);
}
Notification n = nb.build();
n.flags |= FLAG_BUBBLE; n.flags |= FLAG_BUBBLE;
return new NotificationEntryBuilder() return new NotificationEntryBuilder()