Hide notifications when finished transitioning to AOD screen when DND mode is on and notification intercepted by DND are prevented from appearing on ambient displays

Test: manual test with Pixel phone for DND and normal mode, with active notifications and without
Test: atest filterDozingSuppressAmbient
Bug: 264851742
Change-Id: Iff0b825704d054cae3b0b3381c5f849ff1872d62
This commit is contained in:
Kateryna Ivanova
2023-03-27 09:24:30 +00:00
parent f58c1ce7ff
commit 6fd611f6de
2 changed files with 55 additions and 1 deletions

View File

@@ -190,7 +190,9 @@ public class RankingCoordinator implements Coordinator {
"DndSuppressingVisualEffects") {
@Override
public boolean shouldFilterOut(NotificationEntry entry, long now) {
if (mStatusBarStateController.isDozing() && entry.shouldSuppressAmbient()) {
if ((mStatusBarStateController.isDozing()
|| mStatusBarStateController.getDozeAmount() == 1f)
&& entry.shouldSuppressAmbient()) {
return true;
}
@@ -200,6 +202,20 @@ public class RankingCoordinator implements Coordinator {
private final StatusBarStateController.StateListener mStatusBarStateCallback =
new StatusBarStateController.StateListener() {
private boolean mPrevDozeAmountIsOne = false;
@Override
public void onDozeAmountChanged(float linear, float eased) {
StatusBarStateController.StateListener.super.onDozeAmountChanged(linear, eased);
boolean dozeAmountIsOne = linear == 1f;
if (mPrevDozeAmountIsOne != dozeAmountIsOne) {
mDndVisualEffectsFilter.invalidateList("dozeAmount changed to "
+ (dozeAmountIsOne ? "one" : "not one"));
mPrevDozeAmountIsOne = dozeAmountIsOne;
}
}
@Override
public void onDozingChanged(boolean isDozing) {
mDndVisualEffectsFilter.invalidateList("onDozingChanged to " + isDozing);

View File

@@ -25,6 +25,8 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -48,6 +50,7 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Pluggable;
import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider;
import com.android.systemui.statusbar.notification.collection.provider.SectionStyleProvider;
import com.android.systemui.statusbar.notification.collection.render.NodeController;
@@ -75,12 +78,15 @@ public class RankingCoordinatorTest extends SysuiTestCase {
@Mock private NodeController mAlertingHeaderController;
@Mock private NodeController mSilentNodeController;
@Mock private SectionHeaderController mSilentHeaderController;
@Mock private Pluggable.PluggableListener<NotifFilter> mInvalidationListener;
@Captor private ArgumentCaptor<NotifFilter> mNotifFilterCaptor;
@Captor private ArgumentCaptor<StatusBarStateController.StateListener> mStateListenerCaptor;
private NotificationEntry mEntry;
private NotifFilter mCapturedSuspendedFilter;
private NotifFilter mCapturedDozingFilter;
private StatusBarStateController.StateListener mStatusBarStateCallback;
private RankingCoordinator mRankingCoordinator;
private NotifSectioner mAlertingSectioner;
@@ -106,6 +112,10 @@ public class RankingCoordinatorTest extends SysuiTestCase {
verify(mNotifPipeline, times(2)).addPreGroupFilter(mNotifFilterCaptor.capture());
mCapturedSuspendedFilter = mNotifFilterCaptor.getAllValues().get(0);
mCapturedDozingFilter = mNotifFilterCaptor.getAllValues().get(1);
mCapturedDozingFilter.setInvalidationListener(mInvalidationListener);
verify(mStatusBarStateController, times(1)).addCallback(mStateListenerCaptor.capture());
mStatusBarStateCallback = mStateListenerCaptor.getAllValues().get(0);
mAlertingSectioner = mRankingCoordinator.getAlertingSectioner();
mSilentSectioner = mRankingCoordinator.getSilentSectioner();
@@ -170,6 +180,13 @@ public class RankingCoordinatorTest extends SysuiTestCase {
// THEN don't filter out the notification
assertFalse(mCapturedDozingFilter.shouldFilterOut(mEntry, 0));
// WHEN it's not dozing and doze amount is 1
when(mStatusBarStateController.isDozing()).thenReturn(false);
when(mStatusBarStateController.getDozeAmount()).thenReturn(1f);
// THEN filter out the notification
assertTrue(mCapturedDozingFilter.shouldFilterOut(mEntry, 0));
}
@Test
@@ -267,6 +284,27 @@ public class RankingCoordinatorTest extends SysuiTestCase {
verify(mSilentHeaderController, times(2)).setClearSectionEnabled(eq(false));
}
@Test
public void statusBarStateCallbackTest() {
mStatusBarStateCallback.onDozeAmountChanged(1f, 1f);
verify(mInvalidationListener, times(1))
.onPluggableInvalidated(mCapturedDozingFilter, "dozeAmount changed to one");
reset(mInvalidationListener);
mStatusBarStateCallback.onDozeAmountChanged(1f, 1f);
verify(mInvalidationListener, never()).onPluggableInvalidated(any(), any());
reset(mInvalidationListener);
mStatusBarStateCallback.onDozeAmountChanged(0.6f, 0.6f);
verify(mInvalidationListener, times(1))
.onPluggableInvalidated(mCapturedDozingFilter, "dozeAmount changed to not one");
reset(mInvalidationListener);
mStatusBarStateCallback.onDozeAmountChanged(0f, 0f);
verify(mInvalidationListener, never()).onPluggableInvalidated(any(), any());
reset(mInvalidationListener);
}
private void assertInSection(NotificationEntry entry, NotifSectioner section) {
for (NotifSectioner current: mSections) {
if (current == section) {