diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index 64a6114c5e1a5..3092b76e93460 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -106,7 +106,6 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.statusbar.notification.row.ExpandableView; import com.android.systemui.statusbar.notification.row.FooterView; import com.android.systemui.statusbar.notification.row.ForegroundServiceDungeonView; -import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager; import com.android.systemui.statusbar.notification.row.StackScrollerDecorView; import com.android.systemui.statusbar.phone.HeadsUpAppearanceController; import com.android.systemui.statusbar.phone.HeadsUpTouchHelper; @@ -551,13 +550,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable res.getBoolean(R.bool.config_drawNotificationBackground); setOutlineProvider(mOutlineProvider); - // Blocking helper manager wants to know the expanded state, update as well. - NotificationBlockingHelperManager blockingHelperManager = - Dependency.get(NotificationBlockingHelperManager.class); - addOnExpandedHeightChangedListener((height, unused) -> { - blockingHelperManager.setNotificationShadeExpanded(height); - }); - boolean willDraw = mShouldDrawNotificationBackground || DEBUG; setWillNotDraw(!willDraw); mBackgroundPaint.setAntiAlias(true); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java index 4da44970a5489..bfbae4e3e1c59 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java @@ -96,6 +96,7 @@ import com.android.systemui.statusbar.notification.row.ActivatableNotificationVi import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.ExpandableView; import com.android.systemui.statusbar.notification.row.ForegroundServiceDungeonView; +import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager; import com.android.systemui.statusbar.notification.row.NotificationGuts; import com.android.systemui.statusbar.notification.row.NotificationGutsManager; import com.android.systemui.statusbar.notification.row.NotificationSnooze; @@ -154,6 +155,7 @@ public class NotificationStackScrollLayoutController { private final LayoutInflater mLayoutInflater; private final NotificationRemoteInputManager mRemoteInputManager; private final VisualStabilityManager mVisualStabilityManager; + private final NotificationBlockingHelperManager mNotificationBlockingHelperManager; private final KeyguardMediaController mKeyguardMediaController; private final SysuiStatusBarStateController mStatusBarStateController; private final KeyguardBypassController mKeyguardBypassController; @@ -577,7 +579,8 @@ public class NotificationStackScrollLayoutController { ForegroundServiceSectionController fgServicesSectionController, LayoutInflater layoutInflater, NotificationRemoteInputManager remoteInputManager, - VisualStabilityManager visualStabilityManager) { + VisualStabilityManager visualStabilityManager, + NotificationBlockingHelperManager notificationBlockingHelperManager) { mAllowLongPress = allowLongPress; mNotificationGutsManager = notificationGutsManager; mHeadsUpManager = headsUpManager; @@ -622,6 +625,7 @@ public class NotificationStackScrollLayoutController { mLayoutInflater = layoutInflater; mRemoteInputManager = remoteInputManager; mVisualStabilityManager = visualStabilityManager; + mNotificationBlockingHelperManager = notificationBlockingHelperManager; } public void attach(NotificationStackScrollLayout view) { @@ -682,6 +686,10 @@ public class NotificationStackScrollLayoutController { mView.addOnExpandedHeightChangedListener(mNotificationRoundnessManager::setExpanded); mVisualStabilityManager.setVisibilityLocationProvider(this::isInVisibleLocation); + // Blocking helper manager wants to know the expanded state, update as well. + mView.addOnExpandedHeightChangedListener((height, unused) -> + mNotificationBlockingHelperManager.setNotificationShadeExpanded(height) + ); mTunerService.addTunable( (key, newValue) -> { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index 1ed9a5cd81f4c..a2a6514f4b571 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -65,6 +65,7 @@ import com.android.systemui.statusbar.phone.ShadeController; import com.android.systemui.statusbar.phone.StatusBar; import org.junit.After; +import org.junit.Assert; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -74,6 +75,8 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; +import java.util.function.BiConsumer; + /** * Tests for {@link NotificationStackScrollLayout}. */ @@ -216,12 +219,20 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { @Test @UiThreadTest public void testSetExpandedHeight_blockingHelperManagerReceivedCallbacks() { - mStackScroller.setExpandedHeight(0f); - verify(mBlockingHelperManager).setNotificationShadeExpanded(0f); - reset(mBlockingHelperManager); + final float expectedHeight[] = {0f}; + final float expectedAppear[] = {0f}; - mStackScroller.setExpandedHeight(100f); - verify(mBlockingHelperManager).setNotificationShadeExpanded(100f); + mStackScroller.addOnExpandedHeightChangedListener((height, appear) -> { + Assert.assertEquals(expectedHeight[0], height, 0); + Assert.assertEquals(expectedAppear[0], appear, .1); + }); + expectedHeight[0] = 1f; + expectedAppear[0] = 1f; + mStackScroller.setExpandedHeight(expectedHeight[0]); + + expectedHeight[0] = 100f; + expectedAppear[0] = 0f; + mStackScroller.setExpandedHeight(expectedHeight[0]); } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java index 9e9fa8816fdce..969805f61c9a3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java @@ -27,6 +27,7 @@ import static org.mockito.Mockito.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -64,6 +65,7 @@ import com.android.systemui.statusbar.notification.collection.legacy.VisualStabi import com.android.systemui.statusbar.notification.collection.render.SectionHeaderController; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.ForegroundServiceDungeonView; +import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager; import com.android.systemui.statusbar.notification.row.NotificationGutsManager; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController.NotificationPanelEvent; import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; @@ -84,6 +86,8 @@ import org.mockito.Captor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import java.util.function.BiConsumer; + /** * Tests for {@link NotificationStackScrollLayoutController}. */ @@ -127,6 +131,7 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase { @Mock private NotificationRemoteInputManager mRemoteInputManager; @Mock private RemoteInputController mRemoteInputController; @Mock private VisualStabilityManager mVisualStabilityManager; + @Mock private NotificationBlockingHelperManager mNotificationBlockingHelperManager; @Captor private ArgumentCaptor mStateListenerArgumentCaptor; @@ -176,7 +181,8 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase { mFgServicesSectionController, mLayoutInflater, mRemoteInputManager, - mVisualStabilityManager + mVisualStabilityManager, + mNotificationBlockingHelperManager ); when(mNotificationStackScrollLayout.isAttachedToWindow()).thenReturn(true); @@ -369,6 +375,25 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase { any(ForegroundServiceDungeonView.class)); } + @Test + public void testSetExpandedHeight_blockingHelperManagerReceivedCallbacks() { + + ArgumentCaptor> + onExpandedHeightChangeListenerCaptor = ArgumentCaptor.forClass( + BiConsumer.class); + + mController.attach(mNotificationStackScrollLayout); + + verify(mNotificationStackScrollLayout, times(2)).addOnExpandedHeightChangedListener( + onExpandedHeightChangeListenerCaptor.capture()); + + for (BiConsumer listener : + onExpandedHeightChangeListenerCaptor.getAllValues()) { + listener.accept(1f, 2f); + } + verify(mNotificationBlockingHelperManager).setNotificationShadeExpanded(1f); + } + private LogMaker logMatcher(int category, int type) { return argThat(new LogMatcher(category, type)); }